TIP ImageGeneratorPlugin is not installed on Foswiki.org.

ImageGeneratorPlugin

Generates images from text

Description

ImageGeneratorPlugin is a plugin that lets you generate images based on textual information such as a person's first and last name. It will then generate a kind of thumbnail or avatar image by taking the initials of the name and generate an image that is automatically colored. The algorithm for that is the same as in the JQAutoColorContrib extension.

You type:

%GENIMAGE{"Foswiki"}%

You get:

example1.jpeg

You type:

%GENIMAGE{
   "John Doe" 
   form="initials" 
   style="border-radius:50%"
}%

You get:

example3.jpeg

In additon to the text input say "FW" an additional seed may be used to create further color variations.

You type:

%FORMATLIST{"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23"
   format="$percntGENIMAGE{\"Foswiki\" 
               label=\"FW\" 
               seed=\"$1\" 
               title=\"$1\"
               align=\"left\" 
               width=\"100\" 
               height=\"100\" 
           }$percnt"
   separator=""
}%
%CLEAR%

You get:

example

Syntax

The %GENIMAGE makes takes the following arguments:

Parameter Description Default
"...", text="..." text source for the image; colors will be generated on its base  
label="..." explicit label to be displayed, if undefined will use the from parameter to generate a label from the text generated from text
from="initials/firstletter" specifies the way a label is generated from the text: mode "initials" will extract the first letters from each word in the text; mode "firstletter" will take the first letter of the text firstletter
seed="..." any character sequence provided here will be added to the text while computing colors  
width="..." width of the image being generated 150
height="..." height of the image being generated 150
font="..." ttf font to be used see configure, e.g. Helvetica
huefrom="0..359" start range of hues to be chosen from 0
hueto="0..359" end range of hues to be chosen from 359
saturation="..." one or more saturation values 50, 60, 00
lightness="..." one or more lightness values 35, 50, 65, 80
light="..." HLS values of a foreground color to be used on a dark background 0, 0, 100
dark="..." HLS value of a foreground color to be used on a light background 0, 0, 0
class="..." a css class genImage
style="..." css styles  
title="..." title attribute of the img elemenent  
alt="..." alt attribute of the img elemenent  
align="left/right/middle/top/bottom" alignment of the img elemenent  
format="..." format string to render the result
<img src="$url" \
     width="$width" \
     height="$height" \
     $class \
     $align \
     $title \
     $alt /> 

All colors are calculated in HLS space. While hashing the text a hue value is selected in the range specified by huefrom ... hueto. Lightness and staturation as selected in modulo fashion from the given list of values. The resulting background color is analyzed: if it is considered dark or light, a light on dark or dark on light backgrounds will be used as can be seen in the above examples.

Hue values are between 0 and 359, lightness and saturation are on a scale between 0 and 100.

The format parameter may contain the following variables:

  • $url
  • $width
  • $height
  • $class
  • $align
  • $alt

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Dependencies

NameVersionDescription
Digest::HMAC>=0Required
Image::Magick>=7Required

Change History

25 Jan 2024 initial release

PackageForm edit

Author Michael Daum
Version 1.00
Release 25 Jan 2024
Description Generates images from text
Copyright 2022-2024, Michael Daum, All Rights Reserved
License GPL (GNU General Public License)
Home http://foswiki.org/Extensions/ImageGeneratorPlugin
Support http://foswiki.org/Support/ImageGeneratorPlugin
Repository https://github.com/foswiki/ImageGeneratorPlugin
ExtensionClassification Interface and Visualisation
ExtensionType PluginPackage
Compatibility
IncompatibleWith
ImageUrl example2.jpeg
DemoUrl
SupportUrl ImageGeneratorPlugin
ModificationPolicy CoordinateWithAuthor
I Attachment Action Size Date Who Comment
ImageGeneratorPlugin.md5md5 ImageGeneratorPlugin.md5 manage 183 bytes 25 Jan 2024 - 12:48 MichaelDaum  
ImageGeneratorPlugin.sha1sha1 ImageGeneratorPlugin.sha1 manage 207 bytes 25 Jan 2024 - 12:48 MichaelDaum  
ImageGeneratorPlugin.tgztgz ImageGeneratorPlugin.tgz manage 50 K 25 Jan 2024 - 12:48 MichaelDaum  
ImageGeneratorPlugin.zipzip ImageGeneratorPlugin.zip manage 54 K 25 Jan 2024 - 12:48 MichaelDaum  
ImageGeneratorPlugin_installerEXT ImageGeneratorPlugin_installer manage 4 K 25 Jan 2024 - 12:48 MichaelDaum  
example1.jpegjpeg example1.jpeg manage 1 K 25 Jan 2024 - 12:48 MichaelDaum  
example2.jpegjpeg example2.jpeg manage 45 K 25 Jan 2024 - 12:48 MichaelDaum  
example3.jpegjpeg example3.jpeg manage 2 K 25 Jan 2024 - 12:48 MichaelDaum  
Topic revision: r1 - 25 Jan 2024, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy