From: mf <massifr@fastwebnet.it>
To: ntg-context@ntg.nl
Subject: metapost: remapping colors of an SVG picture
Date: Tue, 18 Feb 2020 12:18:16 +0100 [thread overview]
Message-ID: <851949ba-cc76-e672-56d6-0a19c4085f22@fastwebnet.it> (raw)
[-- Attachment #1: Type: text/plain, Size: 1939 bytes --]
Hello list,
I tried this:
\starttext
\startMPcode
picture p ; p := lmt_svg [ filename = "sample.svg" ] ;
draw p ;
color black_rgb ; black_rgb := ( 0, 0, 0 ) ;
color red_rgb ; red_rgb := ( 1, 0, 0 ) ;
remapcolor( black_rgb, red_rgb ) ;
recolor p ;
draw p shifted ( bbwidth(p) + 5mm, 0) ;
\stopMPcode
\stoptext
but recolor gives an error:
metapost log > >> picture
metapost log > ! Wrong picture color model: redpart of grey object.
metapost log > <for(picture)> _f_:=(redpart(EXPR0),
metapost log >
greenpart(EXPR0),bluepart(EXPR0));if.bou...
metapost log >
metapost log > repathed->...fi;fi;else:addto._p_.also.i;fi;endfor
metapost log >
;setbounds._p_.to._b_;_p_....
metapost log > <to be read again>
metapost log > ;
metapost log > <*> ...apcolor( black_rgb, red_rgb ) ; recolor p ;
metapost log >
draw grayed p shifted ( b...
metapost log >
My goal is to remap colors of an SVG image, like this:
\starttext
\startMPcode
picture p ; p := lmt_svg [ filename = "sample.svg" ] ;
draw p ;
color black_rgb ; black_rgb := ( 0, 0, 0 ) ;
cmykcolor black_cmyk ; black_cmyk := ( 0, 0, 0, 1 ) ;
remapcolor( black_rgb, black_cmyk ) ;
recolor p ;
draw p shifted ( bbwidth(p) + 5mm, 0) ;
\stopMPcode
\stoptext
It relates to a recent thread in the mailing list about color management.
It's an attempt to use inkscape-made SVG graphics inside a CMYK
workflow, without using color management.
Naturally it would work under some constraints, but there's a lot of
graphics you can do with Inkscape that falls inside these:
- the number of colors in the input SVG should be limited, so that every
color gets converted
- no embedded bitmaps, only vector graphics
- perhaps some other constraints on gradients, transparency, etc.
A good alternative would be a remapper based on a custom lua function
like this:
function rgb2cmyk( r, g, b )
...
return c, m, y, k
end
Massi
[-- Attachment #2: sample.svg --]
[-- Type: image/svg+xml, Size: 2796 bytes --]
[-- Attachment #3: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next reply other threads:[~2020-02-18 11:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 11:18 mf [this message]
2020-02-18 13:53 ` Hans Hagen
2020-02-18 18:07 ` Jan U. Hasecke
2020-02-18 18:17 ` mf
2020-02-18 18:24 ` Jan U. Hasecke
2020-02-20 9:29 ` Jan U. Hasecke
2020-02-20 17:30 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=851949ba-cc76-e672-56d6-0a19c4085f22@fastwebnet.it \
--to=massifr@fastwebnet.it \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).