Changeset 2661 for extras/pLoader/trunk/src/Uploader/GUI/wxApp.pm
- Timestamp:
- Oct 5, 2008, 12:31:42 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extras/pLoader/trunk/src/Uploader/GUI/wxApp.pm
r2618 r2661 27 27 wxBITMAP_TYPE_PNG 28 28 wxBITMAP_TYPE_JPEG 29 wxIMAGE_QUALITY_NORMAL 30 wxIMAGE_QUALITY_HIGH 29 31 wxSPLASH_CENTRE_ON_SCREEN 30 32 wxSPLASH_TIMEOUT … … 168 170 eval { 169 171 $stored_imagelist = retrieve $self->storable_file; 170 $stored_imagelist->{images_h} = {};171 172 }; 172 173 if($@){ 174 Wx::LogMessage( 175 "An error has occured. Can not read %s\n%s", 176 $self->storable_file, 177 $@ 178 ); 173 179 $stored_imagelist = $self->_default_imagelist_params ; 174 180 } … … 183 189 ) 184 190 ); 191 192 $self->imagelist->ResizeCallback( 193 sub { $self->ResizeImage(@_) } 194 ); 185 195 } 186 196 … … 191 201 my $params = { 192 202 thumb_size => 120, 193 site_thumb_dir 203 site_thumb_dir => $self->thumb_dir, 194 204 wx_thumb_size => 120, 195 205 wx_thumb_dir => $self->wx_thumb_dir, … … 198 208 resize_w => 800, 199 209 resize_h => 600, 200 site_resized_dir 210 site_resized_dir => $self->resized_dir, 201 211 type => 'jpg', 202 212 filter => 'Lanczos', 203 blur => 1,204 quality => 90,213 blur => 0.9, 214 quality => 100, 205 215 prefix => 'TN', 206 216 count => 0, 207 217 storable_file => $self->storable_file, 208 218 images => [], 209 images_h => {},210 219 userdata_dir => $self->userdata_dir, 211 220 default_name_prefix => 'Photo', 212 221 upload_rejects => [], 222 ResizeCallback => sub { $self->ResizeImage(@_) }, 213 223 }; 214 224 … … 254 264 ) 255 265 ); 256 printf( 257 "conf file %s\n", 258 $self->conf_file 259 ); 266 260 267 261 268 … … 326 333 } 327 334 335 336 sub 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 } 328 397 329 398 sub _init_frame { … … 363 432 width => $w, 364 433 height => $h, 365 title => "pLoader - Piwigo uploader - [$url]" ,434 title => "pLoader - Piwigo uploader 1.0 RC2 - [$url]" , 366 435 pwg => $self->pwg, 367 436 imagelist => $self->imagelist,
Note: See TracChangeset
for help on using the changeset viewer.