HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue
Category
Example

Polaroid image

← pingImageFile   polaroidWithTextAndMethod →
Simulates a Polaroid picture. This method is available if Imagick has been compiled against ImageMagick version 6.3.2 or newer.
// Example 1
function polaroidImage($image_path)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagickDraw = new \ImagickDraw();
    $imagick->polaroidImage($imagickDraw, 15);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}
// Example 2 - WithTextAndMethod
function polaroidWithTextAndMethod(
    string $image_path,
    string $text,
    int $interpolate_type,
    float $angle,
    $fill_color,
    $stroke_color
) {
    $imagick = new \Imagick(realpath($image_path));
    $imagickDraw = new \ImagickDraw();

//    $font = findDefaultFont();
//    $imagickDraw->setFont($font);
    $imagickDraw->setFontSize(16);
//    $imagickDraw->setStrokeColor($stroke_color);
//    $imagickDraw->setFillColor($fill_color);
    $imagick->polaroidWithTextAndMethod(
        $imagickDraw,
        $angle,
        $text,
        $interpolate_type
    );
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}