<div dir="ltr"><div class="gmail_default" style="font-size:small">Simplifying a bit:<br><br>                    else:<br>                        rgb = scribus.getColorAsRGB(colorName)<br>                        r = rgb[0]<br>

                        ra = "R"+str(r)<br>                        g = rgb[1]<br>                        ga = "G"+str(g)<br>                        b = rgb[2]<br>                        ba = "B"+str(b)<br>

                        newColorName = ra+"/"+ga+"/"+ba<br>                        cmyk = scribus.getColor(colorName)<br>                        <span style="color:rgb(255,0,0)">c = cmyk[0]<br>                        m = cmyk[1]<br>

                        y = cmyk[2]<br>                        k = cmyk[3]</span><br>                        scribus.defineColor(newColorName,c,m,y,k)<br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

2013/4/7 José Antonio Rocha <span dir="ltr"><<a href="mailto:joseantoniorocha@gmail.com" target="_blank">joseantoniorocha@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div class="gmail_extra"><div class="im"><br><div class="gmail_quote">2013/4/7 "Christoph Schäfer" <span dir="ltr"><<a href="mailto:christoph-schaefer@gmx.de" target="_blank">christoph-schaefer@gmx.de</a>></span><br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hi José,<br>
<br>
Thanks for your effort. Do you think yould also create an extended version of the script that allows for conversion of every <span>Scribus</span>-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.<br>



<br>
Required funtions:<br>
<br>
- Remove "From[Filetype -- see list of supported formats in the File > Open and File > Import > Get Vector File]".<br>
<br>
- Determine the colour space via length of the hex value<br>
<br>
- Replace the hex value with decimal values and colour channels divided by slashes: R5/G116/B20, C5/M30/Y40/K10<br>
<br>
Cheers,<br>
<br>
Christoph</div></blockquote></div><br></div><div class="gmail_default" style="font-size:small">Hi, Christoph!<br><br></div><div class="gmail_default" style="font-size:small">Here is it. But, as there's not a "<span style="font-family:courier new,monospace">defineColorAsRGB()</span>" function in Scripter, the RGB colors are created as CMYK anyway, although have RGB names.<br>


</div><br><div class="gmail_default" style="font-size:small"><span style="font-family:courier new,monospace"><div class="im">#!/usr/bin/env python<br># -*- coding: utf-8 -*-<br><br>import sys<br><br>try:<br>    import scribus<br>

except ImportError,err:<br>
    print "This Python script is written for the Scribus scripting interface."<br>    print "It can only be run from within Scribus."<br>    sys.exit(1)<br><br></div><div class="im">def main(argv):<br>

    """Translate imported RGB colors to CMYK colors."""<br></div>
    if scribus.haveDoc():<br>        colorsList = scribus.getColorNames()<br>        newColorName = ""<br>        for colorName in colorsList:<br>            if colorName.find("From") == 0:<br>                if not scribus.isSpotColor(colorName): <br>


                    colorCode = colorName.split("#")[1]<br>                    if len(colorCode) > 6:<br>                        cmyk = scribus.getColor(colorName)<br>                        c = cmyk[0]<br>                        cd = c*100/255<div class="im">

<br>
                        ca = "C"+str(cd)<br>                        m = cmyk[1]<br></div>                        md = m*100/255<div class="im"><br>                        ma = "M"+str(md)<br>                        y = cmyk[2]<br>

</div>
                        yd = y*100/255<div class="im"><br>                        ya = "Y"+str(yd)<br>                        k = cmyk[3]<br></div>                        kd = k*100/255<br>                        ka = "K"+str(kd)<br>


                        newColorName = ca+"/"+ma+"/"+ya+"/"+ka<br>                        scribus.defineColor(newColorName,c,m,y,k)<br>                    else:<br>                        rgb = scribus.getColorAsRGB(colorName)<br>


                        r = rgb[0]<br>                        ra = "R"+str(r)<br>                        g = rgb[1]<br>                        ga = "G"+str(g)<br>                        b = rgb[2]<br>

                        ba = "B"+str(b)<br>
                        newColorName = ra+"/"+ga+"/"+ba<br>                        cmyk = scribus.getColor(colorName)<br>                        c = cmyk[0]<br>                        cd = c*100/255<br>


                        m = cmyk[1]<br>                        md = m*100/255<br>                        y = cmyk[2]<br>                        k = cmyk[3]<br>                        kd = k*100/255<br>                        scribus.defineColor(newColorName,c,m,y,k)<br>


                    scribus.replaceColor(colorName,newColorName)<br>                    scribus.deleteColor(colorName,newColorName)                <br><div class="im"><br>def main_wrapper(argv):<br>    """The main_wrapper() function."""<br>


    try:<br>        scribus.statusMessage("Running script...")<br>        scribus.progressReset()<br>        main(argv)<br>    finally:<br>        if scribus.haveDoc():<br>            scribus.setRedraw(True)<br>


        scribus.statusMessage("")<br>        scribus.progressReset()<br><br>if __name__ == '__main__':<br>    main_wrapper(sys.argv)</div></span><span class="HOEnZb"><font color="#888888"><br></font></span></div>

<span class="HOEnZb"><font color="#888888"><br clear="all"><br>-- <br>
<font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font size="1"><font><img style="width:75px;min-height:100px" alt="Meira" src="http://lh4.ggpht.com/_75EesisxR5g/TENbAQVXMLI/AAAAAAAADHs/ChNQzn8eOT0/meira-75x100.jpg" align="left" hspace="8" vspace="6"></font></font></font></font><hr>



</font></font></span><div class="im"><span style="font-family:Helvetica,Arial,sans-serif">nome: "</span><span style="font-weight:bold;font-family:Helvetica,Arial,sans-serif">José Antonio Meira da Rocha</span><span style="font-family:Helvetica,Arial,sans-serif">" </span><br style="font-family:Helvetica,Arial,sans-serif">




<small style="font-family:Helvetica,Arial,sans-serif">googletalk: email: MSN: <a href="mailto:joseantoniorocha@gmail.com" target="_blank">joseantoniorocha@gmail.com</a><br>
veículo: [ <a href="http://meiradarocha.jor.br/" target="_blank">http://meiradarocha.jor.br</a>
] <br>fones: <a href="tel:55-8411-3047" value="+555584113047" target="_blank">55-8411-3047</a> / <a href="tel:55-3744-2994" value="+555537442994" target="_blank">55-3744-2994</a><br></small>
</div><hr style="width:100%;min-height:2px;font-family:Helvetica,Arial,sans-serif">

</div></div>
</blockquote></div><br><br clear="all"><br>-- <br>
<font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font style="font-family:Helvetica,Arial,sans-serif" color="#888888"><font size="1"><font><img style="width:75px;min-height:100px" alt="Meira" src="http://lh4.ggpht.com/_75EesisxR5g/TENbAQVXMLI/AAAAAAAADHs/ChNQzn8eOT0/meira-75x100.jpg" hspace="8" vspace="6" align="left"></font></font></font></font><hr>


</font><span style="font-family:Helvetica,Arial,sans-serif">nome: "</span><span style="font-weight:bold;font-family:Helvetica,Arial,sans-serif">José Antonio Meira da Rocha</span><span style="font-family:Helvetica,Arial,sans-serif">" </span><br style="font-family:Helvetica,Arial,sans-serif">



<small style="font-family:Helvetica,Arial,sans-serif">googletalk: email: MSN: <a href="mailto:joseantoniorocha@gmail.com" target="_blank">joseantoniorocha@gmail.com</a><br>
veículo: [ <a href="http://meiradarocha.jor.br/" target="_blank">http://meiradarocha.jor.br</a>
] <br>fones: 55-8411-3047 / 55-3744-2994<br></small>
<hr style="width:100%;height:2px;font-family:Helvetica,Arial,sans-serif">

</div>