masking images

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
lokanath7
New php-forum User
New php-forum User
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am

Fri Sep 02, 2011 3:16 am

try this....

Code: Select all

<?php
$img1 = imagecreateFromjpeg("image.jpg");
$x=imagesx($img1)-$width ;
$y=imagesy($img1)-$height;


$img2 = imagecreatetruecolor($x, $y);
$bg = imagecolorallocate($img2, 255, 255, 255);
imagefill($img2, 0, 0, $bg);

$e = imagecolorallocate($img2, 0, 0, 0);

$r = $x <= $y ? $x : $y;
imagefilledellipse($img2, ($x/2), ($y/2), $r, $r, $e); 

imagecolortransparent($img2, $e);

imagecopymerge($img1, $img2, 0, 0, 0, 0, $x, $y, 100);

imagecolortransparent($img1, $bg);

header("Content-type: image/png");
imagepng($img1);

imagedestroy($img2);
imagedestroy($img1);


?>

mytony

Wed Sep 14, 2011 6:39 pm

a little difficult for me.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests