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.

red color becomes darker after transform png to webp

See original GitHub issue

I’m using sharp to transform images, such as from png to webp format.

some red text in the final webp image, is darker than how it is in the origin png image.

I can’t find any config or arguments to fix this.

following is my code:

sharp( imageAbsolutePath )
        .webp({ quality : 100, alphaQuality : 100 })
        .toFile( webpAbsolutePath )
        .then( function( info ){
            info.webpPath = webpAbsolutePath;
            return info;
        });

This is the origin png image:

origin

and this is the webp version:

webp

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
janwerkhovencommented, Apr 14, 2020

🎉

I’ve found the solution: normalise the colour profile before converting to WEBP.

convert "image.png" -profile "./sRGB_v4_ICC_preference.icc" "normalised.png"

cwebp "normalised.png" -o "image.webp"

Converting PNGs exported by Capture One to WEBP resulted in dark red WEBPs. PNGS exported by Sketch however, resulted in correctly coloured WEBPs. The difference is the colour profiles they use.

I used ImageMagick for converting the colour profile. Below is the ICC file that worked for me:

sRGB_v4_ICC_preference.icc.zip

1reaction
sophistercommented, Oct 24, 2017

@lovell Thx.

lossless : true solves this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image loses color/brightness after converting to webp
1. Convert the image using cwebp · 2. Use nearly any arrangement of arguments · 3. You can noticably see the stars lose...
Read more >
WebP image appears darker than JPG - WordPress.org
Hello, I've noticed that the WebP version of this image, https://www.writesofway. ... It seems that is as good as it gets, since the...
Read more >
WEBP Images - Dark when saved as JPG or PNG - Reddit
Any time I try either, the resulting saved image looks 2-3 times darker then how it's displayed on the web browser. This happens...
Read more >
Webp images to jpg and more: How to convert on Mac - 9to5Mac
This step by step guide with screenshots covers two ways for how to convert webp images to jpg, png, as well as in...
Read more >
Change color of PNG image via CSS? - html - Stack Overflow
In the latest version of Chrome, it looks like the (transparent) background is also getting set to the color. In the linked example,...
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