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

BUG: Fails to apply HSL colors with a decimal point in the hue. #602

Open
Ashwin-Mahadevan opened this issue Mar 12, 2024 · 0 comments
Open

Comments

@Ashwin-Mahadevan
Copy link

Bug report

Description / Observed Behavior

When a decimal point is provided

Expected Behavior

How did you expect Satori to behave here?

Reproduction

Note: Satori functions correctly in the OG-Image Playground (Reproduction)

However, in any Next.js app, the bug occurs. I've tried the lastest next-js and satori releases as well as a few versions back. To reproduce this, git clone https://github.com/ashwin-mahadevan/satori-decimal-hue-reproduction, start the Next server, and navigate to / or /?decimal=true.

or use the following code in an app-router route.tsx file:

import { ImageResponse } from "next/og";

export function GET(request) {
  const decimal = request.nextUrl.searchParams.get("decimal") === "true";

  const element = (
    <div
      style={{
        display: "flex",
        width: 256,
        height: 256,
        backgroundColor: decimal
          ? "hsl(20.5 90.2% 48.2%)" // Shows black image with decimal hue.
          : "hsl(21 90.2% 48.2%)", // Shows correct orange image with integer hue.
      }}
    />
  );

  return new ImageResponse(element, { width: 256, height: 256 });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant