Changeset 2728
- Timestamp:
- Oct 12, 2008, 9:16:39 PM (16 years ago)
- Location:
- extras/pLoader/trunk/src/Uploader
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/pLoader/trunk/src/Uploader/GUI/wxExportProgressDlg.pm
r2597 r2728 20 20 package Uploader::GUI::wxExportProgressDlg; 21 21 use strict; 22 use Carp; 22 23 use Wx qw/ 23 24 wxDefaultSize … … 40 41 processing 41 42 txtprocessing 43 cancelled 42 44 / 43 45 ); … … 75 77 # Update progress information 76 78 sub LogProgress { 77 my ( $self, $text, $value ) = @_; 78 79 79 my ( $self ) = @_; 80 81 printf("$self cancelled %s \n", $self->cancelled); 82 die if $self->cancelled; 80 83 $self->txtprocessing->SetLabel( 81 84 $text || $self->processing … … 84 87 $value || $self->progress 85 88 ); 89 86 90 } 87 91 88 92 # Close the dialog. cancel export 89 93 sub OnExportOK { 90 94 my ( $self, $event ) = @_; 91 95 96 $self->cancelled(1); 92 97 $self->Destroy; 93 98 -
extras/pLoader/trunk/src/Uploader/GUI/wxFrameAUI.pm
r2698 r2728 151 151 152 152 153 # callback for GUI refresh : progress dialog display current uploaded image 154 $self->imagelist->UploadImagesProgressCallback( 155 sub { $self->UploadImagesProgress(@_) } 156 ); 157 158 $self->imagelist->UploadDisplayEndInfoCallback( 153 # callback for GUI refresh : progress dialog display current uploaded image 154 $self->imagelist->progress_thumbnail_refresh( 155 sub { $self->UploadProgressThumbnailRefresh(@_) } 156 ); 157 158 $self->imagelist->progress_msg_refresh( 159 sub { $self->UploadProgressMessageRefresh(@_) } 160 ); 161 162 163 $self->imagelist->progressbar_refresh( 164 sub { $self->UploadProgressBarRefresh(@_) } 165 ); 166 167 $self->imagelist->progress_endinfo_refresh( 159 168 sub { $self->UploadDisplayEndInfo(@_) } 160 169 ); … … 786 795 } 787 796 788 # display uploaded image in progress dlg 789 sub UploadImagesProgress { 797 sub UploadProgressMessageRefresh { 798 my ( $self, $msg ) = @_; 799 800 $self->upload_progressdlg->processing( 801 $msg 802 ); 803 804 Wx::Yield(); 805 } 806 807 sub UploadProgressThumbnailRefresh { 790 808 my ( $self ) = @_; 791 809 792 810 my $imagelist = $self->imagelist ; 793 811 794 my ( $vol, $dir, $file ) = File::Spec->splitpath($imagelist->current_image->file); 795 796 $self->upload_progressdlg->processing( 797 sprintf( 798 $imagelist->progress_msg, 799 $imagelist->current_image->site_name, 800 $file, 812 813 $self->upload_progressdlg->image->SetBitmap(wxNullBitmap); 814 $self->upload_progressdlg->image->SetBitmap( 815 Wx::Bitmap->new( 816 $self->imagelist->current_image->wx_thumb_file, 817 $self->GetWxBitmapType($self->imagelist->type), 801 818 ) 802 819 ); 820 821 Wx::Yield(); 822 } 823 824 sub UploadProgressBarRefresh { 825 my ( $self, $ratio ) = @_; 826 803 827 eval { 804 $self->upload_progressdlg->image->SetBitmap(wxNullBitmap);805 $self->upload_progressdlg->image->SetBitmap(806 Wx::Bitmap->new(807 $self->imagelist->current_image->wx_thumb_file,808 $self->GetWxBitmapType($self->imagelist->type),809 )810 );811 828 $self->upload_progressdlg->progress( 812 $ imagelist->count * ( 100/scalar @{$imagelist->image_selection} )829 $ratio*$self->imagelist->count * ( 100/scalar @{$self->imagelist->image_selection} ) 813 830 ); 814 831 $self->upload_progressdlg->LogProgress(); 815 832 }; 816 if($@){ 817 croak "Upload cancelled.\n"; 818 } 819 833 croak "Upload cancelled" if $@; 834 820 835 Wx::Yield(); 821 822 } 823 836 } 824 837 825 838 sub SetNewFilesDisplayEndInfo { … … 830 843 831 844 sub UploadDisplayEndInfo { 832 my ( $self ) = @_;845 my ( $self, $msg ) = @_; 833 846 834 847 my $imagelist = $self->imagelist ; 835 848 836 $self->upload_progressdlg->DisplayEndInfo ;849 $self->upload_progressdlg->DisplayEndInfo($msg); 837 850 } 838 851 -
extras/pLoader/trunk/src/Uploader/GUI/wxImageProcessingProgressDlg.pm
r2597 r2728 41 41 txtprocessing 42 42 image 43 cancelled 43 44 / 44 45 ); 45 46 use Carp; 46 47 47 48 sub new { … … 65 66 }; 66 67 68 $self->btok->SetLabel( 69 $params->{bt_label}||'Cancel' 70 ); 71 67 72 if($@){ 68 73 Wx::LogMessage("Error during dialogbox initialization"); … … 75 80 my ( $self ) = @_; 76 81 77 EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&On ExportOK );82 EVT_BUTTON( $self, $main::ID_PROGRESS_OK, \&OnOK ); 78 83 79 84 … … 82 87 # Update progress information 83 88 sub LogProgress { 84 my ( $self , $text, $value) = @_;89 my ( $self ) = @_; 85 90 91 croak "Cancelled by user\n" if $self->cancelled; 86 92 87 93 $self->txtprocessing->SetLabel( 88 $ text || $self->processing94 $self->processing 89 95 ); 90 96 $self->gauge->SetValue( 91 $ value || $self->progress97 $self->progress 92 98 ); 93 99 } 94 100 101 sub DisplayEndInfo { 102 my ( $self, $msg ) = @_; 95 103 96 sub OnExportOK { 104 $self->txtprocessing->SetLabel( 105 $msg 106 ); 107 $self->image->Show(0); 108 $self->gauge->Show(0); 109 110 $self->btok->SetLabel( 111 'Close' 112 ); 113 114 } 115 116 sub OnOK { 97 117 my ( $self, $event ) = @_; 98 118 119 $self->cancelled(1); 99 120 $self->Destroy; 100 121 -
extras/pLoader/trunk/src/Uploader/Image.pm
r2597 r2728 27 27 wx_thumb_file 28 28 preview_file 29 site_high_file 29 30 site_name 30 31 site_resized_file -
extras/pLoader/trunk/src/Uploader/ImageList.pm
r2696 r2728 64 64 SetNewFilesDisplayEndInfoCallback 65 65 UploadImagesViewerCallback 66 UploadImagesProgressCallback 67 UploadDisplayEndInfoCallback 66 progress_thumbnail_refresh 67 progress_msg_refresh 68 progressbar_refresh 69 progress_endinfo_refresh 68 70 ResizeCallback 69 71 upload_rejects … … 615 617 my ( $self ) = @_; 616 618 617 my $progress_msg;618 my $progress_callback = $self->UploadImagesProgressCallback;619 619 my $viewer_callback = $self->UploadImagesViewerCallback ; 620 620 … … 624 624 ); 625 625 626 my $count = 0;627 626 my $count = 1; 627 my $msg; 628 628 $self->count( 629 629 $count 630 630 ); 631 my $uploaded = 0; 632 my $rejected = 0; 633 my $time_begin = time; 631 634 map { 632 635 # current image object … … 638 641 $self->current_image->file 639 642 ); 643 644 my $site_name = $self->current_image->site_name; 640 645 641 646 my ( $filename, $ext ) = split /\./, $file ; 642 647 643 # is defined latelyto make sure we have the last global properties ( resize_w, resize_h )648 # lately defined to make sure we have the last global properties ( resize_w, resize_h ) 644 649 $self->current_image->site_resized_file( 645 650 File::Spec->catfile( … … 654 659 ) 655 660 ); 656 657 658 $self->progress_msg(659 "Preparing resized image for %s - %s"660 );661 662 # update upload progress dialog 661 662 $msg = sprintf( 663 "Preparing resized image for %s - %s", 664 $site_name, 665 $file, 666 ); 667 663 668 eval { 664 $progress_callback->(); 669 # set current image thumbnail 670 $self->progress_thumbnail_refresh->(); 671 672 $self->progress_msg_refresh->($msg); 673 674 # update upload progress dialog 675 $self->progressbar_refresh->(0.25); 665 676 }; 666 # user cancelled 667 if($@){ 668 croak "Upload cancelled."; 669 } 677 # user cancelled : dialog box is destroyed 678 croak "Upload cancelled." if $@ ; 679 670 680 eval { 671 681 if(!$self->CreateResized()){ … … 695 705 696 706 697 if($@){ 698 $progress_msg = "An error has occured %s - %s\n$@"; 707 # if upload high, rotate a copy of original file 708 if($self->upload_high){ 709 $self->CreateHigh(); 699 710 } 700 else{ 701 $progress_msg = "Preparing thumbnail for %s - %s"; 702 } 703 704 $self->progress_msg( 705 $progress_msg 706 ); 707 # update upload progress dialog 708 $progress_callback->(); 711 712 713 714 715 $msg = sprintf( 716 "Preparing thumbnail for %s - %s", 717 $site_name, 718 $file, 719 ); 720 721 eval { 722 $self->progress_msg_refresh->($msg); 723 }; 724 croak "Upload cancelled." if $@ ; 709 725 710 726 eval { 711 727 $self->CreateThumbnail(); 712 728 }; 729 713 730 if($@){ 714 $self->progress_msg( 715 "An error has occured %s - %s\n$@" 731 $msg = sprintf( 732 "An error has occured %s - %s\n$@", 733 $site_name, 734 $file 716 735 ); 717 736 } 718 737 else{ 719 $self->progress_msg( 720 "Uploading %s - %s" 738 $msg = sprintf( 739 "Uploading %s - %s", 740 $site_name, 741 $file 721 742 ); 722 743 } 723 # update upload progress dialog 724 $progress_callback->() ; 744 eval { 745 $self->progress_msg_refresh->($msg); 746 $self->progressbar_refresh->(0.50); 747 }; 748 croak "Upload cancelled." if $@ ; 725 749 726 750 # photo metadata … … 729 753 730 754 if ( $status ){ 731 $self->progress_msg( 732 "%s : %s upload succcessful." 755 $msg = sprintf( 756 "%s : %s upload succcessful.", 757 $site_name, 758 $file 733 759 ); 760 $uploaded++; 734 761 } else { 735 $self->progress_msg( 736 "An error has occured.\n%s : %s upload is cancelled.\n$status_msg" 762 $msg = sprintf( 763 "An error has occured.\n%s : %s upload is cancelled.\n$status_msg", 764 $site_name, 765 $file 737 766 ); 738 push @{$self->upload_rejects}, $self->current_image;767 $rejected++; 739 768 } 740 769 … … 744 773 ); 745 774 # update upload progress dialog 746 $progress_callback->() ; 775 eval { 776 $self->progress_msg_refresh->($msg); 777 $self->progressbar_refresh->(1); 778 }; 779 croak "Upload cancelled." if $@ ; 747 780 748 781 } 749 782 @{$self->image_selection} if defined 750 783 $self->image_selection; 751 752 $self->UploadDisplayEndInfoCallback->(); 784 785 my $time_end = time; 786 my $duration = $time_begin - $time_end; 787 $msg = sprintf( 788 "%s images processed\n\n%s images uploaded\n\n%s images in errors and not uploaded\n\nDuration : %s seconds", 789 $self->count - 1, 790 $uploaded, 791 $rejected, 792 $duration, 793 ); 794 $self->progress_endinfo_refresh->($msg); 795 } 796 797 # if we need to rotate 798 sub CreateHigh { 799 my ( $self ) = @_; 800 801 my $orientation = $self->current_image->exif_metadata->{Orientation}; 802 803 # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW 804 if( $orientation =~ m/Rotate (\d+)/ ){ 805 806 my ( $vol, $dir, $file ) = File::Spec->splitpath( 807 $self->current_image->file 808 ); 809 810 my ( $filename, $ext ) = split /\./, $file ; 811 812 # high_file is a copy of original 813 $self->current_image->site_high_file( 814 File::Spec->catfile( 815 $self->site_resized_dir, 816 sprintf( 817 "%s_high.%s", 818 $filename, 819 $self->type, 820 ) 821 ) 822 ); 823 824 my $image = Image::Magick->new(); 825 # we read original 826 my $status = $image->Read( 827 $self->current_image->file 828 ); 829 warn "$status ", $self->current_image->file, "\n" if $status ; 830 return 0 if $status; 831 832 $image->Rotate( degrees=>$1 ); 833 834 $image->Write( 835 filename=>$self->current_image->site_high_file 836 ); 837 warn "$status ", $self->current_image->site_high_file, "\n" if $status ; 838 return 0 if $status; 839 840 undef $image; 841 842 $self->_set_exif_tag( 843 $self->current_image->site_high_file, 844 'Orientation', 845 'Horizontal (normal)', 846 ); 847 848 849 # Now all images that need to be rotated are done. Update exif 850 $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)'; 851 } 852 else{ 853 # high file is the original file 854 $self->current_image->site_high_file( 855 $self->current_image->file 856 ); 857 } 858 859 return 1; 753 860 } 754 861 … … 810 917 my ( $self, $file ) = @_; 811 918 919 # exif from original image 812 920 my $orientation = $self->current_image->exif_metadata->{Orientation}; 813 921 … … 820 928 821 929 my $image = Image::Magick->new(); 822 930 931 # read resized file 823 932 my $status = $image->Read( 824 933 $file … … 829 938 $image->Rotate( degrees=>$1 ); 830 939 940 # write resizd file 831 941 $image->Write( 832 942 filename=>$file -
extras/pLoader/trunk/src/Uploader/PWG/WebServices.pm
r2696 r2728 160 160 161 161 162 printf(163 "UploadImage %s\n",164 $self->site_resized_file165 );166 162 167 163 my $file_content = encode_base64( … … 205 201 206 202 if($self->upload_high){ 207 $form->{high_content} = encode_base _64(203 $form->{high_content} = encode_base64( 208 204 read_file( 209 205 $self->site_high_file, … … 211 207 ) 212 208 ); 209 213 210 $form->{high_sum} = file_md5_hex( 214 211 $self->site_high_file
Note: See TracChangeset
for help on using the changeset viewer.