Danbooru

Color space support in danbooru

Posted under Bugs & Features

It seems like, when an illustration is created with color spaces that are not sRGB, the thumbnailing algorithm cannot properly handle such image.
An example can be seen in post #2970342 which was created using the ProPhoto RGB color space, you see the text is colored in one color, but once you click the "view original" button, the text would become another color, as long as you are not using IE6 or some phone browsers. The color appear in original mode is correctly displayed by most browser while the thumbnailed image display the wrong color. The same problem probably will also occur when a CMYK or Adobe RGB colored image get uploaded.

tapnek said:

This is more of a browserside issue than an website issue. We can just have ImageMagick convert to the sRGB colorspace for thumbnails anyway.

If the browser is viewing the "original" file then it is displayed correctly,
However the thumbnail does not display correctly in the browser
So I believe it was caused by the color space information being dropped during the thumbnailing process

c933103 said:

Edit: If I uploaded the image there and then want to link the image in forum post here then is there any special dtext syntax for it?

No... DText links everything relatively. If you want to link Testbooru, then you have to either use the link itself or a textile link.

  • URL link: http://testbooru.donmai.us
    • Cannot have surrounding text
  • Bounded URL link: <http://testbooru.donmai.us>
    • Can have surrounding text
  • Textile link: "Visible link text":http://testbooru.donmai.us
    • Cannot have surrounding text
  • Bracketed Textile link: "Visible link text":[http://testbooru.donmai.us]
    • Can have surrounding text

See help:dtext for more.

c933103 said:

It seems like, when an illustration is created with color spaces that are not sRGB, the thumbnailing algorithm cannot properly handle such image.
An example can be seen in post #2970342 which was created using the ProPhoto RGB color space, you see the text is colored in one color, but once you click the "view original" button, the text would become another color, as long as you are not using IE6 or some phone browsers. The color appear in original mode is correctly displayed by most browser while the thumbnailed image display the wrong color. The same problem probably will also occur when a CMYK or Adobe RGB colored image get uploaded.

Danbooru’s sample and thumbnail generation code strips all color profiles from the output files to save space.

danbooru_image_resizer.rb line 18:

image.strip!

strip! documentation

The solution would be to unconditionally convert to sRGB before stripping. This works even if the input file has no profile because sRGB is assumed in that case anyway. With command line ImageMagick, this does the trick (if you have GhostScript installed):

convert input.png -resize 850x -profile /usr/share/color/icc/ghostscript/srgb.icc -strip sample.jpg

Unfortunately, I don’t know how to do that with RMagic in Ruby. Maybe one of our Ruby wizards can figure it out?

I’ll go open an issue for it.

c933103 said:

"You cannot upload during your first week of registration"

Hum ok. It'll probably be many weeks before I have some other things that would like to test

Danbooru uses ImageMagic (well, RMagick), so I suggest you install ImageMagick and play around with it locally to figure things out first.

Also, I noticed that you created your test image with Gimp. Interestingly, the color profile contained in your test PNG seems to be ignored when I load the file in Gimp. The colors I see are exactly the same as in the incorrectly generated sample (more olive/brown). The image also looks exactly the same in any other image viewer I tried (ImageMagick’s display, Eye of Gnome, MComix). Only Firefox displays the correct(?) more orange color.

Edit: Opened issue #3476.

Updated

Danbooru uses ImageMagic (well, RMagick), so I suggest you install ImageMagick and play around with it locally to figure things out first.

Also, I noticed that you created your test image with Gimp. Interestingly, the color profile contained in your test PNG seems to be ignored when I load the file in Gimp. The colors I see are exactly the same as in the incorrectly generated sample (more olive/brown). The image also looks exactly the same in any other image viewer I tried (ImageMagick’s display, Eye of Gnome, MComix). Only Firefox displays the correct(?) more orange color.

Humm the image is displayed correctly in Windows Photo Viewer here.
For GIMP, when I open the image, I would be presented with a dialogue box that would tell me the image is in a different color space and ask whether I want to convert the image to sRGB or keep it as is.

c933103 said:

For GIMP, when I open the image, I would be presented with a dialogue box that would tell me the image is in a different color space and ask whether I want to convert the image to sRGB or keep it as is.

My bad. I had color management globally turned off in Gimp. Now it’s working fine in Gimp.

This has been fixed, mostly. Non-sRGB images are converted to sRGB before stripping the color profile. It should be noted that now we're using libvips instead of ImageMagick, partly because ImageMagick couldn't convert to sRGB properly.

There's still an outstanding bug with certain non-sRGB PNGs not being converted to sRGB (issue #2870). As far as I can tell, this is a bug in ImageMagick that libvips also shares.

Existing samples/thumbnails still need to be regenerated, but that depends on fixing issue #3553 first.

1