How do I covert all images in folder with all images in another folder?

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
rothschild
Posts: 2
Joined: 2017-09-02T14:11:31-07:00
Authentication code: 1151

How do I covert all images in folder with all images in another folder?

Post by rothschild » 2017-09-02T14:14:53-07:00

I'm currently working on a project where I'll be creating mockups of hundreds of shirts, sweatshirts, ect. All images in "Fill" folder are ~6000px. The images in "Mask" Folder are all exactly 6000x6000px.

I currently have this command. Now I have to manually input the fill name and mask name to get a desired output.

Code: Select all

convert /Users/name/Desktop/fill.png /Users/name/Desktop/mask.png -gravity center -composite -extent 6000x6000 -resize 2000x2000 /Users/name/Desktop/result.png

Here's what I'm trying to accomplish.
I want to take all images in a specific folder, Run them through ImageMagick to create multiple mockups of different product types.

Here's a example.

FillFolder-->
Fill1.png
fill2.png
fill3.png
ect..

MaskFolder-->
Shirt.png
Sweatshirt.png
Hoodie.png
ect..

OutPutFolder-->
Fill1Shirt.png Fill1Sweatshirt.png Fill1Hoodie.png
Fill2Shirt.png Fill2Sweatshirt.png Fill2Hoodie.png
Fill3Shirt.png Fill3Sweatshirt.png Fill3Hoodie.png
ect..

I know this can be complicated. But I'm hoping somebody can help me out. I'm pretty new to ImageMagick and Command/Terminal in general.

Thank You.

rothschild
Posts: 2
Joined: 2017-09-02T14:11:31-07:00
Authentication code: 1151

Re: How do I covert all images in folder with all images in another folder?

Post by rothschild » 2017-09-02T20:28:35-07:00

I found the solution. I'll post it just in case somebody else has a similar problem. Obviously the paths for A-D would depend on your own paths. Also you can copy from i=0 to "done" and paste under, also adding another letter. This gives you the ability to create multiple different mockups of the same list file. I hope this helps somebody. I've been looking for a solution like this myself for about a week. Extent and Resize can be removed per your project requirements.

Code: Select all

#!/bin/sh

A=/Users/name/Documents/PNG-JPG_Files
B=/Users/name/Desktop/mock_auto/pngs/shirt
C=/Users/name/Desktop/done
D=/Users/name/Desktop/mock_auto/pngs/tank
ls $A/*.png > listA.txt

i=0
for f in $A/*.png
do
        i=$((i+1))
        g=$(head -n$i listA.txt | tail -n1)
        convert $g $B/*.png -extent 6000x6000 -composite -resize 2000x2000 $C/$(printf "mock_shirt%05d.png" $i)
done


i=0
for f in $A/*.png
do
        i=$((i+1))
        g=$(head -n$i listA.txt | tail -n1)
        convert $g $D/*.png -extent 6000x6000 -composite -resize 2000x2000 $C/$(printf "mock_tank%05d.png" $i)
done

Lost the main source. But it was somewhere on StackOverlfow.

Post Reply