The <annotateimage>
Ant task allows you to annotate an image
with text. It can be used to automate steps in a build
such as stamping an image used for a splash screen or in an About dialog
with release/version information of the build.
Currently only JPEG images are supported. (TO DO: add GIF support... need a locate Java impl of a writer)
The image to be annotated may be either updated in-place or obtained from a source and used to create an annotated image in the specified target location.
The font to be used for the annotations is specified by indicating the font family, optional style attribute such as italic and bold, and the point size to be used. The font name may be either the name of a specific font family or one of the following logical font names:
The font family names that are available are platform-specific and may depend on the comfiguration of the build machine. A default font is used if font attributes are not specified.
The content and position of the text annotations are defined
in nested <annotation>
elements.
The position of the text annotation line(s) is specified by the { x, y } coordinate
of the upper left corner of the area in which the annotation is to be drawn.
The position is specified relative to the { 0, 0 } upper left coordinate of the image.
To use this optional task, place the jar file in your
%ANT_HOME%/lib
directory and include the following
optional task definition in your project buildfile:
<taskdef name="annotateimage" classname="com.glaivestone.ant.taskdefs.AnnotateImage"/>
black
One or more nested <annotation>
elements are defined
to specify the position and content of the text annotations.
An annotation is added in a text area specified by the
upper left corner relative to the containing image.
If multiple lines of text are specified, each subsequent
line after the first is positioned at the left margin
of the text area and down one line from the preceding
annotation.
A single-line annotation is specified using the text
attribute.
Multiple-line annotations are specified by specifying one or more lines
of text content within the <annotation>
element.
Multiline annotations are trimmed of leading and trailing blanks
before being positioned in lines of text starting from the top of the text area.
In-place update using the default font to insert one line of text
<annotateimage imagefile="${build.dir}/splashscreen.jpg" fontsize="10"> <annotation x="100" y="100" text="Release 1.0"/> </annotateimage>
In-place update using a specific font to insert two lines of text
<annotateimage imagefile="${build.dir}/splashscreen.jpg" font="SansSerif" bold="true" italic="yes" fontsize="14" color="red"> <annotation x="150" y="200" text="Release 1.0"/> <annotation x="100" y="220" text="Nightly build: ${DSTAMP}"/> </annotateimage>
Annotate a template image with multiple lines of text
<annotateimage imagefile="${build.dir}/splashscreen.jpg" imagesource="splashscreen-template.jpg" font="Serif" bold="true" italic="yes" fontsize="14"> <annotation x="20" y="100"> Release 1.0 (development build) </annotation> </annotateimage>
Created by D. Lewis on 22-Oct-2002. Idea and prototype from G. Gregory.