graham23s Posted September 18, 2010 Share Posted September 18, 2010 Hi Guys, Using this code i am able to overlay a logo onto an image: <?php // Load the image where the logo will be embeded into $image = imagecreatefromjpeg("box.jpg"); // Load the logo image $logoImage = imagecreatefrompng("logo.png"); imagealphablending($logoImage, true); // Get dimensions $imageWidth=imagesx($image); $imageHeight=imagesy($image); $logoWidth=imagesx($logoImage); $logoHeight=imagesy($logoImage); // Paste the logo imagecopy( // source $image, // destination $logoImage, // destination x and y $imageWidth-$logoWidth, $imageHeight-$logoHeight, // source x and y 0, 0, // width and height of the area of the source to copy $logoWidth, $logoHeight); // Set type of image and send the output //header("Content-type: image/png"); //imagePng($image); imagejpeg($logoImage, "imageWithLogo.jpg", 100); // Release memory imageDestroy($image); imageDestroy($imageLogo); ?> this part: //header("Content-type: image/png"); //imagePng($image); shows me the complete image with the logo ontop, what i'm having trouble with is saving the image. any help would be appreciated thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/213734-saving-watermarked-image/ Share on other sites More sharing options...
adrianTNT Posted September 18, 2010 Share Posted September 18, 2010 I think the part of that code that saves the actual image file on server is: imagejpeg($logoImage, "imageWithLogo.jpg", 100); if you call that in site root it would probably not work, I would try something like this: imagejpeg($logoImage, "images/imageWithLogo.jpg", 100); where "images" is a folder that is made writable. Link to comment https://forums.phpfreaks.com/topic/213734-saving-watermarked-image/#findComment-1112480 Share on other sites More sharing options...
Andy-H Posted September 18, 2010 Share Posted September 18, 2010 I duno whats up but you got the source and destination in the wrong order in the imagecopy function, destination comes first, so you should be saving $image. Doesa file of that name already exist? Do you have error reporting and display errors on? Link to comment https://forums.phpfreaks.com/topic/213734-saving-watermarked-image/#findComment-1112488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.