ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: ANT Image Manipulation
Date Mon, 29 Jul 2002 16:57:38 GMT
Kevin - I've committed your <image> task and supporting classes.  There 
will, of course, need to be some refactorings and test cases added to 
make it really solid, but my attempts at using it worked fine except on 
OS X where I got some kind of index out of bounds error.

One question - how do I process a directory of images but not overwrite 
them?  I set overwrite="false" which did not seem to do anything.

	Erik


Kevin Z Grey wrote:
> 
> Heya,
> 
>     Here's what I've got so far for the image manipulation tasks. 
>  Before I dish out the high-level description of whats in the zip, I 
> want to note that it does not have support for depend sets only because 
> this past week has been extremely hectic.  I have added in "thumbnail" 
> support via a "scale" task, as well as support for all the other image 
> codecs that JAI supports (JPEG, PNG, BMP, PNM, etc).  I also added in 
> the Apache license and javadoc descriptions which are incomplete for a 
> couple files (I'll update those ASAP).  Here is a description of the 
> architecture:
> 
>     * Relevent packages for this are:
>       org.apache.tools.ant.taskdefs.optional.image  and
>       org.apache.tools.ant.types.optional.image  I chose optional for
>       the obvious reasons
>     * There is only one "Task" object called Image which extends
>       MatchingTask
>     * All of the image manipulations are represented as nested elements
>       under the Image task and extend from the ImageOperation class
>     * The ImageOperation class extends DataType
>     * There are two types of ImageOperations:  TransformOperation and
>       DrawOperation
>     * TransformOperations are any image manipulations that require an
>       image buffer to execute  (i.e. Scale needs an image buffer to
>       scale and it returns the modified buffer)
>     * DrawOperations are image manipulations that only return an image
>       buffer (i.e. Ellipse needs only to create an image buffer to draw
>       a circle in and return that buffer)
> 
> The resulting ANT XML looks like this:
> 
>         <image includes="*.jpg" srcdir="${image.dir}" overwrite="true">
>             <scale width="150" height="110%"/>  <!--  Scale the Width to 
> precisely 150 Pixels and increase the height by 10% -->
>             <draw xloc="0" yloc="40">
>                 <text string="ANT for Image Manipulation" font="Arial" 
> point="16" color="white"/>
>             </draw>
>         </image>
> 
> Current ImageOperations that I have written are:
> 
>     * Rotate: Rotates an image by N degrees
>     * Scale: Scales an image either to a specific pixel value or percentage
>     * Draw: Specifies where to draw an image passed from a DrawOperation
>     * Text: Draws formatted text into the image
>     * Ellipse: Draws an ellipse/circle
>     * Rectangle: Draws a rectangle
> 
> TODO:
> 
>     * Depends support
>     * Change Scale to use attribute "size" rather than "width" and "height"
>     * Add Watermark operation
>     * Add AutoLevels operation plus a Levels operation which allows more
>       control
>     * Add ops to add/subtract/multiply/divide by scalars and entire images
>     * Maybe a method to convert from image format X to Y
>     * Determine whether or not people get really annoyed from me using
>       bullet points in my emails
> 
> Let me know what you guys think.  
> 
> oh yeah, to thumbnail do:
> 
>         <image includes="**.jpg" srcdir="${image.dir}" overwrite="true">
>             <scale width="64" height="48"/>   <!-- Scales to 128x96 
> pixels... you get the point though ;) -->
>         </image>
> 
> ~~K
> 
> 
> ------------------------------------------------------------------------
> 
> Index: C:/development/projects/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
> ===================================================================
> RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
> retrieving revision 1.130
> diff -c -r1.130 defaults.properties
> *** C:/development/projects/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
9 Jul 2002 21:05:59 -0000	1.130
> --- C:/development/projects/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
13 Jul 2002 23:42:44 -0000
> ***************
> *** 72,77 ****
> --- 72,78 ----
>   tempfile=org.apache.tools.ant.taskdefs.TempFile
>   
>   # optional tasks
> + image=org.apache.tools.ant.taskdefs.optional.image.Image
>   script=org.apache.tools.ant.taskdefs.optional.Script
>   netrexxc=org.apache.tools.ant.taskdefs.optional.NetRexxC
>   renameext=org.apache.tools.ant.taskdefs.optional.RenameExtensions
> 
> 
> ------------------------------------------------------------------------
> 
> Index: build.xml
> ===================================================================
> RCS file: /home/cvspublic/jakarta-ant/build.xml,v
> retrieving revision 1.310
> diff -c -r1.310 build.xml
> *** build.xml	12 Jul 2002 10:50:01 -0000	1.310
> --- build.xml	13 Jul 2002 23:41:48 -0000
> ***************
> *** 299,304 ****
> --- 299,308 ----
>     <patternset id="needs.jmf">
>       <exclude name="${optional.package}/sound/*.java" unless="jmf.present" />
>     </patternset>
> +   <patternset id="needs.jai">
> +     <exclude name="${optional.package}/image/*.java" unless="jai.present"/>
> +     <exclude name="${optional.package}/image/types/*.java" unless="jai.present"/>
> +   </patternset>
>     <patternset id="needs.jdepend">
>       <exclude name="${optional.package}/jdepend/*" unless="jdepend.present" />
>     </patternset>
> ***************
> *** 418,423 ****
> --- 422,430 ----
>       <available property="jmf.present"
>                  classname="javax.sound.sampled.Clip"
>                  classpathref="classpath"/>
> +     <available property="jai.present"
> +                classname="javax.media.jai.JAI"
> +                classpathref="classpath"/>
>       <condition property="icontract.present">
>           <and>
>               <isset property="jdk1.2+"/>
> ***************
> *** 615,620 ****
> --- 622,628 ----
>         <patternset refid="needs.vaj" />
>         <patternset refid="needs.servletapi" />
>         <patternset refid="needs.jmf" />
> +       <patternset refid="needs.jai"/>
>         <patternset refid="needs.xalan2" />
>         <patternset refid="needs.jdepend" />
>         <patternset refid="needs.sun.tools" />
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message