Hey.
Jeg har den her kode, som jeg har benyttet i noget tid, men, skal have en kode inden over.
Mit problem ligger på at jeg husker INTET af gdLIB, så jeg skal virkelig bruge hjælp til den her..
Min kode er:
<?php
function imagewlogin($id, $size, $login){
if($login!="false"){
$filename = "http://mydomain.com/". $id;
}
// Set a maximum height and width
if(!is_numeric($size)){
$width = 250;
$height = 250;
} else {
$width = $size;
$height = $size;
}
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
$width = $height*$ratio_orig;
} else {
$height = $width/$ratio_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, null, 100);
return true;
}
imagewlogin($_GET['picid'], $_GET['size'], $_SESSION['login']);
?>
Og skal have den her kode ind i systemet:
<?
$basedir=”/somedir/”;
$watermarkimage=”tbwm.png”;
$file=basename($_GET['i']);
$image = $basedir.””.$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;
}
imagefilledrectangle($im2, 0 , (imagesy($im2))-(imagesy($im)) , imagesx($im2) , imagesy($im2) , imagecolorallocatealpha($im2, 0, 0, 0, 100) );
imagecopy($im2, $im, (imagesx($im2)-(imagesx($im))), (imagesy($im2))-(imagesy($im)), 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);
?>
Indlæg senest redigeret d. 22.11.2009 07:35 af Bruger #6586