Comments (8)
- Add a processing option that will enable the fallback to the original image no matter what. It will be the caller's responsibility to decide if they want the fallback (i.e. use that processing option only when the resizing option is not used).
But isn't that just skp
? Or are you thinking the processing option would do the fallback to the original image only if the size of the "processed" one is larger?
- Change every processing step so it indicates if it actually changed the image.
At least from my POV, what I'm after boils down to that not every image will have some kind of resize/blur/watermark/etc processing done, but may still utilize webp/avif processing, but if e.g. the client does not support webp or avif, one would usually want to deliver in the original format (png -> png, gif -> gif, jpeg -> jpeg for example), but if we end up with larger images we only made the experience worse for the user.
That's why I'd love a "flag" to say, if processed image is larger, then use the original.
I'd love to do the PR if I had any sense of Go experience π
from imgproxy.
even if we imagine that we send already compressed images (I can guarantee that we don't)
I can guarantee that you do. Only a few image formats like BMP or ICO (and very rarely βΒ TIFF) store image data uncompressed.
100% quality of image -> q:85 -> 85%
85% quality of image -> q:85 -> 85*0.85 -> 72.25%
This is not how image compression works.
First of all, PNG does not have a quality factor since it is a lossless format (unless it is a paletted PNG). Yet it can be saved with different compression levels. As I said before, imgproxy doesn't use the maximum compression level for performance reasons.
But formats like JPEG do lossy compression. I won't describe the whole JPEG compression algorithm here, but the most important part is that it does discrete cosine transform (DCT) and removes some data according to the quantization table. When imgproxy (or any other image processing tool) needs to process an image, it decodes it to raw pixels and encodes it back in the end. If you encode it with a larger quality factor, less data will be discarded, and thus file size will be larger. You can ask: "How it can discard less data that was discarded during the initial encoding?" The thing is that the result of DCT will be different as raw pixels are changed.
from imgproxy.
I found the same issue with images in PNG format -> PNG format with compression (q:0 preset and format_quality: png=75). Original image is ~640 KB, compressed by imgproxy results in ~680 KB somehow and I can't understand why.
Would be nice if someone could describe that behavior, because it's kinda weird to see compressed image larger than original image
from imgproxy.
Hey everyone,
Well, we have two options here:
- Add a processing option that will enable the fallback to the original image no matter what. It will be the caller's responsibility to decide if they want the fallback (i.e. use that processing option only when the resizing option is not used).
- Change every processing step so it indicates if it actually changed the image.
Anyway, PRs are always welcome π
Would be nice if someone could describe that behavior, because it's kinda weird to see compressed image larger than original image
Unless the original is BMP or something like that, it is compressed too. The size may increase for various reasons. In the case of JPEG, the original may be saved with lower quality than you set for imgproxy. In the case of PNG, it may be saved with a higher level of compression than imgproxy uses. imgproxy uses compression level 6 for PNGs as it is a good compromise between speed and the resulting size. Higher levels of compression dramatically slow encoding. However, having a config for this would be nice, I guess.
from imgproxy.
In the case of JPEG, the original may be saved with lower quality than you set for imgproxy. In the case of PNG, it may be saved with a higher level of compression than imgproxy uses. imgproxy uses compression level 6 for PNGs as it is a good compromise between speed and the resulting size.
I don't undestand it very well, but even if we imagine that we send already compressed images (I can guarantee that we don't) how imgproxy actually "restore" information for compressed image and return a file larger than we pass to imgproxy? Otherwise I can't describe what's happening in that case
100% quality of image -> q:85 -> 85%
85% quality of image -> q:85 -> 85*0.85 -> 72.25%
I can't see a case when we get a better image than we provide to imgproxy
UPD: I even tried to compare images with PSNR, but it showed me that images are equal (when I used q:0 preset with config formatQuality: png=75)
from imgproxy.
But isn't that just skp? Or are you thinking the processing option would do the fallback to the original image only if the size of the "processed" one is larger?
Yup, this is what I was talking about.
I'd love to do the PR if I had any sense of Go experience π
Neither did I a few years ago π I mean, I could do this myself, but I can't give you any estimations on when this will be done.
from imgproxy.
Thanks for the describing the de-encoding process, I'll test then a few more times with different presets to ensure that problem is not on imgproxy side
from imgproxy.
but I can't give you any estimations on when this will be done.
No worries at all! I just thought it would be an overall nice improvement
I'll likely buy the pro version in the coming days regardless for the more intelligent optimization logic it has, and hope it can help a bit anyway (among some other cool features that I would love to utilize)
Thank you for an amazing piece of software regardless!
from imgproxy.
Related Issues (20)
- ICO files failing with "Cant load from ICO" error HOT 7
- Base64 encoding of local url doesn't work HOT 1
- Resizing with "fit" mode leads to blurry images in some cases HOT 2
- invalid TIFF format: image dimensions are not specified HOT 6
- Support EPS files HOT 1
- "is not a video" error when trying to source PSD file HOT 2
- How to get width and height of original img? HOT 1
- Feature request: support using data urls as watermarkurl HOT 1
- Feature request: Gradient improvements HOT 5
- Text is illegible when a PDF has non-embedded CID TrueType and no character map HOT 4
- Feature Request: Option to limit max dimension of output image HOT 3
- Error: heifsave: image too large HOT 2
- Using imgproxy via Proxy for Amazon S3 HOT 3
- Option to report source image errors HOT 4
- Style transformation for SVG broken since 3.23 HOT 3
- Error: SVG detection does not work when it uses namespaces HOT 2
- Can't download source image: invalid JPEG format: missing SOF marker HOT 2
- ERROR png2vips: unable to read source source HOT 2
- Produces invalid SVG when namespaced attributes appear before namespace declaration HOT 1
- Support for external IDs when using S3 with assumed roles HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgproxy.