- Timestamp:
- Mar 7, 2009, 8:22:06 PM (16 years ago)
- Location:
- extras/pLoader/trunk/src/Uploader
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/pLoader/trunk/src/Uploader/Image.pm
r2728 r3177 37 37 site_categories 38 38 site_tags 39 preview_w 40 preview_h 39 41 / 40 42 ); -
extras/pLoader/trunk/src/Uploader/ImageList.pm
r3163 r3177 72 72 pwg 73 73 upload_high 74 wx_quality 75 th_quality 76 auto_rotate 77 interlace 78 create_resized 79 use_exif_preview 74 80 / 75 81 ); … … 101 107 } 102 108 103 # Rotate exif preview if needed104 sub _rotate_image {105 my ( $self, $file ) = @_;106 107 }108 109 109 110 sub _set_exif_tag { … … 205 206 $self->_set_current_image_filepaths(); 206 207 207 my $create_gui_preview; 208 # an exif preview is available. we try to use it 209 if(defined $info->{PreviewImage} ){ 210 printf("use preview\n"); 211 $self->_write_preview_image( $info->{PreviewImage} ); 212 my $image = new Image::Magick; 213 eval { 214 $create_gui_preview = $image->ReadImage( 215 $self->current_image->preview_file 216 ); 217 }; 218 unlink $self->current_image->preview_file if $create_gui_preview; 219 }else { 208 my $create_gui_preview; 209 if($self->use_exif_preview){ 210 # an exif preview is available. we try to use it 211 if(defined $info->{PreviewImage} ){ 212 printf("use preview\n"); 213 $self->_write_preview_image( $info->{PreviewImage} ); 214 my $image = new Image::Magick; 215 eval { 216 $create_gui_preview = $image->ReadImage( 217 $self->current_image->preview_file 218 ); 219 }; 220 unlink $self->current_image->preview_file if $create_gui_preview; 221 } 222 else { 223 $create_gui_preview = 1; 224 } 225 } 226 else { 220 227 $create_gui_preview = 1; 221 228 } 222 print $create_gui_preview, "\n";229 print "create gui preview", $create_gui_preview, "\n"; 223 230 # have to create a preview file 224 231 if($create_gui_preview) { … … 242 249 $self->RotateImage( 243 250 $self->current_image->preview_file, 244 ) ;251 ) if $self->auto_rotate; 245 252 246 253 $self->_set_exif_tag( … … 248 255 'Orientation', 249 256 'Horizontal (normal)', 250 ) ;257 ) if $self->auto_rotate; 251 258 252 259 … … 357 364 return $rval if $status; 358 365 366 $self->current_image->preview_w( 367 $image->Get('width') 368 ); 369 $self->current_image->preview_h( 370 $image->Get('height') 371 ); 372 373 359 374 $status = $image->Thumbnail( 360 375 geometry=>sprintf("%s%s>", $size*$size, '@') … … 374 389 ); 375 390 376 $image->Set(quality=>100); 391 $image->Set( 392 quality=>$self->wx_quality 393 ); 377 394 378 395 $status = $image->Strip(); … … 398 415 sub CreateGUIPreview { 399 416 my ( $self ) = @_; 400 417 printf("CreateGUIPreview %s\n", $self->current_image->preview_file ); 401 418 return 1 if( -e $self->current_image->preview_file ); 402 419 … … 410 427 my $status = $image->Read( 411 428 sprintf( 412 " '%s'",429 "%s", 413 430 $self->current_image->file, 414 431 ) … … 435 452 436 453 437 $image->Set(quality=>$self-> quality);454 $image->Set(quality=>$self->wx_quality); 438 455 439 456 … … 460 477 return $rval if( -e $self->current_image->site_resized_file ); 461 478 462 printf(463 "Create resized %s\n",464 $self->current_image->file,465 );479 printf( 480 "Create resized %s\n", 481 $self->current_image->file, 482 ); 466 483 467 484 my $image = new Image::Magick; … … 513 530 warn "$status" if $status ; 514 531 515 $status = $image->Set(interlace=> 'Line');532 $status = $image->Set(interlace=>$self->interlace); 516 533 warn "$status" if $status ; 517 534 … … 561 578 warn "$status" if $status ; 562 579 563 $status = $image->Set(quality=>$self-> quality);580 $status = $image->Set(quality=>$self->th_quality); 564 581 warn "$status" if $status ; 565 582 … … 624 641 blur 625 642 quality 643 wx_quality 644 th_quality 626 645 prefix 627 646 author … … 643 662 default_name_prefix 644 663 upload_high 664 auto_rotate 665 interlace 666 create_resized 667 use_exif_preview 645 668 / 646 669 ] … … 722 745 croak "Upload cancelled." if $@ ; 723 746 724 eval { 725 if(!$self->CreateResized()){ 726 printf("CreateResized failed %s. Use ResizeCallback\n", $@); 727 # use method provided by the caller 728 # source, target, type, ratio, width, $height 729 $self->ResizeCallback->( 730 $self->current_image->file, 731 $self->current_image->site_resized_file, 732 $self->type, 733 undef, 734 $self->resize_w, 735 $self->resize_h, 736 $self->quality, 737 ); 747 if( $self->create_resized ){ 748 eval { 749 if(!$self->CreateResized()){ 750 printf("CreateResized failed %s. Use ResizeCallback\n", $@); 751 # use method provided by the caller 752 # source, target, type, ratio, width, $height 753 $self->ResizeCallback->( 754 $self->current_image->file, 755 $self->current_image->site_resized_file, 756 $self->type, 757 undef, 758 $self->resize_w, 759 $self->resize_h, 760 $self->quality, 761 ); 738 762 739 $self->RotateImage( 740 $self->current_image->site_resized_file, 741 ); 742 } 743 }; 744 745 $self->_set_exif_tag( 746 $self->current_image->site_resized_file, 747 'Orientation', 748 'Horizontal (normal)', 749 ); 763 $self->RotateImage( 764 $self->current_image->site_resized_file, 765 ) if $self->auto_rotate; 766 } 767 }; 768 $self->_set_exif_tag( 769 $self->current_image->site_resized_file, 770 'Orientation', 771 'Horizontal (normal)', 772 ) if $self->auto_rotate; 773 } 774 # the original is at the right size, no need to create a resize 775 else { 776 $self->current_image->site_resized_file( 777 $self->current_image->file, 778 ); 779 } 780 750 781 751 782 … … 754 785 $self->CreateHigh(); 755 786 } 756 757 758 759 787 760 788 $msg = sprintf( … … 848 876 849 877 # Valid for Rotate 180, Rotate 90 CW, Rotate 270 CW 850 if( $ orientation =~ m/Rotate (\d+)/ ){878 if( $self->auto_rotate and $orientation =~ m/Rotate (\d+)/ ){ 851 879 852 880 my ( $vol, $dir, $file ) = File::Spec->splitpath( … … 892 920 ); 893 921 894 895 922 # Now all images that need to be rotated are done. Update exif 896 923 $self->current_image->exif_metadata->{Orientation} = 'Horizontal (normal)';
Note: See TracChangeset
for help on using the changeset viewer.