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.

JPEG artifacts when resizing via libjpeg-turbo/mozjpeg but no artifacts resizing via official libjpeg

See original GitHub issue

Using sharp 0.18.2 to resize a jpeg on OSX 10.12.5 with a reasonable pipeline

const img = mod_sharp(input);

img.resize(415, 556);

img.jpeg({
    quality: 85,
    progressive: true,
    chromaSubsampling: '4:2:0'
});

Noticeable artifacts in the following scenarios:

system vips with mozjpeg

1.brew install vips --with-mozjpeg --with-webp 2.npm install sharp 3.run reasonable sharp resize pipeline 4.Artifacts! https://www.dropbox.com/s/hxbsfziz70fct17/brew install vips --with-mozjpeg --with-webp.jpg?dl=0

system vips with jpeg turbo

1.brew install vips --with-webp --with-jpeg-turbo 2.npm install sharp 3.run reasonable sharp resize pipeline 4.Artifacts! https://www.dropbox.com/s/hl878dmsdm0f4w1/brew install vips --with-webp --with-jpeg-turbo.jpg?dl=0

Artifact-free in these scenarios:

systems vips (without jpeg turbo and without mozjpeg)

1.brew install vips ie. (no extra options. presumably bundled libjpeg is used?) 2.npm install sharp 3.run reasonable sharp resize pipeline 4.No artifacts! https://www.dropbox.com/s/hs6t0164ucsaqrj/brew install vips (no options).jpg?dl=0

bundled vips

1.brew remove vips 2.brew remove libjpeg-turbo 3.brew remove mozjpeg 4.npm install sharp (on mac os) 5.No artifacts! https://www.dropbox.com/s/bmb4stf6vn78jcf/vips bundled with sharp (macos).jpg?dl=0

vipsthumbnail (with jpeg turbo)

1.brew install vips --with-jpeg-turbo --with-mozjpeg 2.vipsthumbnail original.jpg -s 415x556 new.jpg[Q=85,no-subsample,optimize-coding,strip] 3.No artifacts! https://www.dropbox.com/s/shh8ykq2mvy5p54/vipsthumbnail [Q%3D85%2Cno-subsample%2Coptimize-coding%2Cstrip].jpg?dl=0

Summary

Artifacts arise when resizing jpegs via sharp when vips is compiled with jpeg-turbo (or mozjpeg). No artifacts when vips compiled against libjpeg.

Worth noting all of these scenarios are also reproducible on Ubuntu Trusty

Dropbox share to all test files + original https://www.dropbox.com/sh/aqtukbjdv0l8lom/AAAAtKp37f52b7SLunPwtBn4a?dl=0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
lovellcommented, Jan 12, 2018

sharp v0.19.0 now available.

1reaction
rn4391commented, Sep 21, 2017

Added https://github.com/lovell/sharp/pull/956 to expose shrinkOnLoad in resize()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange artifacts when resize image with php and GD
I'am resizing very large jpg images (4164x4724) to 1/8 of their original size using GD library in php and saving them to webp...
Read more >
Remove JPEG Compression Artifacts In Photoshop
In today's tutorial, you will learn how to instantly Remove JPEG compression artifacts to improve the quality of an image and make it...
Read more >
Graphical artifacts are not resizing automatically in ...
Cause. Images can be added to a module in two ways: Image that is uploaded within its own artifact and added to a...
Read more >
How to resize photo without jpeg artifact.
I assume you're using pixlr to edit your photos? Make sure when you save your final edit, the quality is set to maximum...
Read more >
Additional JPG compression? - Legacy ...
magick in.jpg -strip -quality 75 -interlace JPEG -resize x500 out.jpg ... they are not doing some further compression optimization using ...
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