Saturday, 17 August 2013

How to set checkerboard pattern as background on any type image using imagick or GD

How to set checkerboard pattern as background on any type image using
imagick or GD

I want to set background like chekerboard pattern on image, but problem is
that when i upload image background becomes white. how can i create
chekerboard background like png background.???
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width,
$height, $this->getWidth(), $this->getHeight());
$img = imagecreatefromstring($new_image); //or whatever loading function
you need $white = imagecolorallocate($img, 255, 255, 255);
imagecolortransparent($img, $white); imagepng($img, $new_image);

No comments:

Post a Comment