1
simeon
myalbum watermarking with gdlib
  • 2005/7/28 15:42

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


hi there

gijoe has posted a watermarkin hack for myalbum that is using imagemagick.

arround line 405 in inludes/function.php
// Do Modify and check success
    
if( $option != "" exec"{$myalbum_imagickpath}convert $option $src_path $dst_path) ;

    if( ! 
is_readable$dst_path ) ) {
        
// didn't exec convert, rename it.
        
@rename$src_path $dst_path ) ;
        
$ret ;
    } else {
        @
unlink$src_path ) ;
        
$ret ;
    }

    
// water mark
    
$wmfile dirnamedirname__FILE__ ) ) . '/images/watermark.gif' ;
    if( 
file_exists$wmfile ) ) {
        
exec"{$myalbum_imagickpath}composite -compose plus $wmfile $dst_path $dst_path) ;
    }

    return 
$ret ;
}


could someone be so kind to help make a watermark funktion for gdlib working with myalbum?
here you can find an example
http://www.macximal.de/index2.php?t=projekte&p=gdlib&ip=gd_wasserzeichen

i think many users waiting for a easy solution of watermaking images.

thanks in advanced
sime

2
simeon
Re: myalbum watermarking with gdlib
  • 2005/7/29 10:36

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


nobody interested?

3
edldp
Re: myalbum watermarking with gdlib
  • 2005/8/8 19:00

  • edldp

  • Just popping in

  • Posts: 1

  • Since: 2002/2/12


hello simeon

try this

Don't forget to force GD2 in myalbum preferences

In the file modules/myalbum/include/functions.php at line 350 you will find the following code which is the end of the fonction : function myalbum_modify_photo_by_gd( $src_path , $dst_path )

imagedestroy$src_img ) ;
    if( ! 
is_readable$dst_path ) ) {
        
// didn't exec convert, rename it.
        
@rename$src_path $dst_path ) ;
        return 
;
    } else {
        @
unlink$src_path ) ;
        return 
;
    }


replace it with the following code.

imagedestroy$src_img ) ;
    if( ! 
is_readable$dst_path ) ) {
        
// didn't exec convert, rename it.
        
@rename$src_path $dst_path ) ;
        [
color=FF0000]$ret ;[/color]
    } else {
        @
unlink$src_path ) ;
        [
color=FF0000]$ret ;[/color]
    }

    [
color=FF0000]$src imagecreatefrompng(XOOPS_ROOT_PATH."/modules/myalbum/images/watermark.png"); 
    
$dst imagecreatefromjpeg($dst_path);

    
$width_src imagesx($src); 
    
$height_src imagesy($src); 
    
$width_dst imagesx($dst); 
    
$height_dst imagesy($dst); 

    
$dst_x $width_dst $width_src
    
$dst_y $height_dst $height_src

    
imagecopymerge($dst$src$dst_x$dst_y00$width_src$height_src60); 
    
imagejpeg$dst $dst_path ) ;

    return 
$ret ;[/color]


Now all you have to do is a transparent png watermark which will be named watermark.png and located in modules/myalbum/images.

If you want the watermark to work also when you do a grouped upload then you must add some more code
in the file modules/myalbum/admin/batch.php you must add line 100 the following red code :
myalbum_create_thumb"$photos_dir/$lid.$ext$lid $ext ) ;
            
            [
color=CC0000]$src imagecreatefrompng(XOOPS_ROOT_PATH."/modules/myalbum/images/watermark.png"); 
            
$dst imagecreatefromjpeg("$photos_dir/$lid.$ext");

            
$width_src imagesx($src); 
            
$height_src imagesy($src); 
            
$width_dst imagesx($dst); 
            
$height_dst imagesy($dst); 

            
$dst_x $width_dst $width_src
            
$dst_y $height_dst $height_src

            
imagecopymerge($dst$src$dst_x$dst_y00$width_src$height_src60); 
            
imagejpeg$dst "$photos_dir/$lid.$ext) ;[/color]
    
            
$xoopsDB->query"INSERT INTO $table_text SET lid='$lid', description='$desc4save'" ) ;


The problem with this last code is that it doesn't respect the class system of the module so if you try to use another library than GD2, you could then have some problems if you don't remove this code first.
Edldp

Login

Who's Online

144 user(s) are online (109 user(s) are browsing Support Forums)


Members: 0


Guests: 144


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits