leachy Posted October 23, 2005 Share Posted October 23, 2005 ive seen lots of topics on here that have people saying they have images on the board watermarked but i cant find a script that does it, does anyone know how to do it and has the script and instructions on how to do it ? Thanks in advance Josh Link to comment Share on other sites More sharing options...
leachy Posted October 27, 2005 Share Posted October 27, 2005 bump? Link to comment Share on other sites More sharing options...
Geraint Posted October 28, 2005 Share Posted October 28, 2005 Here's part of a script of my own, that enables users to upload pics to our Gallery (german), that are automatically watermarked, if there's enough room for. The uploaded images can be of any size and I generate 2 additional ones, that fit into STD_WIDHT x STD_HEIGHT dimensions (800x600 at the moment) and THB_WIDTH x THB_HEIGHT (Thumbnail size). Every scaling is done in respect to the original aspect ratio and the 800x600 and the original image get an additional watermark in the top right corner. ... //----------------------------- // Filesystem $l_oTmp = @imagecreatefromjpeg($p_aFile["tmp_name"]); // watermark image $l_oWater = imagecreatefrompng("pics/watermark.png"); $l_nWidth = imagesx($l_oTmp); $l_nHeight = imagesy($l_oTmp); $l_sName = uniqid(time()."_").".jpg"; $l_sPath = ROOT_PATH.$p_sCatDir."/"; $l_sThumbs = $l_sPath.PREV_PATH; $l_sOrig = $l_sPath.ORIG_PATH; // testing dimensions and relations $l_nOrigScale = 1; $l_nThumbScale = 1; $l_nScaleX = STD_WIDTH / $l_nWidth; // 800 / 1280 = 0.625 $l_nScaleY = STD_HEIGHT / $l_nHeight; // 600 / 1024 = 0.585 $l_nTmp = min($l_nScaleX, $l_nScaleY); $l_nOrigScale = ($l_nTmp < 1)?$l_nTmp:$l_nOrigScale; $l_nScaleX = THB_WIDTH / $l_nWidth; // 120 / 1280 = 0.09375 $l_nScaleY = THB_HEIGHT / $l_nHeight; // 90 / 1024 = 0.0878 $l_nTmp = min($l_nScaleX, $l_nScaleY); $l_nThumbScale = ($l_nTmp < 1)?$l_nTmp:$l_nThumbScale; // 1. picture, shown intially (STD_WIDTH x STD_HEIGHT) $l_nOrigW = (int)($l_nWidth * $l_nOrigScale); $l_nOrigH = (int)($l_nHeight * $l_nOrigScale); $l_oOrig = imagecreatetruecolor($l_nOrigW, $l_nOrigH); imagecopyresized($l_oOrig, $l_oTmp, 0, 0, 0, 0, $l_nOrigW, $l_nOrigH, $l_nWidth, $l_nHeight); // watermark if (imagesx($l_oWater) < $l_nOrigW) imagecopy($l_oOrig, $l_oWater, $l_nOrigW - imagesx($l_oWater) - 10, 10, 0, 0, imagesx($l_oWater), imagesy($l_oWater)); ... If you're familiar with PHP, are able to think some mathematcis over and have access to some server with the needed libs (GD) you should be able to use this snippet. Regards Geraint Link to comment Share on other sites More sharing options...
leachy Posted October 29, 2005 Share Posted October 29, 2005 Thanks, but i dont understand how to make it work!??? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.