generating multiple tile zoom levels from a single convert

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: generating multiple tile zoom levels from a single convert

Post by fmw42 »

try something like this. Using 512x512 mandril2.png and cropping out 128x128 tiles. This makes 16 tiles at level A and 4 tiles at level B.

convert mandril2.png \
\( -clone 0 -crop 128x128 +repage -write mandril2A.jpg \) \
\( -clone 0 -scale 50% -crop 128x128 +repage -write mandril2B.jpg \) \
null:

If you leave off the +repage, then the tiles keep their virtual canvas positions so that they can be put together later after further processing on each. See http://www.imagemagick.org/Usage/crop/#crop_tile (But I am not sure you can use jpg and have it carry the virtual canvas information - use gif or png as I believe those work)


(I believe that IM supports a tiled pyramid TIF format as well, so should/could make them automatically?)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: generating multiple tile zoom levels from a single convert

Post by anthony »

There was a change recently where you can generate and insert a special percent-escape string into the output file name...
http://www.imagemagick.org/Usage/files/#save_escapes

With this you can use a %[fx;...] to name the tiled images more appropriatally.

Hmmm...

convert rose: -crop 20x20 +repage rose_%02d.gif

produces images from rose_00.gif to rose_11.gif which is not very nice.

BUT....

convert rose: -crop 20x20 \
-set filename:tile "%[fx:page.x/20+1]_%[fx:page.y/20+1]" \
+repage +adjoin "rose_%[filename:tile].gif"

produced images rose_1_1.gif to rose_4_3.gif

Their is no formatting of the tile number at this time unfortunately :-(
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply