Create Contact Sheet Large Recursive Directory

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
tuggleg
Posts: 16
Joined: 2017-05-01T08:57:40-07:00
Authentication code: 1151

Create Contact Sheet Large Recursive Directory

Post by tuggleg »

Hello Image Magick Community,
I have found several tutorials regarding contact sheets using the

Code: Select all

montage 
command. However, I have not found any that provide instruction on how to create a contact sheet from multiple directories or even a recursive directory. Is anyone aware of how to perform this action?

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create Contact Sheet Large Recursive Directory

Post by snibgo »

IM won't handle multiple or recursive directories. You would walk through those directories in a shell script, calling montage at each directory.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Create Contact Sheet Large Recursive Directory

Post by GeeMack »

tuggleg wrote: 2017-11-13T11:19:46-07:00I have found several tutorials regarding contact sheets using the

Code: Select all

montage 
command. However, I have not found any that provide instruction on how to create a contact sheet from multiple directories or even a recursive directory. Is anyone aware of how to perform this action?
Depending on your OS, you should be able to use something like "dir" or "ls" or "forfiles" to generate a list of the images you want to use. Those system commands typically have flags to recurse sub-directories. Redirect the output of those commands to a text file. Then you can run your "montage" command, and where you would normally put the names of the image files you can put the name of that text file list preceded by an "@" sign.

Code: Select all

montage ... @filelist.txt ... output.jpg
ImageMagick will read that text file and run the process as if you entered the list of images directly in your command.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create Contact Sheet Large Recursive Directory

Post by snibgo »

In my post above, I was thinking of one montage per directory. But I think GeeMack is correct, that the requirement is for one montage that includes multiple directories, so GeeMack has the solution.
snibgo's IM pages: im.snibgo.com
tuggleg
Posts: 16
Joined: 2017-05-01T08:57:40-07:00
Authentication code: 1151

Re: Create Contact Sheet Large Recursive Directory

Post by tuggleg »

Using PowerShell's 'Get-ChildItem' I have successfully generated a Contact Sheet from multiple directories by doing the following:

Code: Select all

foreach ($dailyPhotoBay in $dailyServerPath)
{
    $dailyImage = Get-ChildItem -Path $dailyPhotoBay -Include *.jpg -Recurse | Where-Object {$_.PSParentPath -like "*Output*"}

    echo $dailyImage
    
    echo $dailyImage.FullName

    montage -verbose -label $dailyImage -font Helvetica -pointsize 50 -background '#FFFFFF' -tile '5x10' -fill 'gray' -define jpeg:size=600x780 -geometry 600x780+40+150 -quality 90  -auto-orient $dailyImage.FullName D:\Contact_Sheet\Sheet.jpg
}
Post Reply