The image canvas (can have transparent areas)
RGBA color values [red, green, blue, alpha] (0-255 range)
HTMLCanvasElement with the specified background color
When canvas context creation fails
// Apply white background
const withWhiteBg = applyBackgroundColor(cutout, [255, 255, 255, 255]);
// Apply red background with 50% opacity
const withRedBg = applyBackgroundColor(cutout, [255, 0, 0, 128]);
// Apply transparent background (no change)
const withTransparentBg = applyBackgroundColor(cutout, [0, 0, 0, 0]);
Apply a solid background color to an image.
Creates a new canvas with the specified background color and composites the original image on top. Useful for replacing transparent backgrounds with solid colors.