- Timestamp:
- Apr 22, 2011, 1:34:57 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r10552 r10563 557 557 } 558 558 559 $starttime = get_moment(); 559 560 $gd_info = gd_info(); 560 561 … … 646 647 647 648 // everything should be OK if we are here! 648 return true; 649 return array( 650 'source' => $source_filepath, 651 'destination' => $destination_filepath, 652 'width' => $resize_dimensions['width'], 653 'height' => $resize_dimensions['height'], 654 'size' => floor(filesize($destination_filepath) / 1024).' KB', 655 'time' => number_format((get_moment() - $starttime) * 1000, 2, '.', ' ').' ms', 656 'library' => 'GD', 657 ); 649 658 } 650 659 651 660 function pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata=false, $crop=false, $follow_orientation=true) 652 661 { 662 $starttime = get_moment(); 663 653 664 // extension of the picture filename 654 665 $extension = strtolower(get_extension($source_filepath)); … … 706 717 707 718 // everything should be OK if we are here! 708 return true; 719 return array( 720 'source' => $source_filepath, 721 'destination' => $destination_filepath, 722 'width' => $resize_dimensions['width'], 723 'height' => $resize_dimensions['height'], 724 'size' => floor(filesize($destination_filepath) / 1024).' KB', 725 'time' => number_format((get_moment() - $starttime) * 1000, 2, '.', ' ').' ms', 726 'library' => 'ImageMagick', 727 ); 709 728 } 710 729 -
trunk/include/ws_functions.inc.php
r10553 r10563 2674 2674 } 2675 2675 2676 if (empty($params['image_id']) and empty($params['image_path'])) 2677 { 2678 return new PwgError(403, "image_id or image_path is missing"); 2679 } 2680 2676 2681 $resize_params = array('maxwidth', 'maxheight', 'quality', 'crop', 'follow_orientation'); 2677 2682 $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize'; … … 2682 2687 } 2683 2688 2684 $query=' 2689 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); 2690 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2691 2692 if (!empty($params['image_id'])) 2693 { 2694 $query=' 2685 2695 SELECT id, path, tn_ext, has_high 2686 FROM '.IMAGES_TABLE.'2687 WHERE id = '.(int)$params['image_id'].'2696 FROM '.IMAGES_TABLE.' 2697 WHERE id = '.(int)$params['image_id'].' 2688 2698 ;'; 2689 $image = pwg_db_fetch_assoc(pwg_query($query)); 2690 2691 if ($image == null) 2692 { 2693 return new PwgError(403, "image_id not found"); 2694 } 2695 2696 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2697 2698 if (!is_valid_image_extension(get_extension($image['path']))) 2699 $image = pwg_db_fetch_assoc(pwg_query($query)); 2700 2701 if ($image == null) 2702 { 2703 return new PwgError(403, "image_id not found"); 2704 } 2705 2706 $image_path = $image['path']; 2707 $thumb_path = get_thumbnail_path($image); 2708 $hd_path = get_high_path($image); 2709 } 2710 else 2711 { 2712 $image_path = $params['image_path']; 2713 $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))) 2699 2718 { 2700 2719 return new PwgError(403, "image can't be resized"); 2701 2720 } 2702 2721 2703 if ($params['type'] == 'thumbnail' and !empty($image['tn_ext'])) 2704 { 2705 trigger_event( 2722 $result = false; 2723 2724 if ($params['type'] == 'thumbnail' and file_exists($image_path)) 2725 { 2726 prepare_directory(dirname($thumb_path)); 2727 2728 $result = trigger_event( 2706 2729 'upload_thumbnail_resize', 2707 2730 false, 2708 $image ['path'],2709 get_thumbnail_path($image),2731 $image_path, 2732 $thumb_path, 2710 2733 $params['maxwidth'], 2711 2734 $params['maxheight'], … … 2715 2738 get_boolean($params['follow_orientation']) 2716 2739 ); 2717 return true; 2718 } 2719 elseif (!empty($image['has_high'])) 2720 { 2721 trigger_event( 2740 } 2741 elseif (file_exists($hd_path)) 2742 { 2743 $result = trigger_event( 2722 2744 'upload_image_resize', 2723 2745 false, 2724 file_path_for_type($image['path'], 'high'),2725 $image ['path'],2746 $hd_path, 2747 $image_path, 2726 2748 $params['maxwidth'], 2727 2749 $params['maxheight'], … … 2730 2752 ); 2731 2753 2732 $conf['use_exif'] = false; 2733 $conf['use_iptc'] = false; 2734 update_metadata(array($image['id'] => $image['path'])); 2735 2736 return true; 2737 } 2738 return false; 2754 if (!empty($image['has_high'])) 2755 { 2756 $conf['use_exif'] = false; 2757 $conf['use_iptc'] = false; 2758 update_metadata(array($image['id'] => $image['path'])); 2759 } 2760 } 2761 return $result; 2739 2762 } 2740 2763 -
trunk/ws.php
r10553 r10563 409 409 'ws_images_resize', 410 410 array( 411 'image_id' => array(), 411 'image_id' => array('default' => null), 412 'image_path' => array('default' => null), 412 413 'type' => array('default' => 'thumbnail'), 413 414 'maxwidth' => array('default' => null), … … 417 418 'quality' => array('default' => null), 418 419 ), 419 'Regenerate thumbnails or websize photo with given arguments. 420 'Create/Regenerate thumbnails or websize photo with given arguments. 421 <br>One of arguments "image_id" or "image_path" must be passed filled. 420 422 <br>Argument "type" can be "thumbnail" or "websize". Default is "thumbnail". 421 423 <br>If maxwidth, maxheight, crop, follow_orientation or quality are missing, default parameters of upload will be used.'
Note: See TracChangeset
for help on using the changeset viewer.