Page 1 of 1

Unexpected CMYK color conversion after PDF flatten

Posted: 2018-04-17T13:09:12-07:00
by latortuga
I'm trying to work through a rather unexpected issue when using convert to flatten a PDF. I'm using the Ruby library MiniMagick and the relevant portion of my code looks like this:

Code: Select all

      img.combine_options do |c|
        c.units("PixelsPerInch")
        c.density(300)
        c.resample(300)
        c.flatten
      end
If I'm not mistaken, this should translate to:

Code: Select all

convert -units "PixelsPerInch" -density 300 -resample 300 -flatten myfile.pdf
The issue is that my PDF comes out with slightly different colors than when it went in! For example, a light blue will be a teal color. Here's a partial diff output of identify -verbose for the before and after PDFs:

Code: Select all

23,26c23,26
<       mean: 20656.3 (0.315195)
<       standard deviation: 18880.7 (0.288101)
<       kurtosis: -1.27762
<       skewness: 0.240914
---
>       mean: 18761.9 (0.286287)
>       standard deviation: 18189.6 (0.277556)
>       kurtosis: -0.93749
>       skewness: 0.437875
30,33c30,33
<       mean: 13986.5 (0.21342)
<       standard deviation: 18464.2 (0.281746)
<       kurtosis: -0.530197
<       skewness: 0.969841
---
>       mean: 14568.8 (0.222306)
>       standard deviation: 19541.1 (0.298178)
>       kurtosis: -0.629342
>       skewness: 0.963269
37,40c37,40
<       mean: 18504.1 (0.282355)
<       standard deviation: 20566.7 (0.313828)
<       kurtosis: -0.50555
<       skewness: 0.868613
---
>       mean: 19502.4 (0.297588)
>       standard deviation: 20893.4 (0.318814)
>       kurtosis: -0.654855
>       skewness: 0.756789
43,47c43,47
<       max: 57568 (0.878431)
<       mean: 8170.54 (0.124674)
<       standard deviation: 16077.5 (0.245327)
<       kurtosis: 2.19983
<       skewness: 1.9042
---
>       max: 56797 (0.866667)
>       mean: 8710.56 (0.132915)
>       standard deviation: 17196.5 (0.262402)
>       kurtosis: 1.73386
>       skewness: 1.81423
52,56c52,56
<       mean: 15329.4 (0.233911)
<       standard deviation: 18566.7 (0.283309)
<       kurtosis: -0.172968
<       skewness: 1.0082
<   Total ink density: 299.608%
---
>       mean: 15385.9 (0.234774)
>       standard deviation: 19006.4 (0.290019)
>       kurtosis: -0.199657
>       skewness: 1.00662
>   Total ink density: 296.078%
77,78c77,78
<     date:create: 2018-04-17T14:40:17-05:00
<     date:modify: 2018-04-17T14:40:17-05:00
---
>     date:create: 2018-04-17T14:40:25-05:00
>     date:modify: 2018-04-17T14:40:25-05:00
80,81c80,81
<     pdf:Version: PDF-1.4
<     signature: 1404ed04acf621bec7ae56c0d0e8c740422b45e8f41b6e79a62461328d34cd59
---
>     pdf:Version: PDF-1.3  1 0 obj << 
>     signature: e07a3bb439b877b4b4fd76ec4588b248506f559d9a4b7294e9a05551bb35dc83
88,90c88,90
<   Pixels per second: 104.3MB
<   User time: 0.010u
<   Elapsed time: 0:01.010
---
>   Pixels per second: 0B
>   User time: 0.000u
>   Elapsed time: 0:01.000
I'm totally confused as to why the colors are changing on flatten. Any ideas?

Re: Unexpected CMYK color conversion after PDF flatten

Posted: 2018-04-17T14:05:30-07:00
by snibgo
What version of IM?

Your command has only one file -- either input or output. So it won't work.

Is the input CMYK? Does it have transparency? A profile?

With only a partial program, and only partial information about the image, we can only guess.