Here's a stumper... hopefully someone can offer some insight for me. I have an image hosting service; by default, the script that I bought tells users to link directly to their uploaded images.
Example:
http://www.website.com/images/Filename.j...
- not -
http://www.website.com/images/Process.ph...
I know how to change the way it works so it would point to an image processing script, but that would not fix the 15,000+ images that are already being directly linked to... so, what I need to know is how I can embed HTML code both above and below an individual image file. So I MUST use .HTACCESS and PHP.
It seems doable, although I don't know enough about .HTACESS to pull it off on my own. I'm 99% there, that is, I have been able to redirect from the actual image to a PHP file which retrieves the requested image - but when I output the HTML code it simply shows a broken image in place of the actual image.
Hope that was all clear enough... anything is appreciated. Thanks!
Using .HTACCESS to embed ad-code above images which are linked directly?
You can have PHP reprocess the image and display it with a watermark.
The PHP would be something like this; the code below assumes all your files are JPGs, and there will be a querystring variable named file to identify the image to display.
%26lt;?
header('Content-type image/jpeg');
$name = $_GET['file'];
$path = "/path/to/image/directory/";
$img = imagecreatefromjpeg($path . $name);
if(!is_file( $img)) {
die('no such image');
}
$imginfo = getimagesize($img);
$y = $imginfo[0]; //horizontal size
$x= $imginfo[1]; //vertical size
$x -= 50; // offset watermark 50 pixels from right margin
$y -= 20; // offset watermark 20 pixels from bottom
$white = imagecolorallocate($im, 255, 255, 255);
$text = "MyImage Server";
$font = "arial.ttf"; // font to use for watermark; must be a font on the Web server
imagettftext($img, 20, 0, $x, $y, $white, $font, $text); //stamp watermark
imagejpeg($img);
imagedestroy($img);
?%26gt;
sensitive teeth
No comments:
Post a Comment