Saving project as PDF - negative colors

This is NOT a support forum. You are welcome to discuss software issues here, but all issues should be reported on Launchpad if you want them fixed.
wiitold
Posts: 5
Joined: Mon Jul 13, 2015 7:24 pm

Saving project as PDF - negative colors

Postby wiitold » Mon Jul 13, 2015 7:31 pm

Hi,
I'm curently transfering my projects, I used to make in Corel, to Inkscape. In one project I have background imported from JPG. After adding some text to this project i wanted to save it as PDF (to send it to printing house). But the results were disappointing. Text that was added in Inkscape is allright but background is in negative collors. Any ideas why? Maybe its some problem with RGB.

One more thing.
When im exporting same project as PNG everything is allright.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Saving project as PDF - negative colors

Postby brynn » Tue Jul 14, 2015 2:48 am

If you're on Windows, it sounds like you have run into a known problem with version 0.91, 64-bit. The last item in this list: http://wiki.inkscape.org/wiki/index.php ... own_issues. And for some more info: viewtopic.php?f=5&t=18969#p72293

You could try using the 32 bit version of 0.91.

wiitold
Posts: 5
Joined: Mon Jul 13, 2015 7:24 pm

Re: Saving project as PDF - negative colors

Postby wiitold » Tue Jul 14, 2015 8:19 am

Unfortunetly, im using Ubuntu 15.04 32 bit

Maybe I have installed Inkscaped 64bit on my 32 bit system? I cant find info about my version. I know its 0.91

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Tue Jul 14, 2015 8:51 am

wiitold wrote:Unfortunetly, im using Ubuntu 15.04 32 bit

Maybe I have installed Inkscaped 64bit on my 32 bit system? I cant find info about my version. I know its 0.91
The mentioned known problem is specific to Inkscape builds for Windows, and (as far as we know for now) specific to the (more recent) version of the cairo graphics library bundled with the 64bit Inkscape builds for Windows, and only happens when printing (either directly or to PDF via custom PDF printer driver), but not when saving as PDF.

And no, a 64bit build won't run on a 32bit system - neither on Windows nor on Linux.

You might want to consider sharing your files (Inkscape SVG file, PDF file saved with Inkscape) to allow others to take a closer look what might trigger your problem.

wiitold
Posts: 5
Joined: Mon Jul 13, 2015 7:24 pm

Re: Saving project as PDF - negative colors

Postby wiitold » Tue Jul 14, 2015 7:40 pm

Those files are too big so i had to upload them on my Google Drive.
https://drive.google.com/folderview?id= ... sp=sharing

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Saving project as PDF - negative colors

Postby Lazur » Tue Jul 14, 2015 8:10 pm

Saving as pdf works well on 0.48.4. -tested-.

wiitold
Posts: 5
Joined: Mon Jul 13, 2015 7:24 pm

Re: Saving project as PDF - negative colors

Postby wiitold » Tue Jul 14, 2015 8:56 pm

What does it mean? I have to downgrade my inkscape? Or maybe wait till next update comes out?

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Tue Jul 14, 2015 9:40 pm

The problem seems to be related to the image format; or rather that the JPEG image for the document background uses the colorspace CMYK (and AFAICT has an embedded ICC color profile).

Problems with such JPEG images seem not limited to Inkscape: Using ImageMagick's display command to view the JPEG image extracted from the SVG file displays with the same color inversion; PDF files created on the command line with rsvg-convert from librsvg produce the same kind of inverted background image in the generated PDF as Inkscape 0.91. For now, I don't really have advice (except maybe to recommend to use raster graphics with colorspace RGB for inclusion in SVG files).

Re Inkscape 0.48 - yes, with the old renderer, and the old PDF exporter which recompressed embedded bitmap images (bug 168708) in the exported PDF file, the exported PDF file seems to render as expected. That does not necessarily mean though that Inkscape 0.91 itself is broken (since the same output reproduces with other software which uses the same shared libraries) - it could be an issue with the original image data, with the embedded version of the original image, with the cairo graphics library (or even with gdk-pixbuf, I don't really know).

Since we don't have the original JPEG image available for further tests (we can't verify the content of the one embedded in the SVG file via gdk-pixbuf) - could you test what happens if you link the bitmap image on import (instead of embedding it into the SVG file)? I doubt that it would make any difference, but one never knows ...

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Saving project as PDF - negative colors

Postby Lazur » Tue Jul 14, 2015 9:59 pm

You can try embedding a raster image of a different format, like a png.
(Extracted the raster image and saved as png with gimp, then embedded it again.)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Tue Jul 14, 2015 10:15 pm

Lazur URH wrote:You can try embedding a raster image of a different format, like a png.
(Extracted the raster image and saved as png with gimp, then embedded it again.)
I'm aware of this - my point was that we cannot tell if any detail of the original image data was changed (or dropped) at the time it was converted to base64-encoded data when embedding the image on import. Thus I do not consider further tests on a bitmap image extracted from the SVG file (which at that point would have undergone two conversion with different software libraries (gdk-pixbuf, python)) as necessarily providing conclusive information.

wiitold - as author of the SVG file - likely has the original, unmodified version of the JPEG image still available - I'd recommend to convert that one to a different image format and color space, if needed.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Saving project as PDF - negative colors

Postby Lazur » Tue Jul 14, 2015 10:24 pm

~suv wrote:I'm aware of this


I know, just thought the original raster image might not be at the hands of the original poster -as it contains text already merged-, and wanted a working file, regardless brute-forcing.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Tue Jul 14, 2015 10:34 pm

In case anyone with more insight into color space and color conversion issues (e.g. in cairo's output to PDF surface) than me is following this topic, here are some of the technical details I took note of while testing wiitold's files:
  • The tests to save the provided SVG file as PDF reproduce inverted colors with Inkscape 0.91 r13725 and Inkscape 0.91+devel r14245 (latest trunk), using current stable cairo (1.14.2) or cairo git master (1.14.3), and with librsvg 2.40.9 (cairo 1.14.2) on OS X 10.7.5
  • Based on tests with archived Inkscape trunk builds, this commit introduced the change in Inkscape 0.91 (compared to Inkscape 0.48.x): r12516
  • Another JPEG image I happened to find among the test cases from the bug tracker (otherwise unrelated) which also uses colorspace CMYK, and a (different) embedded color profile, produces the same inverted colors when included in an SVG file and exported to PDF, or when viewed with X11-based 'display' command from ImageMagick.
  • ImageMagick version tested to display both CMYK JPEG images: 6.7.8-3, 6.9.1-6

wiitold
Posts: 5
Joined: Mon Jul 13, 2015 7:24 pm

Re: Saving project as PDF - negative colors

Postby wiitold » Wed Jul 15, 2015 9:04 am

Original background is in RGB so its not problem with CMYK. I saved background as PDF and the imported it to final project and everything went smooth. Colors were ok. But just for sake of discussion and for knowledge, why it happened with JPG, but didnt with PDF?

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Wed Jul 15, 2015 10:16 am

wiitold wrote:Original background is in RGB so its not problem with CMYK.
*shrug* If you say so …
wiitold wrote:I saved background as PDF and the imported it to final project and everything went smooth. Colors were ok. But just for sake of discussion and for knowledge, why it happened with JPG, but didnt with PDF?
Since the data shared earlier (Inkscape SVG file with embedded bitmap image as background which exported incorrectly to PDF) apparently does not match what original files you actually use (CMYK JPEG vs RGB Image (format unknown)), and it is unknown how that other PDF file now used for the drawing background was created and what it contains, I don't know an answer to this question.

Image information of the bitmap image extracted from SVG file shared earlier, as identified by ImageMagick:

Code: Select all

Image: /tmp/JPEG_Image_1819x2551_pixels.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1819x2551+0+0
  Resolution: 300x300
  Print size: 6.06333x8.50333
  Units: PixelsPerInch
  Type: ColorSeparation
  Endianess: Undefined
  Colorspace: CMYK
  Depth: 8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 8-bit
  Channel statistics:
    Pixels: 4640269
    Cyan:
      min: 0 (0)
      max: 255 (1)
      mean: 62.3235 (0.244406)
      standard deviation: 46.0506 (0.180591)
      kurtosis: 3.11137
      skewness: 1.62513
      entropy: 0.865104
    Magenta:
      min: 0 (0)
      max: 255 (1)
      mean: 159.039 (0.623684)
      standard deviation: 80.7731 (0.316757)
      kurtosis: -1.07238
      skewness: -0.656647
      entropy: 0.909482
    Yellow:
      min: 0 (0)
      max: 255 (1)
      mean: 177.438 (0.695834)
      standard deviation: 75.4784 (0.295994)
      kurtosis: -0.355514
      skewness: -0.96737
      entropy: 0.785401
    Black:
      min: 0 (0)
      max: 255 (1)
      mean: 54.5513 (0.213927)
      standard deviation: 57.5692 (0.225761)
      kurtosis: 1.52379
      skewness: 1.3703
      entropy: 0.873059
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 113.338 (0.444462)
      standard deviation: 66.4382 (0.260542)
      kurtosis: 1.43034
      skewness: 0.649618
      entropy: 0.858262
  Total ink density: 363.137%
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: cmyk(255,255,255,0)
  Border color: cmyk(223,223,223,0)
  Matte color: cmyk(189,189,189,0)
  Transparent color: cmyk(0,0,0,0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1819x2551+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: TopLeft
  Properties:
    date:create: 2015-07-15T01:39:47+02:00
    date:modify: 2015-07-15T01:39:46+02:00
    dc:format: image/jpeg
    exif:ColorSpace: -1
    exif:DateTime: 2015:07:13 10:22:56
    exif:ExifImageLength: 2551
    exif:ExifImageWidth: 1819
    exif:ExifOffset: 164
    exif:NativeDigest: 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;0C4297AA63C3AD0C971DFE4B22403C0D
    exif:Orientation: 1
    exif:PixelXDimension: 1819
    exif:PixelYDimension: 2551
    exif:ResolutionUnit: 2
    exif:Software: Adobe Photoshop CS2 Windows
    exif:thumbnail:Compression: 6
    exif:thumbnail:JPEGInterchangeFormat: 302
    exif:thumbnail:JPEGInterchangeFormatLength: 7024
    exif:thumbnail:ResolutionUnit: 2
    exif:thumbnail:XResolution: 72/1
    exif:thumbnail:YResolution: 72/1
    exif:XResolution: 3000000/10000
    exif:YResolution: 3000000/10000
    icc:copyright: Copyright 2004 Adobe Systems, Inc.
    icc:description: Europe ISO Coated FOGRA27
    icc:manufacturer: Europe ISO Coated FOGRA27
    icc:model: Europe ISO Coated FOGRA27
    jpeg:colorspace: 4
    jpeg:sampling-factor: 1x1,1x1,1x1,1x1
    photoshop:ColorMode: 4
    photoshop:ICCProfile: Europe ISO Coated FOGRA27
    signature: 9a4ee0ba533e77d6e0c1a0e511f4c6d23391f89908f889e7b9a397e08deb4e0a
    stRef:documentID: uuid:5A7C09FC8C4CE41197C0A7851BE67CF5
    stRef:instanceID: uuid:F04721D4904CE41197C0A7851BE67CF5
    tiff:NativeDigest: 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;5E08A0390FE075236D261A043546AE5E
    tiff:Orientation: 1
    tiff:ResolutionUnit: 2
    tiff:XResolution: 3000000/10000
    tiff:YResolution: 3000000/10000
    xap:CreateDate: 2015-07-13T10:22:56+02:00
    xap:CreatorTool: Adobe Photoshop CS2 Windows
    xap:MetadataDate: 2015-07-13T10:22:56+02:00
    xap:ModifyDate: 2015-07-13T10:22:56+02:00
    xapMM:DocumentID: uuid:08D21CEC3729E5119EFCD122947328B9
    xapMM:InstanceID: uuid:09D21CEC3729E5119EFCD122947328B9
  Profiles:
    Profile-8bim: 9138 bytes
    Profile-exif: 7332 bytes
    Profile-icc: 557168 bytes
    Profile-iptc: 7 bytes
      unknown[2,0]:
    Profile-xmp: 15007 bytes
  Artifacts:
    filename: /tmp/JPEG_Image_1819x2551_pixels.jpg
    verbose: true
  Tainted: False
  Filesize: 7.014MB
  Number pixels: 4.64M
  Pixels per second: 149.69GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.1-6 Q16 x86_64 20150613 http://www.imagemagick.org
(verified as identical by two independent extraction methods: Inkscape's Python 2.7 script (Extensions > Images > Extract Image) and Firefox 38.0.5)

PDF info and list of images embedded in the PDF file shared earlier:

Code: Select all

$ pdfinfo Ulotka.pdf
Creator:        cairo 1.14.2 (http://cairographics.org)
Producer:       cairo 1.14.2 (http://cairographics.org)
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      436.535 x 612.283 pts
Page rot:       0
File size:      9330610 bytes
Optimized:      no
PDF version:    1.5

$ pdfimages -list Ulotka.pdf
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1     0 image    1819  2551  cmyk    4   8  jpeg   yes        5  0   301   300 6850K  38%
   1     1 image     470   111  gray    1   1  image  yes        6  0   301   301   29B 0.4%
   1     2 smask     470   111  gray    1   8  image  yes        6  0   301   301 12.1K  24%
   1     3 image    1023   157  gray    1   1  image  yes       54  0   301   301   41B 0.2%
   1     4 smask    1023   157  gray    1   8  image  yes       54  0   301   301 38.1K  24%
   1     5 image    3543  2796  rgb     3   8  image  yes       12  0 10595 10595  279K 1.0%
   1     6 smask    3543  2796  gray    1   8  image  yes       12  0 10595 10595  151K 1.6%
   1     7 image    3543  2939  rgb     3   8  image  yes       14  0 13479 13479  149K 0.5%
   1     8 smask    3543  2939  gray    1   8  image  yes       14  0 13479 13479 87.1K 0.9%
   1     9 image    3543  1966  rgb     3   8  image  yes       16  0  7773  7773  197K 1.0%
   1    10 smask    3543  1966  gray    1   8  image  yes       16  0  7773  7773 88.4K 1.3%
   1    11 image    3543  3557  rgb     3   8  image  yes       17  0 24108 24108  310K 0.8%
   1    12 smask    3543  3557  gray    1   8  image  yes       17  0 24108 24108 21.8K 0.2%
   1    13 image    3543  1266  rgb     3   8  image  yes       18  0 10239 10239  137K 1.0%
   1    14 smask    3543  1266  gray    1   8  image  yes       18  0 10239 10239 62.2K 1.4%
   1    15 image    3543  1065  rgb     3   8  image  yes       19  0 10733 10733  576K 5.2%
   1    16 smask    3543  1065  gray    1   8  image  yes       19  0 10733 10733 6701B 0.2%
   1    17 image    1360   664  gray    1   1  image  yes       20  0  3250  3250  132B 0.1%
   1    18 smask    1360   664  gray    1   8  image  yes       20  0  3250  3250 75.0K 8.5%

$ pdfimages -v
pdfimages version 0.34.0
Copyright 2005-2015 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Saving project as PDF - negative colors

Postby ~suv » Wed Jul 15, 2015 7:54 pm

wiitold wrote:I saved background as PDF and the imported it to final project and everything went smooth. Colors were ok. But just for sake of discussion and for knowledge, why it happened with JPG, but didnt with PDF?

As far as I can tell, Inkscape's own PDF importer will encode embedded bitmap images from PDF files always as PNG data.

Converting PDF to SVG using 'poppler' directly (either as Inkscape PDF import option, or on the command line with poppler's 'pdftocairo') on the other hand will use the mime data of the embedded bitmap image if applicable (i.e. not in all cases), and otherwise also seems to default to encoding the embedded image as PNG data in the output to the cairo SVG surface.

The observed inverted colors of embedded bitmap images in cairo-based PDF exports seems to be only triggered with certain bitmap images (embedded or linked in the original SVG) which have mime type JPEG and use colorspace CMYK (i.e. not if the image data is PNG).


Return to “Discuss Software Issues”