Programmatically change image resolution

后端 未结 2 1473
感情败类
感情败类 2021-02-01 07:33

I have calculated that if I want my generated image to be A4 size @ 600dpi for print purpose, it needs to be 7016x4961px @ 72dpi. So, I generate it programmatically, then test

2条回答
  •  孤城傲影
    2021-02-01 08:14

    This code will resize a PNG image into 7016x4961 with PIL:

    size = 7016, 4961
    im = Image.open("my_image.png")
    im_resized = im.resize(size, Image.ANTIALIAS)
    im_resized.save("my_image_resized.png", "PNG")
    

    Perhaps a better approach would be to make your canvas x times bigger prior to printing, where x is a factor you have to figure out (7016x4961 in size for this particular image).

提交回复
热议问题