GNOME Bugzilla – Bug 621363
CMYK decompose broken
Last modified: 2010-07-07 18:24:39 UTC
CMY decompose works fine, CMYK does not. Under Colors->Components->Decompose (I use the German version, so I'm guessing menu names here). I am guessing that the function simply subtracts the black part from C,M,Y when it should first subtract black and then divide by (100%-black) [that is "100% minus black"]. The result is way to low values for C,M,Y: The maximum possible value per pixel is (100%-black) [again, "100% minus black"]. How to see/reproduce it: - Take any color photo/picture - Do a decompose to CMYK (or to CMY to see it working) - Change mode from Grayscale to RGB - Copy each layer to his mask - Erase then fill each layer with respective color - Add white background layer - Change mode of all color layers to Multiply (I don't have any CMYK profile installed, nor do I want to. I'm perfectly happy with the naive conversion.)
See also bug #499794
Please check the algorithm in libgimpcolor/gimpcmyk.c. If you think there's a bug, please point it out and/or send us a patch.
Created attachment 164853 [details] [review] Fix for described problem ok, so I finally dove in and fixed it. The error was in plug-ins/common/decompose.c and compose.c Some comments about what I did: libgimpcolor/gimpcolorspace.c already contained rgb/cmyk (floating point) conversion routines which work correctly. The Decompose/Recompose plugins did not use those but had its own (integer) algorithms. Instead of fixing those I rewrote the code to use the libgimpcolor routines. (Actually I first did fix them. But I didn't notice a meaningful speed advantage; and it just didn't feel right duplicate that functionality) So it seems to work now. I hope I didn't mess anything up -- this is my first time to supply a patch, so please have mercy... (and don't make me install git) :o)
Review of attachment 164853 [details] [review]: Looks good in general, but the patch doesn't seem to apply to the current development tree. If you could redo the patch against a git checkout and then submit the patch formatted using git-format-patch, that would be great. If that is asked too much, just let us know, then we can port the patch.
Created attachment 164937 [details] [review] Updated patch for current version git is all black magic to me, but it seems to have worked... :) Hope I used the right version this time (compiled to 2.6.10). Current patch works fine, did an additional test with a bitmap containing all possible RGB colors.
Created attachment 165152 [details] [review] cleaned up patch for gimp-2-6 Here's a version of your patch with some coding style cleanups and a properly formatted commit log. Unfortunately this patch is for the gimp-2-6 branch though and we usually apply fixes in the master branch first, then cherry-pick from there. This patch however does not apply to master. So someone needs to port these changes to master manually.
Created attachment 165173 [details] [review] patch for gimp-2-7 Third time's the charm. Maybe. This might actually be the patch for the current version. ;o) I tried to catch all your style objections. I appreciate your patience with a newcomer and hope that I'm not more hassle than help.
Thanks a lot for you help. I have applied the patches to their branches and pushed the changes to the git repository.