Export Montage sizes/positioning

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
chnet

Export Montage sizes/positioning

Post by chnet »

I am wondering if it's possible, after (or during) a montage command if you can get information about the images that made up the montage.

If I use the Concatenate option on a say a folder of images and wanted to know what their widths/heights were, do I have to do a separate Identify command on each or is there a way to pull out their sizes from the montage command? Or even more ideally, the coordinates of their positions in the montage relative to the top left corner.

From reading this:
http://www.imagemagick.org/Usage/montage/#html_jpeg

It seems like you could, but I don't think I understand how he generated the html.

Thanks!
chnet

Re: Export Montage sizes/positioning

Post by chnet »

Okay I see if you change the file you are saving to to an html file it generates a html page with an image map with the coordinates for all of the images. Which is great.

But is there a way to just get the coordinate data in a more usable format directly from the command, so that I can do something with it in PHP without having to read and parse the html that gets generated?

If I'm not being clear, please ask me to reword.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Export Montage sizes/positioning

Post by anthony »

You could try adding a -write info: to the montage command... Arrggg... sorry -write is no an option of montage (request it on the developers forum) so you will need to use a convert | montage pipeline...

Code: Select all

convert image.... -write info:image_info.txt  miff:- |
  montage miff:- .... output.png
The file "image_info.txt" will contain all the information about the images. A separate file was needed as the image is outputing to the normal standard output of the convert command.

Of course the size will be wrong if you are using (and you should be) a JPEG -size hint or a Resize on Read Option. however you could set a -format to specify what information you are wanting to outptu to the info file.

Code: Select all

convert  -size 250x250 '*.jpg[80x80]' \
        -format ''%wx%h' -write info:image_info.txt  miff:- |
  montage miff:- .... -geometry +2+2 output.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply