ImageMagick to create collages based on custom algorithms?

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
Kalantir
Posts: 2
Joined: 2014-03-04T09:04:44-07:00
Authentication code: 6789

ImageMagick to create collages based on custom algorithms?

Post by Kalantir »

Hi, I recently started developing an application which is supposed to select images randomly from a folder, make a collage out of them using a custom algorithm, and then output the collage (the final image should be in the user's current desktop resolution). I originally started this project using SFML, but have found that it is unable to handle images larger than 2048x2048 (hardware limitation supposedly, but ThetaWall seems to have no such restrictions). Anyways, someone in another forum recommended I use ImageMagick. However, I've been reading a lot of documentation and I'm having trouble figuring out where to even begin. Could someone please point me in the right direction here? How would you accomplish this? Basically I just need a way to scale images and apply them to a canvas at specific x,y coordinates. I also need a way to determine height/width of images I am using after I scale them so that I know where to place the next image when I am tiling.

Here's what I want the output to look like (I created this using the Windows application ThetaWall)
http://i199.photobucket.com/albums/aa21 ... g~original

You can even see the algorithm it is using just by looking at the image carefully. First, it placed one image in a random corner (top-right in this case) and scaled it towards the upper limit specified in the config file. Then, it tiled images across starting from the bottom-right corner, scaling everything to fill any empty space. The last image doesn't fit perfectly, so it centered the image relative to the previous image and scaled it to the edge. Then it went to fill in the remaining space and was only able to fit 2 images, which it decided to center relative to the large image.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick to create collages based on custom algorithm

Post by snibgo »

The ImageMagick parts are easy enough. See:

http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/basics/
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/script/comma ... p#geometry

The hardest part is keeping track of what areas need filling. I did something very similar recently, gradually filling an arbitrary area with decreasing rectangles until the area was completely covered.

You might need

Code: Select all

-resize "100x100>"
-format "%%w %%h"
etc.
snibgo's IM pages: im.snibgo.com
Kalantir
Posts: 2
Joined: 2014-03-04T09:04:44-07:00
Authentication code: 6789

Re: ImageMagick to create collages based on custom algorithm

Post by Kalantir »

Thank you for the response. Now that I can understand a little better how imagemagick works, I have opted to use Magick++ since I feel more comfortable with C++ and object oriented design. So far it seems to be working for basic test cases. Now I just need to code in the algorithm I'm going to use and index the images.
Post Reply