Index: extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 4087)
+++ extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm	(revision 4088)
@@ -336,4 +336,5 @@
           preview_settings_panel
           advanced_settings_panel
+          watermark_settings_panel
           piwigo_properties
           exif_properties
@@ -343,4 +344,5 @@
           preview_settings
           advanced_settings
+          watermark_settings
           toolbar
           branding
@@ -720,4 +722,63 @@
     );
 
+    $self->watermark_settings(
+        [
+            {
+              label  => gettext("Activate watermark :"),
+              type   => 'Bool',
+              value  => sub { $self->imagelist->watermark_activate(@_) },
+            },
+            {
+              label => gettext("Activate watermark on high definition :"),
+              type  => 'Bool',
+              value => sub { $self->imagelist->watermark_activate_pwg_high(@_) },
+            },
+            {
+              label  => gettext("Text :"),
+              value  => sub { $self->imagelist->watermark_text(@_) },
+            },
+            {
+                label     => gettext("Text size :"),
+                type      => 'Number',
+                value   => sub { $self->imagelist->watermark_text_size(@_) },
+            },
+            {
+                label     => gettext("Color :"),
+                type      => 'Choice',
+                value   => sub { $self->imagelist->watermark_color(@_) },
+                choice  => [
+                                  gettext("White"),
+                                  gettext("Black"),
+                           ],
+            },            
+            {
+                label     => gettext("Position :"),
+                type      => 'Choice',
+                value   => sub { $self->imagelist->watermark_position(@_) },
+                choice  => [
+                                  gettext("Top"),
+                                  gettext("Top left"),
+                                  gettext("Top right"),
+                                  gettext("Bottom"),
+                                  gettext("Bottom left"),
+                                  gettext("Bottom right"),
+                                  gettext("Center"),
+                                  gettext("Left"),
+                                  gettext("Right"),
+                           ],
+            },
+            {
+                label     => gettext("Top margin :"),
+                type      => 'Number',
+                value   => sub { $self->imagelist->watermark_y(@_) },
+            },
+            {
+                label     => gettext("Left margin :"),
+                type      => 'Number',
+                value   => sub { $self->imagelist->watermark_x(@_) },
+            },            
+        ]
+    );
+
     $self->image_tags(
         sub { eval { $self->imagelist->current_image->site_tags(@_) } }
@@ -764,4 +825,5 @@
         $self->preview_settings_panel,
         $self->advanced_settings_panel,
+        $self->watermark_settings_panel,
     );
     
@@ -841,4 +903,7 @@
     );    
 
+    $self->watermark_settings_panel->properties(
+        $self->watermark_settings,
+    );	
 	
 }
@@ -924,4 +989,14 @@
         )    
     );    
+
+    $self->watermark_settings_panel(
+        Uploader::GUI::wxPropertyGridPanel->new(
+            {
+                parentwnd   => $self,
+                properties  => $self->watermark_settings,
+                frame_callbacks => [],
+            }
+        )
+    );
 
     $self->image_prop_tags(
@@ -1244,4 +1319,8 @@
             gettext("Advanced"),
         ],
+        [
+            $self->watermark_settings_panel,
+            gettext("Watermark"),
+        ]    
     ];
     
Index: extensions/pLoader/trunk/src/Uploader/ImageList.pm
===================================================================
--- extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 4087)
+++ extensions/pLoader/trunk/src/Uploader/ImageList.pm	(revision 4088)
@@ -32,5 +32,5 @@
 use Wx::Locale qw/:default/;
 use Wx;
-
+use Path::Class::Unicode;
 # this class implements a collection of image files with associated data
 $|=1;
@@ -93,4 +93,14 @@
                 imagelist_version
                 uploaded_images
+                watermark_activate
+                watermark_activate_pwg_high
+                watermark_text
+                watermark_text_size
+                watermark_position
+                watermark_y
+                watermark_x
+                watermark_color
+                gravity
+                rgbcolor
      /
 );
@@ -101,4 +111,24 @@
     
     $self->uploaded_images([]);
+    $self->gravity(
+        { 
+            gettext("Top") => 'North',
+            gettext("Left") => 'West',
+            gettext("Right") => 'East',
+            gettext("Bottom") => 'South',
+            gettext("Top left") => 'NorthWest',
+            gettext("Top right") => 'NorthEast',
+            gettext("Bottom left") => 'SouthWest',
+            gettext("Bottom right") => 'SouthEast',
+            gettext("Center") => 'Center',
+       }   
+    );    
+
+    $self->rgbcolor(
+        {
+            gettext("White") => '#FFFFFF',
+            gettext("Black") => '#000000',
+        }    
+    );
     
 }
@@ -642,5 +672,5 @@
         $resize_h = $resize_w_;
     }
-    
+    printf("resize with blur value %s\n", $self->blur);
     $status = $image->Resize(
         geometry => sprintf("%sx%s>", $resize_w, $resize_h), 
@@ -667,4 +697,5 @@
     }
 
+    printf("resize with quality value %s\n", $self->quality);
     $status = $image->Set(quality=>$self->quality);
     warn "$status" if $status ;
@@ -811,4 +842,12 @@
                 version
                 imagelist_version
+                watermark_activate
+                watermark_activate_pwg_high
+                watermark_text
+                watermark_text_size
+                watermark_position
+                watermark_y
+                watermark_x
+                watermark_color
             /
         ] 
@@ -916,4 +955,14 @@
                 'Horizontal (normal)',
             ) if $self->auto_rotate;
+
+            $self->CreateWatermark(
+               $self->watermark_text,
+               $self->watermark_text_size,
+               $self->watermark_position,
+               $self->watermark_x,
+               $self->watermark_y,
+               $self->watermark_color,
+               $self->current_image->site_resized_file
+           ) if $self->watermark_activate;
         }
         # the original is at the right size, no need to create a resize
@@ -1046,8 +1095,80 @@
     my ( $self ) = @_;
 
+    my $bModifyOriginal;
+    my $bRotate;
+    my $bAddWatermark;
     my $orientation = $self->current_image->exif_metadata->{Orientation};
     
     # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW
     if( $self->auto_rotate and $orientation =~ m/Rotate (\d+)/ ){
+        $bModifyOriginal = 1;
+        $bRotate = 1;
+    }
+
+    if( $self->watermark_activate_pwg_high ){
+        $bModifyOriginal = 1;
+        $bAddWatermark = 1;
+    }
+
+    if($bModifyOriginal){
+        $self-> _set_site_high_file ();
+
+        my $image = Image::Magick->new();
+        # we read original
+        my $status = $image->Read(
+            $self->current_image->file
+        );
+        warn "$status ", $self->current_image->file, "\n" if $status ;
+        return 0 if $status;
+
+        if($bRotate){
+            $image->Rotate( degrees=>$1 );	
+        }        
+        $image->Write(
+            filename=>encode('iso-8859-1', $self->current_image->site_high_file)
+        );
+        warn "$status ", $self->current_image->site_high_file, "\n" if $status ;
+        return 0 if $status;
+        
+        undef $image;
+
+        if($bAddWatermark){
+          my $file_out = $self->current_image->site_high_file;
+          $self->CreateWatermark(
+             $self->watermark_text,
+                $self->watermark_text_size,
+                $self->watermark_position,
+                $self->watermark_x,
+                $self->watermark_y,
+                $self->watermark_color,
+                $file_out
+            );
+        }
+
+
+        $self->_set_exif_tag(
+            $self->current_image->site_high_file,
+            'Orientation',
+            'Horizontal (normal)',
+        );
+
+        # Now all images that need to be rotated are done. Update exif
+        $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)';
+
+
+    }
+    else{
+        # high file is the original file
+        $self->current_image->site_high_file(
+            $self->current_image->file
+        );
+    }
+
+    return 1;
+}
+
+# file name for original copy
+sub _set_site_high_file {
+        my ( $self ) = @_;
 
         my ( $vol, $dir, $file ) = File::Spec->splitpath(
@@ -1068,40 +1189,44 @@
             )
         );
-
-        my $image = Image::Magick->new();
-        # we read original
-        my $status = $image->Read(
-            $self->current_image->file
-        );
-        warn "$status ", $self->current_image->file, "\n" if $status ;
-        return 0 if $status;
-
-        $image->Rotate( degrees=>$1 );	
-        
-        $image->Write(
-            filename=>encode('iso-8859-1', $self->current_image->site_high_file)
-        );
-        warn "$status ", $self->current_image->site_high_file, "\n" if $status ;
-        return 0 if $status;
-        
-        undef $image;
-
-        $self->_set_exif_tag(
-            $self->current_image->site_high_file,
-            'Orientation',
-            'Horizontal (normal)',
-        );
-
-        # Now all images that need to be rotated are done. Update exif
-        $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)';
-    }
-    else{
-        # high file is the original file
-        $self->current_image->site_high_file(
-            $self->current_image->file
-        );
-    }
-
-    return 1;
+}
+
+sub CreateWatermark {
+    my ( $self, $text, $text_size, $position, $x, $y, $color, $file_out ) = @_;
+    
+    my $rval = 1 ;
+    my $gravity = $self->gravity->{$position};
+    my $fill = $self->rgbcolor->{$color};
+
+    # debug
+    printf("Create watermark %s\n", $file_out);
+
+    
+
+    my $image = new Image::Magick;
+    
+    my $status = $image->ReadImage(
+        encode('iso-8859-1', $file_out)
+    );      
+printf("gravity %s, color %s, pointsize %s, x %s, y %s\n", $gravity, $fill, $text_size, $x, $y);    
+    my $ratio = $image->Get('height')/($self->resize_h||$image->Get('height'));
+    $ratio||=1;
+    $text ||="Your watermark";
+    $image->Annotate(
+#        font => 'Vera.ttf',
+        pointsize => $text_size*$ratio,
+        fill => $fill,
+        x => $x*$ratio,
+        y => $y*$ratio,
+        text => $text,
+        gravity => $gravity,
+    );
+                      
+    $image->Write(
+        sprintf(
+            "%s:%s",
+            $self->type,
+            encode('iso-8859-1', $file_out),
+        )
+    );
 }
 
