Convert RGB SVG to CMYK SVG possible?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
futuremoose
Posts: 5
Joined: 2012-09-18T19:10:00-07:00
Authentication code: 67789

Convert RGB SVG to CMYK SVG possible?

Post by futuremoose »

Hello, ImageMagick users,

I have an SVG file in RGB colorspace... when I run IM's "identify", I get

Image: test_rgb.svg
Format: SVG (Scalable Vector Graphics)
Class: DirectClass
Geometry: 1500x1500+0+0
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB


I am then using the IM convert utility as follows (which works fine on my JPG and TIFF files):

convert rgb.svg -profile srgb.icm -profile uswebcoatedswop.icc rgb2cmyk.svg

I get the following "verbose" output
srgb.icm ICM 1x1 1x1+0+0 16-bit sRGB 3.14KB 0.000u 0:00.000
uswebcoatedswop.icc ICC 1x1 1x1+0+0 16-bit sRGB 557KB 0.094u 0:00.055
test_rgb.svg=>test_rgb2cmyk.svg SVG 644x429 644x429+0+0 16-bit ColorSeparationAlpha CMYK 0.827u 0:00.530


This seems to run with no errors, and produces the "test_rgb2cmyk.svg" file at about 8k (test_rgb.svg is 8k). However, the "test_rgb2cmyk.svg" will not display in either IE or Gimp, and if I try to run IM's "identify -verbose test_rgb2cmyk.svg" I get the following errors:


identify.exe: Unescaped '<' not allowed in attributes values
`No such file or directory` @ error/svg.c/SVGError/2644.
identify.exe: attributes construct error
`No such file or directory` @ error/svg.c/SVGError/2644.
identify.exe: error parsing attribute name
`No such file or directory` @ error/svg.c/SVGError/2644.
identify.exe: attributes construct error
`No such file or directory` @ error/svg.c/SVGError/2644.
identify.exe: xmlParseStartTag: problem parsing attributes
`No such file or directory` @ error/svg.c/SVGError/2644.
identify.exe: Couldn't find end of Start Tag g
`No such file or directory` @ error/svg.c/SVGError/2644.


NOTE: Gimp fails with
Opening 'C:\SVG_to_CMYK\test_rgb2cmyk.svg' failed:
Could not open 'C:\SVG_to_CMYK\test_rgb2cmyk.svg' for reading:
Error domain 1 code 73 on line 5 column 10 of
file:///C:/SVG_to_CMYK: Couldn't find end of Start Tag g


My questions: Is it possible to do such a conversion (RGB SVG to CMYK SVG)? Am I not using the correct options? The command as I show it is what I use, successfully, to convert JPG and TIFF images.

Any questions / comments? I have uploaded the "test_rgb.svg" file here:
http://www.jon-schmid.com/test_rgb.zip
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert RGB SVG to CMYK SVG possible?

Post by fmw42 »

I don't know too much about svg files, but they are xml text. So can you not just edit the file to change the colorspace.
futuremoose
Posts: 5
Joined: 2012-09-18T19:10:00-07:00
Authentication code: 67789

Re: Convert RGB SVG to CMYK SVG possible?

Post by futuremoose »

In the RGB version of the SVG, there are the following "fill" statements for each of the 5 colors (the first is the white background, and then there are 4 overlapping ovals, each a different color)

fill="#ffffff"
fill="#0126ff"
fill="#ffd800"
fill="#ff0000"
fill="#017f0e"

So, sure, it would be easy to go in and modify those values, but it would still be in RGB colorspace... what could I edit that would actually put the SVG into CMYK colorspace (if that's possible at all?)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert RGB SVG to CMYK SVG possible?

Post by fmw42 »

As I said I do not know much about svg. But why not specify cmyk(c,m,y,k) colors?
futuremoose
Posts: 5
Joined: 2012-09-18T19:10:00-07:00
Authentication code: 67789

Re: Convert RGB SVG to CMYK SVG possible?

Post by futuremoose »

Hi,

Thanks for your comments... SVG started supported CMYK color profiles with v1.2 ; you can see the specifics here:

http://www.w3.org/TR/SVGColor12/#icc-colors

So I think I have what I need... it's just that most (or maybe no) browsers can handle the "fill" parameter with the extra CMYK specification... that entity will be filled with "black" regardless of the fact that the RGB color is supposed to be the fallback.

Here is an example that looks fine in GIMP 2 (both circles green) but in both IE9 and Chrome the second circle is black

Code: Select all

<?xml version="1.0"?>
<parent xmlns="http://example.org"
        xmlns:svg="http://www.w3.org/2000/svg">
   <svg:svg width="400" height="200" version="1.2">
      <svg:ellipse cx="100" cy="100" rx="100" ry="100" 
		fill="rgb(0,255,0)" />
      <svg:ellipse cx="300" cy="100" rx="100" ry="100" 
		fill="rgb(0,255,0) device-cmyk(0.11, 0.48, 0.83, 0.00)" />
   </svg:svg>
</parent>
Post Reply