irishpeck Posted June 10, 2009 Share Posted June 10, 2009 Ok so we have a new classifieds website called www.flog-it.ie. On this website we allow people to upload images to the website. These images are stored in our database. How do we setup so that when someone uploads an image it automatically applys a transparent png or gif as a watermark to each image? Below i have added the code for putting the images into the database imgs.php. ***imgs.php*** <?php require_once("config.inc.php"); require_once("pager.cls.php"); // Pager $page = $_GET['page'] ? $_GET['page'] : 1; $offset = ($page-1) * $images_per_page; if ($sef_urls && !$xsearchmode) { $urlformat = "{$vbasedir}$xcityid/images/".($xposterenc?"$xposterenc/":"")."page{@PAGE}.html"; } else { $urlformat = "?"; $tmp = $_GET; unset($tmp['page'], $tmp['msg']); foreach ($tmp as $k=>$v) $urlformat .= "$k=$v&"; $urlformat .= "page={@PAGE}&cityid=$xcityid&lang=$xlang"; } // The link to see all images if ($sef_urls) { $allimgslink = "{$vbasedir}$xcityid/images/"; } else { $allimgslink = "?view=imgs&cityid=$xcityid&lang=$xlang"; } // View conditions if($xposterenc) $whereplus = "AND MD5(CONCAT('IMG', '$encryptposter_sep', a.postername, '$encryptposter_sep', a.posteremail)) = '$xposterenc'"; $whereplus .= " $loc_condn_img"; ?> <h2><?php if($xposterenc) { ?> <?php echo $lang['IMAGES_BY']; ?> <?php echo $xpostername; ?> <?php } else { ?> <?php echo $lang['IMAGES']; ?> <?php } ?> </h2> <table width="100%" cellpadding="0"><tr><td width="150"> <?php if($xposterenc) { ?> <table><tr><td class="linkbox2" width="150"> <a href="<?php echo $allimgslink; ?>"><?php echo $lang['ALL_IMAGES']; ?></a> </td></tr></table> <?php } ?> </td> <td align="right"> <?php include_once("imgcredits.inc.php"); ?> </td></tr></table><br><br> <table width="98%"><tr><td valign="top"> <div class="imglisting"> <?php $sql = "SELECT COUNT(*) FROM $t_imgs a INNER JOIN $t_cities ct ON a.cityid = ct.cityid WHERE $visibility_condn $whereplus"; list($imgcount) = mysql_fetch_array(mysql_query($sql)); $sql = "SELECT a.*, UNIX_TIMESTAMP(a.createdon) AS createdon, COUNT(*) AS commentcount, ic.imgid AS hascomments FROM $t_imgs a INNER JOIN $t_cities ct ON a.cityid = ct.cityid LEFT OUTER JOIN $t_imgcomments ic ON a.imgid = ic.imgid WHERE $visibility_condn $whereplus GROUP BY a.imgid ORDER BY a.timestamp DESC LIMIT $offset, $images_per_page"; $res = mysql_query($sql) or die($sql.mysql_error()); while ($row=mysql_fetch_array($res)) { $posterenc = EncryptPoster("IMG", $row['postername'], $row['posteremail']); if($sef_urls) $imgurl = "{$vbasedir}$xcityid/images/$posterenc/$row[imgid].html"; else $imgurl = "?view=showimg&posterenc=$posterenc&imgid=$row[imgid]&cityid=$xcityid&lang=$xlang"; $imgsize = GetThumbnailSize("{$datadir[userimgs]}/{$row[imgfilename]}", $thumb_max_width, $thumb_max_height); ?> <div class="imgitem"> <?php echo $lang['POST_ID']; ?> M<?php echo $row['imgid']; ?> <div class="head"><?php echo $row['imgtitle']; ?></div><br> <div class="caption"> <?php echo $lang['POSTED_BY']; ?> <?php if($row['showemail']) echo "<a href=\"mailto:$row[posteremail]\" class=\"poster\">$row[postername]</a>"; else echo "<span class=\"poster\">$row[postername]</span>"; ?> <?php echo $lang['POSTED_ON']; ?> <span class="time"> <?php echo QuickDate($row['createdon']); ?> </span> </div> <a href="<?php echo $imgurl; ?>"><img class="img" id="img<?php echo $row['imgid']; ?>" border="0" src="<?php echo "{$datadir[userimgs]}/{$row[imgfilename]}"; ?>" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>"></a><br> <?php if($row['imgdesc']) { ?><div class="desc"><?php echo $row['imgdesc']; ?></div><?php } ?> <a href="<?php echo $imgurl; ?>#comments"> <?php if($row['hascomments']) { ?> (<?php echo $row['commentcount']; ?> <?php echo $lang['X_COMMENTS']; ?>) <?php } else { ?> (<?php echo $lang['ZERO_COMMENTS']; ?>) <?php } ?> </a> </div> <?php } ?> </div> <?php if ($imgcount > $images_per_page) { $pager = new pager($urlformat, $imgcount, $images_per_page, $page); ?> <br> <div> <table cellspacing="0" cellpadding="0"> <tr><td><b><?php echo $lang['PAGE']; ?>: </b></td><td><?php echo $pager->outputlinks(); ?></td></tr> </table> </div> <?php } ?> </td></tr></table> Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/ Share on other sites More sharing options...
RussellReal Posted June 10, 2009 Share Posted June 10, 2009 imagecopymerge Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/#findComment-853019 Share on other sites More sharing options...
irishpeck Posted June 10, 2009 Author Share Posted June 10, 2009 Would you be able to help me with my code though? I dont know where to enter the code in the relative file. Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/#findComment-853048 Share on other sites More sharing options...
RussellReal Posted June 10, 2009 Share Posted June 10, 2009 click the link that the function name is, it will take you to php.net and they explain all the parameters Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/#findComment-853058 Share on other sites More sharing options...
irishpeck Posted June 10, 2009 Author Share Posted June 10, 2009 Yeah i went there but im not a php programmer i only know the basics, i dont know how to compile the code i need or where it should go in the code ive given! Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/#findComment-853070 Share on other sites More sharing options...
RussellReal Posted June 10, 2009 Share Posted June 10, 2009 there is no INSERT query, in that whole file, this can't be the correct file to help you with, but to be completely honest, this is more of a script request than help, as you personally aren't a PHP developer, and the admins are awake atm for whatever reason and will most likely move the topic to the freelance forum Quote Link to comment https://forums.phpfreaks.com/topic/161663-need-help-with-image-uploads-and-watermarks/#findComment-853075 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.