Home > Software > Automatically processed images

Automatically processed images

As I’m not a graphic designer, I’m not interested very much in image processing. In this area my experience is pretty thin and reduced of simply retouching my own photos or small adapting of some icons and graphics for my applications.
Although, one part of the image processing raises more interest to me: automatic processing. Why would you need such thing? Maybe not clear in the beginning, but this could have huge impact on your projects, like automatic generation of image galleries, adding logos or watermark to pictures and you already got the idea and how useful could be.
Before going any further I have to make one small clarification. As I have mostly a Java background, I use Ant, which is the equivalent of make from the Linux world. And of course, I’ll be interested of integrating the automatic image processing with Ant.
Probably now, the Ant advanced users will jump right on and say: “That’s easy! Use the Image Ant task“. Not quite. This could be one solution, but it is far from easy and complete. Let’s start with the installation. First of all, you should download and install JAI libraries. Second you have to declare(define) the image task and then use it. And that’s the good part. The worst part is that you don’t have support for most of the common operations with images.
So I needed another solution. Something easy to integrate in Ant, cross-platform (at least for the sake of Java principle) and supporting at least the common operations with images. And I came across ImageMagick, a very well-known image processing program with command line interface.
As you all Ant users know, this is very easy to integrate using the exec task and it features huge amounts of image processing operations, enabling you to do almost anything you can think of.
Now for the sake of example, I’ll paste here some parts of build.xml and what you can do with it.

  • Change one color with another in an image (great for automatically creating skins)

    <exec executable="${imagemagick.dir}/convert">
        <arg value="skinnable.gif"/>
        <arg value="-fill"/>
        <arg value="blue"/>
        <arg value="-opaque"/>
        <arg value="#ffffff"/>
        <arg value="blue_skin.gif"/>

  • Generate images from text (great for automatically creating buttons)

    <exec executable="${imagemagick.dir}/convert">
        <!-- background color -->
        <arg value="-background"/>
        <arg value="#ffffff"/>
        <!-- color of the text margin -->
        <arg value="-stroke"/>
        <arg value="#202020"/>
        <arg value="-strokewidth"/>
        <arg value="1"/>
        <!-- color of the text -->
        <arg value="-fill"/>
        <arg value="#909090"/>
        <!-- path to font file -->
        <arg value="-font"/>
        <arg value="/path/to/font.ttf"/>
        <!-- font size -->
        <arg value="-pointsize"/>
        <arg value="14"/>
        <!-- keep the text in center -->
        <arg value="-gravity"/>
        <arg value="center"/>
        <!-- button label -->
        <arg value="label:${label}"/>
        <!-- button label -->
        <arg value="button.gif"/>

  • Generate thumbnails (great for automatically creating image galleries)

    <exec executable="${imagemagick.dir}/convert">
        <arg value="image.jpg"/>
        <arg value="-thumbnail"/>
        <!-- thumbnail size -->
        <arg value="150x150^"/>
        <arg value="-gravity"/>
        <arg value="center"/>
        <arg value="-crop"/>
        <arg value="150x150+0+0"/>
        <arg value="+repage"/>
        <arg value="thumb.jpg"/>

Categories: Software Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: