After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 621363 - CMYK decompose broken
CMYK decompose broken
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
2.6.8
Other All
: Normal minor
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2010-06-12 11:33 UTC by Rupert Weber
Modified: 2010-07-07 18:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix for described problem (5.62 KB, patch)
2010-06-29 00:01 UTC, Rupert Weber
needs-work Details | Review
Updated patch for current version (6.11 KB, patch)
2010-06-29 23:45 UTC, Rupert Weber
none Details | Review
cleaned up patch for gimp-2-6 (6.32 KB, patch)
2010-07-02 22:32 UTC, Sven Neumann
committed Details | Review
patch for gimp-2-7 (6.55 KB, patch)
2010-07-03 11:13 UTC, Rupert Weber
committed Details | Review

Description Rupert Weber 2010-06-12 11:33:15 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.)
Comment 1 Michael Schumacher 2010-06-12 11:57:02 UTC
See also bug #499794
Comment 2 Sven Neumann 2010-06-14 22:01:29 UTC
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.
Comment 3 Rupert Weber 2010-06-29 00:01:56 UTC
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)
Comment 4 Sven Neumann 2010-06-29 19:17:01 UTC
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.
Comment 5 Rupert Weber 2010-06-29 23:45:14 UTC
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.
Comment 6 Sven Neumann 2010-07-02 22:32:15 UTC
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.
Comment 7 Rupert Weber 2010-07-03 11:13:04 UTC
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.
Comment 8 Sven Neumann 2010-07-07 18:24:39 UTC
Thanks a lot for you help. I have applied the patches to their branches and pushed the changes to the git repository.