Magick++: Adding More Space to the Image

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
Bunkai.Satori
Posts: 9
Joined: 2010-10-06T04:05:37-07:00
Authentication code: 8675308

Magick++: Adding More Space to the Image

Post 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.
Last edited by Bunkai.Satori on 2011-03-10T15:25:42-07:00, edited 1 time in total.
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: Magick++: Adding More Space to the Image

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Magick++: Adding More Space to the Image

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++: Adding More Space to the Image

Post by el_supremo »

Look at the extent method here http://www.imagemagick.org/Magick++/Ima ... %20Methods

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Bunkai.Satori
Posts: 9
Joined: 2010-10-06T04:05:37-07:00
Authentication code: 8675308

Re: Magick++: Adding More Space to the Image

Post 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,
Post Reply