convert darkens an xcf image

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
DanielDD
Posts: 17
Joined: 2013-10-28T01:57:10-07:00
Authentication code: 6789

convert darkens an xcf image

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert darkens an xcf image

Post by snibgo »

Put it somewhere on the web, such as dropbox.com, and paste the URL here.

Please also paste your command here.
snibgo's IM pages: im.snibgo.com
DanielDD
Posts: 17
Joined: 2013-10-28T01:57:10-07:00
Authentication code: 6789

Re: convert darkens an xcf image

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert darkens an xcf image

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Dabrosny
Posts: 111
Joined: 2013-10-02T10:49:39-07:00
Authentication code: 6789
Location: New York, US

Re: convert darkens an xcf image

Post 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.)
-Dabrosny [Using IM7.0.6 or higher, Q16 HDRI x64 native executable, command line, often invoked from cygwin bash/sh (as of Aug. 2017)]
DanielDD
Posts: 17
Joined: 2013-10-28T01:57:10-07:00
Authentication code: 6789

Re: convert darkens an xcf image

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert darkens an xcf image

Post 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.
Last edited by snibgo on 2013-10-28T06:16:40-07:00, edited 1 time in total.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert darkens an xcf image

Post by dlemstra »

My mistake I read that the image should be darker. Can you post 'twoGrad2.png' somewhere snibgo?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert darkens an xcf image

Post by snibgo »

snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert darkens an xcf image

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert darkens an xcf image

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert darkens an xcf image

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: convert darkens an xcf image

Post 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
DanielDD
Posts: 17
Joined: 2013-10-28T01:57:10-07:00
Authentication code: 6789

Re: convert darkens an xcf image

Post by DanielDD »

I found a workaround:

Code: Select all

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

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

Re: convert darkens an xcf image

Post 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.
Post Reply