Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/167777-watermark-using-htaccess/
Share on other sites

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

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

 

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]

 

 

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,

 

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 :(

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.