On Fri, 12 Oct 2007 14:59:13 -0000, Christoph Krammer <[EMAIL PROTECTED]> wrote: >Hello everybody, > >I am using a python script to extract images from email messages. This >works fine for some messages, but not all attached images can be >decoded. I use the following code to decode the image and save it to a >database: > >try: > imagedec = base64.b64decode(imageenc) > imagehash = md5.new(imagedec).hexdigest() > dbcurs.execute(<save image>) >except TypeError, e: > print "Error '%s' in Message %s" % (e, dbrow[1]) > print imageenc) > >The problem is that for some images, the method b64decode() returns a >TypeError "Incorrect Padding". But if I paste the content of imageenc >to some other base64 decode (like this one: >http://www.php-einfach.de/base64_generator.php?code=1), I get the >correct result.
If you get an incorrect padding error, try appending a "=" and decoding again. If you get the error again, try appending one more "=". If it still doesn't work, then you might be out of luck. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list