I ran into another slight problem. And I attempted to fix it, but have not
been able to do so yet. If a filename does not contain a space, then this
method works like a charm. But if there is a space then the code throws a
nasty error.
import os
import subprocess
from os import *
imagefile = "/somedir/images/david.huggins/Photo 1.jpg"
cmdw = "identify -format %w '"+imagefile+"'"
cmdh = "identify -format %h '"+imagefile+"'"
pw = subprocess.Popen(cmdw.split(), stdout=subprocess.PIPE, stderr=
subprocess.STDOUT)
ph = subprocess.Popen(cmdh.split(), stdout=subprocess.PIPE, stderr=
subprocess.STDOUT)
w = pw.stdout.read().strip()
h = ph.stdout.read().strip()
------------
identify: Unable to open file ('/somedir/images/david.huggins/Photo) [No
such file or directory].
identify: Unable to open file (1.jpg') [No such file or directory].
identify: Missing an image file name [No such file or directory].
identify: Unable to open file ('/somedir/images/david.huggins/Photo) [No
such file or directory].
identify: Unable to open file (1.jpg') [No such file or directory].
identify: Missing an image file name [No such file or directory].
Traceback (most recent call last):
On 5/31/07, Facundo Batista <[EMAIL PROTECTED]> wrote:
Sick Monkey wrote:
> When I run the following command:
> [EMAIL PROTECTED] david.huggins]# identify -format %w
> '/someDIR/images/david.huggins/100_0264.JPG'
>From Python interpreter:
>>> cmd = "identify -format %w test.jpg"
>>> p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=
subprocess.STDOUT)
>>> t = p.stdout.read()
>>> p.stdout.close()
>>> t
'50\n'
>>>
>From command line:
[EMAIL PROTECTED]:~$ identify -format %w test.jpg
50
[EMAIL PROTECTED]:~$
Regards,
--
. Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list