Ignore:
Timestamp:
Oct 5, 2008, 12:31:42 AM (16 years ago)
Author:
ronosman
Message:
  • remove Save and Cancel buttons from properties panels. Use callbacks instead.
  • limit Global settings panel instances to one.
  • fix resize crash with huge images. use Wx::Image methods when IM fails.
  • add categories is implemented in tree control. right click popup menu with Add an Refresh commands.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extras/pLoader/trunk/src/Uploader/GUI/wxApp.pm

    r2618 r2661  
    2727             wxBITMAP_TYPE_PNG
    2828             wxBITMAP_TYPE_JPEG
     29             wxIMAGE_QUALITY_NORMAL
     30             wxIMAGE_QUALITY_HIGH
    2931             wxSPLASH_CENTRE_ON_SCREEN
    3032             wxSPLASH_TIMEOUT
     
    168170        eval {
    169171            $stored_imagelist = retrieve $self->storable_file;
    170             $stored_imagelist->{images_h} = {};
    171172        };
    172173        if($@){
     174            Wx::LogMessage(
     175                "An error has occured. Can not read %s\n%s",
     176                $self->storable_file,
     177                $@
     178            );
    173179            $stored_imagelist = $self->_default_imagelist_params ;
    174180        }
     
    183189        )
    184190    );
     191
     192    $self->imagelist->ResizeCallback(
     193        sub { $self->ResizeImage(@_) }
     194    );
    185195}
    186196
     
    191201    my $params = {
    192202        thumb_size       => 120,
    193         site_thumb_dir        => $self->thumb_dir,
     203        site_thumb_dir   => $self->thumb_dir,
    194204        wx_thumb_size    => 120,
    195205        wx_thumb_dir     => $self->wx_thumb_dir,
     
    198208        resize_w         => 800,
    199209        resize_h         => 600,
    200         site_resized_dir      => $self->resized_dir,
     210        site_resized_dir => $self->resized_dir,
    201211        type             => 'jpg',
    202212        filter           => 'Lanczos',
    203         blur             => 1,
    204         quality          => 90,
     213        blur             => 0.9,
     214        quality          => 100,
    205215        prefix           => 'TN',
    206216        count            => 0,
    207217        storable_file    => $self->storable_file,
    208218        images           => [],
    209         images_h         => {},
    210219        userdata_dir     => $self->userdata_dir,
    211220        default_name_prefix => 'Photo',
    212221        upload_rejects  =>  [],
     222        ResizeCallback  => sub { $self->ResizeImage(@_) },
    213223    };
    214224
     
    254264        )
    255265    );
    256     printf(
    257         "conf file %s\n",
    258         $self->conf_file
    259     );
     266
    260267   
    261268
     
    326333}
    327334
     335
     336sub ResizeImage {
     337    my ( $self, $image_file, $image_file_out, $type, $ratio, $width, $height, $quality ) = @_;
     338   
     339
     340    my $image = Wx::Image->new(
     341            $image_file,
     342            $self->GetWxBitmapType($type),
     343            0
     344    );
     345   
     346    my $w;
     347    my $h;
     348
     349    my $img_w = $image->GetWidth;
     350    my $img_h = $image->GetHeight;
     351   
     352    # use a ratio ( 25% default ) if defined
     353    # default ratio is used for preview.
     354    if($ratio){
     355        $w = $ratio*$img_w/100 ;
     356        $h = $ratio*$img_h/100 ;
     357    }
     358    # use specified width and height
     359    else{
     360        # portrait
     361        if( $img_w < $img_h ){
     362            $w = $height;
     363        }
     364        else{
     365            $w = $width;
     366        }
     367        # to respect aspect ratio
     368        $h = sprintf(
     369            "%.0f",
     370            ($w*$img_h)/$img_w
     371        );
     372    }
     373
     374    $image->Rescale(
     375        $w,
     376        $h,
     377        wxIMAGE_QUALITY_HIGH
     378    );
     379   
     380    $quality ||= 90;
     381   
     382    $image->SetOption(
     383        "quality",
     384        $quality
     385    );
     386   
     387    if(!$image->SaveFile(
     388        $image_file_out,
     389        $self->GetWxBitmapType($type),
     390    )){
     391        Wx::LogMessage(
     392            "An error has occured. Can not save file %s",
     393            $image_file_out,
     394        )
     395    };
     396}
    328397
    329398sub _init_frame {
     
    363432            width     => $w,
    364433            height    => $h,
    365             title     => "pLoader - Piwigo uploader - [$url]" ,
     434            title     => "pLoader - Piwigo uploader 1.0 RC2 - [$url]" ,
    366435            pwg       => $self->pwg,
    367436            imagelist => $self->imagelist,
Note: See TracChangeset for help on using the changeset viewer.