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?

hell boy
  • 11
  • 3

2 Answers2

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.

faffaffaff
  • 3,429
  • 16
  • 27
  • 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. – Bryan Anthony Abrams Jun 28 '13 at 13:49
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.

Sander Visser
  • 4,144
  • 1
  • 31
  • 42
  • How to resize the image while maintaining a certain dpi (using php)? – hell boy Jun 28 '13 at 14:38
  • I don't understand your question, The DPI has nothing to do with the image size. – Sander Visser Jun 28 '13 at 14:46
  • You should take a look at http://php.net/manual/en/function.imagecopyresampled.php – Sander Visser Jun 28 '13 at 14:51
  • image.jpg file with dpi = 300. after the resized dpi = 96. I want maintaining a certain dpi. Please help! – hell boy Jun 28 '13 at 15:10
  • 1
    @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](http://www.php.net/manual/en/function.imagejpeg.php#78523)'s way. – Alain Tiemblo Jun 29 '13 at 07:03