mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-02-12 11:46:10 +02:00
Fix animated JPEG XL support
This commit is contained in:
parent
9d955444df
commit
d9abf2d3d7
@ -147,7 +147,11 @@ func (it Type) SupportsAlpha() bool {
|
|||||||
return it != JPEG && it != BMP
|
return it != JPEG && it != BMP
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it Type) SupportsAnimation() bool {
|
func (it Type) SupportsAnimationLoad() bool {
|
||||||
|
return it == GIF || it == WEBP || it == JXL
|
||||||
|
}
|
||||||
|
|
||||||
|
func (it Type) SupportsAnimationSave() bool {
|
||||||
return it == GIF || it == WEBP
|
return it == GIF || it == WEBP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func isImageTypePreferred(imgtype imagetype.Type) bool {
|
|||||||
|
|
||||||
func findBestFormat(srcType imagetype.Type, animated, expectAlpha bool) imagetype.Type {
|
func findBestFormat(srcType imagetype.Type, animated, expectAlpha bool) imagetype.Type {
|
||||||
for _, t := range config.PreferredFormats {
|
for _, t := range config.PreferredFormats {
|
||||||
if animated && !t.SupportsAnimation() {
|
if animated && !t.SupportsAnimationSave() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
|
|||||||
|
|
||||||
animationSupport :=
|
animationSupport :=
|
||||||
po.SecurityOptions.MaxAnimationFrames > 1 &&
|
po.SecurityOptions.MaxAnimationFrames > 1 &&
|
||||||
imgdata.Type.SupportsAnimation() &&
|
imgdata.Type.SupportsAnimationLoad() &&
|
||||||
(po.Format == imagetype.Unknown || po.Format.SupportsAnimation())
|
(po.Format == imagetype.Unknown || po.Format.SupportsAnimationSave())
|
||||||
|
|
||||||
pages := 1
|
pages := 1
|
||||||
if animationSupport {
|
if animationSupport {
|
||||||
@ -304,7 +304,7 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
|
|||||||
return nil, fmt.Errorf("Can't save %s, probably not supported by your libvips", po.Format)
|
return nil, fmt.Errorf("Can't save %s, probably not supported by your libvips", po.Format)
|
||||||
}
|
}
|
||||||
|
|
||||||
if po.Format.SupportsAnimation() && animated {
|
if po.Format.SupportsAnimationSave() && animated {
|
||||||
if err := transformAnimated(ctx, img, po, imgdata); err != nil {
|
if err := transformAnimated(ctx, img, po, imgdata); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips_jxlload_go(void *buf, size_t len, VipsImage **out)
|
vips_jxlload_go(void *buf, size_t len, int pages, VipsImage **out)
|
||||||
{
|
{
|
||||||
return vips_jxlload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
|
return vips_jxlload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "n", pages, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -337,7 +337,7 @@ func (img *Image) Load(imgdata *imagedata.ImageData, shrink int, scale float64,
|
|||||||
case imagetype.JPEG:
|
case imagetype.JPEG:
|
||||||
err = C.vips_jpegload_go(data, dataSize, C.int(shrink), &tmp)
|
err = C.vips_jpegload_go(data, dataSize, C.int(shrink), &tmp)
|
||||||
case imagetype.JXL:
|
case imagetype.JXL:
|
||||||
err = C.vips_jxlload_go(data, dataSize, &tmp)
|
err = C.vips_jxlload_go(data, dataSize, C.int(pages), &tmp)
|
||||||
case imagetype.PNG:
|
case imagetype.PNG:
|
||||||
err = C.vips_pngload_go(data, dataSize, &tmp, vipsConf.PngUnlimited)
|
err = C.vips_pngload_go(data, dataSize, &tmp, vipsConf.PngUnlimited)
|
||||||
case imagetype.WEBP:
|
case imagetype.WEBP:
|
||||||
|
@ -16,7 +16,7 @@ int gif_resolution_limit();
|
|||||||
int vips_health();
|
int vips_health();
|
||||||
|
|
||||||
int vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out);
|
int vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out);
|
||||||
int vips_jxlload_go(void *buf, size_t len, VipsImage **out);
|
int vips_jxlload_go(void *buf, size_t len, int pages, VipsImage **out);
|
||||||
int vips_pngload_go(void *buf, size_t len, VipsImage **out, int unlimited);
|
int vips_pngload_go(void *buf, size_t len, VipsImage **out, int unlimited);
|
||||||
int vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out);
|
int vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out);
|
||||||
int vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out);
|
int vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user