[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS Update: gleipnir
- To: cvs@lists.cleannorth.org
- Subject: CVS Update: gleipnir
- From: Dan Brosemer <odin@cleannorth.org>
- Date: Sun, 17 Aug 2008 11:48:44 -0401 (EDT)
- List-help: <mailto:cvs-request@lists.cleannorth.org?subject=help>
- List-post: <mailto:cvs@lists.cleannorth.org>
- List-subscribe: <mailto:cvs-request@lists.cleannorth.org?subject=subscribe>
- List-unsubscribe: <mailto:cvs-request@lists.cleannorth.org?subject=unsubscribe>
- Resent-date: Sun, 17 Aug 2008 11:48:48 -0401 (EDT)
- Resent-from: cvs@lists.cleannorth.org
- Resent-message-id: <aep5V.A.oGE.2hEqIB@skroob.cleannorth.org>
- Resent-sender: cvs-request@lists.cleannorth.org
Log Message: ----------- Watermarking based on http://sidster.org/code/gd/ Modified Files: -------------- gleipnir/public_html/gallery: upload.pl Revision Data ------------- Index: upload.pl =================================================================== RCS file: /cvs/gleipnir/public_html/gallery/upload.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -Lpublic_html/gallery/upload.pl -Lpublic_html/gallery/upload.pl -u -r1.7 -r1.8 --- public_html/gallery/upload.pl +++ public_html/gallery/upload.pl @@ -128,24 +128,6 @@ return $gleipnir->body($template->output); } - # Grab the image. - my $image_out = ($fmt eq 'png')?$image->png():$image->jpeg();; - - # Grab a SHA1 hash for later - my $hash = sha1_hex( $image_out ); - - # Write it out to a file - open( MYIMAGE, ">$storagedir/$id.$fmt" ) or $fail = 1; - if ( $fail > 0 ) - { - $message = " Could not write Image file: $! at $storagedir/$id.$fmt"; - $template->param(message => $message, failed => $fail ); - return $gleipnir->body($template->output); - } - binmode MYIMAGE; - print MYIMAGE $image_out; - close MYIMAGE; - # Find the appropriate dimensions for the thumbnail # Calculate aspect ratio my $thumbmaxsize = $gleipnir->cfetch('images' => 'thumbsize'); @@ -187,6 +169,49 @@ binmode MYTHUMBNAIL; print MYTHUMBNAIL $thumb_out; close MYTHUMBNAIL; + + # Watermark + if ($gleipnir->cfetch(images => 'watermark')) + { + my $percent = $gleipnir->cfetch(images => 'wmalpha'); + my $iw = GD::Image->new($gleipnir->cfetch(images => 'watermark')); + $iw->alphaBlending(0); + $percent /= 100.00; + for (my $h = 0; $h < $iw->height; ++$h) + { + for (my $x = 0; $x < $iw->width; ++$x) + { + my ($px, $alpha) = (); + $px = $iw->getPixel($x, $h); + $alpha = ($px >> 24) & 0xff; + if ($alpha == 127) { next; }; + $alpha += int((127 - $alpha) * $percent); + $alpha = 127 if ($alpha > 127); + $px = ($px & 0x00ffffff) | ($alpha << 24); + $iw->setPixel($x, $h, $px); + }; + }; + $iw->alphaBlending(1); + $image->copy($iw, $image->width-$iw->width-$gleipnir->cfetch(images=>'wmpad'), $image->height-$iw->height-$gleipnir->cfetch(images=>'wmpad'), 0, 0, $iw->width, $iw->height); + }; + + # Grab the image. + my $image_out = ($fmt eq 'png')?$image->png():$image->jpeg();; + + # Grab a SHA1 hash for later + my $hash = sha1_hex( $image_out ); + + # Write it out to a file + open( MYIMAGE, ">$storagedir/$id.$fmt" ) or $fail = 1; + if ( $fail > 0 ) + { + $message = " Could not write Image file: $! at $storagedir/$id.$fmt"; + $template->param(message => $message, failed => $fail ); + return $gleipnir->body($template->output); + } + binmode MYIMAGE; + print MYIMAGE $image_out; + close MYIMAGE; my $aSQL =<<EOT; insert into gallery_picture (pictureid, original_hash, uploader, gallery, thumb_path, original_path, image_path, caption, title ) values (?,?,?,?,?,?,?,?,?)
- Prev by Date: CVS Update: gleipnir
- Next by Date: CVS Update: svartalfheim.net
- Previous by thread: CVS Update: gleipnir
- Next by thread: CVS Update: gleipnir
- Index(es):