[scribus] Scripting expert needed to speed up colour palette conversion
José Antonio Rocha
joseantoniorocha at gmail.com
Sun Apr 7 20:32:25 UTC 2013
2013/4/7 "Christoph Schäfer" <christoph-schaefer at gmx.de>
> Hi José,
>
> Thanks for your effort. Do you think yould also create an extended version
> of the script that allows for conversion of every Scribus-style import of
> non-spot colours (e.g. "FromWMF#b8bbab") to something meaningful, so the
> previously mentioned letter-hex combination becomes "R184/G187/B171"? Such
> a script would be well worth including in 1.4.3 and 1.5.0.
>
> Required funtions:
>
> - Remove "From[Filetype -- see list of supported formats in the File >
> Open and File > Import > Get Vector File]".
>
> - Determine the colour space via length of the hex value
>
> - Replace the hex value with decimal values and colour channels divided by
> slashes: R5/G116/B20, C5/M30/Y40/K10
>
> Cheers,
>
> Christoph
>
Hi, Christoph!
Here is it. But, as there's not a "defineColorAsRGB()" function in
Scripter, the RGB colors are created as CMYK anyway, although have RGB
names.
#!/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)
def main(argv):
"""Translate imported RGB colors to CMYK colors."""
if scribus.haveDoc():
colorsList = scribus.getColorNames()
newColorName = ""
for colorName in colorsList:
if colorName.find("From") == 0:
if not scribus.isSpotColor(colorName):
colorCode = colorName.split("#")[1]
if len(colorCode) > 6:
cmyk = scribus.getColor(colorName)
c = cmyk[0]
cd = c*100/255
ca = "C"+str(cd)
m = cmyk[1]
md = m*100/255
ma = "M"+str(md)
y = cmyk[2]
yd = y*100/255
ya = "Y"+str(yd)
k = cmyk[3]
kd = k*100/255
ka = "K"+str(kd)
newColorName = ca+"/"+ma+"/"+ya+"/"+ka
scribus.defineColor(newColorName,c,m,y,k)
else:
rgb = scribus.getColorAsRGB(colorName)
r = rgb[0]
ra = "R"+str(r)
g = rgb[1]
ga = "G"+str(g)
b = rgb[2]
ba = "B"+str(b)
newColorName = ra+"/"+ga+"/"+ba
cmyk = scribus.getColor(colorName)
c = cmyk[0]
cd = c*100/255
m = cmyk[1]
md = m*100/255
y = cmyk[2]
k = cmyk[3]
kd = k*100/255
scribus.defineColor(newColorName,c,m,y,k)
scribus.replaceColor(colorName,newColorName)
scribus.deleteColor(colorName,newColorName)
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)
--
[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/20130407/b5834316/attachment.html>
More information about the scribus
mailing list