kulan
kulan

Reputation: 1391

How do I distort arc image on only top and bottom sides using imagick?

I want it to be like this:

enter image description here

But I am getting this:

enter image description here

<?php
$image = new imagick( $_SERVER['DOCUMENT_ROOT']."/test/op.jpg" );
$points = array(
    90,
);
$image->setimagebackgroundcolor("#fad888");
$image->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_BACKGROUND);
$image->distortImage(\Imagick::DISTORTION_CYLINDER2PLANE, $points, true);
header("Content-Type: image/jpeg");
echo $image;

Upvotes: 1

Views: 242

Answers (1)

miken32
miken32

Reputation: 42715

You want to use the wave filter, not the distortion filter.

<?php
$image = new Imagick("googlelogo_color_272x92dp.png");
$image->setImageBackgroundColor("#fad888");
$image->setImageVirtualPixelMethod(\Imagick::VIRTUALPIXELMETHOD_BACKGROUND);
$image->waveImage($image->getImageHeight() / -2, $image->getImageWidth() * 2);
header("Content-Type: image/jpg");
echo $image->getImageBlob();

You'll need to trim the image to remove the extra space added at the bottom. Output:

enter image description here

Upvotes: 1

Related Questions