Page 1 of 1

convert darkens an xcf image

Posted: 2013-10-28T02:07:19-07:00
by DanielDD
Hallo,

I have Fedora 19, ImageMagick-6.7.8.9-5.fc19.i686 I use convert on a xcf, but the result is
darker than the original image.

Could you please allow me to attach the xcf-file?

DanielDD

Re: convert darkens an xcf image

Posted: 2013-10-28T03:50:59-07:00
by snibgo
Put it somewhere on the web, such as dropbox.com, and paste the URL here.

Please also paste your command here.

Re: convert darkens an xcf image

Posted: 2013-10-28T04:01:17-07:00
by DanielDD
Link: https://www.dropbox.com/s/v8a7b7vp3d7pcny/i1.xcf

I took a photo with a Canon 70D, and I cropped a part with gimp.

I tried convert i1.xcf i1.jpg
but the image becomes darker.

DanielDD

Re: convert darkens an xcf image

Posted: 2013-10-28T04:23:37-07:00
by dlemstra
It seems that ImageMagick sets the colorspace to sRGB instead of RGB. Not sure if this is a bug. Changing the colorspace to RGB fixes the problem.

Re: convert darkens an xcf image

Posted: 2013-10-28T05:17:50-07:00
by Dabrosny
dlemstra wrote:It seems that ImageMagick sets the colorspace to sRGB instead of RGB. Not sure if this is a bug. Changing the colorspace to RGB fixes the problem.
Should IM assume an xcf image is RGB by default? Is there something in the image format that indicates this or is it always in the same colorspace? (Of course if someone want to get the results even more accurate, they might have to use an icc profile of the image format or camera for the transformation to sRGB.)

Re: convert darkens an xcf image

Posted: 2013-10-28T05:26:09-07:00
by DanielDD
I tried:

Code: Select all

convert i1.xcf   -colorspace RGB   i1.jpg
and

Code: Select all

convert   -colorspace RGB   i1.xcf   i1.jpg
The image became even darker.

Using sRGB instead of RGB produced the same result as before.

DanielDD

Re: convert darkens an xcf image

Posted: 2013-10-28T05:37:26-07:00
by snibgo
There seems to be a bug, though I don't know whether in IM or Gimp.

1. Create a sample file:

Code: Select all

"%IM%convert" -size 300x200 xc: ^
  -sparse-color Bilinear "0,0 white %%[fx:w-1],0 rgb(90%%,60%%,50%%) 0,%%[fx:h-1] rgb(20%%,30%%,40%%) %%[fx:w-1],%%[fx:h-1] black" ^
  twoGrad.png
2. Read this in Gimp v2.8.2. Save as twoGrad.xcf, and export as twoGrad2.png.

3. Convert the XCF to PNG, and compare with the original.

D:\web\im>%IM%convert twoGrad.xcf tg.png

D:\web\im>%IM%compare -metric RMSE twoGrad.png tg.png NULL:
12589.7 (0.192106) <== bad

4. Convert the XCF to PNG, forcing a conversion from RGB->sRGB, and compare with the original.

D:\web\im>%IM%convert twoGrad.xcf -set colorspace RGB -colorspace sRGB tgrgb.png

D:\web\im>%IM%compare -metric RMSE twoGrad.png tgrgb.png NULL:
4009.47 (0.0611806) <== acceptable

5. Compare the PNG creeated by Gimp with the original.

D:\web\im>%IM%compare -metric RMSE twoGrad.png twoGrad2.png NULL:
94.0714 (0.00143544) <== good

EDIT to add: tests done with IM v6.8.7-0 and Gimp 2.8.2 on Windows 7.

Re: convert darkens an xcf image

Posted: 2013-10-28T06:02:13-07:00
by dlemstra
My mistake I read that the image should be darker. Can you post 'twoGrad2.png' somewhere snibgo?

Re: convert darkens an xcf image

Posted: 2013-10-28T06:11:26-07:00
by snibgo

Re: convert darkens an xcf image

Posted: 2013-10-28T07:43:10-07:00
by dlemstra
I get an error when I run your command:
convert.exe: invalid argument for option `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/522.

Re: convert darkens an xcf image

Posted: 2013-10-28T08:09:25-07:00
by snibgo
Copying the command into a bat file, and executing that, works for me (on Windows 7).

It also works by pasting it directly into a command window, but then we need to replace each "%%[fx" with "%[fx".

If on Unix, it needs more changes, of course.

Re: convert darkens an xcf image

Posted: 2013-10-28T08:42:07-07:00
by dlemstra
I just copy pasted into the command line and that didn't work. It works when I run it from a batch file, I will investigate it further.

Re: convert darkens an xcf image

Posted: 2013-10-28T09:29:05-07:00
by glennrp
This works on Ubuntu:

Code: Select all

convert -debug coder -log %e -verbose -size 300x200 xc: \
  -sparse-color Bilinear '0,0 white %[fx:w-1],0 rgb\(90%,60%,50%\) 0,%[fx:h-1] rgb\(20%,30%,40%\) %[fx:w-1],%[fx:h-1] black' \
  twoGrad.png

Re: convert darkens an xcf image

Posted: 2013-10-28T10:04:57-07:00
by DanielDD
I found a workaround:

Code: Select all

xcf2pnm i1.xcf | convert - i1.jpg
xcf2pnm is a part of the xcftools package.

DanielDD

Re: convert darkens an xcf image

Posted: 2013-11-03T10:34:56-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.7-5 Beta available by sometime tomorrow. Thanks.