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.

PNG adaptiveFiltering is slow

See original GitHub issue

Resize of png file (2048x2048 to 1920) is very slow, takes more than 6 seconds on (4gb ram and 2 vCPUs) CPU Optimized Droplet of Digital Ocean.

The code:

sharp(file.Body).resize({ width: 1920 }).png({ progressive:true, adaptiveFiltering:true }).toBuffer()

Versions and cache:

{ cairo: '1.16.0',
  croco: '0.6.12',
  exif: '0.6.21',
  expat: '2.2.6',
  ffi: '3.2.1',
  fontconfig: '2.13.1',
  freetype: '2.10.0',
  fribidi: '1.0.5',
  gdkpixbuf: '2.36.12',
  gettext: '0.19.8.1',
  gif: '5.1.4',
  glib: '2.56.4',
  gsf: '1.14.45',
  harfbuzz: '2.3.1',
  jpeg: '2.0.2',
  lcms: '2.9',
  orc: '0.4.28',
  pango: '1.42.4',
  pixman: '0.38.0',
  png: '1.6.34',
  svg: '2.45.5',
  tiff: '4.0.10',
  uuid: '2.33.1',
  vips: '8.7.4',
  webp: '1.0.2',
  xml: '2.9.9',
  zlib: '1.2.11' }

{ memory: { current: 0, high: 0, max: 50 },
  files: { current: 0, max: 20 },
  items: { current: 0, max: 100 } }

Some help to improve the resize time?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lovellcommented, Mar 27, 2019

You’ll need to experiment - good luck!

0reactions
nunowarcommented, Mar 27, 2019

@lovell Thanks. I will disabling adaptiveFiltering for now.

About the PNG lossless optimization, what you recommend, to get the min size and the same quality with Sharp?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compression and Filtering (PNG: The Definitive Guide)
Filtering is a method of reversibly transforming the image data so that the main compression engine can operate more efficiently. As a simple...
Read more >
PNG Specification: Rationale - W3C
PNG includes filtering capability because filtering can significantly reduce the compressed size of truecolor and grayscale images. Filtering is also sometimes ...
Read more >
Chapter 9. Compression and Filtering - PNG - O'Reilly
Filtering is a method of reversibly transforming the image data so that the main compression engine can operate more efficiently. As a simple...
Read more >
Incredibly slow PNG saving - 2.5 minutes!
I'm saving a fairly small image (3000x3300) as PNG and it's taking 2.5 minutes! That's insane! My CPU sits at 100% the entire...
Read more >
ImageMagick: Lossless max compression for PNG?
For photos of natural landscapes an "adaptive" filtering ( -quality 05 ) is generally ... PNG compression tends to be rather slow because...
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