bob2588 Posted July 28, 2009 Share Posted July 28, 2009 Hi i am try to put a watermark on all images in a dirctory but i cant get it to work can you guys look at it and tell me what i am doing worng here is the .htaccess file # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName stuff AuthUserFile /home/bob/public_html/stuff/_vti_pvt/service.pwd AuthGroupFile /home/bob/public_html/stuff/_vti_pvt/service.grp RewriteRule ^(.*)wp-content/images/(.*) $1watermark.php?src=wp-content/images/$2 Here is the watermark.php <?php $src = $_GET['src']; header('Content-type: image/jpeg'); if (eregi("150x150", $src)) { $watermark = imagecreatefrompng('empty.png'); } else { $watermark = imagecreatefrompng('watermark.png'); } $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); if(eregi('.gif',$src)) { $image = imagecreatefromgif($src); } elseif(eregi('.jpeg',$src)||eregi('.jpg',$src)) { $image = imagecreatefromjpeg($src); } elseif(eregi('.png',$src)) { $image = imagecreatefrompng($src); } else { exit("Your image is not a gif, jpeg or png image. Sorry."); } $size = getimagesize($src); $dest_x = $size[0] - $watermark_width - 0; $dest_y = $size[1] - $watermark_height - 0; imagecolortransparent($watermark,imagecolorat($watermark,0,0)); imagecopyresampled($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height); imagejpeg($image, "", 95); imagedestroy($image); imagedestroy($watermark); ?> Thank you Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/ Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 Does the watermark.php work manually ? Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884788 Share on other sites More sharing options...
patrickmvi Posted July 28, 2009 Share Posted July 28, 2009 Are you getting any kind of errors that you could post? Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884795 Share on other sites More sharing options...
bob2588 Posted July 28, 2009 Author Share Posted July 28, 2009 Does the watermark.php work manually ? it should work with the .haaccess file all picture in the images dic should have a watermark on them but i cant get the stupid thing to work Also there are no error. it just not putting the watermarks on the images Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884797 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 That wasn't the question.. try it manually if that fails we need to fix the code, if it work we need to fix the rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884802 Share on other sites More sharing options...
bob2588 Posted July 28, 2009 Author Share Posted July 28, 2009 That wasn't the question.. try it manually if that fails we need to fix the code, if it work we need to fix the rewrite. it a problem with the rewrite http://stuff.bob.tdsnet.org/watermark.php?src=http://www.stuff.bob.tdsnet.org/images/meandshannon041.jpg it works manually Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884814 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 Okay.. try changing RewriteRule ^(.*)wp-content/images/(.*) watermark.php?src=wp-content/images/$2 to RewriteCond %{REQUEST_URI} ^wp-content/images/(.*)$ [nc] RewriteRule ^wp-content/images/(.*)$ watermark.php?src=wp-content/images/$1 [NC] I'll move this to the correct section as a note, this would probably be better http://stuff.bob.tdsnet.org/watermark.php?src=images/meandshannon041.jpg Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884821 Share on other sites More sharing options...
bob2588 Posted July 28, 2009 Author Share Posted July 28, 2009 i did the Tutorials wrong RewriteCond %{REQUEST_URI} ^wp-content/images/(.*)$ [nc] RewriteRule ^wp-content/images/(.*)$ watermark.php?src=wp-content/images/$1 [NC] My Webserver is cpanel based so the code should look like this right RewriteCond %{REQUEST_URI} ^/home/bob/public_html/stuff/images/(.*)$ [nc] RewriteRule ^/home/bob/public_html/stuff/images/(.*)$ watermark.php?src=/home/bob/public_html/stuff/images/$1 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884828 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 No, {REQUEST_URI} is pulled from the URL after the domain ie the {REQUEST_URI} of http://mydomain.com/test/hello.test?blar is /test/hello.test?blar however http://stuff.bob.tdsnet.org/watermark.php?src=/home/bob/public_html/stuff/images/meandshannon041.jpg would also work, Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884852 Share on other sites More sharing options...
bob2588 Posted July 28, 2009 Author Share Posted July 28, 2009 ok let try this the .htaccess is still not working here what i got # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName stuff AuthUserFile /home/bob/public_html/stuff/_vti_pvt/service.pwd AuthGroupFile /home/bob/public_html/stuff/_vti_pvt/service.grp RewriteCond %{REQUEST_URI} ^wp-content/images/(.*)$ [nc] RewriteRule ^wp-content/images/(.*)$ watermark.php?src=wp-content/images/$1 [NC] is there a problem with this or with the server i dont have a folder call wp-content :/ i thank i missed this all up Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884859 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 I just looked at the sites URL, i'm not sure why you have wp-content, in anycase try RewriteCond %{REQUEST_URI} ^images/(.*)$ [nc] RewriteRule ^images/(.*)$ watermark.php?src=images/$1 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884861 Share on other sites More sharing options...
bob2588 Posted July 28, 2009 Author Share Posted July 28, 2009 there is still a problem with the .htaccess file Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884910 Share on other sites More sharing options...
MadTechie Posted July 28, 2009 Share Posted July 28, 2009 Humm okay fine, lets try a simple one, (i also don't see the engine on!) let try this RewriteEngine On RewriteRule ^images/(.*) watermark.php?src=images/$1 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/#findComment-884921 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.