Python Image Library Image Resolution when Resizing

后端 未结 1 1862
孤街浪徒
孤街浪徒 2021-01-13 18:33

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

1条回答
  •  执笔经年
    2021-01-13 19:14

    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)
    

    0 讨论(0)
提交回复
热议问题