以编程方式更改图像分辨率
我计算过,如果我希望生成的图像为 A4 尺寸 @ 600dpi 用于打印目的,则需要为 7016x4961px @ 72dpi。因此,我以编程方式生成它,然后在 Photoshop 中测试它,它似乎很好,所以如果我调整它的大小,它会获得适当的大小和分辨率
。
我想知道是否可以通过编程方式调整大小,最好使用 PIL,但不一定使用它。我需要提高 DPI。
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 it in Photoshop and it seems to be fine so if I resize it, it gets proper size and resolution
.
What I wonder about is if it's possible to make this resizing programmatically, preferably with PIL, but not necessarily with it. I need to make it higher DPI.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您生成的图像尺寸为 7016 x 4961 像素,则它已经是 600 dpi 的 A4 尺寸。所以你不需要调整它的大小,你只需要在文件中设置分辨率信息。
你可以用 PIL 来做到这一点:
If you have generated your image 7016 x 4961 px, it is already A4 at 600 dpi. So you don't need to resize it, you just have to set resolution information in file.
You can do it with PIL:
此代码将使用 PIL 将 PNG 图像的大小调整为 7016x4961:
也许更好的方法是在打印之前将画布放大
x
倍,其中x
是您拥有的一个因素找出(此特定图像的尺寸为 7016x4961)。This code will resize a PNG image into 7016x4961 with PIL:
Perhaps a better approach would be to make your canvas
x
times bigger prior to printing, wherex
is a factor you have to figure out (7016x4961 in size for this particular image).以下是如何批量调整大小(每个文件夹)并跳过其他文件类型和 Mac 系统文件(例如 .DS_Store)
Here's how you can resize by batch (per folder) and skip other file types and Mac system files like .DS_Store