HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue
Category
Example

Frame image

← forwardFourierTransformImage   functionImage →
Adds a simulated three-dimensional border around the image. The width and height specify the border width of the vertical and horizontal sides of the frame. The inner and outer bevels indicate the width of the inner and outer shadows of the frame.
function frameImage(
    $image_path,
    $frame_color,
    $matte_color,
    $width,
    $height,
    $inner_bevel,
    $outer_bevel
) {
    $imagick = new \Imagick(realpath($image_path));

    $width = $width + $inner_bevel + $outer_bevel;
    $height = $height + $inner_bevel + $outer_bevel;

    $imagick->setImageMatteColor($matte_color);
    $imagick->frameimage(
        $frame_color,
        $width,
        $height,
        $inner_bevel,
        $outer_bevel
    );
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}