views:

45

answers:

4

I'm having trouble in my python script, and I don't understand it :

subprocess.call(['convert', file, '-crop', '80x10+90+980', '+repage', 'test.jpg'])

Returns "invalid argument - -crop"

But if I run this from the command line, it works fine :

convert test.jpg -crop 80x10+90+980 +repage test.jpg

What am I missing here ?

+1  A: 

Is there more than one convert in the system? Try an absolute path to the command you want?

MattH
@MattH: agreed!
bhups
+1  A: 

What about using the python image library instead? That seems much more reliable than to call a subprocess (especially for error handling...).

Olivier
Well I want to use crop and compare.. does the PIL provide that ?
Manu
I don't know what you mean by "compare", but PIL is certainly able to crop images.
Olivier
+1  A: 

file is a __builtin__ class. Overriding it may produce unwanted results. Try using a different variable name.

pwdyson
I changed it to "fichier" (french for file), but the problem remains. Thanks for the tip anyways.
Manu
+1  A: 

I've actually tried your code:

>>> import subprocess
>>> subprocess.call(['convert', 'capa.jpg', '-crop', '80x10+90+980', '+repage', 'capa2.jpg'])
0
>>> 

And it works for me!

So you must have something wrong, somewhere else. Check our assumptions again.

nosklo