1
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




TopTop



Login

Who's Online

221 user(s) are online (129 user(s) are browsing Support Forums)


Members: 0


Guests: 221


more...

Donat-O-Meter

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

Latest GitHub Commits