Skip to content

Commit d4eb2e8

Browse files
authored
cgifsave: Make loop counts more accurate (#2709)
* cgifsave: Added "noloop" option * cgifsave: Change loop count logic * make sure nsgifload returns the correct loop count * Revert "make sure nsgifload returns the correct loop count" This reverts commit 77550f0. * Add fallback
1 parent 356edc3 commit d4eb2e8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

libvips/foreign/cgifsave.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,19 @@ vips_foreign_save_cgif_write_frame( VipsForeignSaveCgif *cgif )
310310
*/
311311
if( !cgif->cgif_context ) {
312312
cgif->cgif_config.pGlobalPalette = cgif->palette_rgb;
313+
#ifdef HAVE_CGIF_ATTR_NO_LOOP
314+
cgif->cgif_config.attrFlags = CGIF_ATTR_IS_ANIMATED | ( cgif->loop == 1 ? CGIF_ATTR_NO_LOOP : 0 );
315+
#else
313316
cgif->cgif_config.attrFlags = CGIF_ATTR_IS_ANIMATED;
317+
#endif/*HAVE_CGIF_ATTR_NO_LOOP*/
314318
cgif->cgif_config.width = frame_rect->width;
315319
cgif->cgif_config.height = frame_rect->height;
316320
cgif->cgif_config.numGlobalPaletteEntries = cgif->lp->count;
321+
#ifdef HAVE_CGIF_ATTR_NO_LOOP
322+
cgif->cgif_config.numLoops = cgif->loop > 1 ? cgif->loop - 1 : cgif->loop;
323+
#else
317324
cgif->cgif_config.numLoops = cgif->loop;
325+
#endif/*HAVE_CGIF_ATTR_NO_LOOP*/
318326
cgif->cgif_config.pWriteFn = vips__cgif_write;
319327
cgif->cgif_config.pContext = (void *) cgif->target;
320328

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ if quantisation_package.found()
238238
if cgif_dep.found()
239239
libvips_deps += cgif_dep
240240
cfg_var.set('HAVE_CGIF', '1')
241+
if cc.compiles('#include <cgif.h>\nint i = CGIF_ATTR_NO_LOOP;', name: 'Has CGIF_ATTR_NO_LOOP', dependencies: cgif_dep)
242+
cfg_var.set('HAVE_CGIF_ATTR_NO_LOOP', '1')
243+
endif
241244
endif
242245
endif
243246

0 commit comments

Comments
 (0)