Reputation: 2654
I have an animated gif and i offer the ability to resize it using drag. I wonder if i can guess the filesize of the resized gif before the resize is done server side.
Thank you
Upvotes: 1
Views: 104
Reputation: 700322
Yes, you can use different methods to make a guess.
The easiest guess that would give a reasonably good result would be to assume that the resized image would contain approximately the same amount of information per pixel, i.e. a linear function for the file size change. You would simply calculate the resized image size by multiplying the original size by the change in number of pixels.
If you for example resize the image from 100x100 pixels to 200x200 pixels, the file size would change by (200x200)/(100x100)
, i.e. 4 times the original size.
From that you can make more advanced algorithms for guessing the size, based on the actual results that you get, i.e. linear or non-linear functions for how much the file size changes when you reduce or enlarge the image.
Upvotes: 1