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

Open graph image. Failed to parse linear-gradient with oklch values. #637

Open
samcx opened this issue Sep 19, 2024 Discussed in #636 · 2 comments
Open

Open graph image. Failed to parse linear-gradient with oklch values. #637

samcx opened this issue Sep 19, 2024 Discussed in #636 · 2 comments
Labels
bug Something isn't working Image (next/image)

Comments

@samcx
Copy link
Member

samcx commented Sep 19, 2024

Discussed in #636

Originally posted by firmart September 16, 2024

Link to the code that reproduces this issue

codesandbox

To Reproduce

  1. Start the app npm run dev
  2. Go to <baseURL>/test

Current vs. Expected behavior

ImageResponse failed to parse background: linear-gradient(15deg, oklch(65.69% 0.196 275.75), oklch(74.8% 0.26 342.55), oklch(74.51% 0.167 183.61)) which resulted in the following error : (65.69% 0.196 275.75), oklch(74.8% 0.26 342.55), oklch(74.51% 0.167 183.61)): Missing ).

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #111-Ubuntu SMP Tue Mar 5 20:16:58 UTC 2024
  Available memory (MB): 15888
  Available CPU cores: 4
Binaries:
  Node: 21.6.2
  npm: 10.2.4
  Yarn: 1.22.10
  pnpm: 8.15.4
Relevant Packages:
  next: 14.2.11 // Latest available version is detected (14.2.11).
  eslint-config-next: 14.1.0
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.6.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

According to the error message, I believe that there is an issue parsing oklch values.

It might also be a resvg-js issue as satori render the image correctly in the OG image playground, but resvg-js fails to convert it in png.

@samcx samcx added bug Something isn't working Image (next/image) labels Sep 19, 2024
@Jackie1210
Copy link
Contributor

this latest satori can convert it to svg and has that same effect with browser, but resvg-js cannot convert our svg to png. So I am afraid there are 2 issues:

  1. next/image haven't use latest satori
  2. resvg cannot handle oklch

@naaa760
Copy link

naaa760 commented Sep 22, 2024

Hello @samcx

While satori works, the problem seems to come from resvg-js, which might not fully support oklch. To resolve this, check your syntax and consider using a fallback color format like rgb or hsl, or update resvg-js if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Image (next/image)
Projects
None yet
Development

No branches or pull requests

3 participants