4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: okram on April 29, 2005, 08:37:18 PM
-
hi there! :P
I'm trying 4images and i want to put a watermark in the pics, i saw in this topic: http://www.4homepages.de/forum/index.php?topic=3808.00 but it is not what i really want in fact, 'cos it aplies the mark when uploading the pics, but i want to geta watermarked image only when showing the pic, so the original is not changed at all.
I have a php file which inserts a watermark on every image, and it can be access like an image itself... let me explain, the file is named watermark.php and the code is:
<?php
$image = $_GET['get_image'];
$watermark = "water.png";
$im = imagecreatefrompng($watermark);
$ext = substr($image, -3);
if(strtolower($ext) == "gif") {
if (!$im2 = imagecreatefromgif($image)) {
echo "Error opening $image!"; exit;
}
} else if(strtolower($ext) == "jpg") {
if (!$im2 = imagecreatefromjpeg($image)) {
echo "Error opening $image!"; exit;
}
} else if(strtolower($ext) == "png") {
if (!$im2 = imagecreatefrompng($image)) {
echo "Error opening $image!"; exit;
}
} else {
die;
}
imagecopy($im2, $im, (imagesx($im2)/100)-(imagesx($im)/100), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
if($_GET[repeat]) {
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/1);
for($n=1; $n<=$rest; $n++) {
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))-(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))+(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
}
}
header("Content-Type: image/jpeg");
imagejpeg($im2);
imagedestroy($im);
imagedestroy($im2);
?>
Let's see: suposse i have another page called show.html, which shows the picture. This page is in the folder /images/, just as watermark.php (they both are in the same path /images/) and if I try to show a pic in the folder /images/pics/cat1/pic.jpg the code would be:
<img src="watermark.php?get_image=images/pics/cat1/pic.jpg">
instead of
<img src="images/pics/cat1/pic.jpg">
SO, my question is how to do it in 4images, what should i change... i have already look for tha code that shows the image in the file details.php, so i can change it, but i find nothing... how am i supossed to do it?
thanks a lot
-
did u try add in jpg.html template:
<img src="watermark.php?get_image={media_src}">
? (make sure watermark.php is located in 4images root directory.)
-
thanks for that, i got what i wanted.
2 more questions :lol: (forgive my bad english.. i'm a spanish speaker):
1. And how can i do the same thing when downloading the file by pressing the download buttons (as jpg or as zip)? i mean, download the marked pic instead of the original?
2. If a user see the source code will find the pic easily... what i want to do is to set in the file watermark.php a "secret" folder... :? ill explain: I have my data folder (and of course all the pics) into anoher one called hideimagesfromuser/ (it's just a name), so when the jpg.html file calls the media_src the folder shown is hideimagesfromuser/data/media/004/001.jpg... well i want to do in fact is to create one more variable to write instead of media_src to not show the full directory, fore example only media/004/001.jpg, and the rest is given by the file watermark.php but not shown... (i hope you did understand.... xoxo my english is so bad :P)
Just one more... I wonder if it is possible to restrict the access to the folder hideimagesfromuser/data/media/ and all the subfolders in there to the users who try to enter directly to one file in this folder... i read that i could do it by using a .htaccess file... but i dont even know it... thanks again and i hope for some help... greets!
-
2. If a user see the source code will find the pic easily... what i want to do is to set in the file watermark.php a "secret" folder... :? ill explain: I have my data folder (and of course all the pics) into anoher one called hideimagesfromuser/ (it's just a name), so when the jpg.html file calls the media_src the folder shown is hideimagesfromuser/data/media/004/001.jpg... well i want to do in fact is to create one more variable to write instead of media_src to not show the full directory, fore example only media/004/001.jpg, and the rest is given by the file watermark.php but not shown... (i hope you did understand.... xoxo my english is so bad :P)
Just one more... I wonder if it is possible to restrict the access to the folder hideimagesfromuser/data/media/ and all the subfolders in there to the users who try to enter directly to one file in this folder... i read that i could do it by using a .htaccess file... but i dont even know it... thanks again and i hope for some help... greets!
1) we have a very usefull topic Pic Security u might want to check it out ;)
here is your modifyed watermark script:<?php
$nozip = 1;
define('ROOT_PATH', './');
define('GET_CACHES', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
//$user_access = get_permission();
$watermark = "water.png";
if (!$image_id)
{
die("Security violation");
}
$sql = "SELECT cat_id, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row)
{
die("No permission");
}
$im = imagecreatefrompng($watermark);
$image = MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
if ($image_info = @getimagesize($image))
{
$image_create_handle = "imagecreatefrom".$types[$image_info[2]];
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
imagecopy($im2, $im, (imagesx($im2)/100)-(imagesx($im)/100), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
if($_GET[repeat])
{
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/1);
for($n=1; $n<=$rest; $n++)
{
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))-(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))+(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
}
}
header("Content-Type: image/jpeg");
imagejpeg($im2);
imagedestroy($im);
imagedestroy($im2);
}
else
{
die("Error opening $image!");
}
?>
and jpg.html template:<img src="watermark.php?image_id={image_id}">
no more showing the images path.
but I must warn u, this version will much slower then yours.
-
well thanks again... i've done it! works fine too!, but there's something you missed... when pressing the download and download as zip buttons, it is the original pic the one downloaded, not the marked one. Is there anyway to download the marked one? i know that when uploading the pics i can put the download dir, but i cannot do that with all the pics, it would last a whole life to have it done, so...
Or maybe it is not possible, in that case (but only in that case) how can i delete the download buttons and remove the copyright notice shown in the rightclick? so the user can save the image as usual, but it goes with the mark.
Thanks
P.D.: I'm starter in this stuff :lol:... can i change the thumbnails directory even if the gallery have already been installed? i know i have to modify the constants.php file, but this will not make the gallery work wrong right? Thanks
-
well thanks again... i've done it! works fine too!, but there's something you missed... when pressing the download and download as zip buttons, it is the original pic the one downloaded, not the marked one. Is there anyway to download the marked one? i know that when uploading the pics i can put the download dir, but i cannot do that with all the pics, it would last a whole life to have it done, so...
ofcourse its possible ;), but it would require havy modifications in download.php...sorry, u are on your own there.
Or maybe it is not possible, in that case (but only in that case) how can i delete the download buttons and remove the copyright notice shown in the rightclick? so the user can save the image as usual, but it goes with the mark.
FAQ: Remove the right-click disabler (http://www.4homepages.de/forum/index.php?topic=3088)
P.D.: I'm starter in this stuff :lol:... can i change the thumbnails directory even if the gallery have already been installed? i know i have to modify the constants.php file, but this will not make the gallery work wrong right? Thanks
it will work just fine. 4images does not store the full path to the images in the database, only filenames and calculating the path to the images when they are being requested.
-
hmmm...I just got an idea about download thingie...
what if u rename in download.phpfunction get_file_data($file_path) {
to function get_file_data2($file_path) {
and above that line add this:function get_file_data($image)
{
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
if ($image_info = @getimagesize($image))
{
$image_create_handle = "imagecreatefrom".$types[$image_info[2]];
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
imagecopy($im2, $im, (imagesx($im2)/100)-(imagesx($im)/100), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
if($_GET[repeat])
{
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/1);
for($n=1; $n<=$rest; $n++)
{
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))-(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))+(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
}
}
ob_start();
@ob_implicit_flush(0);
imagejpeg($im2);
$file_data = ob_get_contents();
ob_end_clean();
imagedestroy($im);
imagedestroy($im2);
return $file_data;
}
else
{
return get_file_data2($image);
}
}
:?:
-
hi, i have fixed the problem when downloading the pic, thnks for that, now i have discovered another problem, i didn't notice that because i was trying with only one pic, but now i added others,and it does not works good. It's about the watermark.php file... Lets suposse i want to view the pic 001.jpg, i open it and everything is normal. But if i want to see the next picture, or any other, and click in the thumbnail, the details.php page shows the same first pic (001.jpg), everything esle, like the name of the pic, the comments and the stats of the image are normal, even the size of the image is correct, but the pic itself is wrong. it seems the watermark.php file is not reloaded when seeing other pictures :cry: can you help me with this? please?
thanks u very much
-
what is that path to the "image" u see? (either look in the source, or right click on the image -> properties)
can I see it in action?
-
the path of the image is:
when seeing the first: watermark.php?repeat=1&image_id=1 and the sorce code is:
<img src="watermark.php?repeat=1&image_id=1" border="1" alt="001" width="361" height="540" />
and the second: watermark.php?repeat=1&image_id=2
<img src="watermark.php?repeat=1&image_id=2" border="1" alt="002" width="361" height="540" />
as u can c both codes are almost the same, so the problem is in the file watermark.php (the source code is the one you gave me before)... how can i solve this? thanks
-
the only explanation I have is that your browser some how caching the first image and use the cache for the second image...
anyway, can I see it in action?
-
wait on.... the problem is in the code i think, cuz i've notice something else, the pic shown is the same of the thumbnail shown as the random pic, so the problem must be in the source code of watermark.php... can you review it pleaze? thanks
if u find no mistake, i gill give the url i'm working on
-
that's it, that's the problem.
ok, in includes/functions.php find: "image_name" => $image_name,
Insert below: "image_id" => $image_id,
-
good! it is working well now. Thanks for all...
by the way, the download.php mod you gave me didnt work, but that's ok. I removed the download buttons
-
well its a long time since my last post on this topic, but there's always something that does not work fine. All's fine with the watermark mod you gave me, but the pic is not shown in the e-cards. I mean, if i try to send the pic as an ecard, the person i sent it to cannot see the pic in the card... why is that?
-
not showing as what? as a broken image or no image at all?
if its a broken image (red x) then what is the path to it in the page source?
-
well i think i should remove this lines from the watermark.php
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row)
{
die("No permission");
}
in that way it workks correctly..... id it good?
thanks
-
nice idea!
maybe its a little bit off topic but i think your pictures will suffer a certain loss of quality by watermarking them "on the fly".
the best workflow is:
1. open the picture in original size
2. reduce the size
3. watermark it
4. save it.
never save between step 2 and 3, close the picture and open it again.
So I think its a better idea to upload the unmarked AND the watermarked picture. Or to upload a picture a little bit bigger in size than the output and add an additional command "reduce size" before watermarking the picture.
-
maybe its a little bit off topic but i think your pictures will suffer a certain loss of quality by watermarking them "on the fly".
well i'm using this method and the watermarked pictures are as good as the original ones...
the best workflow is:
1. open the picture in original size
2. reduce the size
3. watermark it
4. save it.
never save between step 2 and 3, close the picture and open it again.
So I think its a better idea to upload the unmarked AND the watermarked picture. Or to upload a picture a little bit bigger in size than the output and add an additional command "reduce size" before watermarking the picture.
could you explain it a bit better? i did not understand :lol:
greets 8)
-
ok no prob:
every time you save a jpeg-picture this results in a certain loss of quality.
so if you have to modify a picture NEVER:
save between the steps
close the picture
and open the partially modified picture again to go on with the modification.
for example: by saving the picture you get a quality loss of 10%
if you save the picture AFTER the complete workflow: 10%
if you save it, close it and reopen it DURING the workflow: 20%
the effect is similar when you use a graphic library.
edit: its no problem if you just save it during the workflow without closing and reopening, because the image is still in your memory
-
yep, perhaps you're right, but like i said, my pics don't lose their quality at all when watermarking them, and if it does, it can't be more than 1 or 2 % cuz they look just as the original ones... (no better, no worse)
Greets
-
thanks for this...
I use watermark on the fly for some time 8) and the process works well, why not to move him towards the Mods & Plugins (Publishing & Support) forum? :wink:
my question : :?: How may I prevent the direct access to the watermark.php file? (for the moment when you call : http://your.domain.net/4images/watermark.php?image_id=xxx :arrow: it shows 1 watermark pic)
i think about a line of code at the top of the watermark.php file to verifiy if the access is direct or from a file...
Regards.
-
thanks for this...
I use watermark on the fly for some time 8) and the process works well, why not to move him towards the Mods & Plugins (Publishing & Support) forum? :wink:
yeah... that would be great :lol:
How may I prevent the direct access to the watermark.php file? (for the moment when you call : http://your.domain.net/4images/watermark.php?image_id=xxx :arrow: it shows 1 watermark pic)
i think about a line of code at the top of the watermark.php file to verifiy if the access is direct or from a file...
I've been using sessions to solve this... here's the solution:
File page_header.php in includes folder:
Add this line somewhere at the beginning of the page_header.php file... I put it before $total_images = 0;
$_SESSION['_access_is_correct']="y";
As far as I could see, page_header.php is included in every page of the gallery, so what we do here is just registering a new session variable -> $_SESSION['_access_is_correct']... It doesn't mind the value you gave to it...
File watermark.php at the main root:
Well the final code would be like this:
watermark.php<?php
$nozip = 1;
$image_id = $_GET['image_id'];
define('ROOT_PATH', './');
define('GET_CACHES', 1);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
//here we check if our session variable is set...
//if it's not, the pic is not shown
if(!isset($_SESSION['_access_is_correct']))
{
die("You are not allowed to see this page");
}
else
{
//if the variable is set, it means the user is accessing
//the image correctly, then we show it.
//but before showing the pic, we unset our variable for security reasons
$_SESSION['_access_is_correct']="";
unset($_SESSION['_access_is_correct']);
$watermark = "water.png";
if (!$image_id)
{
die("Security violation");
}
$sql = "SELECT cat_id, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
$im = imagecreatefrompng($watermark);
$image = MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
if ($image_info = @getimagesize($image))
{
$image_create_handle = "imagecreatefrom".$types[$image_info[2]];
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
imagecopy($im2, $im, (imagesx($im2)/100)-(imagesx($im)/100), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/1);
for($n=1; $n<=$rest; $n++)
{
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))-(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))+(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
}
header("Content-Type: image/jpeg");
imagejpeg($im2);
imagedestroy($im);
imagedestroy($im2);
}
else
{
die("Error opening $image!");
$_SESSION['_access_is_correct']="";
unset($_SESSION['_access_is_correct']);
}
}
?>
Try it, and if you have any problems, post a new msg here
Best regards
-
@okram:
better yet store time() in that session so it can expired in, let say, 1 minute after any page was opened.
-
I really prefer unsetting the variable before showing the image...
If you set a life time for the session, 4example 1 minute, so the visitor will be able to access the watermark.php file during all that time... and what we're trying to prevent is the direct access to this file at anytime or anyway...
I think its much better if we unset our variable once we've checked that it exists and that the visitor is accessing the picture correctly...
Regards
-
Can anyone help?
I use this Modification , but when someone tries to directlink it onto another forum
you get a
Sorry, dynamic pages in the [IMG] tags are not allowed
Is there anyway to fix it so it would work?
thanks for anyhelp
-
I'm afraid you can't do nothing about that... If that other forum does not allow dynamic pages in its [IMG] tags, so whatever you do with your watermark.php code will not change that... watermark.php is a dynamic file, and that's why we use it to watermark serveral different pictures...
when someone tries to directlink it onto another forum
you get a
Sorry, dynamic pages in the [IMG] tags are not allowed
can i see that other forum you mentioned? can you post the url plz???
Best regards
-
well i think i should remove this lines from the watermark.php
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row)
{
die("No permission");
}
in that way it workks correctly..... id it good?
thanks
Rather than removing it, if you replace it
with :
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
show_error_page($lang['no_permission']);
} ###### End of if statement.
Will it work ? ;)
As for this line :
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
it could always be
replaced with :
$types = str_replace(",",", ",$config['allowed_mediatypes']);
;)
As for this one :
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
replace with :
if (!$im2 = @$image_create_handle($image)) {
show_error_page($lang['no_image_found']);
} ###### End of if statement.
;)
-
How may I prevent the direct access to the watermark.php file? (for the moment when you call : http://your.domain.net/4images/watermark.php?image_id=xxx :arrow: it shows 1 watermark pic)
i think about a line of code at the top of the watermark.php file to verifiy if the access is direct or from a file...
I was forgetting somethign in the mod i posted to solve that problem... In the page_footer.php file we need to add this line:
// This is necessary in case user did not see any picture in a page,
// and due to that, our session variable is still active and exists
if(isset($_SESSION['_access_is_correct']))
{
unset($_SESSION['_access_is_correct']);
}
Regards
-
I figured that was the case :?
this is the forum the gives me that error, http://www.inegma.net/mb/index.php?act=?
and another one i use just gives me a red x - http://www.impalasuperstore.com/naisso/Forum2005/
I dont use this script to watermark the pics on my site, I allow members to use the pictures on the forums by protecting the actuall image and giving them a link that uses the watermark script.
My only option might be to try to fgure out how to use .htaccess for leeched images to watermark the pictures. but as of yet, i havent been able to figure that out.
the image works on this forum though
(http://www.cusstom.com/gallery/img.php?get_image=./data/media/20/103-0301_IMG.jpg)
-
well i think i should remove this lines from the watermark.php
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row)
{
die("No permission");
}
in that way it workks correctly..... id it good?
thanks
Rather than removing it, if you replace it
with :
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
show_error_page($lang['no_permission']);
} ###### End of if statement.
Will it work ? ;)
As for this line :
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
it could always be
replaced with :
$types = str_replace(",",", ",$config['allowed_mediatypes']);
;)
As for this one :
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
replace with :
if (!$im2 = @$image_create_handle($image)) {
show_error_page($lang['no_image_found']);
} ###### End of if statement.
;)
well... what does exactly do the -> show_error_page() <- function?
-
well... what does exactly do the -> show_error_page() <- function?
It returns, in this case, the ' no permission ' page by keeping the site layout as it should. Otherwise, it will return a restricted message with a white page. ;)
-
If anyone is Interested this is the php file I use to add text to a image on the fly
<?php
//=========== change the text to display in the image
$text = 'YOURTEXT';
$imgfile= $_GET['get_image'];
$font = 'arial.ttf';
$ext=substr($imgfile,-3);
$ext=strtolower($ext);
if($ext=="jpg" || $ext=="jpe") $im=@imagecreatefromjpeg("$imgfile");
elseif ($ext=="gif") $im=@imagecreatefromgif("$imgfile");
else {print "Unknown image format"; exit;}
if (!$im) { /* See if it failed */
$im = ImageCreate (150, 30); /* Create a blank image */
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
ImageString($im, 1, 5, 5, "Error loading $imgfile", $tc);
return $im;
}
$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/40;
$fontsize=floor($fontsize);
if($fontsize<10) $fontsize=10;
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, $fontsize, 0, 12, $fontsize+8, $black, $font, $text);
imagettftext($im, $fontsize, 0, 10, $fontsize+6, $white, $font, $text);
if($ext=="gif")
{
header("Content-type: image/gif");
imageGIF($im);
}
else
{
header("Content-type: image/jpeg");
imagejpeg($im);
}
imagedetroy($im);
?>
-
Hum ... are these functions intended to be used as part of the execution of 4images ?
-
If anyone is Interested this is the php file I use to add text to a image on the fly
<?php
//=========== change the text to display in the image
$text = 'YOURTEXT';
$imgfile= $_GET['get_image'];
$font = 'arial.ttf';
$ext=substr($imgfile,-3);
$ext=strtolower($ext);
if($ext=="jpg" || $ext=="jpe") $im=@imagecreatefromjpeg("$imgfile");
elseif ($ext=="gif") $im=@imagecreatefromgif("$imgfile");
else {print "Unknown image format"; exit;}
if (!$im) { /* See if it failed */
$im = ImageCreate (150, 30); /* Create a blank image */
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
ImageString($im, 1, 5, 5, "Error loading $imgfile", $tc);
return $im;
}
$x=imagesx($im);
$y=imagesy($im);
$fontsize=$x/40;
$fontsize=floor($fontsize);
if($fontsize<10) $fontsize=10;
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, $fontsize, 0, 12, $fontsize+8, $black, $font, $text);
imagettftext($im, $fontsize, 0, 10, $fontsize+6, $white, $font, $text);
if($ext=="gif")
{
header("Content-type: image/gif");
imageGIF($im);
}
else
{
header("Content-type: image/jpeg");
imagejpeg($im);
}
imagedetroy($im);
?>
I used that for sometime, but i decided not to use a text watermark but a image watermark... As far as i know the imagettftext() function requires a special library (freefonttype :?: i do not remember the exact name) Once it didn't worked, so i started with an image watermark
Regards
-
Hum ... are these functions intended to be used as part of the execution of 4images ?
If your refering to me, I used this code in place of this mods watermark.php
-
Hum ... are these functions intended to be used as part of the execution of 4images ?
which functions do you mean?
-
As far as i know the imagettftext() function requires a special library (freefonttype Question i do not remember the exact name)
Correct. The name is GD Library which must be installed from the server end in order, for this MOD, to work properly. ;)
-
which functions do you mean?
Sorry, I meant codings - not functions. My bad. Are these codings intended to work under 4images ?
-
I used that for sometime, but i decided not to use a text watermark but a image watermark... As far as i know the imagettftext() function requires a special library (freefonttype :?: i do not remember the exact name) Once it didn't worked, so i started with an image watermark
Regards
Yea, I was just offering this as another option
-
Correct. The name is GD Library which must be installed from the server end in order, for this MOD, to work properly. ;)
No i didn't mean the gd library... that's for copying 1 image into another... for adding text to 1 image there's another library that muist be installed... let me find out more about this library and then i will make a new post here
-
Sorry, I meant codings - not functions. My bad. Are these codings intended to work under 4images ?
If you're refering to this watermark codes, yeah they are intended to work along with 4images... it's just a mod for it... i guess
Regards
-
let me find out more about this library and then i will make a new post here
This function requires both the GD library and the FreeType library....
yeah that's it... the name is freetype library...
Please read this article -> http://cheetahscripts.com/modules.php?name=PHP_Manual&page=function.imagettftext.html <- That's what i meant
Regards
-
Thanks for mentionning about the freetype module.
As for :
it's just a mod for it... i guess
Well ... actually, I don't mean to be rude but, even if the idea is great, it is a highly unsecured one as no sessions protection has been preset in that MOD. 8O
-
Well ... actually, I don't mean to be rude but, even if the idea is great, it is a highly unsecured one as no sessions protection has been preset in that MOD. 8O
I think there's no a strong reason to prevent the direct access to this file. At least in my case, it's not in my plans setting a complete high secure system for this page... all we want is prevent the direct access from standard users... i mean we don't expect all visitors know php programming or stuff like that.. as i said... all we want is prevent the directaccess to standard users, and those users represent the 95 % or more of our visitors... so i think no secure systems are required for this last mod, the one that sets a session variable...
Regards
-
ll we want is prevent the direct access from standard users
If it's the case, then I'd strongly advise you re-evaluate your codes again as no restrictions has been set-up in order to block anonymous visits on that MOD. ;)
so i think no secure systems are required for this last mod
It is up to you of course. Althought, I'd still recommend that you do so. ;)
-
no restrictions has been set-up in order to block anonymous visits on that MOD. ;)
Yes there have... in the watermark.php file we check the existance of the $_SESSION['_access_is_correct']-variable... if it hasn't been set... then we don not show the pic, but an error message... i chose the page_header.php file to set our variable, because this page is included in all the gallery php-files, just to mention: details.php, postcard.php, etc etc... BUT it is not included at all in the watermark file, so if the user type the url http://mysite.com/gallery/watermark.php?id=353 wont see any image as long as the variable does not exists... Standard users won't know of course how to create this variable manually... and in page_footer.php, which is also include in all pages, we unset the variable just in case it is set yet... i think it's enough with that
It is up to you of course. Althought, I'd still recommend that you do so. ;)
I stand by what i said before... i do not come to a reason for highly-prottecting this file...
The only thing i care in this mod is avoid users access to unmarked images...
Regards
-
$_SESSION['_access_is_correct']
You should really replace that
with :
$user_info['user_level'] != GUEST
instead. ;)
i think it's enough with that
Sure. Have a good one. 8)
-
Quote
$_SESSION['_access_is_correct']
You should really replace that
with :
Code:
$user_info['user_level'] != GUEST
instead.
I've done a general overview of the last 20 posts in this topic, and I've come to the conclussion that there's a misunderstanding with the direct-access-prevent stuff... when we say we want to prevent the direct access to the watermark php-file we are not talking about the user level... i mean guests, registered users or admins... I think you TheOracle understood all this like that.
When saying direct-access we are talking about accessing the WMark file by writting the url in the browser...
no restrictions has been set-up in order to block anonymous visits on that MOD.
I guess you mean unregistered users when you say {anonymous visits}... In fact, we dont care if the user is registered or not, logged in or not... I think that can be well configured from the 4images control panel... As i said, all we want to do is avoid direct accessing by typing the watermark.php URL in the browser...
That's why i check a session var instead of checking the user level...
$user_info['user_level'] != GUEST
The reason to prevent this direct access is just to avoid massive downloads of pics out of the details.php page, which is bound to show the images...
P.D. Sorry 4 my bad english :lol: ... in fact i'm a spanish speaker :?
-
My earlier posts was simply about suggested / recommended technics since you wish to use it under 4images. ;)
-
did u try add in jpg.html template:<img src="watermark.php?get_image={media_src}">
? (make sure watermark.php is located in 4images root directory.)
works like a charm, no problems , check on my site, click on pic at the bottom to see this script in action.
-
Hi,
Is it possible to use only one of this script ability to not show full patch to image? I'm talking about watermark.php?image_id=xxx, this works great for images but how to set it to show other files? It's no needed to add watermark, just image_id=xx instead of data/media/489/game_shooting.swf in the end of site url.
Thanks. :wink: :oops: 8O
-
Hi all!
First of all I want to thank the topicstarter and the people who gave help! So...Thanks! Because the main meaning of the Mod is working for me, but there is a problem:
The things I did:
- put the 'watermark.php' in the 4images root
- put a 'watermark.png' image in the 4images root
- added the line (<img src="watermark.php?get_image={media_src}">) in jpg.html
Everything is working BUT the uploaded photo is now posted 2 times, under eachother :S It looks like this -> http://www.relic-hunters.nl/gallery/details.php?image_id=3
How do I get rid of that?
Friendly regards,
Benjamin
P.S. Sorry for my bad English!
-
hi,
this mod is better
http://www.4homepages.de/forum/index.php?topic=13719.0
gruss ivan
Is it ? I can't even find Instalation Notes... Don't know how to install it if the docs aren't there... :oops:
-
Thank you very much! Got the wrong instalation files...because the info wasn't there... Downloaded it from another place.
It's working now! Thank you! :D
-
hmmm...I just got an idea about download thingie...
what if u rename in download.phpfunction get_file_data($file_path) {
to function get_file_data2($file_path) {
and above that line add this:function get_file_data($image)
{
$types = array(1 => "gif", 2 => "jpeg", 3 => "png");
if ($image_info = @getimagesize($image))
{
$image_create_handle = "imagecreatefrom".$types[$image_info[2]];
if (!$im2 = @$image_create_handle($image))
{
die("Error opening $image!");
}
imagecopy($im2, $im, (imagesx($im2)/100)-(imagesx($im)/100), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
if($_GET[repeat])
{
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/1);
for($n=1; $n<=$rest; $n++)
{
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))-(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/100)-(imagesx($im)/100))+(imagesx($im)*$n), (imagesy($im2)/100)-(imagesy($im)/100), 0, 0, imagesx($im), imagesy($im));
}
}
ob_start();
@ob_implicit_flush(0);
imagejpeg($im2);
$file_data = ob_get_contents();
ob_end_clean();
imagedestroy($im);
imagedestroy($im2);
return $file_data;
}
else
{
return get_file_data2($image);
}
}
:?:
I tried to do this, but I don't find the lines in the download.php. That's because I have 4images 1.7.6.
I have a mod that makes an annotation over a watermark.php file (a transparent PNG). Unfortenately I want the Watermark to appear on the downloaded image, too, but I don't want to brand the pictures with the annotation (because I want to use the original ones for another thing).
Can anybody help me