dawhoo
03-24-2006, 02:47 PM
I have been using the same method to watermark my images for a very long time and I've used in on several different hosting companies. I just moved to BLuehost and cannot get my combination to work anymore.
Filed a ticket, but they won't provide support for this, which is understandable. However, this works on 6 different servers and not working seems to be unique to Bluehost, which isn't understandable, since I was told mod rewrite is installed and working properly.
Here's the htaccess file
RewriteEngine on
RewriteRule ^(.*)\.jpg /home/12345678(first 8 letters of domain)/public_html/watermark/image.php?%{REQUEST_FILENAME}
SetEnvIfNoCase Referer "^http://www.follywaves.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://follywaves.com/" locally_linked=1
SetEnvIf Referer "^$" locally_linked=1
<FilesMatch "\.(gif|png|jpeg|jpg)$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch>
And here's the file it calls.
<?php
//watermark program
//Show that a jpeg image is going to be returned
//echo $QUERY_STRING;
//exit;
header("Content-type: image/jpeg");
//File names
$wmark='watermark.png';
$wmarks='watermark_s.png';
$noimg='noimg.png';
$mimage=$QUERY_STRING;
// mod to display default image instead of 404
if (file_exists($QUERY_STRING)) {
//echo "The file $QUERY_STRING exists";
//Loading
$watermark_img = imagecreatefrompng($wmark);
$watermarks_img = imagecreatefrompng($wmarks);
$wmrk_size = getimagesize($wmark);
$wmrks_size = getimagesize($wmarks);
$main_img = imagecreatefromjpeg($mimage);
//ImageAlphaBlending($main_image, true);
//Merge the 2 buffers
//The figure "300" can be changed to any figure suitable for your situation.
if (ImageSX($main_img) > 300) {
$posx = (ImageSX($main_img) - ImageSX($watermark_img))/4;
$posy = (ImageSY($main_img) - ImageSY($watermark_img));
imagecopy($main_img, $watermark_img, $posx, $posy, 0, 0, $wmrk_size[0], $wmrk_size[1]);
}else{
$posxs = (ImageSX($main_img) - ImageSX($watermarks_img))/4;
$posys = (ImageSY($main_img) - ImageSY($watermarks_img));
imagecopy($main_img, $watermarks_img, $posxs, $posys, 0, 0, $wmrks_size[0], $wmrks_size[1]);
}
//Output file to browser
imagejpeg($main_img);
imagedestroy($watermark_img);
imagedestroy($watermarks_img);
imagedestroy($main_img);
} else {
//echo "The file $QUERY_STRING does not exist";
//Loading
$noimg_show = imagecreatefrompng($noimg);
//Output file to browser
imagejpeg($noimg_show);
imagedestroy($noimg_show);
}
?>
I'm stumped
Filed a ticket, but they won't provide support for this, which is understandable. However, this works on 6 different servers and not working seems to be unique to Bluehost, which isn't understandable, since I was told mod rewrite is installed and working properly.
Here's the htaccess file
RewriteEngine on
RewriteRule ^(.*)\.jpg /home/12345678(first 8 letters of domain)/public_html/watermark/image.php?%{REQUEST_FILENAME}
SetEnvIfNoCase Referer "^http://www.follywaves.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://follywaves.com/" locally_linked=1
SetEnvIf Referer "^$" locally_linked=1
<FilesMatch "\.(gif|png|jpeg|jpg)$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch>
And here's the file it calls.
<?php
//watermark program
//Show that a jpeg image is going to be returned
//echo $QUERY_STRING;
//exit;
header("Content-type: image/jpeg");
//File names
$wmark='watermark.png';
$wmarks='watermark_s.png';
$noimg='noimg.png';
$mimage=$QUERY_STRING;
// mod to display default image instead of 404
if (file_exists($QUERY_STRING)) {
//echo "The file $QUERY_STRING exists";
//Loading
$watermark_img = imagecreatefrompng($wmark);
$watermarks_img = imagecreatefrompng($wmarks);
$wmrk_size = getimagesize($wmark);
$wmrks_size = getimagesize($wmarks);
$main_img = imagecreatefromjpeg($mimage);
//ImageAlphaBlending($main_image, true);
//Merge the 2 buffers
//The figure "300" can be changed to any figure suitable for your situation.
if (ImageSX($main_img) > 300) {
$posx = (ImageSX($main_img) - ImageSX($watermark_img))/4;
$posy = (ImageSY($main_img) - ImageSY($watermark_img));
imagecopy($main_img, $watermark_img, $posx, $posy, 0, 0, $wmrk_size[0], $wmrk_size[1]);
}else{
$posxs = (ImageSX($main_img) - ImageSX($watermarks_img))/4;
$posys = (ImageSY($main_img) - ImageSY($watermarks_img));
imagecopy($main_img, $watermarks_img, $posxs, $posys, 0, 0, $wmrks_size[0], $wmrks_size[1]);
}
//Output file to browser
imagejpeg($main_img);
imagedestroy($watermark_img);
imagedestroy($watermarks_img);
imagedestroy($main_img);
} else {
//echo "The file $QUERY_STRING does not exist";
//Loading
$noimg_show = imagecreatefrompng($noimg);
//Output file to browser
imagejpeg($noimg_show);
imagedestroy($noimg_show);
}
?>
I'm stumped