Skip to content Skip to sidebar Skip to footer

Python Image Library Image Resolution When Resizing

I am trying to shrink some jpeg images from 24X36 inches to 11X16.5 inches using the python image library. Since PIL deals in pixels this should mean scaling from 7200X 4800 pixels

Solution 1:

To preserve the DPI, you need to specify it when saving; the info attribute is not always preserved across image manipulations:

dpi = im.info['dpi']  # Warning, throws KeyError if no DPI was set to begin with

# resize, etc.

out.save("out.jpg", dpi=dpi)

Post a Comment for "Python Image Library Image Resolution When Resizing"