mikeboers / Flask-Images

On-demand resizing of images for Flask applications.
https://mikeboers.github.io/Flask-Images/
BSD 3-Clause "New" or "Revised" License
81 stars 43 forks source link

Generated image is bigger than original #17

Open lovato opened 10 years ago

lovato commented 10 years ago

Please, validate this. When opening this, https://pbs.twimg.com/media/Bq1dN3lIEAAgQbv.jpg, a 800px wide image, I got on chrome inspect a 33.2k size. If I pass it through FlaskImages, default quality (75), and ask for 800 px as width output, I got a 33.7k size.

I am doing imgsizer/remote?w=800&u=https://pbs.twimg.com/media/Bq1dN3lIEAAgQbv.jpg

What do you think if FlaskImages, after generating the final file, knowing that the original is smaller, deliver and cache the original, as if it was generated by itself.

I know it depends on the original image, but it did happen sometimes.

Best Lovato

mikeboers commented 10 years ago

I have verified your result.

So if the derived output size exactly matches the input, and is the same format, then we can consider returning the original image.

I wonder if there are any other side-effects (metadata, etc.) that we would always want to maintain, and I wonder how well this would play with the storage abstraction that is being discusses in the GAE compatibility issue (#13).

Hmm...

lovato commented 10 years ago

Indeed, i tought that too.

Meanwhile, I ended starting a generic FlaskImages service for my app, hosted on Dreamhost, which i have full I/O access. Then I discovered this when checking how my app was behaving.

What surprised me was the default=75. I tough the default was 95, and this was to be the explanation for the similar size file. When trying to lower it, I found the "problem". So, if we try to get a q=90 for this file, it will be (more) bigger than the original.

Perhaps after generating the image, do this analysis and determine which file to store as "generated" (no matter where it came from). For sure it will be (or must be) the optimal. Do FI rewrite file metadata or just update the changes in comparison with the original one?

Best,

[]s

Lovato

sent from GMail

On Thu, Jun 26, 2014 at 9:15 AM, Mike Boers notifications@github.com wrote:

I have verified your result.

So if the derived output size exactly matches the input, and is the same format, then we can consider returning the original image.

I wonder if there are any other side-effects (metadata, etc.) that we would always want to maintain, and I wonder how well this would play with the storage abstraction that is being discusses in the GAE compatibility issue (#13 https://github.com/mikeboers/Flask-Images/issues/13).

Hmm...

— Reply to this email directly or view it on GitHub https://github.com/mikeboers/Flask-Images/issues/17#issuecomment-47218186 .