Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Watermark script not work in php5
Old 11-21-2008, 04:45 PM Watermark script not work in php5
Junior Talker

Posts: 2
Trades: 0
Hi, first at all i want to say hello to all the forum people, this its my first topic here.

I have a big problem with a watermark script i use on my site, days ago i changed the host, and the new server has php5 instead php4,
the watermark script not longer works in php5,

File watermark.php

Quote:
<?php

################################################## ###
$basedir="/home/lalala/public_html";
$watermarkimage="watermark.png";

################################################## ###
# end user modifiable stuff...

$file=basename($_GET['i']);
$path=($_GET['p']);

$image = $basedir."/".$path."/".$file;
$watermark = $basedir."/".$watermarkimage;

$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)/2)-(imagesx($im)/2), (imagesy($im2)/2)-(imagesy($im)/2), 0, 0, imagesx($im), imagesy($im));

if($_GET[repeat]) {
$waterless = imagesx($im2) - imagesx($im);
$rest = ceil($waterless/imagesx($im)/2);

for($n=1; $n<=$rest; $n++) {
imagecopy($im2, $im, ((imagesx($im2)/2)-(imagesx($im)/2))-(imagesx($im)*$n), (imagesy($im2)/2)-(imagesy($im)/2), 0, 0, imagesx($im), imagesy($im));
imagecopy($im2, $im, ((imagesx($im2)/2)-(imagesx($im)/2))+(imagesx($im)*$n), (imagesy($im2)/2)-(imagesy($im)/2), 0, 0, imagesx($im), imagesy($im));
}
}

$last_modified = gmdate('D, d M Y H:i:s T', filemtime ($image));

header("Last-Modified: $last_modified");
header("Content-Type: image/jpeg");
imagejpeg($im2,NULL,95);
imagedestroy($im);
imagedestroy($im2);

?>
htaccesss code


Quote:
RewriteEngine on
RewriteBase /images
RewriteRule ^(img.*)/(.*\.[jJ].*)$ /home/lalala/public_html/wm.php?p=$1&i=$2
Any ideas about why this script not longer work?

Thanks in advance
best regards
JFPM
jfpm is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-21-2008, 04:55 PM Re: Watermark script not work in php5
Experienced Talker

Posts: 32
Trades: 0
Any error messages you are getting?
__________________

Please login or register to view this content. Registration is FREE
Professional PSD to XHTML coding services
tsiger is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 05:06 PM Re: Watermark script not work in php5
Junior Talker

Posts: 2
Trades: 0
Thanks for reply

Fatal error
: Call to undefined function imagecreatefrompng() in /home/lalala/public_html/watermark.php on line 19


jfpm is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 05:15 PM Re: Watermark script not work in php5
Experienced Talker

Posts: 32
Trades: 0
Hm.. is GD library installed? If you are not sure, create a php file with just the phpinfo() command. This will show you if GD library is installed or not. You can ask your host as well
__________________

Please login or register to view this content. Registration is FREE
Professional PSD to XHTML coding services
tsiger is offline
Reply With Quote
View Public Profile
 
Old 11-24-2008, 05:30 AM Re: Watermark script not work in php5
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
1. Not GD library but GD extension.
2. You should not use GD to manipulate images in php. Use imagemagick's command line utility named convert.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 11-24-2008, 10:54 AM Re: Watermark script not work in php5
Super Talker

Posts: 102
Trades: 0
Why not just use Photoshop and just set the "Ocipacy" to 10-50.
Aaron™ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Watermark script not work in php5
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23587 seconds with 12 queries