[Image-SIG] COM blocks in jpeg files

Joel Rodrigues joelrodrigues at Phreaker.net
Sun Dec 21 05:15:53 EST 2003


Is there any way to read & write comment blocks in jpeg files within 
Python ? The only way I've been able to see doing it is using the system 
jpeg utilities rdjpgcom & wrjpgcom.

Something like (not elegant I imagine, so any help would be nice) :

 >>> import os, string
 >>> cmd = 'wrjpgcom -c "this Joel rodrigues" canon-ixus.jpg > 
 >>> handle = os.popen(cmd, 'r')
 >>> os.popen(cmd, 'r')
<open file 'wrjpgcom -c "this Joel rodrigues" canon-ixus.jpg > 
canon-ixus_out.jpg', mode 'r' at 0x4d7760>


 >>> cmd2 = 'rdjpgcom canon-ixus_out.jpg'
 >>> handle = os.popen(cmd2, 'r')
 >>> print handle
<open file 'rdjpgcom canon-ixus_out.jpg', mode 'r' at 0x4d38a0>
 >>> print string.join(handle.readlines())
this Joel rodrigues

Any thoughts / advice will be much appreciated.


More information about the Image-SIG mailing list