Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugo does not read color profiles when resizing images #8298

Open
codelogic opened this issue Mar 4, 2021 · 2 comments
Open

Hugo does not read color profiles when resizing images #8298

codelogic opened this issue Mar 4, 2021 · 2 comments

Comments

@codelogic
Copy link

While working on updating my site, I put together some test pages to make sure the content I was showing was rendering the way I expected it to. When doing so, I noticed that resized versions of images looked more muted than I expected, and so I pulled down several wide-gamut test images.

It turns out that Hugo discards the color profile when resizing images. This wouldn't be all bad if the color profile was read, and out-of-gamut colors were clipped (essentially doing a color correct conversion to sRGB), however the color profile is discarded which means that any non-sRGB image that gets resized will appear overly muted and faded when compared to the original in the same browser.

Here is an example of a test image getting resized by hugo. Because of the color shift, it means the color profile was discarded:

Original Resized (Incorrect)
rgb-to-gbr-test rgb-to-gbr-test_huc6d924f2a03db68685f37002346c5668_305745_384x0_resize_q98_lanczos

Here's what happens to a normal DCI-P3 image when it gets resized (Notice the fading)

Original Resized (Incorrect)
P3-sRGB-red P3-sRGB-red_hu9d2a68cb3d1f72119c854fd1da8adbda_264311_384x0_resize_q98_lanczos

I've done a little bit of digging, but I could not find any open issues on this for Hugo, nor for https://github.com/disintegration/gift which appears to be the image processing library that Hugo uses.

If you're building a site there are really only two ways to work around this right now:

  1. Never use wide gamut images.
  2. Never resize images you display.

However, these aren't ideal for anyone using Hugo for photography that wants to give the best possible experience for devices that support wide gamut content (Such as almost all Apple devices, and many modern cell phones). Many many templates have gallery or thumbnail views of images that would be affected by this. If it helps, I put together a set of wide-gamut test images a while ago along with a bunch of documentation if it helps reproducing this bug: https://github.com/codelogic/wide-gamut-tests

Thanks!

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.81.0+extended linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes

@bep bep added the Bug label Mar 4, 2021
@bep bep added this to the v0.82 milestone Mar 4, 2021
@bep bep modified the milestones: v0.82, v0.83 Mar 21, 2021
@bep bep modified the milestones: v0.83, v0.84 May 1, 2021
@jmooring
Copy link
Member

jmooring commented May 3, 2021

git clone --single-branch -b hugo-github-issue-8298 https://github.com/jmooring/hugo-testing hugo-github-issue-8298
cd hugo-github-issue-8298
hugo server

@bep
Copy link
Member

bep commented May 3, 2021

This is currently a limitation in Go's image handling -- so you currently need to apply a profile that's compatible (e.g. sRGB. I asssume).

@bep bep modified the milestones: v0.84, v0.85 Jun 18, 2021
@bep bep modified the milestones: v0.85, v0.86 Jul 5, 2021
@bep bep modified the milestones: v0.86, v0.87, v0.88 Jul 26, 2021
@bep bep modified the milestones: v0.88, v0.89 Sep 2, 2021
@bep bep modified the milestones: v0.89, v0.90 Nov 2, 2021
@bep bep modified the milestones: v0.90, v0.91.0 Dec 13, 2021
@bep bep modified the milestones: v0.91.0, v0.92.0 Dec 22, 2021
@bep bep modified the milestones: v0.92.0, v0.93.0 Jan 12, 2022
@bep bep modified the milestones: v0.93.0, v0.94.0 Mar 1, 2022
@bep bep removed this from the v0.94.0 milestone Mar 9, 2022
@bep bep added this to the v0.115.0 milestone Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants