Changeset 4088 for extensions/pLoader/trunk
- Timestamp:
- Oct 22, 2009, 8:26:46 PM (15 years ago)
- Location:
- extensions/pLoader/trunk/src/Uploader
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
r4086 r4088 336 336 preview_settings_panel 337 337 advanced_settings_panel 338 watermark_settings_panel 338 339 piwigo_properties 339 340 exif_properties … … 343 344 preview_settings 344 345 advanced_settings 346 watermark_settings 345 347 toolbar 346 348 branding … … 720 722 ); 721 723 724 $self->watermark_settings( 725 [ 726 { 727 label => gettext("Activate watermark :"), 728 type => 'Bool', 729 value => sub { $self->imagelist->watermark_activate(@_) }, 730 }, 731 { 732 label => gettext("Activate watermark on high definition :"), 733 type => 'Bool', 734 value => sub { $self->imagelist->watermark_activate_pwg_high(@_) }, 735 }, 736 { 737 label => gettext("Text :"), 738 value => sub { $self->imagelist->watermark_text(@_) }, 739 }, 740 { 741 label => gettext("Text size :"), 742 type => 'Number', 743 value => sub { $self->imagelist->watermark_text_size(@_) }, 744 }, 745 { 746 label => gettext("Color :"), 747 type => 'Choice', 748 value => sub { $self->imagelist->watermark_color(@_) }, 749 choice => [ 750 gettext("White"), 751 gettext("Black"), 752 ], 753 }, 754 { 755 label => gettext("Position :"), 756 type => 'Choice', 757 value => sub { $self->imagelist->watermark_position(@_) }, 758 choice => [ 759 gettext("Top"), 760 gettext("Top left"), 761 gettext("Top right"), 762 gettext("Bottom"), 763 gettext("Bottom left"), 764 gettext("Bottom right"), 765 gettext("Center"), 766 gettext("Left"), 767 gettext("Right"), 768 ], 769 }, 770 { 771 label => gettext("Top margin :"), 772 type => 'Number', 773 value => sub { $self->imagelist->watermark_y(@_) }, 774 }, 775 { 776 label => gettext("Left margin :"), 777 type => 'Number', 778 value => sub { $self->imagelist->watermark_x(@_) }, 779 }, 780 ] 781 ); 782 722 783 $self->image_tags( 723 784 sub { eval { $self->imagelist->current_image->site_tags(@_) } } … … 764 825 $self->preview_settings_panel, 765 826 $self->advanced_settings_panel, 827 $self->watermark_settings_panel, 766 828 ); 767 829 … … 841 903 ); 842 904 905 $self->watermark_settings_panel->properties( 906 $self->watermark_settings, 907 ); 843 908 844 909 } … … 924 989 ) 925 990 ); 991 992 $self->watermark_settings_panel( 993 Uploader::GUI::wxPropertyGridPanel->new( 994 { 995 parentwnd => $self, 996 properties => $self->watermark_settings, 997 frame_callbacks => [], 998 } 999 ) 1000 ); 926 1001 927 1002 $self->image_prop_tags( … … 1244 1319 gettext("Advanced"), 1245 1320 ], 1321 [ 1322 $self->watermark_settings_panel, 1323 gettext("Watermark"), 1324 ] 1246 1325 ]; 1247 1326 -
extensions/pLoader/trunk/src/Uploader/ImageList.pm
r4086 r4088 32 32 use Wx::Locale qw/:default/; 33 33 use Wx; 34 34 use Path::Class::Unicode; 35 35 # this class implements a collection of image files with associated data 36 36 $|=1; … … 93 93 imagelist_version 94 94 uploaded_images 95 watermark_activate 96 watermark_activate_pwg_high 97 watermark_text 98 watermark_text_size 99 watermark_position 100 watermark_y 101 watermark_x 102 watermark_color 103 gravity 104 rgbcolor 95 105 / 96 106 ); … … 101 111 102 112 $self->uploaded_images([]); 113 $self->gravity( 114 { 115 gettext("Top") => 'North', 116 gettext("Left") => 'West', 117 gettext("Right") => 'East', 118 gettext("Bottom") => 'South', 119 gettext("Top left") => 'NorthWest', 120 gettext("Top right") => 'NorthEast', 121 gettext("Bottom left") => 'SouthWest', 122 gettext("Bottom right") => 'SouthEast', 123 gettext("Center") => 'Center', 124 } 125 ); 126 127 $self->rgbcolor( 128 { 129 gettext("White") => '#FFFFFF', 130 gettext("Black") => '#000000', 131 } 132 ); 103 133 104 134 } … … 642 672 $resize_h = $resize_w_; 643 673 } 644 674 printf("resize with blur value %s\n", $self->blur); 645 675 $status = $image->Resize( 646 676 geometry => sprintf("%sx%s>", $resize_w, $resize_h), … … 667 697 } 668 698 699 printf("resize with quality value %s\n", $self->quality); 669 700 $status = $image->Set(quality=>$self->quality); 670 701 warn "$status" if $status ; … … 811 842 version 812 843 imagelist_version 844 watermark_activate 845 watermark_activate_pwg_high 846 watermark_text 847 watermark_text_size 848 watermark_position 849 watermark_y 850 watermark_x 851 watermark_color 813 852 / 814 853 ] … … 916 955 'Horizontal (normal)', 917 956 ) if $self->auto_rotate; 957 958 $self->CreateWatermark( 959 $self->watermark_text, 960 $self->watermark_text_size, 961 $self->watermark_position, 962 $self->watermark_x, 963 $self->watermark_y, 964 $self->watermark_color, 965 $self->current_image->site_resized_file 966 ) if $self->watermark_activate; 918 967 } 919 968 # the original is at the right size, no need to create a resize … … 1046 1095 my ( $self ) = @_; 1047 1096 1097 my $bModifyOriginal; 1098 my $bRotate; 1099 my $bAddWatermark; 1048 1100 my $orientation = $self->current_image->exif_metadata->{Orientation}; 1049 1101 1050 1102 # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW 1051 1103 if( $self->auto_rotate and $orientation =~ m/Rotate (\d+)/ ){ 1104 $bModifyOriginal = 1; 1105 $bRotate = 1; 1106 } 1107 1108 if( $self->watermark_activate_pwg_high ){ 1109 $bModifyOriginal = 1; 1110 $bAddWatermark = 1; 1111 } 1112 1113 if($bModifyOriginal){ 1114 $self-> _set_site_high_file (); 1115 1116 my $image = Image::Magick->new(); 1117 # we read original 1118 my $status = $image->Read( 1119 $self->current_image->file 1120 ); 1121 warn "$status ", $self->current_image->file, "\n" if $status ; 1122 return 0 if $status; 1123 1124 if($bRotate){ 1125 $image->Rotate( degrees=>$1 ); 1126 } 1127 $image->Write( 1128 filename=>encode('iso-8859-1', $self->current_image->site_high_file) 1129 ); 1130 warn "$status ", $self->current_image->site_high_file, "\n" if $status ; 1131 return 0 if $status; 1132 1133 undef $image; 1134 1135 if($bAddWatermark){ 1136 my $file_out = $self->current_image->site_high_file; 1137 $self->CreateWatermark( 1138 $self->watermark_text, 1139 $self->watermark_text_size, 1140 $self->watermark_position, 1141 $self->watermark_x, 1142 $self->watermark_y, 1143 $self->watermark_color, 1144 $file_out 1145 ); 1146 } 1147 1148 1149 $self->_set_exif_tag( 1150 $self->current_image->site_high_file, 1151 'Orientation', 1152 'Horizontal (normal)', 1153 ); 1154 1155 # Now all images that need to be rotated are done. Update exif 1156 $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)'; 1157 1158 1159 } 1160 else{ 1161 # high file is the original file 1162 $self->current_image->site_high_file( 1163 $self->current_image->file 1164 ); 1165 } 1166 1167 return 1; 1168 } 1169 1170 # file name for original copy 1171 sub _set_site_high_file { 1172 my ( $self ) = @_; 1052 1173 1053 1174 my ( $vol, $dir, $file ) = File::Spec->splitpath( … … 1068 1189 ) 1069 1190 ); 1070 1071 my $image = Image::Magick->new(); 1072 # we read original 1073 my $status = $image->Read( 1074 $self->current_image->file 1075 ); 1076 warn "$status ", $self->current_image->file, "\n" if $status ; 1077 return 0 if $status; 1078 1079 $image->Rotate( degrees=>$1 ); 1080 1081 $image->Write( 1082 filename=>encode('iso-8859-1', $self->current_image->site_high_file) 1083 ); 1084 warn "$status ", $self->current_image->site_high_file, "\n" if $status ; 1085 return 0 if $status; 1086 1087 undef $image; 1088 1089 $self->_set_exif_tag( 1090 $self->current_image->site_high_file, 1091 'Orientation', 1092 'Horizontal (normal)', 1093 ); 1094 1095 # Now all images that need to be rotated are done. Update exif 1096 $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)'; 1097 } 1098 else{ 1099 # high file is the original file 1100 $self->current_image->site_high_file( 1101 $self->current_image->file 1102 ); 1103 } 1104 1105 return 1; 1191 } 1192 1193 sub CreateWatermark { 1194 my ( $self, $text, $text_size, $position, $x, $y, $color, $file_out ) = @_; 1195 1196 my $rval = 1 ; 1197 my $gravity = $self->gravity->{$position}; 1198 my $fill = $self->rgbcolor->{$color}; 1199 1200 # debug 1201 printf("Create watermark %s\n", $file_out); 1202 1203 1204 1205 my $image = new Image::Magick; 1206 1207 my $status = $image->ReadImage( 1208 encode('iso-8859-1', $file_out) 1209 ); 1210 printf("gravity %s, color %s, pointsize %s, x %s, y %s\n", $gravity, $fill, $text_size, $x, $y); 1211 my $ratio = $image->Get('height')/($self->resize_h||$image->Get('height')); 1212 $ratio||=1; 1213 $text ||="Your watermark"; 1214 $image->Annotate( 1215 # font => 'Vera.ttf', 1216 pointsize => $text_size*$ratio, 1217 fill => $fill, 1218 x => $x*$ratio, 1219 y => $y*$ratio, 1220 text => $text, 1221 gravity => $gravity, 1222 ); 1223 1224 $image->Write( 1225 sprintf( 1226 "%s:%s", 1227 $self->type, 1228 encode('iso-8859-1', $file_out), 1229 ) 1230 ); 1106 1231 } 1107 1232
Note: See TracChangeset
for help on using the changeset viewer.