1

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Just to add DPI is for printing, if you have a 128x128 image with a DPI of 72 it'll be the same on the computer as a 128x128 image with a DPI of 300.
0

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.

5 Comments

How to resize the image while maintaining a certain dpi (using php)?
I don't understand your question, The DPI has nothing to do with the image size.
<?php $image = imagecreatefromjpeg("image.jpg"); $width = imagesx($image); $height = imagesx($image); $new_width = 500; $new_height = 800; $im = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($im, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($im, "new_image.jpg", 100); imagedestroy($im); ?> image.jpg file with dpi = 300. after the resized dpi = 96. I want maintaining a certain dpi. Please help!
@VisserSander is right, DPI is a simple information stored on the header on each image; you'll get the same size (bytes) for an image if it has a 72 or a 300dpi, as this information only tells how many Dots Per Inch should be used to print it (or at least to know its size (inches)). GD saves all your images with a 72dpi. You can overwrite the used dpi on the header of your .jpg files using Michaelsoft's way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.