<?php
// 6x6 color matrix for CMYKA
$colorMatrix = [
1.5, 0.0, 0.0, 0.0, 0.0, -0.157,
0.0, 0.0, 0.5, 0.0, 0.0, -0.157,
0.0, 0.0, 0.0, 0.0, 0.5, -0.157,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 0.5, 0.0, 1.0
];
// Create Imagick object
$imagick = new \Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');
// Set image opacity
$imagick->evaluateImage(
Imagick::EVALUATE_MULTIPLY,
0.6,
Imagick::CHANNEL_ALPHA
);
// Create new Imagick object
$background = new \Imagick();
// Creating new pseudo image with hexagon pattern
$background->newPseudoImage(
$imagick->getImageWidth(),
$imagick->getImageHeight(),
"pattern:hexagons"
);
// Set the image format
$background->setImageFormat('png');
$imagick->setImageFormat('png');
// Use Imagick::colorMatrixImage() function
$imagick->colorMatrixImage($colorMatrix);
// Use Imagick::compositeImage() function
$background->compositeImage(
$imagick,
\Imagick::COMPOSITE_SRCATOP,
0,
0
);
header("Content-Type: image/png");
// Display the output image
echo $background->getImageBlob();
?>