[scribus] Scripting expert needed to speed up colour palette conversion
José Antonio Rocha
joseantoniorocha at gmail.com
Tue Apr 2 00:26:22 UTC 2013
The whole thing (do the job with SVG imported colors too):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
try:
import scribus
except ImportError,err:
print "This Python script is written for the Scribus scripting
interface."
print "It can only be run from within Scribus."
sys.exit(1)
#########################
# YOUR IMPORTS GO HERE #
#########################
def main(argv):
"""Translate imported RGB colors to CMYK colors."""
#########################
# YOUR CODE GOES HERE #
#########################
if scribus.haveDoc():
clrs = scribus.getColorNames()
newname = ""
for clr in clrs:
if clr.find("From") == 0:
cmyk = scribus.getColor(clr)
c = cmyk[0]
cd = cmyk[0]*100/255
ca = "c"+str(cd)
m = cmyk[1]
md = cmyk[1]*100/255
ma = "m"+str(md)
y = cmyk[2]
yd = cmyk[2]*100/255
ya = "y"+str(yd)
k = cmyk[3]
kd = cmyk[3]*100/255
ka = "k"+str(kd)
newname = ca+ma+ya+ka
scribus.defineColor(newname,c,m,y,k)
scribus.replaceColor(clr,newname)
scribus.deleteColor(clr,newname)
def main_wrapper(argv):
"""The main_wrapper() function."""
try:
scribus.statusMessage("Running script...")
scribus.progressReset()
main(argv)
finally:
if scribus.haveDoc():
scribus.setRedraw(True)
scribus.statusMessage("")
scribus.progressReset()
if __name__ == '__main__':
main_wrapper(sys.argv)
2013/4/1 José Antonio Rocha <joseantoniorocha at gmail.com>
> Unbelievably easy:
>
> clrs = getColorNames()
> newname = ""
> for clr in clrs:
> if clr.find("FromPDF") == 0:
> cmyk = getColor(clr)
> c = cmyk[0]
> cd = cmyk[0]*100/255
> ca = "c"+str(cd)
> m = cmyk[1]
> md = cmyk[1]*100/255
> ma = "m"+str(md)
> y = cmyk[2]
> yd = cmyk[2]*100/255
> ya = "y"+str(yd)
> k = cmyk[3]
> kd = cmyk[3]*100/255
> ka = "k"+str(kd)
> newname = ca+ma+ya+ka
> defineColor(newname,c,m,y,k)
> replaceColor(clr,newname)
> deleteColor(clr,newname)
>
>
>
> 2013/3/31 "Christoph Schäfer" <christoph-schaefer at gmx.de>
>
>> Hi all,
>>
>> I have brought on board another commercial colour vendor, this time one
>> from North America. At the moment, we are feverishly working on all sorts
>> of issues, including documentation, colour correctness, logo exchange,
>> licensing etc.
>>
>> You could help to speed up the process by writing a shell or Python
>> script.
>>
>> I receive all palettes as EPS files, which are easy to convert to
>> Scribus's own XML palette format. However, since the colours aren't stored
>> as spot colours, they end up being imported as something like
>> "FromPDF#00000040", which is completely useless when referring to a printed
>> colour swatch that is based on CMYK ink mixtures.
>>
>> In a Scribus XML palette file, the converted colour entry looks like this:
>>
>> <COLOR NAME="FromPDF#00404040" CMYK="#00404040"/>
>>
>> What is needed is a script that strips the string FromPDF and converts
>> the hex value in a specific way (adding ink channel abbreviations and
>> slashes), so that the end result looks like this:
>>
>> <COLOR NAME="C25/M25/Y25/K25" CMYK="#40404040"/>
>>
>> Anyone willing to step in?
>>
>>
>> Thanks in advance and Happy Easter,
>>
>> Christoph
>>
>> ___
>> Scribus Mailing List: scribus at lists.scribus.net
>> Edit your options or unsubscribe:
>> http://lists.scribus.net/mailman/listinfo/scribus
>> See also:
>> http://wiki.scribus.net
>> http://forums.scribus.net
>>
>
>
>
> --
> [image: Meira]
> ------------------------------
> nome: "José Antonio Meira da Rocha"
> googletalk: email: MSN: joseantoniorocha at gmail.com
> veículo: [ http://meiradarocha.jor.br ]
> fones: 55-8411-3047 / 55-3744-2994
> ------------------------------
>
--
[image: Meira]
------------------------------
nome: "José Antonio Meira da Rocha"
googletalk: email: MSN: joseantoniorocha at gmail.com
veículo: [ http://meiradarocha.jor.br ]
fones: 55-8411-3047 / 55-3744-2994
------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20130401/6f7a24e8/attachment.html>
More information about the scribus
mailing list