Page 1 of 1

How to create collage

Posted: 2010-05-19T02:31:58-07:00
by hellocatfood
I have a set of images and want to create a collage similar to this one made in Picasa

Image

I've tried using and modifying this script but it doesn't produce similar results.

What I want the script to do is resize and crop the images to a square then arrange them randomly but in a way that allows me to specify the amount of rows and how many photos are on each row. Repetition of images isn't really a problem at this moment.

Can anyone help?

Re: How to create collage

Posted: 2010-05-19T09:27:34-07:00
by snibgo
Perhaps this will do what you want. Caution: this is a Windows 7 script.

Code: Select all

set SRC=\pictures\20091205\
del *.png

for %%F in (%SRC%*.jpg) do "%IMG%convert" %%F -gamma .45455 -resize "32x32^^" -crop 32x32+0+0 +repage -gamma 2.2 !RANDOM!_%%~nF.png
  
"%IMG%montage" *.png -geometry 32x32+0+0 -tile 10x10 collage.jpg
Notes:

!RANDOM! will be a random integer each time it is used.

%%~nF will include the original filename (without path or extension) in case two images get the same random number.

If more than 100 input images, we will get multiple outputs.

You can change 32x32 throughout to some other rectangle. Likewise the 10x10 (columns and rows in the output).

Images won't repeat.

%IMG% points to my IM directory. Most people won't need this.

Re: How to create collage

Posted: 2010-05-20T21:35:03-07:00
by anthony
hellocatfood wrote:I've tried using and modifying this script but it doesn't produce similar results.
Warning. that script appears to rename images to a random number, but no check is made to prevent two images being saved to the same number!!!!!

Re: How to create collage

Posted: 2010-06-13T13:05:35-07:00
by hellocatfood
snibgo wrote:Perhaps this will do what you want. Caution: this is a Windows 7 script.

Code: Select all

set SRC=\pictures\20091205\
del *.png

for %%F in (%SRC%*.jpg) do "%IMG%convert" %%F -gamma .45455 -resize "32x32^^" -crop 32x32+0+0 +repage -gamma 2.2 !RANDOM!_%%~nF.png
  
"%IMG%montage" *.png -geometry 32x32+0+0 -tile 10x10 collage.jpg
Thanks for that!

This code modified for Linux worked for me

Code: Select all

#!/bin/sh
for f in 'ls *.jpg' ; do convert collage_$f -resize "100x100^^" -crop 100x100+0+0 +repage %03d.png; done 

montage *.png -geometry 32x32+0+0 -tile 10x10 collage.jpg
I tried adding an rm command but realised that it could remove the originals too. I tried adding a cp command to rename the files to something different but it didn't work. I might just be doing it wrong