View Full Version : Watermark Attached Images
filburt1
05-31-2003, 10:00 PM
This hack adds a watermark to attached images. The watermark, as specified by your own .png image, is added on image download, not when the image is attached. Requires GD2. Do not even try installing if you don't have GD2.
filburt1
06-01-2003, 05:59 PM
A watermarked image (image and watermark shrunk in Photoshop):
This could be useful to prevent people from using my site as a sig host....
Little child: How many licks does it take to get to the center of the install Button?
Old Owl: One, Two, *crunch*, Three.
Announcer: The world may never know......
/me licks the install button
DPoole
06-01-2003, 06:06 PM
any image added to any website is downloaded using right click so how will this work then ??
`Save Image as`
filburt1
06-01-2003, 06:07 PM
This processes the image sent to the browser in any situation. It'll always be there, and there isn't anything the user can do about it short of faking a file extension (AFAIK).
jdmuniverse
06-01-2003, 06:17 PM
Thanks alot!!! I am going to install right now!! You're the best :D
Pretty cool. I'll try it out. :)
jdmuniverse
06-01-2003, 06:31 PM
Hmmm... I cannot delete those 2 lines because they are not there... what should I do?
Here is my attachment.php I am using 229
FFArmageddon
06-01-2003, 06:34 PM
very nice :)
*clicks install
Mike11212
06-01-2003, 06:35 PM
question just to make sure I understand.
It doesn't add the watermark unless its downloaded?
or lets say if i have images enabled to view in threads would it show the watermark as well?
assassingod
06-01-2003, 06:37 PM
jdmuniverse, I can see you code fine,
it's under:
header("Last-Modified: " . gmdate("D, d M Y H:i:s",$attachmentinfo[dateline]) . "GMT");
And please keep from posting vB files.
jdmuniverse
06-01-2003, 06:40 PM
Oops, sorry bout that.... Is that the line I should delete?
Edit.. I see it now! Thanks!
assassingod
06-01-2003, 06:42 PM
No, the code you are looking for is under that line i posted.
Boofo
06-01-2003, 07:29 PM
Today at 01:59 PM filburt1 said this in Post #2 (https://vborg.vbsupport.ru/showthread.php?postid=402993#post402993)
A watermarked image (image and watermark shrunk in Photoshop):
filburt. I have to know...what kind of Widescreen TV is that? And how big is it?
filburt1
06-01-2003, 07:30 PM
It's not my picture...
Xenon
06-01-2003, 07:41 PM
nice hack turtle :)
LavaNoX
06-01-2003, 07:58 PM
He's actually Nibbler from Futurama now ;)
Xenon
06-01-2003, 08:15 PM
he'll always be our turtle :)
Chris M
06-01-2003, 08:33 PM
Nice nibbler, I mean filby;):p
Satan
Grrr... I have GD2 but still after installing this all my attatchments show up as little X's...
Could it be that my .png file wasn't the right type?
Magic Spark
06-01-2003, 09:03 PM
Thanks for this one, Filburt!
Great! ;)
Velocd
06-01-2003, 09:47 PM
Awesome job filb! This should help with preventing people from hotlinking attachments (not that I think they can anyway, since .htaccess things I've applied).
Mike11212
06-01-2003, 11:46 PM
can anyone tell me if this shows the watermark on every image or only when the image is hotlinked
WEForums
06-02-2003, 12:18 AM
To my understanding, everytime the image is downloaded (viewed), you will get a watermark picture.I think (but don't quote me) it works for hotlinking as well as yoursite.
Anyway, how do you know if GD2 is enabled? Is there an easy way to find out? (I don't really know all the server details, I don't own the site/forum or anything.) Hopefully it's located somewhere on the site...
I found out by simply emailing my host and confirming it that way...
Email=good :)
Anyway, speaking of that I am using 2.2.9 and the code in attatchment.php is very similar.. Is that the reason this doesn't work for me? Has anyone else tried this in 2.2.9? What should I do? This is one of the coolest ideas ever and I can't use it :(
jdmuniverse
06-02-2003, 12:49 AM
I'm having a small problem with gif files... the watermark shows all screwy :) On jpg it works like a charm though... Any ideas?
Heres a gif to see what I mean...
thanks again...
Austin Dea
06-02-2003, 01:16 AM
Nice seat ;)
jdmuniverse
06-02-2003, 01:17 AM
Not bad eh? LOL
filburt1
06-02-2003, 01:20 AM
GIF support in PHP is generally horrible. However, I have a solution (which I don't have time to implement but anyone with GD2 experience can):
1. Load the gif using imagecreatefromstring
2. Create a new image via imagecreatetruecolor of the same dimensions
3. Copy the entire gif onto the new image
4. Destroy the original gif
The problem is likely a palette issue.
Mike11212
06-02-2003, 02:18 AM
Today at 02:18 AM WEForums said this in Post #25 (https://vborg.vbsupport.ru/showthread.php?postid=403180#post403180)
To my understanding, everytime the image is downloaded (viewed), you will get a watermark picture.I think (but don't quote me) it works for hotlinking as well as yoursite.
Anyway, how do you know if GD2 is enabled? Is there an easy way to find out? (I don't really know all the server details, I don't own the site/forum or anything.) Hopefully it's located somewhere on the site...
If thats the case I can't use this hack :(
a lot of people upload wallpapers to my site and the watermark would damage them.
matthepepe
06-02-2003, 02:47 AM
has anyone got this working w/ 2.2.9, when i search for the stuff it says to find it cant find it. Ive found similar code but wheni replace those w/ the new it doenst work.
Erwin
06-02-2003, 04:14 AM
Very cool hack. :)
Yesterday at 10:47 PM matthepepe said this in Post #32 (https://vborg.vbsupport.ru/showthread.php?postid=403235#post403235)
has anyone got this working w/ 2.2.9, when i search for the stuff it says to find it cant find it. Ive found similar code but wheni replace those w/ the new it doenst work.
I'm having this same problem dude. :( Anyone know?
sabret00the
06-02-2003, 08:01 AM
this is a great hack filburt, thank you
Dean C
06-02-2003, 01:59 PM
An awesome idea filburt! :)
- miSt
Mickie D
06-02-2003, 02:03 PM
fantastic hack filbert and probably the easy'st hack i have ever installed
*Mickie clicks install
thanks again
Anyone have problems with this in 2.2.9??? I can't get it to work and I do have GD2....
matthepepe
06-02-2003, 07:39 PM
everyone thats posted so far w/ 2.2.9 is having a problem, im just getting red x's for my images when i install.
jdmuniverse
06-02-2003, 08:12 PM
I have 2.2.9 and it is working fine... I had the same problem finding the code... read the first page and they told me where the lines were.
Delete the 2 lines below this...
header("Last-Modified: " . gmdate("D, d M Y H:i:s",$attachmentinfo[dateline]) . "GMT");
The only problem I am having is with the gif files.... which I described on page 2.
matthepepe
06-03-2003, 12:34 AM
I did delete those 2 lines, and it still did not do me any good,
first i deleted
header("Content-disposition:$attachment filename=$attachmentinfo[filename]");
header("Content-Length: ".strlen($attachmentinfo[filedata]));
then i replaced,
if ($extension=="gif") {
header("Content-type: image/gif");
} elseif ($extension=="jpg" or $extension=="jpeg") {
header("Content-type: image/pjpeg");
} elseif ($extension=="png") {
header("Content-type: image/png");
} elseif ($extension=="pdf") {
header("Content-type: application/pdf");
} else {
header("Content-type: unknown/unknown");
}
echo $attachmentinfo[filedata];
with
$isimage = true;
switch ($extension)
{
case "gif":
$header = "image/gif";
break;
case "jpg":
case "jpeg":
$header = "image/jpeg";
break;
case "png":
$header = "image/png";
break;
case "pdf":
$header = "application/pdf";
$isimage = false;
break;
default:
$isimage = false;
$header = "unknown/unknown";
}
header("Content-disposition: inline; filename=" . $attachmentinfo['filename']);
header("Content-type: $header");
if ($isimage)
{
// watermark options:
$filename = "watermark.png"; // use a PNG-24 to preserve transparency!
$im = imagecreatefromstring($attachmentinfo['filedata']);
imagealphablending($im, true);
$watermark = imagecreatefrompng($filename);
$y = imagesy($im) - imagesy($watermark);
$w = imagesx($watermark);
$h = imagesy($watermark);
imagecopy($im, $watermark, 0, $y, 0, 0, $w, $h);
imagejpeg($im, "", 80);
}
else echo $attachmentinfo['filename'];
and i still get the red x's for images.
Yep, exactly. :( I'm going to try upgrading to 2.3.0 and see how it works then...
S.Shady
06-03-2003, 01:10 AM
works fine but none of my attachments of images fully gets uploaded it seams
Ok I just upgraded to 2.3.0 and still nothing. :(
(Yes I do have GD2 and I have it selected in the options..)
filburt1
06-03-2003, 07:27 PM
What exactly happens when you go to an attachment directly?
matthepepe
06-03-2003, 07:34 PM
you get a red x.
Courage
06-03-2003, 08:49 PM
I have attachments as files hack installed
Instead of
header("Content-disposition: inline; filename=$attachmentinfo[filename]");
header("Content-Length: ".strlen($attachmentinfo[filedata]));
I have:
header("Content-disposition: inline; filename=$attachmentinfo[filename]");
header("Content-Length: $filesize"); // attachments as files hack
I deleted header("Content-Length: $filesize"); , but I think that now i can add files without size limit checking ...
Ideeas ?
Yeah I now have 2.3.0 and I still have a red X. I contacted my host again to see if I really do have GD2.0+ and they said I do...
:(
Skyline_GT
06-04-2003, 07:08 AM
How come I have this line header("Content-disposition: inline; filename=$attachmentinfo[filename]"); instead of header("Content-disposition:$attachment filename=$attachmentinfo[filename]");
bitbender
06-04-2003, 03:10 PM
Where the heck does a fella FIND a good copy of gd2 for Red Splat ?? I want to use this hack, as well as watermark the pix outa the gallery (photopost), but I can't seem to locate a decent RPM for red splat 7.1 and 7.3.
Any Ideas any one ? All I can find wants tons of pre 6.2 rpm's installed as dependencies..
WEForums
06-04-2003, 03:44 PM
I installed it out of curiosity, and this is what I get:
<br />
<b>Fatal error</b>: Call to undefined function: imagecreatefromstring() in <b>/home2/wef/public_html/forums/attachment.php</b> on line <b>89</b><br />
Does this, by chance, mean there is no GD2? Still haven't contacted the hosts... :oops:
Well I got a similar error and I contacted my host again and they said "Oh wait, we don't have GD2... we have GD 1.6 or something.." lol
*sigh* Anyway they are going to upgrade to GD2 and I should be fine then.
Try contacting them. You have nothing to loose by doing so..
WEForums
06-04-2003, 04:26 PM
Today at 06:15 PM 006 said this in Post #52 (https://vborg.vbsupport.ru/showthread.php?postid=404363#post404363)
Try contacting them. You have nothing to loose by doing so.. Yeah, just got to wait for the owner to get online. He doesn't deal with the forums (I do, obviously) and they are on a separate forum than the site...so got to wait for him to get on.
Doubt we have it since I got that error.
wooolF[RM]
06-05-2003, 02:41 PM
]same here... jog works fine... gif = red cross :(
otherwise nice idea :classic:
gmarik
06-09-2003, 04:55 PM
Soungs great. You're a real coder.
If a user attatches a copyrighted image, and my custom watermark is added to it, is this bad? Just wondering because this is an issue that could come up..
:ermm:
Intex
07-11-2003, 11:35 AM
Filburt1 - any way this could be adopted to work with Imagemagick?
Highlander
07-15-2003, 07:42 AM
and GD 1,6 or 1,8 is not working?
Brandon
07-19-2003, 03:54 AM
06-01-03 at 07:20 PM filburt1 said this in Post #30 (https://vborg.vbsupport.ru/showthread.php?postid=403217#post403217)
GIF support in PHP is generally horrible. However, I have a solution (which I don't have time to implement but anyone with GD2 experience can):
1. Load the gif using imagecreatefromstring
2. Create a new image via imagecreatetruecolor of the same dimensions
3. Copy the entire gif onto the new image
4. Destroy the original gif
The problem is likely a palette issue.
I know this thread is ungodly old, but I have a question:
How would I go about doing this? I am having the same problem, if someone could explain or give a code for me to add it would be great, I dont have any GD experience :surprised: :cry: Thanks! :)
Brandon
07-20-2003, 06:41 AM
*bump* can anyone help? :D
Brandon
07-20-2003, 06:42 AM
*bump* can anyone help? :D
sabret00the
08-02-2003, 06:28 PM
is there any way to get this so that the watermark scales with the size of the image?
system8
09-04-2003, 09:46 AM
I have install it on 2.2.8 Ad it's Work Fine with images
But i find onther proplem is the all other files is broken
when i download and other file like zip or txt it will download it
but i cant open it it's like correbted i open the txt file that i have download it i find inside just the ame of the file test.txt
jdmuniverse
09-05-2003, 07:40 AM
Yesterday at 06:46 AM system8 said this in Post #63 (https://vborg.vbsupport.ru/showthread.php?postid=431258#post431258)
I have install it on 2.2.8 Ad it's Work Fine with images
But i find onther proplem is the all other files is broken
when i download and other file like zip or txt it will download it
but i cant open it it's like correbted i open the txt file that i have download it i find inside just the ame of the file test.txt
Ah ha! So that's why my other files do that! I was trying to figure out what hack did it and I guess this is it... anyone have a fix for this??
TIA
PAINTBALLM
10-10-2003, 10:26 AM
Ok my stats page verifys that I have GD2, however, when I install this hack, images show up with a red X.
Hi Paintballm,
I will guess that you have saved the image as CMYK and it need to be RGB! Or your location is incorrect.
Let me know if this helps!
Rampag33
10-25-2003, 06:11 AM
Ok my stats page verifys that I have GD2, however, when I install this hack, images show up with a red X.
Proably means that you have the watermark image in the wrong location.
PAINTBALLM
11-03-2003, 03:22 AM
will this hack be upgraded to vb3?
Installed great and working, I do have a question though, I can't figure out how to make the watermark appear on the bottom right instead of left. Could you offer a bit of code for this? Thanks again for the hack.
*UPDATE* - Was having trouble with other files like PDF's not getting the right header info. I rewrote a few things and it works like I wanted, but I am not having a problem with GD or VB sending the watermark image as code and than refresh and it is an image again, back and forth. So uninstalling for now until I can work this out. 2.3.0 GD2 php 4.3.3
Rampag33
11-13-2003, 10:55 PM
Great hacc, installed!
alkatraz
11-22-2003, 06:19 PM
awesome hack! working on vb2.28
kuska
12-05-2003, 09:25 AM
2.3.0 here.
Nice hack but a problem.
It corrupts every ZIP, MP3, TXT, BMP file thats uploaded.
Any ideas how to fix that?
Skyline_GT
01-02-2004, 05:36 AM
hm.. how much it is not working for gif files?
Skyline_GT
01-16-2004, 10:49 PM
THis hack does not support 2.3.0 and up..
Gary King
03-19-2004, 12:46 PM
THis hack does not support 2.3.0 and up..
100%? There have been no filechanges to attachment.php from 2.3.0 all the way to 2.3.4, I'm sure of that. I don't have an archived copy of 2.2.9 or before, though :(
juanchi
12-18-2004, 10:14 AM
could someone port this mod to vb 3.0.3, right now there is no working solution for vb 3.0.3, thanks to anyone that can help with this.
y2ksa
04-04-2005, 11:57 AM
ignore wrong forum sorry
sabret00the
06-05-2005, 03:22 PM
suprised this wasn't stock for vb3
croportal
12-01-2005, 12:26 AM
are this hack exist in 3.5 vbulletin version
croportal
12-12-2005, 10:17 AM
anonye know 3.5 version
croportal
12-24-2005, 08:58 AM
how can add this in 3.5.0 version
Marco van Herwaarden
12-24-2005, 09:24 AM
vB2.x modifications will not work on vB3.5
croportal
12-24-2005, 09:32 AM
i am desperatly looking this hack for 3.5.0
ConqSoft
12-24-2005, 11:25 AM
Yeah, I'd like to see this for 3.5.x also.
croportal
12-24-2005, 11:26 AM
its bvery important to me
PowerStroke
12-29-2005, 07:10 PM
I too am interested in a 3.5.2 version.
shadyninja
07-23-2006, 04:40 PM
i think there is one now
Red Spider
02-18-2007, 04:52 PM
Can someone port this to 3.6.4 P L E A S E !
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.