In article <5yudnafyso8houtwnz2dnuvz_tidn...@westnet.com.au>,
R (Chandra) Chandrasekhar <chyav...@gmail.com> wrote:
>
>---
>import subprocess
>
>width = 5
>height = 30
>colors = ['#abcdef]', '#456789']
>filename = "/tmp/image.png"
>
># I want to get the equivalent of variable interpolation in Perl
># so that the command
>#
># convert -size 5x30 gradient:#abcdef-#456789 /tmp/image.png

Here's the equivalent of Peter's cute code in simpler form:

cmd = [
    'convert',
    '-size',
    '%sx%s' % (width, height),
    'gradient:%s-%s' % tuple(colors),
    # above could also be: 'gradient:%s-%s' % (colors[0], colors[1]),
    filename,
    ]
subprocess.Popen(cmd)
-- 
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"At Resolver we've found it useful to short-circuit any doubt and just        
refer to comments in code as 'lies'. :-)"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to