How to change the dpi or density when saving images using PIL
问题 I'm trying to compress a jpg file using PIL (to be more specific, Pillow) I know images can be compressed by doing this: from PIL import Image im = Image.open(img_path) im = im.resize(new_size, Image.ANTIALIAS) im.save(output_path, optimize=True, quality=50) But I want to go further by tweaking more params, like this: im.save(output_path, optimize=True, quality=50, jfif_unit=1, dpi=(72,72), jfif_density=(72,72)) Unfortunately, it does not change dpi or density at all. How am I suppose to