Changeset 13316


Ignore:
Timestamp:
02/23/12 13:44:25 (8 years ago)
Author:
plg
Message:

only rotate the biggest size and regenerate smaller sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rotateImage/ws_functions.inc.php

    r13315 r13316  
    5050  } 
    5151 
    52   $image_path = $image['path']; 
     52  if ($rotate_hd and get_boolean($image['has_high'])) { 
     53    $to_rotate_path = file_path_for_type($image['path'], 'high'); 
     54    $quality = $conf['upload_form_hd_quality']; 
     55    $regenerate_websize = true; 
     56  } 
     57  else { 
     58    $to_rotate_path = $image['path']; 
     59    $quality = $conf['upload_form_websize_quality']; 
     60    $regenerate_websize = false; 
     61  } 
    5362 
    54      
    55   $thumb_path = get_thumbnail_path($image); 
     63  $rotated = new pwg_image($to_rotate_path); 
     64  $rotated->set_compression_quality($quality); 
     65  $rotated->rotate($angle); 
     66  $rotated->write($to_rotate_path); 
    5667 
    57   $img = new pwg_image($image_path); 
    58   $img->set_compression_quality($conf['upload_form_websize_quality']); 
    59   $img->rotate($angle); 
    60   $img->write($image_path); 
    61   update_metadata(array($image_id=>$image_path)); 
    62   if ($rotate_hd) { 
    63     $sizes = array('thumb','high'); 
    64   } else { 
    65     $sizes = array('thumb'); 
     68  if ($regenerate_websize) { 
     69    ws_images_resizewebsize( 
     70      array( 
     71        'image_id' => $params['image_id'], 
     72        'maxwidth' => $conf['upload_form_websize_maxwidth'], 
     73        'maxheight' => $conf['upload_form_websize_maxheight'], 
     74        'quality' => $conf['upload_form_websize_quality'], 
     75        'automatic_rotation' => $conf['upload_form_automatic_rotation'], 
     76        'library' => $conf['graphics_library'], 
     77        ), 
     78      &$service 
     79      ); 
    6680  } 
     81 
     82  ws_images_resizethumbnail( 
     83    array( 
     84      'image_id' => $params['image_id'], 
     85      'maxwidth' => $conf['upload_form_thumb_maxwidth'], 
     86      'maxheight' => $conf['upload_form_thumb_maxheight'], 
     87      'quality' => $conf['upload_form_thumb_quality'], 
     88      'crop' => $conf['upload_form_thumb_crop'], 
     89      'follow_orientation' => $conf['upload_form_thumb_follow_orientation'], 
     90      'library' => $conf['graphics_library'], 
     91      ), 
     92    &$service 
     93    ); 
     94 
     95  $conf['use_exif'] = false; 
     96  $conf['use_iptc'] = false; 
     97  update_metadata(array($image['id'] => $image['path'])); 
    6798   
    68   foreach ($sizes as $size) { 
    69     $resized_path = file_path_for_type($image_path,$size); 
    70      
    71     $quality = $conf['upload_form_hd_quality']; 
    72     if ('thumb' == $size) { 
    73       $quality = $conf['upload_form_thumb_quality']; 
    74     } 
    75      
    76     if (file_exists($resized_path)) { 
    77       $resized = new pwg_image($resized_path); 
    78       $resized->set_compression_quality($quality); 
    79       $resized->rotate($angle); 
    80       $resized->write($resized_path); 
    81     } 
    82   } 
    8399  return true; 
    84100} 
Note: See TracChangeset for help on using the changeset viewer.