Skip to content

Enhancement: non-animated GIF output should default to no-loop #3394

@thatsmydoing

Description

@thatsmydoing

Question about an existing feature

What are you trying to achieve?

When naively converting non-GIF to GIF, the output GIF is set to loop forever. It might make more sense to default to 1 instead.

When you searched for similar issues, what did you find that might be related?

I did not find anything related to loop forever.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

const sharp = require('sharp');

async function main() {
  await sharp(process.argv[2]).gif().toFile('out.gif');
  console.log(await sharp('out.gif').metadata());
}

main();

will have metadata loop: 0 when passed in a non-GIF but loop: 1 when passed in a non-animated GIF. In practice, they probably display the same but the output is technically an infinitely looping GIF with 1 frame. Tools like gifsicle also indicate "loop forever" on the output image.

Please provide sample image(s) that help explain this question

PNG input -> "animated" GIF output

non-animated GIF input -> non-animated GIF output

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions