-fx fails in one case

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
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

-fx fails in one case

Post by GreenKoopa » 2014-10-03T14:38:42-07:00

Code: Select all

convert rose: -evaluate Set 50% test_1.png
convert rose: -fx "0.5" test_2.png
convert in.tif -evaluate Set 50% test_3.png
convert in.tif -fx "0.5" test_4.png
The first three test cases result in a gray image as expected. The forth results in a black image. Has anyone encountered this before?

in.tif is 78MB, 16MP, 16-bit RGB tif output from Adobe Lightroom 5.5. IM reports warnings on some tags, but these files are handled properly outside of -fx. This happens using more than one such file. I can upload it tonight if needed.

This happens with the current version of IM, as well as a months old version.

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

Re: -fx fails in one case

Post by snibgo » 2014-10-03T15:55:40-07:00

On IM v6.8.9-5, on Windws 8.1, I can't reproduce the problem.

Code: Select all

F:\web\im>%IM%convert rose: -depth 16 -type truecolor r.tiff

F:\web\im>%IM%convert r.tiff -fx "0.5" -unique-colors txt:
# ImageMagick pixel enumeration: 1,1,65535,gray
0,0: (50.0008%,50.0008%,50.0008%)  #800080008000  gray(50.0008%)
Perhaps there is something distinctive in your file. If you upload it, someone can take a look.

What version IM are you using? What platform?
snibgo's IM pages: im.snibgo.com

User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: -fx fails in one case

Post by GreenKoopa » 2014-10-03T16:00:36-07:00

This test shows it too:

Code: Select all

convert in.tif -format "%[mean]\n" info:-
> 28624
convert in.tif -strip -resize 200x200 -format "%[mean]\n" info:-
> 28626.4
convert in.tif -fx "0.5" -format "%[mean]\n" info:-
> 0
convert in.tif -strip -resize 200x200 -fx "0.5" -format "%[mean]\n" info:-
> 0
convert in.tif in2.tif
convert in2.tif -fx "0.5" -format "%[mean]\n" info:-
> 32768
I am on Windows 7.

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

Re: -fx fails in one case

Post by snibgo » 2014-10-03T17:47:44-07:00

Perhaps there is something distinctive in your file. If you upload it, someone can take a look.

What version IM are you using?
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -fx fails in one case

Post by fmw42 » 2014-10-03T19:51:55-07:00

what are you expecting

convert in.tif -fx "0.5" ...

to do? If you want to make the image half as bright, then I believe you want

convert in.tif -fx "u*0.5"

see
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx

Perhaps I misunderstand what you are trying to do?

User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: -fx fails in one case

Post by GreenKoopa » 2014-10-03T21:32:17-07:00

I expect a gray image, as demonstrated in the other tests. Of course I want -fx to work for a more complex case, but "0.5" is the most "neutral" operation I could conjure.

An example image:
https://drive.google.com/file/d/0Bxw3ym ... pPNS0zcTA/

Tested using IM 6.8.8-1 and 6.8.9-8 on Windows 7 with several tiffs outputted from Adobe Lightroom 5.5. This happens with any size image, compressed or not, 8 or 16 bit. I think it has something to do with the tiff settings or metadata, but I reached a dead end there. Now I'm just using the workaround I demonstrated for in2.tif earlier.

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -fx fails in one case

Post by fmw42 » 2014-10-04T19:31:05-07:00

Does it fail for other formats, PNG, JPG, GIF, etc? Is it particular to one TIF file or all?

User avatar
fmw42
Posts: 25761
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -fx fails in one case

Post by fmw42 » 2014-10-04T19:45:48-07:00

I can reproduce this in IM 6.8.9.8 Q16 Mac OSX with the image provided.

convert in.tif -fx "0.5" show:

is black, even if I add -strip.

Whereas converted to PNG it comes out properly gray.

convert in.tif in.png
convert in.png -fx "0.5" show:


If I convert other format images to tif, such as png or jpg (24 bit color, just as in the supplied image), it works fine.

So there appears to be something odd about this image. But I opened it in Photoshop CS (very old) and it looks fine. It appears to be just 8-bit per channel RGB with only the one layer. So I am puzzled about why this might be happening.

User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: -fx fails in one case

Post by GreenKoopa » 2014-10-04T20:29:19-07:00

The weirdest part is Lightroom tiffs work great in IM. My only problem has been -fx, and I have no hypothesis as to how this could be.

User avatar
magick
Site Admin
Posts: 11098
Joined: 2003-05-31T11:32:55-07:00

Re: -fx fails in one case

Post by magick » 2014-10-05T06:22:51-07:00

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.9-9 Beta, available by sometime tomorrow. Thanks.

Post Reply