Set foreground and background colors in RGB or CMYK mode, apply grayscale tones, and add directional gradients to your Laravel QR codes.
The package supports three color models — RGB (default), CMYK, and grayscale. Switch between them at any point in the builder chain. Every method returns a clonedGenerator so previous state is never mutated.
Alpha values throughout this package use a 0–100 scale (0 = fully opaque,
100 = fully transparent). The package converts this internally to the range
PHP’s GD library expects (0–127). You do not need to perform this conversion
yourself.
Switch the active color model to RGB. This is the default mode — call it explicitly only when you need to revert from CMYK in a chain.Each channel uses a 0–255 scale. Alpha uses a 0–100 scale.
Switch the active color model to CMYK. All subsequent calls to color() and backgroundColor() interpret channel values on a 0–100 scale (percentage).
Gradients (gradient()) are only available in RGB mode. Calling gradient()
while in CMYK mode will produce unexpected results. Switch back to rgb()
before using gradients.
QrCode::size(300) ->cmyk() ->color(100, 50, 0, 10) // deep blue in CMYK ->backgroundColor(0, 0, 0, 0) // white background in CMYK ->generate('https://example.com');
gradient() takes color values directly rather than using whatever was set by
a prior color() call. The gradient replaces the foreground color entirely.