[SOLVED] Combining two sets of images into third set

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
RyanBram
Posts: 30
Joined: 2013-03-25T22:55:10-07:00
Authentication code: 6789
Contact:

[SOLVED] Combining two sets of images into third set

Post by RyanBram »

Let's say, I have two sets of images, in two different folder (directory)
First directory contains:
A.png ; B.png; C.png

Second directory contains:
1.png ; 2.png; 3.png

How to combine (composite) those two into third set and become:
A1.png; A2.png; A3.png;
B1.png; B2.png; B3.png;
C1.png; C2.png; C3.png;

I already read http://www.imagemagick.org/Usage/files/ and try something like

Code: Select all

for %a in *.* do
, but still cannot find (or not aware) the correct method.

Regards.
Last edited by RyanBram on 2014-02-09T22:02:21-07:00, edited 1 time in total.
OS: Windows 7 Ultimate, 32-Bit
CPU: Intel Core i3 2350M @ 2.30GHz
RAM: 2.00 GB Single-Channel DDR3 @ 665MHz
IM Version: 6.8.3-8 2013-03-04 Q16
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jp2 jpeg lcms lzma pango png ps tiff x xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Contact:

Re: Combining two sets of images into third set

Post by snibgo »

In a Windows BAT script:

Code: Select all

for %%a in (dir1\*.png) do (
  for %%b in (dir2\*.png) do (
    convert %%a %%b {something} %%a_%%b_out.png
  )
)
snibgo's IM pages: im.snibgo.com
RyanBram
Posts: 30
Joined: 2013-03-25T22:55:10-07:00
Authentication code: 6789
Contact:

Re: Combining two sets of images into third set

Post by RyanBram »

Code: Select all

for %%a in ("%~d0%~p0Original\*.*") do ( for %%b in ("%~d0%~p0Mask\*.png") do ( "%~d0%~p0bin\imagemagick\convert" "%%a" ( "%%b" -negate ) -alpha off -compose copy-opacity -composite "%~d0%~p0Result\%%~na%%~nb.png" ) )
That's my script. But the result is only the console who appear and disappear immediately without I noticed what message it tries to tell.

Something wrong with my script?
OS: Windows 7 Ultimate, 32-Bit
CPU: Intel Core i3 2350M @ 2.30GHz
RAM: 2.00 GB Single-Channel DDR3 @ 665MHz
IM Version: 6.8.3-8 2013-03-04 Q16
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jp2 jpeg lcms lzma pango png ps tiff x xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Contact:

Re: Combining two sets of images into third set

Post by snibgo »

It's hard to say without peering over your shoulder, but you probably need to escape the parentheses:

Code: Select all

^( "%%b" -negate ^)
snibgo's IM pages: im.snibgo.com
RyanBram
Posts: 30
Joined: 2013-03-25T22:55:10-07:00
Authentication code: 6789
Contact:

Re: Combining two sets of images into third set

Post by RyanBram »

It works. Thank you very much, Snibgo.

Problem Solved. (I don't know how to mark problem as solved)
OS: Windows 7 Ultimate, 32-Bit
CPU: Intel Core i3 2350M @ 2.30GHz
RAM: 2.00 GB Single-Channel DDR3 @ 665MHz
IM Version: 6.8.3-8 2013-03-04 Q16
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jp2 jpeg lcms lzma pango png ps tiff x xml zlib
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:

Re: Combining two sets of images into third set

Post by fmw42 »

RyanBram wrote:It works. Thank you very much, Snibgo.

Problem Solved. (I don't know how to mark problem as solved)
Edit the title of your very first post on this topic
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 12 guests