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.
<br><br>import os<br>import subprocess<br>from os import *<br>imagefile = "/somedir/images/david.huggins/Photo 1.jpg"<br>cmdw = "identify -format %w '"+imagefile+"'"<br>cmdh = "identify -format %h '"+imagefile+"'"
<br>pw = subprocess.Popen(cmdw.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)<br>ph = subprocess.Popen(cmdh.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)<br>w = pw.stdout.read().strip()<br>h = ph.stdout.read
().strip()<br><br>------------<br>identify: Unable to open file ('/somedir/images/david.huggins/Photo) [No such file or directory].<br>identify: Unable to open file (1.jpg') [No such file or directory].<br>identify: Missing an image file name [No such file or directory].
<br>identify: Unable to open file ('/somedir/images/david.huggins/Photo) [No such file or directory].<br>identify: Unable to open file (1.jpg') [No such file or directory].<br>identify: Missing an image file name [No such file or directory].
<br>Traceback (most recent call last):<br><br><br><div><span class="gmail_quote">On 5/31/07, <b class="gmail_sendername">Facundo Batista</b> <<a href="mailto:facundo@taniquetil.com.ar">facundo@taniquetil.com.ar</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sick Monkey wrote:<br><br>> When I run the following command:<br>> ozdon@SickCodeMonkey
david.huggins]# identify -format %w<br>> '/someDIR/images/david.huggins/100_0264.JPG'<br><br>>From Python interpreter:<br><br>>>> cmd = "identify -format %w test.jpg"<br>>>> p =
subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)<br>>>> t = p.stdout.read()<br>>>> p.stdout.close()<br>>>> t<br>'50\n'<br>>>><br><br>>From command line:
<br><br>facundo@expiron:~$ identify -format %w test.jpg<br>50<br>facundo@expiron:~$<br><br>Regards,<br><br>--<br>. Facundo<br>.<br>Blog: <a href="http://www.taniquetil.com.ar/plog/">http://www.taniquetil.com.ar/plog/</a>
<br>PyAr: <a href="http://www.python.org/ar/">http://www.python.org/ar/</a><br><br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote>
</div><br>