lopes_andre Posted December 13, 2009 Share Posted December 13, 2009 Hi all, I'am trying to resize an image and watermarking in the same proccess using CodeIgniter, but without success, I'am able to do only one operation at the same time. Because I'am not able to do it using CodeIgniter Image_lib... my question is: It is possible to resize an image and watermarking On The Fly using GD library? If yes, do you know some examples? Best Regards, Link to comment https://forums.phpfreaks.com/topic/184979-image-resize-and-watermarking-on-the-fly/ Share on other sites More sharing options...
daydreamer Posted December 13, 2009 Share Posted December 13, 2009 Here is some code I wrote a while back for the same feature. Works like this: script.php?src=yourimage.jpg Then you can put that in an img html tag: <img src="script.php?src=youimage.jpg" /> <?php header('content-type: image/jpeg'); $watermark = imagecreatefromgif('watermark.gif'); //your watermark image. $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg("imageuploads/".$_GET['src']); // change to location of file. $get[src] is just the file name and extensions. e.g filename.jpg $size = getimagesize("imageuploads/".$_GET['src']); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); ?> Link to comment https://forums.phpfreaks.com/topic/184979-image-resize-and-watermarking-on-the-fly/#findComment-976507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.