Young OG
Young OG

Reputation: 3

Imagick's 'thumbnailImage' function doesn't work

I use the Imagick's function thumbnailImage to resize my PNG image.

It doesn't change the size on my website, but with the function getImageGeometry the new dimension has been applied. I've also used the function resizeImage but nothing changes.

My script (running on Windows):

$im = new \Imagick();
$im->readImage('page.png');
$im->thumbnailImage(1024, 768, TRUE);

echo "<img src='page.png'>";

Upvotes: 0

Views: 107

Answers (2)

Mike Doe
Mike Doe

Reputation: 17576

Do it better, in case other MIME type is used:

printf(
    '<img src="data:%s;base64,%s">',
    $imagick->getImageMimeType(),
    base64_encode($imagick->getImageBlob())
);

Upvotes: 0

shingo
shingo

Reputation: 27021

Resized image data is in Imagick object, you may save it back, or output the content directly.

echo "<img src='data:image/png;base64,".base64_encode($imagick->getImageBlob())."'>";

Upvotes: 1

Related Questions