| @@ 918-949 (lines=32) @@ | ||
| 915 | * |
|
| 916 | * @return bool |
|
| 917 | */ |
|
| 918 | public static function resizePicture( |
|
| 919 | $src_path, |
|
| 920 | $dst_path, |
|
| 921 | $param_width, |
|
| 922 | $param_height, |
|
| 923 | $keep_original = false, |
|
| 924 | $fit = 'inside' |
|
| 925 | ) { |
|
| 926 | // require_once XOOPS_PATH . '/vendor/wideimage/WideImage.php'; |
|
| 927 | $resize = true; |
|
| 928 | $pictureDimensions = getimagesize($src_path); |
|
| 929 | if (is_array($pictureDimensions)) { |
|
| 930 | $pictureWidth = $pictureDimensions[0]; |
|
| 931 | $pictureHeight = $pictureDimensions[1]; |
|
| 932 | if ($pictureWidth < $param_width && $pictureHeight < $param_height) { |
|
| 933 | $resize = false; |
|
| 934 | } |
|
| 935 | } |
|
| 936 | ||
| 937 | $img = WideImage::load($src_path); |
|
| 938 | if ($resize) { |
|
| 939 | $result = $img->resize($param_width, $param_height, $fit); |
|
| 940 | $result->saveToFile($dst_path); |
|
| 941 | } else { |
|
| 942 | @copy($src_path, $dst_path); |
|
| 943 | } |
|
| 944 | if (!$keep_original) { |
|
| 945 | @unlink($src_path); |
|
| 946 | } |
|
| 947 | ||
| 948 | return true; |
|
| 949 | } |
|
| 950 | } |
|
| 951 | ||
| @@ 796-827 (lines=32) @@ | ||
| 793 | * |
|
| 794 | * @return bool |
|
| 795 | */ |
|
| 796 | function news_resizePicture( |
|
| 797 | $src_path, |
|
| 798 | $dst_path, |
|
| 799 | $param_width, |
|
| 800 | $param_height, |
|
| 801 | $keep_original = false, |
|
| 802 | $fit = 'inside' |
|
| 803 | ) { |
|
| 804 | // require_once XOOPS_PATH . '/vendor/wideimage/WideImage.php'; |
|
| 805 | $resize = true; |
|
| 806 | $pictureDimensions = getimagesize($src_path); |
|
| 807 | if (is_array($pictureDimensions)) { |
|
| 808 | $pictureWidth = $pictureDimensions[0]; |
|
| 809 | $pictureHeight = $pictureDimensions[1]; |
|
| 810 | if ($pictureWidth < $param_width && $pictureHeight < $param_height) { |
|
| 811 | $resize = false; |
|
| 812 | } |
|
| 813 | } |
|
| 814 | ||
| 815 | $img = WideImage::load($src_path); |
|
| 816 | if ($resize) { |
|
| 817 | $result = $img->resize($param_width, $param_height, $fit); |
|
| 818 | $result->saveToFile($dst_path); |
|
| 819 | } else { |
|
| 820 | @copy($src_path, $dst_path); |
|
| 821 | } |
|
| 822 | if (!$keep_original) { |
|
| 823 | @unlink($src_path); |
|
| 824 | } |
|
| 825 | ||
| 826 | return true; |
|
| 827 | } |
|
| 828 | ||