forked from ZwiiCMS-Team/ZwiiCMS
[10.0.060] Optimisation du code de création des images mini
This commit is contained in:
parent
6eb697e427
commit
a3d0f7ac71
@ -37,7 +37,7 @@ class common {
|
|||||||
const THUMBS_WIDTH = 320;
|
const THUMBS_WIDTH = 320;
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '10.0.059';
|
const ZWII_VERSION = '10.0.060';
|
||||||
const ZWII_UPDATE_CHANNEL = "v10";
|
const ZWII_UPDATE_CHANNEL = "v10";
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
@ -799,37 +799,42 @@ class common {
|
|||||||
if (!is_dir($path['dirname'])) {
|
if (!is_dir($path['dirname'])) {
|
||||||
mkdir($path['dirname']);
|
mkdir($path['dirname']);
|
||||||
}
|
}
|
||||||
// Image jpeg
|
|
||||||
if (mime_content_type($src) === 'image/jpeg' ) {
|
|
||||||
if ($source_image = imagecreatefromjpeg($src)) {
|
|
||||||
$width = imagesx($source_image);
|
|
||||||
$height = imagesy($source_image);
|
|
||||||
/* find the "desired height" of this thumbnail, relative to the desired width */
|
|
||||||
$desired_height = floor($height * ($desired_width / $width));
|
|
||||||
/* create a new, "virtual" image */
|
|
||||||
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
|
||||||
/* copy source image at a resized size */
|
|
||||||
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
|
||||||
/* create the physical thumbnail image to its destination */
|
|
||||||
return (imagejpeg($virtual_image, $dest));
|
|
||||||
|
|
||||||
}
|
switch(mime_content_type($src) ) {
|
||||||
|
case 'image/jpeg':
|
||||||
|
case 'image/jpg':
|
||||||
|
$source_image = imagecreatefromjpeg($src);
|
||||||
|
break;
|
||||||
|
case 'image/png':
|
||||||
|
$source_image = imagecreatefrompng($src);
|
||||||
|
break;
|
||||||
|
case 'image/gif':
|
||||||
|
$source_image = imagecreatefromgif($src);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// image png
|
|
||||||
if ( mime_content_type($src) === 'image/png' ) {
|
if ($source_image) {
|
||||||
/* read the source image */
|
$width = imagesx($source_image);
|
||||||
if ($source_image = imagecreatefrompng($src)) {;
|
$height = imagesy($source_image);
|
||||||
$width = imagesx($source_image);
|
/* find the "desired height" of this thumbnail, relative to the desired width */
|
||||||
$height = imagesy($source_image);
|
$desired_height = floor($height * ($desired_width / $width));
|
||||||
/* find the "desired height" of this thumbnail, relative to the desired width */
|
/* create a new, "virtual" image */
|
||||||
$desired_height = floor($height * ($desired_width / $width));
|
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
||||||
/* create a new, "virtual" image */
|
/* copy source image at a resized size */
|
||||||
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
|
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
||||||
/* copy source image at a resized size */
|
switch(mime_content_type($src) ) {
|
||||||
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
|
case 'image/jpeg':
|
||||||
/* create the physical thumbnail image to its destination */
|
case 'image/jpg':
|
||||||
return (imagepng($virtual_image, $dest));
|
return (imagejpeg($virtual_image, $dest));
|
||||||
|
break;
|
||||||
|
case 'image/png':
|
||||||
|
return (imagepng($virtual_image, $dest));
|
||||||
|
break;
|
||||||
|
case 'image/gif':
|
||||||
|
return (imagegif($virtual_image, $dest));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user