[magick-users] Optimise convert.exe with -compose and -composite switches.

erik at sitadella.com erik at sitadella.com
Sun Feb 24 11:48:13 PST 2008


Anthony,

Thank you very much for your advice.

"Second you can use -flatten to compose multiply images more quickyly. The  
Virtual canvas size of the first image can define the final size.

   convert -background none -page 1680x1050 \
           bg.jpg image1.png image2.png image3.png image4.png image5.png \
           -flatten newWallpaper.bmp"

"There are a few different varients of the BMP image file format
try
    bmp3:newWallpaper.bmp"


I'm not sure if I noticed any significant increase in perfomance when  
using the -flatten switch, but I've changed the command based on your  
recommendations. Regarding the bmp format, explicitly specifying the bmp3  
format didn't seem to change anything, though it point me in the right  
direction. I found this information:

"The PNG file contains a gAMA and cHRM chunk (gamma and chromaticity  
information) either of which forces "convert" to write a BMP-4. To get a  
BMP3 you need to get rid of that information.

convert button.png PPM:- | convert PPM:- button.bmp

will get rid of profiles, chromaticity, gamma, and transparency, title,  
copyright info, and should produce a BMP3 instead of a BMP4."

(http://www.cit.gu.edu.au/~anthony/info/graphics/imagemagick.hints)

Based on this and hours of debugging, this is what I now have:
convert -background none -page 1680x1050 bg.jpg image1.png image2.png  
image3.png image4.png image5.png -flatten tempfile.ppm - convert  
newimage.bmp

It currently executes in 2-3 seconds which is acceptable and the resulting  
image seems to be a valid bmp image that can be used as a windows  
background. It would be nice to avoid using a temporary PPM file, but it  
seems to be a format specifically made for this kind of thing and it  
works. Wikipedia has this to say about the format: "The portable pixmap  
file format (PPM), the portable graymap file format (PGM) and the portable  
bitmap file format (PBM) specify rules for exchanging graphics files. They  
provide very basic functionality and serve as a least-common-denominator  
for converting pixmap, graymap, or bitmap files between different  
platforms. Several applications refer to them collectively as the PNM  
format (portable anymap)."

I'm fairly satisfied with this solution. I only have two more small  
questions.

6. Could the above be accomplished without piping the ouput of one convert  
command to another convert command? It definetly seems like something that  
should be done in one shot.

7. Since I never actually see the tempfile.ppm being written to disk, am I  
right in assuming that everything is being done in memory and that it  
doesn't really matter if everything is accomplished in one or two  
commands? (Refer above question)


P.S. For anyone interested. I'm finished with the first beta version of  
this program. It's a free program to make use of wallpaper clocks from  
www.vladstudio.com/wallpaperclock and can be downloaded here at the  
moment: www.sitadella.com/SitaShots/Install_Wallpaperclock.exe


Thanks again for the help -much obliged!
Ciao!
Erik


More information about the Magick-users mailing list