简体   繁体   中英

PHP GD calculate size

How to calculate the size of a resized image file without resizing (based on the parameters width, height and dpi)?

Example: I have image resolution is 6158x4190, dpi = 300, size = 13.2 MB. So when resized = 2939x2000, dpi = 150, the size is how much?

Will someone please help me?

DPI does not affect the file size, only the amount of pixels. Most image formats (png, jpeg) apply compression, and I don't think there's a way to calculate the final image size without actually performing the compression.

It really depends on wich format you use, because of the compression and maybe impossible without really scaling it. Gif should be possible

BUT You can estimate the size So if you scale something down with a factor 0.3 you can do something like size * factor = estimation. It's not the exact size but it probably is close to it, and you should maintain the same quality and image settings. I think you should start experimenting with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM