damo Posted July 16, 2008 Share Posted July 16, 2008 Hi We are retrieving an image from the database and displaying it to the user. We would like to be able to watermark this image from the database before it is displayed to the user. We don't want to watermark it when the user adds it to the database , just when they view the images Any idea if this can be done? And if s, does anyone have sample code? Here is the code we use to retrieve and display the image include('includes/database.php'); $car_name = $_GET['car_name']; $size = $_GET['size']; $query = "select content, type from upload where car_name = '". $car_name ."' and name LIKE '%image1%'"; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0,"content"); $type = @MYSQL_RESULT($result,0,"type"); header('Content-type: ' . $type); $im = imagecreatefromstring($data); $width = imagesx($im); $height = imagesy($im); $imgw = $size; $imgh = $height / $width * $imgw; $thumb=imagecreatetruecolor($imgw,$imgh); ImageCopyResized($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im)); $out = ImagejpeG($thumb, "", 80); echo $out; imagedestroy ($im); imagedestroy ($thumb); Any help would be greatly appreciated Thanks Damien Link to comment https://forums.phpfreaks.com/topic/115019-php-image-watermark/ Share on other sites More sharing options...
samshel Posted July 16, 2008 Share Posted July 16, 2008 Check this out.. http://in2.php.net/manual/en/function.imagecopy.php Link to comment https://forums.phpfreaks.com/topic/115019-php-image-watermark/#findComment-591476 Share on other sites More sharing options...
damo Posted July 16, 2008 Author Share Posted July 16, 2008 Hi Samshel Thanks for that link it was very useful. i ran into another problem though. When i display an image it displays ok but when i tried to add a watermark to the image i get this error sometimes Fatal error: Allowed memory size of 12582912 bytes exhausted (tried to allocate 2048 bytes) in /home/... This error only seems to occur for images over half a meg in size. Any thoughts on what i could do to fix this issue? Thanks Damien Link to comment https://forums.phpfreaks.com/topic/115019-php-image-watermark/#findComment-591915 Share on other sites More sharing options...
monkeytooth Posted July 16, 2008 Share Posted July 16, 2008 could be your php.ini files size limits.. Link to comment https://forums.phpfreaks.com/topic/115019-php-image-watermark/#findComment-591937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.