Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Watermark 1.3  (Read 3339 times)

0 Members and 1 Guest are viewing this topic.

zpeek

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Watermark 1.3
« on: December 07, 2004, 04:15:40 am »

Ok Now i got some errors:

Warning: imagesx(): supplied argument is not a valid Image resource in /home/m/public_html/photos/logo.php on line 50

Warning: imagesy(): supplied argument is not a valid Image resource in /home/m/public_html/photos/logo.php on line 51



Code: [Select]
<?
// SCHIPT BY DJ AXION
// e-mail: DJ@the-expansion.com
// Enjoy this script!
// Altered by Aemege almonare[at]ing[dot]uchile[dot]cl

// Need GD && PHP >= 4.3.0


$logo="../relative/paht/to/watermark.ext";


$datos[foto][tipo]=exif_imagetype($picturename);
$datos[logo][tipo]=exif_imagetype($logo);
$datos[foto][MimeType]=mimetype($datos[foto][tipo]);
if (function_exists("imagegif")) {
 $gi["GIF Read Support"] = 1;
}elseif (function_exists("imagejpeg")) {
 $gi["JPG Support"] = 1;
}elseif (function_exists("imagepng")) {
 $gi["PNG Support"] = 1;
}

// Try to dicide
if ($datos[foto][tipo]) {
  switch ($datos[foto][tipo]) {
     case '2' :
        if ($gi["JPG Support"]){
           $b = imagecreatefromjpeg($picturename);
        } else {
           $image = $picturename;
        }
     break;
     case '1' :
        if ($gi["GIF Read Support"]) {
           $b = imagecreatefromgif($picturename);
        } else {
           $image = $picturename;
        }
     break;
     case '3' :
        if ($gi["PNG Support"]){
           $b = imagecreatefrompng($picturename);
        } else {
           $image = $picturename;
        }
     break;
  }
}
     $bx = ImageSX($b);
     $by = ImageSY($b);

if(!empty($b)) {
  $lm = $b;

  if ($bx > 200)  {  // this ensures no watermark is added to small images (e.g. thumbnails)
  // ADD WATERMARK
     $pos = "bottomleft"; //where is the watermark displayed...

// Try to dicide the Logo Vemos que tipo de archivo es el logo
if ($datos[logo][tipo]) {
  switch ($datos[logo][tipo]) {
     case '1' :
 





$logoImage=imagecreatefromgif($logo);
     break;
     case '2' :





$logoImage=imagecreatefromjpeg($logo);
     break;



case '3' :



   



$logoImage=imagecreatefrompng($logo);
     break;
  }
}
  // THIS IS THE CODE FOR THE WATERMARK
     ImageAlphaBlending($lm, true) or die ("Could not alpha blend"); // Enable when on GD 2+
     $logoW = ImageSX($logoImage);
     $logoH = ImageSY($logoImage);
     if ($pos == "topleft") {
        $src_x = 0;
        $src_y = 0;
     } else if ($pos == "topright") {
        $src_x = $bx - $logoW;
        $src_y = 0;
     } else if ($pos == "bottomleft") {
        $src_x = 0;
        $src_y = $by - $logoH;
     } else if ($pos == "bottomright") {
        $src_x = $bx - $logoW;
        $src_y = $by - $logoH;
     }
     ImageCopy($lm,$logoImage,$src_x,$src_y,0,0,$logoW,$logoH);
  }
}

if ($datos[foto][MimeType] && !empty($b)) {
  Header("Content-type: $datos[foto][Mimetype]");
  switch ($datos[foto][tipo]) {
     case 1:
        ImageGif($lm);
     break;
     case 2:
        Imagejpeg($lm,'',60); //80 means JPEG quality
     break;
     case 3:
        ImagePnG($lm);
     break;
  }
imageDestroy($lm);
} else {
  // No usable GD image Function ? Ok preventing brocken Images and give back the untouched Image
  Header("Content-type: $datos[foto][MimeType]");
  $fp = fopen($image,"r");
  $fa = fread($fp,filesize ($image));
  print($fa);
  fclose($fp);
}
function mimetype($tipo){



switch($tipo){





case 1:







return "image/gif";





case 2:







return "image/jpeg";





case 3;







return "image/png";





default:







return "";



}
}
   
?>
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Watermark 1.3
« Reply #1 on: December 07, 2004, 05:13:22 am »

There are multiple watermark hacks. To which are you referring? It would be better if you post questions in the thread discussing the watermark.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Watermark 1.3
« Reply #2 on: December 07, 2004, 08:16:26 am »

To back up what TranzNDance said: the djaxion hack was made for cpg1.2.x afaik. You have to understand that modifications posted on the mods board are user contributions which are not integral part of coppermine, so there can be only limited support for mods.

Joachim
Logged

zpeek

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Watermark 1.3
« Reply #3 on: December 08, 2004, 08:28:30 pm »

TranzNDance : you sad that there are some hacks that do what i want?

I need a watermark hack that i can add to image and change later if need.
Logged

Nibbler

  • Guest
Re: Watermark 1.3
« Reply #4 on: December 08, 2004, 08:30:58 pm »

Search the mods board for them.

I dont think TranzNDance would be particularly sad if you found what you wanted though :)
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 15 queries.