change dpi without changing pixels dimensions with PIL?

duikboot a at spam.nl
Wed Dec 17 04:16:48 EST 2003


Hi there,

In Photoshop I can, when I want to change the dpi(dots per inch) of a
picture, arrange that the picture won't be resized. Do you know of a way, I
can accomplish this in python with PIL? If I use this script it changes the
dpi, but the picture becomes huge.

Thanks

Arjen

import sys
import Image
import os
a=sys.argv[1]
print a
c="or"+a
b=os.system("rename %s %s" % (a, c))
im=Image.open(c)
print im.info["dpi"]
im.save(a, dpi=(150, 150)






More information about the Python-list mailing list