Emulating convert -crop using MagickWand
Posted: 2013-01-05T15:57:43-07:00
Hi,
I'm trying to work out the best way to chop up a large image into a load of rectangular, equal-sized tiles.
I'm inspired by the ability to use the following command line: with no x and y offset arguments to generate a set of tiles of size width by height covering the whole image. (As described here: http://www.imagemagick.org/script/comma ... s.php#crop )
For my application these tiles are to be saved to disk as binary data. As far as I can tell, ImageMagick doesn't support the right format, otherwise I'd just use the command line. There may be another way of doing this with the command line, but I'm intrigued as to how ImageMagick works as much as anything. Instead, I've started trying to crop images using the MagickWand C interface.
I have implemented a single crop easily enough with MagickCropImage(). I realise I could just duplicate my image a whole bunch of times, and crop a different tile each time. I'd like to know if the wand still maintains the image data outside the cropped region somehow. If so, is there a way to move the crop 'window', such that I could write all these tiles to disk from a single image in memory?
I hope this is clear.
I'm trying to work out the best way to chop up a large image into a load of rectangular, equal-sized tiles.
I'm inspired by the ability to use the following command line:
Code: Select all
convert infile -crop widthxheight outfile
For my application these tiles are to be saved to disk as binary data. As far as I can tell, ImageMagick doesn't support the right format, otherwise I'd just use the command line. There may be another way of doing this with the command line, but I'm intrigued as to how ImageMagick works as much as anything. Instead, I've started trying to crop images using the MagickWand C interface.
I have implemented a single crop easily enough with MagickCropImage(). I realise I could just duplicate my image a whole bunch of times, and crop a different tile each time. I'd like to know if the wand still maintains the image data outside the cropped region somehow. If so, is there a way to move the crop 'window', such that I could write all these tiles to disk from a single image in memory?
I hope this is clear.