Page 1 of 1
Composite - Images in different folder with similar filenames
Posted: 2016-06-06T13:49:50-07:00
by burt46
Hi,
I have recently discovered ImageMagick and the ability to overlay images. I am terrible with scripts and not familiar with the scripting language used. I am trying to run ImageMagick from the command line (actually in a dos batch file) to merge (using the Composite function) which works well for selecting particular images. However, I have a folder with 200 images that I want to merge with 200 images in another folder. The filenames are very similar whereby the date in the filename is the same for the two images to combine.
So is it possible to composite two images that have a similar filename (or the same) from different folders and process the folder automatically?
Thanks in advance,
Burt
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T14:17:07-07:00
by snibgo
ImageMagick contains very limited facilities for finding "similar" filenames. The obvious solution is to have a shell script that loops through files in one directory. For each one, it finds the corresponding file in the other directory, then calls ImageMagick with the two filenames.
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T14:21:26-07:00
by burt46
Thanks for the quick reply. When you say limited, could ImageMagick do it if the file names were the identical in each folder?
The Shell script sound interesting. Any ideas on how i would apply this to my particular situation? I guess i wont find it on a beach....thats my limited knowledge of a Shell script.
Thanks again
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T16:45:39-07:00
by snibgo
I suggest you set aside a day or so to read "help for" and experiment with it.
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T17:08:37-07:00
by burt46
Would it be expensive to pay an expert to write the code for me?
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T19:29:38-07:00
by GeeMack
burt46 wrote:Thanks for the quick reply. When you say limited, could ImageMagick do it if the file names were the identical in each folder?
That would make it fairly easy, yep. It would also be pretty simple if a DIR command for both folders output the listing in the order needed for the composites. In other words, if the first image listed with the DIR command for your overlay images will be composited onto the first image in the DIR command for the background images, and the second onto the second, and so on. Also, if you can output the DIR /B command of both folders to text files, and edit one or both so they are in corresponding order, that would make it pretty easy, too.
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-06T20:14:43-07:00
by fmw42
What version of IM and what platform?
Then as Geemack says, how would one coordinate the file names? What are examples of names from both folders and what parts are the same?
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-07T06:57:38-07:00
by burt46
Hi thanks for the comments. I am using Windows 7 and ImageMagick 7.0.2-8.
The problem is that the number of images in each of the two folders to join is different, so i only want to composite two images that share the same filename. An example of the image names are>
Folder1
TEXT-C_R_19S_LC5126472013333_ND_B4B7_Color.png
TEXT-C_R_19S_LC5126472014002_ND_B4B7_Color.png
TEXT-C_R_19S_LC5126472014102_ND_B4B7_Color.png
Folder2
TEXT-C_R_19S_LC5146472013317_B895_Final.png
TEXT-C_R_19S_LC5146472013333_B895_Final.png
TEXT-C_R_19S_LC5146472014102_B895_Final.png
Note the differences in filenames where only the 201XXXX is similar between the two folders. I can however change the files names to be the same in each folder if this was easier, but each file wont necesariliy be in the order, as Folder 1 may have 200 images and Folder 2 60 images, so i need to extract the 60 images from the first to do the composite.
Bit more difficult than i thought.
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-07T07:52:36-07:00
by snibgo
The trick is to break it down into sub-problems. Something like this.
1. Loop through all the files in Folder1. For each file:
2. Extract the characters from position 22, length 7 characters. (I may have mis-counted.)
3. If Folder2 contains exactly one file that matches in those characters:
3a. Do a convert command with those two directory/filenames.
4. Continue from step 1.
Re: Composite - Images in different folder with similar filenames
Posted: 2016-06-07T09:50:32-07:00
by GeeMack
burt46 wrote:Hi thanks for the comments. I am using Windows 7 and ImageMagick 7.0.2-8.
The problem is that the number of images in each of the two folders to join is different, so i only want to composite two images that share the same filename [...] Bit more difficult than i thought.
I still think I'd do something like "DIR /B >> folderlist.txt" to list both of those folders to a text file, and sort the text file which will put the corresponding pairs adjacent to each other in the list. Then I'd manually delete all the ones that aren't pairs (or more automated with a slightly fancy text editor like Notepad++). There are some not so difficult ways to have ImageMagick read the remaining text file and composite every other image onto every other one (think "modulo 2").