Notebook / Archives / "ImageMagick"

"ImageMagick" entries.

April 29, 2003

The Making-Of a Blog: adding a photo-like border to your images

After reading this entry from Paolo Valdemarin about Food blogging (more info here in a previous entry) and watching the beautiful photo effect, I wanted to do the same thing.

I tried to mimic the effect with the command line tools conjure from ImageMagick (a collection of tools and libraries to manipulate images) which can process a Magick Scripting Language (MSL) file – conjure is useful to accomplish custom image processing tasks without using PerlMagick for example (PerlMagick is the Perl binding to ImageMagick). Apart ImageMagick, you will need the XML parser which comes with Libxml2 (The XML C library for Gnome); you can find the Windows port on Igor Zlatkovic's website (on the page where you can download binaries, do not forget to get iConv if you do not want to be reminded by conjure that you lack a library). After theses downloads, you must modify the path to point to the two new libraries.

To accomplish this effect, I wanted to take a JPEG file f.jpg to get another JPEG file f_photo.jpg (without needing to add the file extension):


  1. resize the original image to get a width of 200 pixels;

  2. add a white border of 4 pixels;

  3. add a black border of 1 pixel;

  4. rotate the image by -5 degrees.


Here is my MSL file:

<?xml version="1.0" encoding="UTF-8"?>
<image>
<read filename="%[f].jpg" />
<resize geometry="200x" />
<border fill="white" width="4" height="4" />
<border fill="black" width="1" height="1" />
<rotate degrees="-5" />
<write filename="%[f]_photo.jpg" />
</image>

You can interpret this doeffect_photo.msl XML script and see the result on Windows using IMDisplay with the following batch file:

@echo off
conjure -f %1 doeffect_photo.msl
imdisplay %1_photo.jpg

My result:

As you can see, I have two main problems. First, the image is aliased and it seems you cannot script an antialiasing inside a MSL file (and I have many problems today with convert and as always with mogrify – the first reason I am using an MSL script is that I do not succeed using these tools :( ). Secondly, I absolutely do not know how to make this shadow effect which gives a relief to the image.
I have to explore further. But I think it could be easier with the Perl binding.

Posted by Jean-Philippe on April 29, 2003 31 Comments, 1135 TrackBacks

Entries on this page

Entries by category

Entries by month