Page 1 of 1
Howto split image?
Posted: 2007-10-31T05:56:01-07:00
by const
Hello, is there simple way to split Magick::Image to sequence of images?
Image - is an image (1024x1024), created in photoshop by artists, now I want to split this image to 64x64 tiles and write them to file sequence (img000.tga, img001.tga etc), but couldn't find suitable method so far.
Re: Howto split image?
Posted: 2007-11-07T09:17:40-07:00
by const
Browsing documentation, I've found something suitable in convert utility -
-crop parameter
Quote from
documentation:
If the x and y offsets are omitted, a set of tiles of the specified geometry, covering the entire input image, is generated. The rightmost tiles and the bottom tiles are smaller if the specified geometry extends beyond the dimensions of the input image.
Is there way to implement this functionality using C/C++ API?
Re: Howto split image?
Posted: 2007-11-19T17:43:38-07:00
by anthony
See IM examples, tile cropping
http://imagemagick.org/Usage/crop/#crop_tile
The same syntax should be used for all API crop operators.
NOTE remember IM does not deal in units of single images, but lists or sequences of images. as such the one image will become many images refered to by the one reference. When you save you then specify how you want to save the many images using things like...
Writing a Multi-Image Sequence
http://imagemagick.org/Usage/files/#write_seq
the same methods are also using in API's
Re: Howto split image?
Posted: 2009-11-12T04:20:49-07:00
by live4fun
I try to split an image horizontal into two tiles.
Code: Select all
convert -crop 100%x50% 0017kh.gif +repage tiles%d.gif
The Tiles show the upper and lower part of the images but the opposite half is filled with black. The tiles still have the same size as the original image not only half of it as expected. Looks to me as if repage is ignored or am i using it wrong??
I just want to split my image horizontal and get two tiles that represent the upper and the lower half of the input image.
When I run after tile generation:
black areas of the tiles get removed and I get the tiles I wanted in the first place. Why isn't the repage option respected in the convert call?
Best Regards
Re: Howto split image?
Posted: 2009-11-12T10:22:38-07:00
by fmw42
put your input image before -crop. see
http://www.imagemagick.org/Usage/basics/#why
for 50% split, see
http://www.fmwconcepts.com/imagemagick/ ... .php#crop1
for 25% split or 128x128 tiles, see
http://www.fmwconcepts.com/imagemagick/ ... .php#crop2
perhaps your IM version is too old. try upgrading if needed.
Re: Howto split image?
Posted: 2009-11-12T16:31:44-07:00
by anthony
As you saved to GIF the virtual canvas position was preserved. The black areas is empty space containing no image.
To remove all the position information leaving just the image without a virtual canvas and offset do a +repage afetr the crop.
See Tile Cropping, which has examples showing this.
http://www.imagemagick.org/Usage/crop/#crop_tile
PS the black sections you see in some examples to the right of the real image is a BUG in firefox. It was reported at the start of the year but NOTHING has been done about it.
https://bugzilla.mozilla.org/show_bug.cgi?id=487562