combine two commands into one (clone)

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
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

combine two commands into one (clone)

Post by mikmach »

Hello,

I have two commands which are working perfectly separately (thanks to you all!):

Code: Select all

		convert $i -quiet -profile x:\\icc\\adobeRGB.icc \
			\( +clone -gaussian-blur 6x3 \) -compose Colorize -composite j:\\hot\\$i	
		convert j:\\hot\\$i -quiet \( -clone 0 -blur 0x1.5 \) \
			\( -clone 0 -clone 1 +swap -compose mathematics -set option:compose:args "0,1,-1,0.5" -composite \) \
			\( -clone 0 -clone 2 -compose overlay -composite \) -delete 0-2 j:\\hot\\$i
First one is converting image to aRGB and does subtle denoising, second one applies high pass filter to sharpen image a bit.
I'd like to combine them into one to avoid one write to disk operation (which is costly when handling hundreds of 200MB+ files).
Unfortunately no matter how I combine them I loss one of operations, image is denoised but not sharpened or the other way around. Please, help!

Notes:
- regular sharpen filter will not cut it due to halos
- syntax oddities are due to running of regular Windows IM inside of Cygwin's zsh
- IM 6.9.3, 16-bit

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

Re: combine two commands into one (clone)

Post by snibgo »

Here are your two commands, removing paths etc:

Code: Select all

convert \
  toes.png -quiet \
  -profile AdobeRGB1998.icc \
  \( +clone -gaussian-blur 6x3 \) \
  -compose Colorize -composite \
  t2.png

convert \
  t2.png -quiet \
  \( -clone 0 -blur 0x1.5 \) \
  \( -clone 0 -clone 1 +swap -compose mathematics -set option:compose:args "0,1,-1,0.5" -composite \) \
  \( -clone 0 -clone 2 -compose overlay -composite \) \
  -delete 0-2 \
  t3.png
Removing the output filename from the first, and the input filename from the second, should work.

Code: Select all

convert \
  toes.png -quiet \
  -profile AdobeRGB1998.icc \
  \( +clone -gaussian-blur 6x3 \) \
  -compose Colorize -composite \
  \( -clone 0 -blur 0x1.5 \) \
  \( -clone 0 -clone 1 +swap -compose mathematics -set option:compose:args "0,1,-1,0.5" -composite \) \
  \( -clone 0 -clone 2 -compose overlay -composite \) \
  -delete 0-2 \
  t3b.png

compare -metric RMSE t3.png t3b.png NULL:
The "compare" shows the result is identical. What combined command did you use? Perhaps you had a typo somewhere.

(I should say I tested on bash, not zsh. I don't know how they differ.)
snibgo's IM pages: im.snibgo.com
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: combine two commands into one (clone)

Post by mikmach »

Thank you very much! I've started to mess with parentheses and didn't go with simplest solution...
Post Reply