[scribus] Scripting expert needed to speed up colour palette conversion
"Christoph Schäfer"
christoph-schaefer at gmx.de
Mon Apr 8 05:29:49 UTC 2013
Hi José,
I get an error when executing the script:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/home/christoph/Dokumente/Simplify_Color_Names.py", line 58, in <module>
scribus.deleteColor(colorName,newColorName)
NameError: name 'colorName' is not defined
Could you also add a proper licence to the script, please?
Thanks a lot for your efforts!
Christoph
> Gesendet: Sonntag, 07. April 2013 um 22:50 Uhr
> Von: "José Antonio Rocha" <joseantoniorocha at gmail.com>
> An: "Scribus User Mailing List" <scribus at lists.scribus.net>
> Betreff: Re: [scribus] Scripting expert needed to speed up colour palette conversion
>
> Simplifying a bit:
>
> 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]
> m = cmyk[1]
> y = cmyk[2]
> k = cmyk[3]
> scribus.defineColor(newColorName,c,m,y,k)
>
>
>
> 2013/4/7 José Antonio Rocha <joseantoniorocha at gmail.com>
>
> >
> > 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
> > ------------------------------
> >
>
>
>
> --
> [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/6c823842/attachment.html>
> ___
> 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
>
More information about the scribus
mailing list