-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support AVIF format encoding #70
Conversation
@@ -133,29 +133,44 @@ func MainHandler(w http.ResponseWriter, r *http.Request, conf *configure.Conf, l | |||
case "jpeg": | |||
if q.UseWebP() { | |||
err = imageprocessor.EncodeWebP(w, img.GetImg(), q.Quality(), false) | |||
} else if q.UseAVIF() { | |||
w.Header().Set("Content-Type", "image/avif") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Browser downloads the response body as a file if the explicit header specification is none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
|
||
opts := avif.Options{ | ||
Threads: 0, // all available cores | ||
Speed: avif.MaxSpeed, // bigger is faster, but lower compress ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Considering the compression speed of AVIF, I agree with you that the default is speed first.
libaom
requiredhttp://localhost:3000/Lenna.jpg?w=1618&h=1000
116KB
123ms
http://localhost:3000/Lenna.jpg?w=1618&h=1000&avif=true&quality=100
606KB
660ms
http://localhost:3000/Lenna.jpg?w=1618&h=1000&avif=true&quality=50
85.4KB
551ms
http://localhost:3000/Lenna.jpg?w=1618&h=1000&avif=true&quality=20
11.8KB
421ms
Although my monitor is cheap, it looks to me the image quality might be fine even if the quality is
20
. The compression ratio is awesome but the encoding speed is slower. The lossless is useless for us. Since WebP is well-balanced, I think we should prior WebP than AVIF when both are specified in a query string. I implemented only an encoding feature for AVIF bacause I think it is a rare case that the format is being a source image.