How can I change the color model of an SVG image from RGB to CMYK and vice versa?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I change the color model of an SVG image from RGB to CMYK and vice versa?

olivierk
Hi, our web app let users download dynamically generated images in different formats, including SVG. Some of our users download the images for printing, thus we would like to allow them to choose between RGB or CMYK. Is there a way to specify the color model when creating an SVG image? If not, what is the default color model and how can I change it to another? Code snippets are welcome :)

Thanks,

Olivier.
Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Jeremias Maerki-2
Olivier,
a question for you to begin with: do you know the difference between
calibrated and uncalibrated/device colors? I'm asking because when
people talk RGB or CMYK they very often mean uncalibrated/device colors.
That's not something that is useful except if you have the whole
printing workflow fully under control. Only in this case can you work
without color management.

That said, an SVG image must always have sRGB colors (not true for
referenced bitmap images). Any other colors are always added as
alternatives that are taken if supported. Right now, SVG supports only
icc-color(), i.e. ICC-based calibrated colors. That way, it is possible
to define calibrated CMYK colors. AFAIK, SVGGraphics2D only generates
sRGB colors right now. So even if you specify an ICC-based Paint/Color on
the Graphics2D side, the color in SVG will end up being converted to
sRGB through Java's color management.

In the end, I believe that unless your application creates images that
need to be in exact colors (ex. CI/CD colors from a company, spot colors) for
a printing workflow, it doesn't make much sense to think about switching
between color models in the context of SVG. Just use sRGB. The printer
will then convert the sRGB to the printer's specific CMYK color space
through one single conversion (if the calibrated colors get preserved
through the whole workflow).

If the only thing you had in mind was converting some RGB value with a
fixed formula to CMYK (i.e. uncalibrated colors), you're better off just
working with sRGB.

http://en.wikipedia.org/wiki/Color_management

HTH

On 17.12.2010 17:24:34 olivierk wrote:

>
> Hi, our web app let users download dynamically generated images in different
> formats, including SVG. Some of our users download the images for printing,
> thus we would like to allow them to choose between RGB or CMYK. Is there a
> way to specify the color model when creating an SVG image? If not, what is
> the default color model and how can I change it to another? Code snippets
> are welcome :)
>
> Thanks,
>
> Olivier.
> --
> View this message in context: http://batik.2283329.n4.nabble.com/How-can-I-change-the-color-model-of-an-SVG-image-from-RGB-to-CMYK-and-vice-versa-tp3092769p3092769.html
> Sent from the Batik - Users mailing list archive at Nabble.com.



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Martin Jacobson
I'm going to join this thread because I have an application that
produces SVG maps that are ultimately printed to a vitreous enamel
panel that forms part of a street sign. The app has to work in RGB
because SVG only understands RGB, but the graphic design specification
defines all colours as precise CMYK values. These CMYK values were
arrived at by experimentation with the printer, and cannot be
compromised.
As you know, most RGB values map to a range of CMYK values, depending
mostly on the amount of black (K), so there isn't a nice 1 to 1
relationship between RGB & CMYK. Is there a simple, and foolproof way
of doing the conversion? Our method at the moment is a horrendous hack
that I would blush to describe!

thanks
Martin

On 17 December 2010 21:41, Jeremias Maerki <[hidden email]> wrote:

> Olivier,
> a question for you to begin with: do you know the difference between
> calibrated and uncalibrated/device colors? I'm asking because when
> people talk RGB or CMYK they very often mean uncalibrated/device colors.
> That's not something that is useful except if you have the whole
> printing workflow fully under control. Only in this case can you work
> without color management.
>
> That said, an SVG image must always have sRGB colors (not true for
> referenced bitmap images). Any other colors are always added as
> alternatives that are taken if supported. Right now, SVG supports only
> icc-color(), i.e. ICC-based calibrated colors. That way, it is possible
> to define calibrated CMYK colors. AFAIK, SVGGraphics2D only generates
> sRGB colors right now. So even if you specify an ICC-based Paint/Color on
> the Graphics2D side, the color in SVG will end up being converted to
> sRGB through Java's color management.
>
> In the end, I believe that unless your application creates images that
> need to be in exact colors (ex. CI/CD colors from a company, spot colors) for
> a printing workflow, it doesn't make much sense to think about switching
> between color models in the context of SVG. Just use sRGB. The printer
> will then convert the sRGB to the printer's specific CMYK color space
> through one single conversion (if the calibrated colors get preserved
> through the whole workflow).
>
> If the only thing you had in mind was converting some RGB value with a
> fixed formula to CMYK (i.e. uncalibrated colors), you're better off just
> working with sRGB.
>
> http://en.wikipedia.org/wiki/Color_management
>
> HTH
>
> On 17.12.2010 17:24:34 olivierk wrote:
>>
>> Hi, our web app let users download dynamically generated images in different
>> formats, including SVG. Some of our users download the images for printing,
>> thus we would like to allow them to choose between RGB or CMYK. Is there a
>> way to specify the color model when creating an SVG image? If not, what is
>> the default color model and how can I change it to another? Code snippets
>> are welcome :)
>>
>> Thanks,
>>
>> Olivier.
>> --
>> View this message in context: http://batik.2283329.n4.nabble.com/How-can-I-change-the-color-model-of-an-SVG-image-from-RGB-to-CMYK-and-vice-versa-tp3092769p3092769.html
>> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
>
> Jeremias Maerki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
From my MacBook Pro

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Johan Stuyts-3
> Is there a simple, and foolproof way of doing the conversion?

The short answer: no.

Any kind of value is useless without the correct unit (in this case: color  
spaces). There are many CMYK and RGB spaces and unless you know what your  
source and target spaces are, you don't know what color is actually  
intended, and the only thing you can do is guess. And that is what you are  
doing now.

To resolve the situation you have to:
- Ask the designer which CMYK color space is used for the source files. If  
they can't tell you, they don't know what color they want.
- Create an RGB color profile for your printer/product. In your case I  
guess this could be quite difficult because you don't print on paper. You  
can use sRGB if you can't create a color profile, but I expect that this  
doesn't come close to the color profile of your final product.
- Send your RGB color profile to the designer, so they can check that the  
CMYK colors they choose can actually be reproduced on your printer.
- The designer must decide which rendering intent you must use to convert  
the CMYK colors to the RGB colors of your printer. This can differ per  
file ('saturation' is typically used for logos, while 'relative  
colorimetric' is common for pictures).
- Convert the CMYK colors in the files you receive to RGB colors using the  
rendering intent specified by the designer before you print them.

It is a lot of work, but it will save you and the designers a lot of  
hassle once it has been set up.

Regards,

Johan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Jeremias Maerki-2
In reply to this post by Martin Jacobson
On 19.12.2010 18:10:42 Martin Jacobson wrote:
> I'm going to join this thread because I have an application that
> produces SVG maps that are ultimately printed to a vitreous enamel
> panel that forms part of a street sign. The app has to work in RGB
> because SVG only understands RGB, but the graphic design specification

/s/only understands RGB/always requires a fallback sRGB value

SVG does support non-RGB colors. But currently, Batik doesn't support
passing on non-sRGB colors (they are converted to sRGB). I've added
support for that this summer in development branches [1] which I'm in
the process of getting ready to merge back into the respective trunks.

> defines all colours as precise CMYK values. These CMYK values were
> arrived at by experimentation with the printer, and cannot be
> compromised.
> As you know, most RGB values map to a range of CMYK values, depending
> mostly on the amount of black (K), so there isn't a nice 1 to 1
> relationship between RGB & CMYK. Is there a simple, and foolproof way
> of doing the conversion? Our method at the moment is a horrendous hack
> that I would blush to describe!

No, there is no foolproof way for such a conversion. Color conversions
have the habit of being lossy. In your case, I believe there are two
possible ways:

1. if you can get hold of the ICC output color profile for your printer,
you can specify your carefully determined CMYK values with the
icc-color() function [2] and the color-profile element [3].

2. you can use the new functions specified in the SVG Color 1.2 working
draft to specify device-specific CMYK colors (device-cmyk() function [4]).
I've implemented this in the color branches but this is work in progress
on the side of the specification so this can still change.

But in both cases, you need the code from the color branches to have the
colors make it into the PDF "as is".

[1] http://wiki.apache.org/xmlgraphics/ColorHandling
[2] http://www.w3.org/TR/SVG11/types.html#DataTypeICCColor
[3] http://www.w3.org/TR/SVG11/color.html#ColorProfileElement
[4] http://www.w3.org/TR/SVGColor12/#device

> thanks
> Martin
<snip/>


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

BATIK RASTERIZER under Linux is not rendering TEXT

Petronel MALUTAN
BATIK RASTERIZER under Linux is not rendering TEXT
Anyone please have any ideea what can be wrong with this ?

Petronel

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: BATIK RASTERIZER under Linux is not rendering TEXT

Helder Magalhães
Administrator
Hi Petronel,


> BATIK RASTERIZER under Linux is not rendering TEXT
> Anyone please have any ideea what can be wrong with this ?

It's funny that's under Linux and you provide almost no information
(Java vendor, JDK/JRE version, Linux flavor - remember there are
dozens!, Batik version, etc.) but it might be related with bug 47917
[1].

Please confirm if so and add, at least, the missing information above
and other you may find interesting to help us understanding what's
happening.

Hope this helps,
 Helder


[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=47917

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: BATIK RASTERIZER under Linux is not rendering TEXT

Petronel MALUTAN
Hi All

I was not sure I am really adding messages to a queue somewhere so please
excuse me beeing so short.

I was tested the issue with 2 standard installations of the CENTOS 5.5

1. Provided as VPS by hostv.com

java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

java -Xmx50M -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

Batik is 1.7
and the command I issue is working fine under windows where I was able to
use batik 1.7 from the version 1.5 I think

The svg is at www.referax.ro/ALFA1.SVG and is containing Arial and Arial MS,
then I've installed msfonts on the VPS

Same result !
Now ed_ on irc told me to try to install sun-java but not sure how to do
that

2. Installed by me on a Vista host inside a VBOX same CENTOS

Is anybody having some ideeas ?

With kind regards

Petronel

----- Original Message -----
From: "Helder Magalhães" <[hidden email]>
To: <[hidden email]>
Sent: Monday, December 20, 2010 7:43 PM
Subject: Re: BATIK RASTERIZER under Linux is not rendering TEXT


> Hi Petronel,
>
>
>> BATIK RASTERIZER under Linux is not rendering TEXT
>> Anyone please have any ideea what can be wrong with this ?
>
> It's funny that's under Linux and you provide almost no information
> (Java vendor, JDK/JRE version, Linux flavor - remember there are
> dozens!, Batik version, etc.) but it might be related with bug 47917
> [1].
>
> Please confirm if so and add, at least, the missing information above
> and other you may find interesting to help us understanding what's
> happening.
>
> Hope this helps,
> Helder
>
>
> [1] https://issues.apache.org/bugzilla/show_bug.cgi?id=47917
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Chris Lilley
In reply to this post by Jeremias Maerki-2
On Monday, December 20, 2010, 9:33:57 AM, Jeremias wrote:

JM> On 19.12.2010 18:10:42 Martin Jacobson wrote:
>> I'm going to join this thread because I have an application that
>> produces SVG maps that are ultimately printed to a vitreous enamel
>> panel that forms part of a street sign. The app has to work in RGB
>> because SVG only understands RGB, but the graphic design specification

JM> /s/only understands RGB/always requires a fallback sRGB value

JM> SVG does support non-RGB colors. But currently, Batik doesn't support
JM> passing on non-sRGB colors (they are converted to sRGB). I've added
JM> support for that this summer in development branches [1] which I'm in
JM> the process of getting ready to merge back into the respective trunks.

OOh, please let me know when that trunk merge is available for testing.


--
 Chris Lilley   Technical Director, Interaction Domain                
 W3C Graphics Activity Lead, Fonts Activity Lead
 Co-Chair, W3C Hypertext CG
 Member, CSS, WebFonts, SVG Working Groups


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

Jeremias Maerki-2
I wish that were so quick & easy to do. The Java code is ready and
working but the whole build process is a different story with the new
dependencies. I found a lot of code duplication in the build script and a
lot of hard-coded JAR names in Class-Path manifest entries or security
policy files. I think I have some serious refactoring before me to make
that easier.

In the meantime, you can try working with the "all-jar" Ant target on
the branch: https://svn.apache.org/repos/asf/xmlgraphics/batik/branches/svgcolor12
At least, the "all-jar" seems to build fine, although starting it with
"java -jar" doesn't work right now.

On 13.01.2011 22:43:56 Chris Lilley wrote:

> On Monday, December 20, 2010, 9:33:57 AM, Jeremias wrote:
>
> JM> On 19.12.2010 18:10:42 Martin Jacobson wrote:
> >> I'm going to join this thread because I have an application that
> >> produces SVG maps that are ultimately printed to a vitreous enamel
> >> panel that forms part of a street sign. The app has to work in RGB
> >> because SVG only understands RGB, but the graphic design specification
>
> JM> /s/only understands RGB/always requires a fallback sRGB value
>
> JM> SVG does support non-RGB colors. But currently, Batik doesn't support
> JM> passing on non-sRGB colors (they are converted to sRGB). I've added
> JM> support for that this summer in development branches [1] which I'm in
> JM> the process of getting ready to merge back into the respective trunks.
>
> OOh, please let me know when that trunk merge is available for testing.
>
>
> --
>  Chris Lilley   Technical Director, Interaction Domain                
>  W3C Graphics Activity Lead, Fonts Activity Lead
>  Co-Chair, W3C Hypertext CG
>  Member, CSS, WebFonts, SVG Working Groups
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

danielz
This post has NOT been accepted by the mailing list yet.
Hi, I've been trying to generate a cmyk pdf using batik rasterizer from svgcolor12 branch, but it always comes out with sRGB color space.
My input file is like this: https://gist.github.com/danielzzz/1ecfad9e2a8ef9023eb2

I use java-sun-6
I tested it with batik 1.7, trunk, and svgcolor12 branch.

I check the output.pdf with identify -verbose output.pdf | grep space.
The input.pdf shows CMYK, but the output is always sRGB.

I've been trying to figure that out with another user, who does the conversion directly from java, not using batik-rasterizer.jar
(you can check the conversation here:
https://forums.adobe.com/thread/1450079)

What else could I try?
thanks
Dan
Reply | Threaded
Open this post in threaded view
|

Re: How can I change the color model of an SVG image from RGB to CMYK and vice versa?

chriddyp
In reply to this post by Jeremias Maerki-2
Jeremias Maerki-2 wrote
.

2. you can use the new functions specified in the SVG Color 1.2 working
draft to specify device-specific CMYK colors (device-cmyk() function [4]).
I've implemented this in the color branches but this is work in progress
on the side of the specification so this can still change.

But in both cases, you need the code from the color branches to have the
colors make it into the PDF "as is".
Has there been any updates to CMYK support or any other work-arounds?

I help develop a web-based graphing library (https://github.com/plotly/plotly.js) that draws graphics in the browser with SVG. Users use Batik to print their graphics in PDF or EPS format. Some users would like to specify both RGB (for web-based viewing) and CMYK colors for printing.

If we add `device-cmyk(0.11, 0.48, 0.83, 0.00)"` to our SVG paths, will these colors be used in PDF conversion?