将像素转换为pdf的点数 [英] Convert pixels to points for pdf

查看:313
本文介绍了将像素转换为pdf的点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用php和fpdf生成pdf。如何缩放400像素高的图像以适应300点高的空间?尺寸只是示例,图像和可用空间是动态的。

I am using php and fpdf to generate a pdf. How can I scale a 400 pixel high image to fit in a 300 point high space? The dimensions are just examples, the image and available space are dynamic.

推荐答案

如果你想在300点中调整400像素,然后你的调整大小因子只是 300/400 = 0.75。你需要将每个像素放在0.75点。

If you want to fit 400 pixels in 300 points, then your resizing factor would simply be 300 / 400 = 0.75. You need to put each pixel in 0.75 of a point.

但是你应该知道另一个故事:每个点都是1/72英寸。以及1英寸的像素是选择的问题

But there is another story you should know: Each point is 1/72 of an inch. and how many pixels make 1 inch is a matter of choice.

所有图像都有一个名为DPI的属性:每英寸点数。它指定图片的每英寸有多少像素。因此,如果您想将400px * 400px图片转换为(例如)96 dpi图像,则调整大小因子将为 400 /((72/96)* 400)。 72这里是将英寸转换为点数。

All images have a property called DPI: dots per inch. It specifies how many pixels are there for each inch of the picture. So if you want to convert a 400px * 400px picture to a (say) 96 dpi image, your resizing factor will be 400 / ((72 / 96) * 400). 72 here is for converting inches to points.

这篇关于将像素转换为pdf的点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆