Changeset 16973 for extensions/rotateImage
- Timestamp:
- Jul 24, 2012, 3:38:35 PM (12 years ago)
- Location:
- extensions/rotateImage
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rotateImage/language/en_UK/plugin.lang.php
r13319 r16973 4 4 $lang['Angle'] = 'Angle'; 5 5 $lang['Also rotate HD image'] = 'Also rotate HD image'; 6 $lang['90° right'] = '90° right';7 $lang['90° left'] = '90° left';6 $lang['90° right'] = '90° clockwise'; 7 $lang['90° left'] = '90° counter-clockwise'; 8 8 $lang['180°'] = '180°'; 9 9 $lang['auto (EXIF orientation tag)'] = 'auto (EXIF orientation tag)'; -
extensions/rotateImage/language/fr_FR/plugin.lang.php
r13319 r16973 4 4 $lang['Angle'] = 'Angle'; 5 5 $lang['Also rotate HD image'] = 'Pivoter aussi l\'image HD'; 6 $lang['90° right'] = '90° à droite';7 $lang['90° left'] = '90° à gauche';6 $lang['90° right'] = '90° dans le sens des aiguilles d\'une montre'; 7 $lang['90° left'] = '90° dans le sens inverse des aiguilles d\'une montre'; 8 8 $lang['180°'] = '180°'; 9 9 $lang['auto (EXIF orientation tag)'] = 'automatique (selon le tag d\'orientation EXIF)'; -
extensions/rotateImage/main.inc.php
r13524 r16973 2 2 /* 3 3 Plugin Name: Rotate Image 4 Version: 0.64 Version: auto 5 5 Description: enables to rotate images in batch processing 6 6 Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=578 … … 8 8 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 9 9 10 add_event_handler('loc_begin_element_set_global', 'rotate_image_set_template_data');11 10 add_event_handler('ws_add_methods', 'add_image_rotate_method'); 12 add_event_handler('element_set_global_action', 'rotate_image_element_action', 50, 2);13 14 11 function add_image_rotate_method($arr) 15 12 { … … 17 14 } 18 15 16 add_event_handler('loc_begin_element_set_global', 'rotate_image_set_template_data'); 19 17 function rotate_image_set_template_data() { 20 18 global $template,$lang; 21 19 load_language('plugin.lang', dirname(__FILE__).'/'); 20 21 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); 22 22 23 $angles = array ( 23 array('value' => 90, 'name' => l10n('90° left')),24 24 array('value' => 270, 'name' => l10n('90° right')), 25 array('value' => 90, 'name' => l10n('90° left')), 25 26 array('value' => 180, 'name' => l10n('180°')) 26 27 ); … … 40 41 } 41 42 43 add_event_handler('element_set_global_action', 'rotate_image_element_action', 50, 2); 42 44 function rotate_image_element_action($action, $collection) { 43 global $template;44 45 if ($action == 'rotateImg') { 45 //flush thumbnails links by regenerating ramdom ids to uris 46 $template->delete_compiled_templates(); 46 add_event_handler('get_derivative_url', 'rotate_image_force_refresh', EVENT_HANDLER_PRIORITY_NEUTRAL, 4); 47 47 } 48 48 } 49 49 50 function rotate_image_force_refresh($root_url, $params, $src_image, $rel_url) 51 { 52 global $collection; 53 54 if (in_array($src_image->id, $collection)) 55 { 56 if (strpos($root_url, '?') === false) 57 { 58 $root_url.= '?'; 59 } 60 else 61 { 62 $root_url.= '&'; 63 } 64 65 $root_url.= 'rand='.md5(uniqid(rand(), true)); 66 } 67 68 return $root_url; 69 } 50 70 ?> -
extensions/rotateImage/rotate_image.tpl
r13319 r16973 26 26 27 27 jQuery('#applyAction').click(function(e) { 28 if (elements.length != 0) 29 { 28 if (typeof(elements) != "undefined") { 30 29 return true; 31 30 } 32 elseif (jQuery('[name="selectAction"]').val() == 'rotateImg')31 if (jQuery('[name="selectAction"]').val() == 'rotateImg') 33 32 { 34 33 angle = jQuery('select[name="rotate_angle"]').val(); … … 40 39 return true; 41 40 } 41 42 42 jQuery('.bulkAction').hide(); 43 43 jQuery('#regenerationText').html(rotateImagesMessage); … … 49 49 maxRequests: maxRequests 50 50 }); 51 52 elements = Array(); 51 53 if (jQuery('input[name="setSelected"]').attr('checked')) 52 54 elements = all_elements; … … 83 85 }, 84 86 dataType: 'json', 85 success: ( function(data) { progress (++todo, progressBar_max, data['result']) }),86 error: ( function(data) { progress (++todo, progressBar_max, false) })87 success: ( function(data) { progressRotate(++todo, progressBar_max, data['result']) }), 88 error: ( function(data) { progressRotate(++todo, progressBar_max, false) }) 87 89 }); 88 90 } 89 91 return false; 90 92 }); 93 94 function progressRotate(val, max, success) { 95 jQuery('#progressBar').progressBar(val, { 96 max: max, 97 textFormat: 'fraction', 98 boxImage: 'themes/default/images/progressbar.gif', 99 barImage: 'themes/default/images/progressbg_orange.gif' 100 }); 101 type = success ? 'regenerateSuccess': 'regenerateError' 102 s = jQuery('[name="'+type+'"]').val(); 103 jQuery('[name="'+type+'"]').val(++s); 104 105 if (val == max) 106 jQuery('#applyAction').click(); 107 } 108 91 109 }); 92 110 {/literal}{/footer_script} -
extensions/rotateImage/ws_functions.inc.php
r13524 r16973 1 1 <?php 2 3 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 3 … … 34 33 } 35 34 36 include_once(PHPWG_ROOT_PATH.'admin/include/functions _upload.inc.php');35 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 37 36 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); 37 38 38 $image_id=(int)$params['image_id']; 39 39 40 40 $query=' 41 SELECT id, path, tn_ext, has_high 41 SELECT 42 id, 43 path, 44 representative_ext, 45 rotation 42 46 FROM '.IMAGES_TABLE.' 43 47 WHERE id = '.$image_id.' 44 48 ;'; 45 $ image= pwg_db_fetch_assoc(pwg_query($query));46 if ($ image== null)49 $row = pwg_db_fetch_assoc(pwg_query($query)); 50 if ($row == null) 47 51 { 48 52 return new PwgError(403, "image_id not found"); 49 53 } 50 54 51 // rotation angle 52 if ('auto' == $params['angle']) { 53 $angle = $params['angle']; 55 $base_angle = pwg_image::get_rotation_angle_from_code($row['rotation']); 56 57 if (get_boolean($params['rotate_hd'])) { 58 if ('auto' == $angle) { 59 $angle = pwg_image::get_rotation_angle($row['path']); 60 $rotation_code = 0; 61 } 62 else { 63 // the angle is based on what the user sees (the thumbnail) and not on 64 // the original, which may have a different angle 65 $angle = ($base_angle + $params['angle']) % 360; 66 67 // the derivatives must not be rotated 68 $rotation_code = 4; 69 } 70 71 if (isset($conf['rotate_image_jpegtran']) and $conf['rotate_image_jpegtran']) { 72 $angle = ($angle + 180) % 360; 73 $command = 'jpegtran -copy all -rotate '.$angle.' -outfile '.$row['path'].' '.$row['path']; 74 exec($command); 75 } 76 else { 77 $image = new pwg_image($row['path']); 78 $image->set_compression_quality(98); 79 $image->rotate($angle); 80 $image->write($row['path']); 81 } 82 83 $conf['use_exif'] = false; 84 $conf['use_iptc'] = false; 85 sync_metadata(array($row['id'])); 86 87 single_update( 88 IMAGES_TABLE, 89 array('rotation' => $rotation_code), 90 array('id' => $row['id']) 91 ); 54 92 } 55 else { 56 $angle = (int)$params['angle']; 93 elseif ('auto' != $params['angle']) { 94 $new_angle = ($base_angle + $params['angle']) % 360; 95 $rotation_code = pwg_image::get_rotation_code_from_angle($new_angle); 96 97 // to show that it's a manual rotation, we use 4,5,6,7 instead of 0,1,2,3 98 $rotation_code+= 4; 99 100 single_update( 101 IMAGES_TABLE, 102 array('rotation' => $rotation_code), 103 array('id' => $row['id']) 104 ); 57 105 } 58 106 59 if (get_boolean($params['rotate_hd']) and get_boolean($image['has_high'])) { 60 $to_rotate_path = file_path_for_type($image['path'], 'high'); 61 $quality = $conf['upload_form_hd_quality']; 62 $regenerate_websize = true; 63 64 if ('auto' == $angle) { 65 $angle = pwg_image::get_rotation_angle($to_rotate_path); 66 } 67 } 68 else { 69 $to_rotate_path = $image['path']; 70 $quality = $conf['upload_form_websize_quality']; 71 $regenerate_websize = false; 72 } 73 74 $rotated = new pwg_image($to_rotate_path); 75 $rotated->set_compression_quality($quality); 76 $rotated->rotate($angle); 77 $rotated->write($to_rotate_path); 78 79 if ($regenerate_websize) { 80 ws_images_resizewebsize( 81 array( 82 'image_id' => $params['image_id'], 83 'maxwidth' => $conf['upload_form_websize_maxwidth'], 84 'maxheight' => $conf['upload_form_websize_maxheight'], 85 'quality' => $conf['upload_form_websize_quality'], 86 'automatic_rotation' => $conf['upload_form_automatic_rotation'], 87 'library' => $conf['graphics_library'], 88 ), 89 $service 90 ); 91 } 92 93 ws_images_resizethumbnail( 94 array( 95 'image_id' => $params['image_id'], 96 'maxwidth' => $conf['upload_form_thumb_maxwidth'], 97 'maxheight' => $conf['upload_form_thumb_maxheight'], 98 'quality' => $conf['upload_form_thumb_quality'], 99 'crop' => $conf['upload_form_thumb_crop'], 100 'follow_orientation' => $conf['upload_form_thumb_follow_orientation'], 101 'library' => $conf['graphics_library'], 102 ), 103 $service 104 ); 105 106 $conf['use_exif'] = false; 107 $conf['use_iptc'] = false; 108 update_metadata(array($image['id'] => $image['path'])); 107 delete_element_derivatives($row); 109 108 110 109 return true;
Note: See TracChangeset
for help on using the changeset viewer.