REGISTER


Edge Development
Login:
Password:
features:
SourceForge.net Logo
tarball
edge mods
buttons


Forums

Links

Post News

View Blogs

Active Users
Active users in the last 5 mins

Registered Users:5017

There are currently 0 registered users and 6 guests browsing the website.

Welcome our latest member: nqetofs


Backends
A news back-end to implement into your website is Articals/RSS or SMS news XML/RSS.
SMS News
Image watermark feature
@ :: code ::
Feb 28 2003, 04:20 (UTC+0)
From:
ElfQrin :

   This function adds a text into an image.

Supports JPGs and PNGs.
You need GD library to make it works (included in PHP since v4.3.0, but you have to enable it in php.ini)
You need a True Type (.TTF) font.
The hotspot feature is approximated.

Hot Spots:
1-2-3
4-5-6
7-8-9

0 = Free X/Y text coordinates.

Simple usage examples:

<IMG SRC="watermark.php?wmimg=image.jpg">
<IMG SRC="watermark.php?wmimg=image.jpg&wmtext=Hello%20World" BORDER=0 ALT="test image" TITLE="this is a test" ALIGN=LEFT>

Create a file called watermark.php with this content:

// watermark by Elf Qrin ( http://www.ElfQrin.com/ )
function watermark($img,$text="[date]",$datfmt="Y-m-d",$font="ARIAL.TTF",$font_size=12,$rgbtext="FFFFFF",$rgbtsdw="000000",$hotspot=8,$txp=0,$typ=0,$sxp=1,$syp=1) {

$suffx=substr($img,strlen($img)-4,4);
if (
$suffx==".jpg" || $suffx=="jpeg" || $suffx==".png") {
$text=str_replace("[date]",date($datfmt),$text);

if (
$suffx==".jpg" || $suffx=="jpeg") {
$image=imagecreatefromjpeg($img);
}
if (
$suffx==".png") {
$image=imagecreatefrompng($img);
}

$rgbtext=HexDec($rgbtext);
$txtr=floor($rgbtext/pow(256,2));
$txtg=floor(($rgbtext%pow(256,2))/pow(256,1));
$txtb=floor((($rgbtext%pow(256,2))%pow(256,1))/pow(256,0));

$rgbtsdw=HexDec($rgbtsdw);
$tsdr=floor($rgbtsdw/pow(256,2));
$tsdg=floor(($rgbtsdw%pow(256,2))/pow(256,1));
$tsdb=floor((($rgbtsdw%pow(256,2))%pow(256,1))/pow(256,0));

$coltext imagecolorallocate($image,$txtr,$txtg,$txtb);
$coltsdw imagecolorallocate($image,$tsdr,$tsdg,$tsdb);

if (
$hotspot!=0) {
$ix=imagesx($image); $iy=imagesy($image); $tsw=strlen($text)*$font_size/imagefontwidth($font)*3$tsh=$font_size/imagefontheight($font);
switch (
$hotspot) {
case 
1:
$txp=$txp$typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 
2:
$txp=floor(($ix-$tsw)/2); $typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 
3:
$txp=$ix-$tsw-$txp$typ=$tsh*$tsh+imagefontheight($font)*2+$typ;
break;
case 
4:
$txp=$txp$typ=floor(($iy-$tsh)/2);
break;
case 
5:
$txp=floor(($ix-$tsw)/2); $typ=floor(($iy-$tsh)/2);
break;
case 
6:
$txp=$ix-$tsw-$txp$typ=floor(($iy-$tsh)/2);
break;
case 
7:
$txp=$txp$typ=$iy-$tsh-$typ;
break;
case 
8:
$txp=floor(($ix-$tsw)/2); $typ=$iy-$tsh-$typ;
break;
case 
9:
$txp=$ix-$tsw-$txp$typ=$iy-$tsh-$typ;
break;
}
}

ImageTTFText($image,$font_size,0,$txp+$sxp,$typ+$syp,$coltsdw,$font,$text);
ImageTTFText($image,$font_size,0,$txp,$typ,$coltext,$font,$text);

if (
$suffx==".jpg" || $suffx=="jpeg") {
header("Content-type: image/jpg");
imagejpeg($image);
}
if (
$suffx==".png") {
header("Content-type: image/png");
imagepng($image);
}

imagedestroy($image);

}
}

if (isset(
$wmimg)) {
if (!isset(
$wmtext)) {$wmtext="[date]";}
if (!isset(
$wmdatfmt)) {$wmdatfmt="Y-m-d";}
if (!isset(
$wmfont)) {$wmfont="ARIAL.TTF";}
if (!isset(
$wmfont_size)) {$wmfont_size=12;}
if (!isset(
$wmrgbtext)) {$wmrgbtext="FFFFFF";}
if (!isset(
$wmrgbtsdw)) {$wmrgbtsdw="000000";}
if (!isset(
$wmhotspot)) {$wmhotspot=8;}
if (!isset(
$wmtxp)) {$wmtxp=0;}
if (!isset(
$wmtyp)) {$wmtyp=0;}
if (!isset(
$wmsxp)) {$wmsxp=1;}
if (!isset(
$wmsyp)) {$wmsyp=1;}

watermark($wmimg,$wmtext,$wmdatfmt,$wmfont,$wmfont_size,$wmrgbtext,$wmrgbtsdw,$wmhotspot,$wmtxp,$wmtyp,$wmsxp,$wmsyp);
}


Sample HTML page:

<HTML>
<
HEAD>
<
TITLE>Watermark test</TITLE>
</
HEAD>
<
BODY>

This is a watermarked picture:
<
P>
<
IMG SRC="watermark.php?wmimg=image.jpg&wmtext=TEST">
<
P>
END

</BODY>
</
HTML>

Read Comments (0)
Write Comments | Views: 2885

Events
<>
MonTueWedThuFriSatSun
1
2345678
9101112131415
16171819202122
23242526272829
3031

Add an event to the calendar
Today's events :
None

Select Skin
FAQ



pic of the week
Apr 07, 2006


brain.jpg /
click on the picture to enlarge and see description

Read comments (0)
Write comment
View the archive(86) :
General(76) / edgy pics(3) / geeky girlz(2) / other's stuff(5)

Submit your picture to the gallery
Random Picture
Aug 17, 2005

martin-323x264-261x172.jpg / :: Random ::
Random Quotes
"The only element in the Universe more plentiful than Hydrogen is stupidity."
Albert Einstein


Recent board posts
Subject Author Date
jabber xavier Nov / 12
Question nitestryker Jan / 01
multiple XSS vu... morbid Feb / 04
Files Missing maddlejg Dec / 25
Detailed log monfree Dec / 05


Recently replied posts
Subject Author Date
jabber Strokerace Nov/19
Question jrlj Feb/28
Detailed log nitestryker Jan/01
multiple XSS vu... morbid Feb/04
Files Missing Strokerace Dec/26

Select a Theme
Search the site


Select your language
Current Poll
a poll is useless here

 damn straight
 no
Total votes: 8
Read comments (0)
Write comment

Poll archive
Active news posters
based on the number of submissions for the last 30 days
User Number of news items posted
Recent blog entries
bwphotos Jul 14, 17:08
netboom Sep 19, 15:29
Luxilius Aug 30, 20:33
aastronoix Nov 15, 22:46
aastronoix Nov 15, 22:38

Complete members list


powered by

"Try not. Do or do not, there is no try..."

Valid XHTML 1.0 Transitional
Page loading took:0.765 seconds