Lack of transparency with the Imagick polaroid effect

I use the code below to create a polaroid effect, but it really distracts without any transparent effect.

<?php /* Create the object */ $image = new Imagick('wood.png'); /* Set the opacity */ $image->polaroidImage(new ImagickDraw(), 25); /* output the image */ header('Content-type: image/png'); echo $image; ?> 

I get a result like http://photoapp.biz/polaroid/test.php

Regular Image http://photoapp.biz/polaroid/wood.png

What is the problem? This happens in almost all 10 images that I tried.

Example:

enter image description here

+4
source share
3 answers

Transparency set using Imagick :: setImageOpacity

 $image->setImageOpacity(0.7); 

In addition, you may need to work with a different image format:

However, some web browsers, however, do NOT display transparent "PNGs" (primarily Microsoft Internet Explorer v6, although IE v7). Because of this, I usually prefer to use JPEG and GIF image formats and use PNG only when creating images using translucent pixels or requiring exact colors for subsequent examples.

Source: http://www.imagemagick.org/Usage/#PNG

EDIT 1

to try

$ image-> setBackgroundColor (new ImagickPixel ('transparent'));

0
source

Correct me if I am wrong, but you are really asking about smoothing, aren't you?

http://www.imagemagick.org/Usage/antialiasing/

0
source

Try this function http://php.net/manual/en/function.imageantialias.php .

What does he do:

enter image description here

Just remember that IMAGIC can be compiled in many different ways, and you can have different effects in different environments.

0
source

Source: https://habr.com/ru/post/1436618/


All Articles