Changeset 4747 for extensions/pLoader/trunk/src/Uploader/ImageList.pm
- Timestamp:
- Jan 26, 2010, 8:15:55 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/pLoader/trunk/src/Uploader/ImageList.pm
r4724 r4747 81 81 progressbar_refresh 82 82 progress_endinfo_refresh 83 RescaleCallback84 83 ResizeCallback 85 84 upload_rejects … … 159 158 160 159 sub _set_exif_tag { 161 my ( $self, $file, $tag, $newValue ) = @_; 160 my ( $self, $file, $tag, $newValue ) = @_; 162 161 163 162 my $options = {}; … … 195 194 196 195 $self->current_image->site_thumb_file( 197 File::Spec->catfile( 198 $self->site_thumb_dir, 199 $filename 196 sprintf("%s.%s", 197 File::Spec->catfile( 198 $self->site_thumb_dir, 199 'thumbnail' 200 ), 201 $self->type 200 202 ) 201 203 ); … … 205 207 206 208 sub SetCurrentImage { 207 my ( $self, $indx ) = @_; 209 my ( $self, $indx ) = @_; 208 210 209 211 $self->current_image( … … 226 228 227 229 map { 228 229 my $is_new_image = $self->_add_image($_, $info, $i);230 my $info = $self->_read_exif_metatdata($_->{ANSIPathName}); 231 my $is_new_image = $self->_add_image($_, $info, $i); 230 232 $self->SetCurrentImage($i); 231 233 $self->_set_current_image_filepaths(); 232 234 233 235 if($is_new_image){ 234 235 236 #my $use_wx_resize = $self->_create_gui_preview($info); 237 $self->_create_gui_thumbnail(); 236 238 237 239 # ok … … 284 286 # key is file path 285 287 sub _add_image { 286 my ( $self, $file, $info, $i ) = @_; 288 my ( $self, $file, $info, $i ) = @_; 287 289 288 290 my $is_new_image; … … 340 342 my $chrono = join('', $yyyy, $mm, $dd); 341 343 if('Prefix' eq $self->default_photo_name){ 342 344 $name = $self->default_name_prefix 343 345 } 344 346 elsif('File name' eq $self->default_photo_name){ 345 347 $name = $filename 346 348 } 347 349 elsif('File path and name' eq $self->default_photo_name){ … … 349 351 "%s", 350 352 File::Spec->catfile($path, $filename), 351 ) 352 } 353 ) 354 } 353 355 elsif('Prefix + rank number' eq $self->default_photo_name){ 354 356 $name = sprintf( … … 356 358 $self->default_name_prefix, 357 359 1+$i, 358 ) 359 } 360 ) 361 } 360 362 elsif('Rank number + prefix' eq $self->default_photo_name){ 361 363 $name = sprintf( … … 363 365 1+$i, 364 366 $self->default_name_prefix, 365 ) 366 } 367 ) 368 } 367 369 elsif('Prefix + create date chrono' eq $self->default_photo_name){ 368 370 $name = sprintf( … … 370 372 $self->default_name_prefix, 371 373 $chrono, 372 ) 373 } 374 ) 375 } 374 376 elsif('Create date chrono + prefix' eq $self->default_photo_name){ 375 377 $name = sprintf( … … 377 379 $chrono, 378 380 $self->default_name_prefix, 379 ) 381 ) 380 382 } 381 383 … … 388 390 389 391 eval { 390 printf("create gui thumbnail\n");391 # use the preview image to create a gui display thumbnail392 392 if(!$self->CreateGUIThumbnail()) 393 393 { 394 print "CreateGUIThumbnail failed, use callback\n";395 394 $self->ResizeCallback->( 396 395 $self->current_image->file, … … 401 400 $self->wx_quality, 402 401 ); 403 402 404 403 } 405 404 }; … … 440 439 splice @{$self->sums}, $index, 1 ; 441 440 $self->wx_thumb_imglist->Remove($index); 442 441 443 442 } 444 443 … … 447 446 my ( $self ) = @_; 448 447 449 # return 1 if( -e $self->current_image->wx_thumb_file );450 448 my $rval = 0; 451 print "CreateGUIThumbnail ", $self->current_image->wx_thumb_file, "\n";452 449 my $image = new Image::Magick; 453 450 … … 471 468 472 469 473 470 # maximize size and keep aspect ratio 474 471 $status = $image->Thumbnail( 475 472 geometry=>sprintf("%s%s>", $size*$size, '@') … … 493 490 gravity=>'center', 494 491 ); 495 492 496 493 $image->Set( 497 494 quality=>$self->wx_quality||90 … … 511 508 ); 512 509 513 $image->Rotate( degrees=>$1 ) if $self->auto_rotate; 510 $image->Rotate( degrees=>$1 ) if $self->auto_rotate; 514 511 } 515 512 … … 537 534 538 535 my $rval = 1 ; 539 #return $rval if( -e $self->current_image->site_resized_file ); 540 541 printf( 542 "Create resized %s\n", 543 $self->current_image->file, 544 ); 536 545 537 546 538 my $image = new Image::Magick; … … 586 578 ); 587 579 588 $image->Rotate( degrees=>$1 ) if $self->auto_rotate; 580 $image->Rotate( degrees=>$1 ) if $self->auto_rotate; 589 581 } 590 582 … … 671 663 return { 672 664 map { 673 665 $_ => $exif->{$_}, 674 666 } 675 667 qw/ … … 698 690 qw/ 699 691 images 700 692 thumb_size 701 693 preview_ratio 702 703 704 705 706 707 708 709 710 694 type 695 filter 696 blur 697 quality 698 wx_quality 699 th_quality 700 prefix 701 author 702 count 711 703 resize_w 712 704 resize_h 713 714 715 705 hd_filter 706 hd_blur 707 hd_quality 716 708 hd_w 717 709 hd_h 718 710 hd_interlace 719 711 new_files 720 712 storable_file 721 713 wx_thumb_size 722 714 current_image 723 715 exif_metadata … … 728 720 progress_msg 729 721 default_photo_name 730 731 732 733 734 735 736 737 738 739 722 default_name_prefix 723 upload_high 724 upload_hd 725 remove_uploaded_from_selection 726 auto_rotate 727 interlace 728 create_resized 729 use_exif_preview 730 image_sums 731 sums 740 732 version 741 733 imagelist_version … … 748 740 watermark_x 749 741 watermark_color 750 751 752 753 742 reupload_action_files 743 reupload_action_properties 744 reupload_action_properties_m 745 display_mode 754 746 / 755 747 ] … … 760 752 }; 761 753 if($@){ 762 print $@, "\n"; 754 print $@, "\n"; 763 755 } 764 756 } … … 767 759 768 760 sub UploadSelection { 769 my ( $self ) = @_; 761 my ( $self ) = @_; 770 762 771 763 my $viewer_callback = $self->UploadImagesViewerCallback ; … … 784 776 $self->upload_begin_time(time); 785 777 $self->upload_selection_count(scalar @{$self->image_selection}); 786 778 # for re-upload management 787 779 $self->upload_image_sums( [ 788 789 790 791 792 793 794 795 796 797 798 780 map { $self->GetImage($_)->file_sum } 781 @{$self->image_selection} 782 ] 783 ); 784 785 # check if already exist on server 786 my $uploaded = $self->pwg->IsAlreadyUploaded($self->upload_image_sums); 787 my @already_uploaded = grep { $_ } values %$uploaded ; 788 $self->ReuploadCallback->() if ( scalar @already_uploaded and !$self->reupload_not_ask ); 789 790 799 791 foreach(@{$self->image_selection}) { 800 # current image object 801 802 803 792 # current image object 793 $self->current_image( 794 $self->GetImage($_) 795 ); 804 796 # prepare resized, high, thumbnail 805 797 # if not already uploaded 806 798 $self->_set_site_resized_file(); 807 799 $self-> _set_site_high_file (); 808 800 # photo metadata 809 801 $self->_upload_selection_prepare() if (!$uploaded->{$self->current_image->file_sum} or $self->reupload_action_files); 810 $self->_prepare_upload_properties(); 802 $self->_prepare_upload_properties(); 811 803 812 804 # transfert resized, high, thumbnail to site … … 817 809 1+$self->count 818 810 ); 811 # remove thumbnail, resized, HD files 812 # to make sure everything is clean 813 map{ 814 unlink $self->current_image->$_ if -e $self->current_image->$_; 815 } 816 qw/ site_resized_file site_high_file site_thumb_file/; 819 817 } 820 818 … … 848 846 } 849 847 850 848 my $decode = { 851 849 'No' => 0, 852 853 854 }; 850 'Yes, use HD resized of the original photo' => 'HD', 851 'Yes, use a copy of the original photo' => 'ORIGINAL', 852 }; 855 853 #printf("upload HD %s\n", $self->upload_hd); 856 857 858 854 $self->upload_high( 855 $decode->{$self->upload_hd} 856 ); 859 857 #printf("upload High %s\n", $self->upload_high); 860 858 861 859 # if upload high, rotate a copy of original file 862 860 if($self->upload_high){ … … 883 881 ); 884 882 # set current image thumbnail 885 883 # update upload progress dialog 886 884 #$self->progressbar_refresh->($value); 887 885 }; … … 970 968 1+$self->upload_rejected_count 971 969 ); 972 } 970 } 973 971 974 972 } … … 1020 1018 sprintf( 1021 1019 "%s_%sx%s.%s", 1022 $filename, 1020 # $filename, 1021 'resized', 1023 1022 $self->resize_w, 1024 1023 $self->resize_h, … … 1027 1026 ) 1028 1027 ); 1029 #printf("_set_site_resized_file %s\n", $self->current_image->site_resized_file);1028 printf("_set_site_resized_file %s\n", $self->current_image->site_resized_file); 1030 1029 } 1031 1030 … … 1035 1034 eval { 1036 1035 if(!$self->CreateResized()){ 1037 $self->_ _create_resized_fallback();1036 $self->_create_resized_fallback(); 1038 1037 }; 1039 1038 … … 1059 1058 my ( $self ) = @_; 1060 1059 # use wx builtin rescale if IM fails 1061 #printf("CreateResized failed %s. Use ResizeCallback\n", $@);1060 printf("CreateResized failed %s. Use ResizeCallback\n", $@); 1062 1061 # use method provided by the caller 1063 1062 # source, target, type, ratio, width, $height … … 1066 1065 $self->current_image->site_resized_file, 1067 1066 $self->type, 1068 undef,1069 1067 $self->resize_w, 1070 1068 $self->resize_h, … … 1085 1083 my $bRotate; 1086 1084 my $bAddWatermark; 1087 1085 my $bResize; 1088 1086 my $orientation = $self->current_image->exif_metadata->{Orientation}; 1089 1087 my $degrees; 1090 1088 1091 1089 # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW … … 1093 1091 $bModifyOriginal = 1; 1094 1092 $bRotate = 1; 1095 1093 $degrees = $1; 1096 1094 } 1097 1095 … … 1100 1098 $bAddWatermark = 1; 1101 1099 } 1102 1103 1104 1100 1101 # HD resize 1102 if('HD' eq $self->upload_high){ 1105 1103 $bModifyOriginal = 1; 1106 1104 $bResize = 1; 1107 1105 } 1108 1106 1109 1107 if($bModifyOriginal){ … … 1132 1130 $status = $image->Set(interlace=>$self->interlace); 1133 1131 warn "$status" if $status ; 1134 1132 1135 1133 if($bRotate){ 1136 $image->Rotate( degrees=>$degrees ); 1134 $image->Rotate( degrees=>$degrees ); 1137 1135 } 1138 1136 $image->Write( … … 1181 1179 1182 1180 # file name for original copy 1181 # we do not need the original file name 1183 1182 sub _set_site_high_file { 1184 1183 my ( $self ) = @_; … … 1195 1194 $self->site_resized_dir, 1196 1195 sprintf( 1197 "%s _high.%s",1198 $filename,1196 "%s.%s", 1197 'high_file', 1199 1198 $self->type, 1200 1199 ) … … 1245 1244 my ( $self ) = @_; 1246 1245 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1246 1247 $self->pwg->reupload_action_files( 1248 $self->reupload_action_files||1 1249 ); 1250 $self->pwg->reupload_action_properties( 1251 $self->reupload_action_properties||2 1252 ); 1253 1254 $self->pwg->reupload_action_properties_m( 1255 $self->reupload_action_properties_m||1 1256 ); 1258 1257 1259 1258 $self->pwg->upload_high( … … 1289 1288 ); 1290 1289 1291 1292 1293 1294 1290 $self->pwg->privacy_level( 1291 $self->current_image->privacy_level 1292 ); 1293 1295 1294 $self->current_image->site_categories( 1296 1295 $self->categories … … 1308 1307 ); 1309 1308 1310 1309 1311 1310 } 1312 1311 … … 1335 1334 return 0 if $status; 1336 1335 1337 $image->Rotate( degrees=>$1 ); 1336 $image->Rotate( degrees=>$1 ); 1338 1337 1339 1338 # write resized file … … 1346 1345 undef $image; 1347 1346 1348 } 1347 } 1349 1348 return 1; 1350 1349 }
Note: See TracChangeset
for help on using the changeset viewer.