question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GIF output palette size doubles (from 8 to 16)

See original GitHub issue

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System: OS: macOS 12.6 CPU: (8) x64 Apple M1 Pro Memory: 28.89 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.17.2 - ~/.nvm/versions/node/v14.17.2/bin/node npm: 6.14.13 - ~/.nvm/versions/node/v14.17.2/bin/npm npmPackages: sharp: ^0.31.1 => 0.31.1

What are the steps to reproduce?

  • Take any input animated gif
  • Call await sharp('input_filename.gif', { animated: true }).toFile('output_filename.gif');
  • File size is more than double the original.

What is the expected behaviour?

Output file size should be the same or nearly the same as the input file size.

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

await sharp('input_filename.gif', { animated: true }).toFile('output_filename.gif');

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

https://media.giphy.com/media/jUwpNzg9IcyrK/giphy.gif

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
lovellcommented, Nov 14, 2022

The new interFrameMaxError and interPaletteMaxError GIF options are exposed in commit https://github.com/lovell/sharp/commit/5740f4545efd2c4fd0d98a2b6104f8e0da111e66 and will be part of v0.31.3.

Example usage:

// interFrameMaxError API available from v0.31.3
await sharp('in.gif', { animated: true })
  .gif({ interFrameMaxError: 8 })
  .toFile('optim.gif');
2reactions
lovellcommented, Dec 21, 2022

v0.31.3 now available with support for interFrameMaxError and interPaletteMaxError.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Animated GIF Best Practices - Create & Optimize GIFs Like Pros
Learn how to improve GIF quality and the tricks to getting the best GIF size. Use this guide to create animated GIFs that...
Read more >
Size of GIF way too high? - ffmpeg - Super User
Because of how GIFs work, the more complicated the palette, the resulting gif becomes larger pretty quickly.
Read more >
How to reduce GIF filesize without losing quality - YouTube
This is how I export small but high quality animated GIFs for my animation portfolio website, or for websites like Tumblr with filesize ......
Read more >
AspJpeg.com - User Manual Chapter 9: GIF Output
GIF format requires that a palette contain 2, 4, 8, 16, 32, 64, 128, or 256 colors. Each color entry in a palette...
Read more >
How to Reduce GIF File Size for Better Website Performance
Reduce the number of colors in the image. GIFs only display 256 colors, but if your image only has a few, then reduce...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found