Page 1 of 1
Magick++: Adding More Space to the Image
Posted: 2010-10-28T06:02:50-07:00
by Bunkai.Satori
Dear all,
I use Bin-Packing algorithm to construct one large image set (a game tileset). When I run out of space on the originally created image canvas (just an image with predetermined dimensions), I need increase its size, so I can continue placing image tiles into it.
What Magick++ function to call to increase the size of the original image? If I call Image::resize(Geometry), I increase the imagesize, but I scale all its content as well (tiles within it). That is wrong. I need something that adds more space to the bottom of the canvas image, but does not scale/modify existing tiles, which are already contained.
Thank you.
Re: Magick++: Adding More Space to the Image
Posted: 2010-10-29T08:33:29-07:00
by indiego
Bunkai.Satori wrote:
What Magick++ function to call to increase the size of the original image? If I call Image::resize(Geometry), I increase the imagesize, but I scale all its content as well (tiles within it). That is wrong. I need something that adds more space to the bottom of the canvas image, but does scale/modify existing tiles contained.
Thank you.
Well, I don't know the exact name of the function, but probably it's the same as for the command line. I think this is want you want
http://www.imagemagick.org/Usage/crop/#extent
Greetings, Peter
Re: Magick++: Adding More Space to the Image
Posted: 2010-10-31T17:32:08-07:00
by anthony
Resizing an image in IM involves creating a new image and composing (coping) the old image into the new image. It does not matter if the operation is
-border,
-splice, or
-extent the solution is the same, and is what these command do internally.
The better idea is to read all the images first -- then calculate the final image size!
This is what image layering operators
-mosaic and
-layers merge do.... It loots at all the images given, then determines the final image canvas size, before layering all the images onto that canvas in the sequence and (per-image) compose settings given, so as to merge them all into one final image.
http://www.imagemagick.org/Usage/layers/#mosaic
By contrast,
-flatten just uses the virtual canvas size of the firat image, completely ignoring the size and virtual canvas settings of all the other images.
This need to 'compose' to enlarge is also why all the operators I mentioned need at least one color setting (usually
-background), as it is used to initialize the new 'canvas' on which to compose all the images. The canvas image itself is created from a 'clone' of the first image so as to preserve that images meta-data.
Don't forget to study the complex 'looped' example in
http://www.imagemagick.org/Usage/layers/#example
And watch your virtual canvas 'page offset' positioning.
Re: Magick++: Adding More Space to the Image
Posted: 2010-10-31T18:26:37-07:00
by el_supremo
Re: Magick++: Adding More Space to the Image
Posted: 2011-03-10T15:29:10-07:00
by Bunkai.Satori
Dear Indiego, Anthony, Pete,
Thank you very much for your kind and detailed advices. You were correct that image.extent() method worked very well.
Anthony, your answer was excelptionally detailed and helpful.
Regards,