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?".
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2018-06-11T02:23:13-07:00
Hi folks!
I've searched the forums and tried several methods but i am unable to get what i need to work.
Basically i have several hundred images which i would like composited onto a single common background.
Common background image:
Sample Image:
Result:
I am currently using the following code:
Code: Select all
composite -gravity center -geometry -0+5 top1.jpg back.jpg composite_top1.jpg
Is there a way to accomplish this in batch?
Thank you so much for your help!
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2018-06-11T03:14:06-07:00
You could put it in a for loop, for example:
Code: Select all
md newdir
for VAR in $(ls *.jpg)
do
echo $VAR
composite -gravity center -geometry -0+5 $VAR back.jpg newdir\$VAR
done
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2018-06-11T03:37:27-07:00
snibgo wrote: ↑ 2018-06-11T03:14:06-07:00
You could put it in a for loop, for example:
Code: Select all
md newdir
for VAR in $(ls *.jpg)
do
echo $VAR
composite -gravity center -geometry -0+5 $VAR back.jpg newdir\$VAR
done
Hi snibgo,
Thank you very much! I tried what you mentioned. I put your code in a .sh file ( composite.sh ) and ran "sh composite.sh" from Ubuntu terminal.
Nothing happened expect the red back.jpg file was duplicated to a new file called "newdir$VAR"
Am i doing something wrong ?
Thank you
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2018-06-11T03:46:33-07:00
Yeah, my fault, sorry. For bash, use forward slash "/" as directory separator. And use "mkdir" to create a directory:
Code: Select all
mkdir newdir
for VAR in $(ls z*.jpg)
do
echo $VAR
composite -gravity center -geometry -0+5 $VAR back.jpg newdir/$VAR
done
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2018-06-11T03:54:09-07:00
snibgo wrote: ↑ 2018-06-11T03:46:33-07:00
Yeah, my fault, sorry. For bash, use forward slash "/" as directory separator. And use "mkdir" to create a directory:
Code: Select all
mkdir newdir
for VAR in $(ls z*.jpg)
do
echo $VAR
composite -gravity center -geometry -0+5 $VAR back.jpg newdir/$VAR
done
Hi snibgo : )
Wow Thank you so much!
It worked perfectly! Just what i needed.
Your help is much appreciated.
Thank you again for helping me! : )))
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS