1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00

Fix not animated gifs support

This commit is contained in:
DarthSim 2018-12-21 02:09:58 +06:00
parent 5501c3cff7
commit f679a7ddec
2 changed files with 12 additions and 1 deletions

View File

@ -524,7 +524,7 @@ func processImage(ctx context.Context) ([]byte, error) {
}
defer C.clear_image(&img)
if imgtype == imageTypeGIF && po.Format == imageTypeGIF {
if imgtype == imageTypeGIF && po.Format == imageTypeGIF && vipsIsAnimatedGif(img) {
if err := transformGif(ctx, &img, po); err != nil {
return nil, err
}
@ -682,6 +682,10 @@ func vipsArrayjoin(in []*C.struct__VipsImage, out **C.struct__VipsImage) error {
return nil
}
func vipsIsAnimatedGif(img *C.struct__VipsImage) bool {
return C.vips_is_animated_gif(img) > 0
}
func vipsImageHasAlpha(img *C.struct__VipsImage) bool {
return C.vips_image_hasalpha_go(img) > 0
}

7
vips.h
View File

@ -148,6 +148,13 @@ vips_band_format(VipsImage *in) {
return in->BandFmt;
}
gboolean
vips_is_animated_gif(VipsImage * in) {
return( vips_image_get_typeof(in, "page-height") != G_TYPE_INVALID &&
vips_image_get_typeof(in, "gif-delay") != G_TYPE_INVALID &&
vips_image_get_typeof(in, "gif-loop") != G_TYPE_INVALID );
}
gboolean
vips_image_hasalpha_go(VipsImage * in) {
#if VIPS_SUPPORT_HASALPHA