Something has changed around IM 6.7.2-10. Help please!

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
jaz99
Posts: 3
Joined: 2012-11-23T02:00:56-07:00
Authentication code: 6789

Something has changed around IM 6.7.2-10. Help please!

Post by jaz99 »

Hello, I'm new here and I hope I can get some help.
I'm using ImageMagick on regular basis in my scanning workflow to automate turning the C-41 negative with orange mask (in linear TIFF file) into the positive image.
I'm very happy with it, however the script stopped working with newest IM versions (latest working version reported by other is 6.7.2-10).

The core part of my script is:

Code: Select all

convert "input.tif[0]" -colorspace RGB \
    -channel R -fx "$1/u" \
    -channel G -fx "$2/u" \
    -channel B -fx "$3/u"  -channel RGB out.tif
The full script and test image are available here.

With the newest IM versions the generated colors are way off.

I've spent a lot of time searching for solution (including some -colorspace sRGB and -set colorspace sRGB|RGB experiments), however I've failed.
Does anybody know what has changed in the IM? I'm run out of ideas.

Regards, JaZ

P.S. Is it possible to speed up the -fx "1/u" operation?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Something has changed around IM 6.7.2-10. Help please!

Post by fmw42 »

can you give me test values for the original file test.tif for $1, $2, and $3 so I can test them.

Just using 0.1, the following two are equivalent. Not sure if that is what you want.


convert 1test.tif -set colorspace RGB \
-channel R -fx ".1/u" \
-channel G -fx ".1/u" \
-channel B -fx ".1/u" +channel 1tmp.tif


convert 1test.tif -set colorspace RGB -separate \
\( -clone 0 -fill "gray(10%)" -colorize 100% \) \
\( -clone 3 -clone 0 +swap -compose divide -composite \) \
\( -clone 3 -clone 1 +swap -compose divide -composite \) \
\( -clone 3 -clone 2 +swap -compose divide -composite \) \
-delete 0-3 -combine 1tmp2.tif
jaz99
Posts: 3
Joined: 2012-11-23T02:00:56-07:00
Authentication code: 6789

Re: Something has changed around IM 6.7.2-10. Help please!

Post by jaz99 »

I can't believe I havn't seen it before. There is a very vicious bug in IM.
In old Imagemagick versions the expression below is working OK, in spite the fact the is one extra parenthesis:

Code: Select all

.... %%[fx: log(maxima.b/minima.b)/log(maxima.r/minima.r))] ...
In newer versions the expression is yelding incorrect outcome without complaining about it.
I have corrected it and the script is working again!

Thanks for helping ;)

The second question remaining: is any way to process it faster?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Something has changed around IM 6.7.2-10. Help please!

Post by fmw42 »

As I mentioned in my second example above

convert 1test.tif -set colorspace RGB -separate \
\( -clone 0 -fill "gray(10%)" -colorize 100% \) \
\( -clone 3 -clone 0 +swap -compose divide -composite \) \
\( -clone 3 -clone 1 +swap -compose divide -composite \) \
\( -clone 3 -clone 2 +swap -compose divide -composite \) \
-delete 0-3 -combine 1tmp2.tif

use -compose divide for each 1/u. In the above I used .1/u so that is 10% gray divided by the image
Post Reply