14 if (!defined(
'IN_PEEL')) {
33 function image_resize($origin_filename_with_path, $new_filename_with_path, $destinationW = null, $destinationH = null, $resize_even_if_smaller =
false, $allow_keep_origin_file_if_resize_not_needed =
true, $filesize_limit_keep_origin_file = 102400, $jpeg_quality = 85, $gammacorrect = 1.0)
35 $origin_file_extension = pathinfo($origin_filename_with_path, PATHINFO_EXTENSION);
36 if (
String::strtolower($origin_file_extension) ===
'png' && function_exists(
'imagecreatefrompng')) {
37 $source = @imagecreatefrompng($origin_filename_with_path);
39 $source = @imagecreatefromgif($origin_filename_with_path);
41 if (empty($source) && function_exists(
'imagecreatefromjpeg')) {
43 $source = @imagecreatefromjpeg($origin_filename_with_path);
45 $source = @imagecreatefrompng($origin_filename_with_path);
51 $sourceW = @imagesx($source);
52 $sourceH = @imagesy($source);
53 if (empty($sourceW) || empty($sourceH)) {
59 if ((!empty($destinationW) && $sourceW * $default_zoom > $destinationW) || (!empty($destinationH) && $sourceH * $default_zoom > $destinationH) || ((!empty($destinationW) || !empty($destinationH)) && $resize_even_if_smaller)) {
60 if(empty($destinationW)){
61 $destinationW = $sourceW;
63 if(empty($destinationH)){
64 $destinationH = $sourceH;
66 if ($sourceH * $destinationW > $destinationH * $sourceW) {
68 $destinationW = ($sourceW * $destinationH) / $sourceH;
70 $destinationH = ($sourceH * $destinationW) / $sourceW;
73 $destinationW = $sourceW * $default_zoom;
74 $destinationH = $sourceH * $default_zoom;
76 if ($destinationW != $sourceW || $destinationH != $sourceH || !$allow_keep_origin_file_if_resize_not_needed || filesize($origin_filename_with_path) > $filesize_limit_keep_origin_file || abs(1-$gammacorrect)>=0.1) {
78 $im = imagecreatetruecolor($destinationW, $destinationH);
80 $bg = imagecolorallocate($im, 255, 255, 255);
81 imagefill($im, 0, 0, $bg);
83 imagecopyresampled($im, $source, 0, 0, 0, 0, $destinationW, $destinationH, $sourceW, $sourceH);
84 imagedestroy($source);
85 if (abs(1-$gammacorrect)>=0.1) {
86 imagegammacorrect ($im, 1.0, $gammacorrect);
88 if (!imagejpeg($im, $new_filename_with_path, $jpeg_quality)) {
92 if ($new_filename_with_path != $origin_filename_with_path) {
93 unlink($origin_filename_with_path);
95 return $new_filename_with_path;
97 imagedestroy($source);
98 return $origin_filename_with_path;
static strtolower($string)
Returns string with all alphabetic characters converted to lowercase.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
if(!defined('IN_PEEL')) image_resize($origin_filename_with_path, $new_filename_with_path, $destinationW=null, $destinationH=null, $resize_even_if_smaller=false, $allow_keep_origin_file_if_resize_not_needed=true, $filesize_limit_keep_origin_file=102400, $jpeg_quality=85, $gammacorrect=1.0)
On redimensionne l'image pour qu'elle ne dépasse pas la taille de destination Le ratio largeur / haut...