Changeset 10686
- Timestamp:
- Apr 29, 2011, 7:38:59 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/image.class.php
r10684 r10686 291 291 if (is_null($library)) 292 292 { 293 $library = $conf[' image_library'];293 $library = $conf['graphics_library']; 294 294 } 295 295 -
trunk/admin/themes/default/template/batch_manager_global.tpl
r10637 r10686 334 334 else if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') 335 335 { 336 type = 'thumbnail';336 resizeMethod = 'pwg.images.resizeThumbnail'; 337 337 maxRequests = 3; 338 338 maxwidth = jQuery('input[name="thumb_maxwidth"]').val(); … … 344 344 else if(jQuery('[name="selectAction"]').val() == 'regenerateWebsize') 345 345 { 346 type = 'websize';346 resizeMethod = 'pwg.images.resizeWebsize'; 347 347 maxRequests = 1; 348 348 maxwidth = jQuery('input[name="websize_maxwidth"]').val(); … … 391 391 url: 'ws.php', 392 392 data: { 393 method: 'pwg.images.resize', 394 type: type, 393 method: resizeMethod, 395 394 maxwidth: maxwidth, 396 395 maxheight: maxheight, -
trunk/admin/themes/default/template/thumbnail.tpl
r10571 r10686 31 31 url: 'ws.php', 32 32 data: { 33 method: 'pwg.images.resize ',33 method: 'pwg.images.resizeThumbnail', 34 34 image_path: image_path, 35 type: 'thumbnail',36 35 maxwidth: width, 37 36 maxheight: height, -
trunk/include/ws_functions.inc.php
r10653 r10686 2659 2659 } 2660 2660 2661 function ws_images_resize($params, &$service) 2662 { 2663 global $conf; 2664 2661 function ws_images_resizethumbnail($params, &$service) 2662 { 2665 2663 if (!is_admin()) 2666 2664 { … … 2668 2666 } 2669 2667 2670 if (!in_array($params['type'], array('thumbnail', 'websize')))2671 {2672 return new PwgError(403, 'Unknown type (only "thumbnail" or "websize" are accepted');2673 }2674 2675 2668 if (empty($params['image_id']) and empty($params['image_path'])) 2676 2669 { … … 2678 2671 } 2679 2672 2680 $resize_params = array('maxwidth', 'maxheight', 'quality', 'crop', 'follow_orientation');2681 $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize';2682 foreach ($resize_params as $param)2683 {2684 if (empty($params[$param]) and isset($conf['upload_form_'.$type.'_'.$param]))2685 $params[$param] = $conf['upload_form_'.$type.'_'.$param];2686 }2687 2688 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');2689 2673 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2690 2674 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); … … 2706 2690 $image_path = $image['path']; 2707 2691 $thumb_path = get_thumbnail_path($image); 2708 $hd_path = get_high_path($image);2709 2692 } 2710 2693 else … … 2712 2695 $image_path = $params['image_path']; 2713 2696 $thumb_path = file_path_for_type($image_path, 'thumb'); 2714 $hd_path = file_path_for_type($image_path, 'high'); 2715 } 2716 2717 if (!is_valid_image_extension(get_extension($image_path))) 2697 } 2698 2699 if (!file_exists($image_path) or !is_valid_image_extension(get_extension($image_path))) 2718 2700 { 2719 2701 return new PwgError(403, "image can't be resized"); … … 2721 2703 2722 2704 $result = false; 2723 2724 if ($params['type'] == 'thumbnail' and file_exists($image_path)) 2725 { 2726 prepare_directory(dirname($thumb_path)); 2727 2728 $img = new pwg_image($image_path, $params['library']); 2729 2730 $result = $img->pwg_resize( 2731 $thumb_path, 2732 $params['maxwidth'], 2733 $params['maxheight'], 2734 $params['quality'], 2735 $params['automatic_rotation'], 2736 true, 2737 get_boolean($params['crop']), 2738 get_boolean($params['follow_orientation']) 2739 ); 2740 2741 $img->destroy(); 2742 } 2743 elseif (file_exists($hd_path)) 2744 { 2745 $img = new pwg_image($hd_path); 2746 2747 $result = $img->pwg_resize( 2748 $image_path, 2749 $params['maxwidth'], 2750 $params['maxheight'], 2751 $params['quality'], 2752 $params['automatic_rotation'], 2753 false 2754 ); 2755 2756 $img->destroy(); 2757 2758 if (!empty($image['has_high'])) 2759 { 2760 $conf['use_exif'] = false; 2761 $conf['use_iptc'] = false; 2762 update_metadata(array($image['id'] => $image['path'])); 2763 } 2764 } 2705 prepare_directory(dirname($thumb_path)); 2706 $img = new pwg_image($image_path, $params['library']); 2707 2708 $result = $img->pwg_resize( 2709 $thumb_path, 2710 $params['maxwidth'], 2711 $params['maxheight'], 2712 $params['quality'], 2713 false, // automatic rotation is not needed for thumbnails. 2714 true, // strip metadata 2715 get_boolean($params['crop']), 2716 get_boolean($params['follow_orientation']) 2717 ); 2718 2719 $img->destroy(); 2720 return $result; 2721 } 2722 2723 function ws_images_resizewebsize($params, &$service) 2724 { 2725 if (!is_admin()) 2726 { 2727 return new PwgError(401, 'Access denied'); 2728 } 2729 2730 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 2731 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2732 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php'); 2733 2734 $query=' 2735 SELECT id, path, tn_ext, has_high 2736 FROM '.IMAGES_TABLE.' 2737 WHERE id = '.(int)$params['image_id'].' 2738 ;'; 2739 $image = pwg_db_fetch_assoc(pwg_query($query)); 2740 2741 if ($image == null) 2742 { 2743 return new PwgError(403, "image_id not found"); 2744 } 2745 2746 $image_path = $image['path']; 2747 $hd_path = get_high_path($image); 2748 2749 if (empty($image['has_high']) or !file_exists($hd_path) or !is_valid_image_extension(get_extension($image_path))) 2750 { 2751 return new PwgError(403, "image can't be resized"); 2752 } 2753 2754 $result = false; 2755 $img = new pwg_image($hd_path); 2756 2757 $result = $img->pwg_resize( 2758 $image_path, 2759 $params['maxwidth'], 2760 $params['maxheight'], 2761 $params['quality'], 2762 $params['automatic_rotation'], 2763 false // strip metadata 2764 ); 2765 2766 $img->destroy(); 2767 2768 global $conf; 2769 $conf['use_exif'] = false; 2770 $conf['use_iptc'] = false; 2771 update_metadata(array($image['id'] => $image['path'])); 2772 2765 2773 return $result; 2766 2774 } -
trunk/ws.php
r10684 r10686 406 406 407 407 $service->addMethod( 408 'pwg.images.resize ',409 'ws_images_resize ',408 'pwg.images.resizeThumbnail', 409 'ws_images_resizethumbnail', 410 410 array( 411 411 'image_id' => array('default' => null), 412 412 'image_path' => array('default' => null), 413 'type' => array('default' => 'thumbnail'), 413 'maxwidth' => array('default' => $conf['upload_form_thumb_maxwidth']), 414 'maxheight' => array('default' => $conf['upload_form_thumb_maxheight']), 415 'quality' => array('default' => $conf['upload_form_thumb_quality']), 416 'crop' => array('default' => $conf['upload_form_thumb_crop']), 417 'follow_orientation' => array('default' => $conf['upload_form_thumb_follow_orientation']), 418 'library' => array('default' => $conf['graphics_library']), 419 ), 420 'Create/Regenerate thumbnails photo with given arguments. 421 <br>One of arguments "image_id" or "image_path" must be sent.' 422 ); 423 424 $service->addMethod( 425 'pwg.images.resizeWebsize', 426 'ws_images_resizewebsize', 427 array( 428 'image_id' => array(), 429 'maxwidth' => array('default' => $conf['upload_form_websize_maxwidth']), 430 'maxheight' => array('default' => $conf['upload_form_websize_maxheight']), 431 'quality' => array('default' => $conf['upload_form_websize_quality']), 414 432 'automatic_rotation' => array('default' => $conf['upload_form_automatic_rotation']), 415 433 'library' => array('default' => $conf['graphics_library']), 416 'maxwidth' => array('default' => null),417 'maxheight' => array('default' => null),418 'crop' => array('default' => null),419 'follow_orientation' => array('default' => null),420 'quality' => array('default' => null),421 434 ), 422 'Create/Regenerate thumbnails or websize photo with given arguments. 423 <br>One of arguments "image_id" or "image_path" must be passed filled. 424 <br>Argument "type" can be "thumbnail" or "websize". Default is "thumbnail". 425 <br>If maxwidth, maxheight, crop, follow_orientation or quality are missing, default parameters of upload will be used.' 426 ); 435 'Regenerate websize photo with given arguments.' 436 ); 427 437 428 438 $service->addMethod(
Note: See TracChangeset
for help on using the changeset viewer.