Version 4.3.2
This commit is contained in:
parent
0399cb07fb
commit
ed74256a6f
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
setlocale(LC_NUMERIC,'English','en_US','en_US.UTF-8');
|
||||
class album extends common {
|
||||
const VERSION = '4.0';
|
||||
const VERSION = '4.3.2';
|
||||
const REALNAME = 'Album Photo';
|
||||
const DELETE = true;
|
||||
const UPDATE = '0.0';
|
||||
|
@ -15,15 +15,10 @@ class album extends common {
|
|||
const SORT_HAND = 'SORT_HAND';
|
||||
|
||||
public static $directories = [];
|
||||
|
||||
public static $firstPictures = [];
|
||||
|
||||
public static $galleries = [];
|
||||
|
||||
public static $galleriesId = [];
|
||||
|
||||
public static $pictures = [];
|
||||
|
||||
public static $picturesId = [];
|
||||
|
||||
public static $actions = [
|
||||
|
@ -529,6 +524,7 @@ class albumHelper extends helper {
|
|||
else { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
// relevés exif gps des photos
|
||||
public static function gps_exif($foto) {
|
||||
if (!preg_match('/(\.jpe?g)$/i', $foto)) {
|
||||
|
@ -572,26 +568,43 @@ class albumHelper extends helper {
|
|||
$sign = ($hemisphere == 'W' || $hemisphere == 'S') ? -1 : 1;
|
||||
return $sign * ($degrees + $minutes/60 + $seconds/3600);
|
||||
}
|
||||
|
||||
// formatage light des noms d'images
|
||||
public static function formate($foto) {
|
||||
$foto = trim($foto);
|
||||
$foto = preg_replace('/[^[:alnum:]_.\-\/]/', '', $foto);
|
||||
return $foto;
|
||||
}
|
||||
// reorientation
|
||||
}
|
||||
|
||||
// renommage des fichiers transformés
|
||||
public static function renamePic($foto) {
|
||||
$imor = basename($foto);
|
||||
$extension = strrchr($imor,'.');
|
||||
$namimor = str_replace($extension,'',$imor);
|
||||
$redimg = dirname($foto).'/'.$namimor.'_t960.jpg';
|
||||
return $redimg;
|
||||
}
|
||||
|
||||
// backup des images réorientées ou redimensionnées
|
||||
public static function backUp($foto) {
|
||||
$backup = dirname($foto).'/backup';
|
||||
self::makeDir($backup);
|
||||
$backimg = $backup.'/'.strtolower(str_replace('.jpeg','.jpg',basename($foto)));
|
||||
rename($foto,$backimg);
|
||||
}
|
||||
|
||||
// réorientation
|
||||
public static function reorientation($foto) {
|
||||
$size = @getimagesize($foto);
|
||||
$mime = $size['mime'];
|
||||
if ((function_exists('exif_read_data')) && ($mime == 'image/jpeg'))
|
||||
{
|
||||
// seules les images/jpeg sont réorientées
|
||||
if ((function_exists('exif_read_data')) && ($mime == 'image/jpeg')) {
|
||||
$exif = @exif_read_data($foto);
|
||||
$image = imagecreatefromstring(file_get_contents($foto));
|
||||
if ($image !== false) {
|
||||
$orientation = isset($exif['Orientation']) === true ? $exif['Orientation'] : '';
|
||||
if ( (!empty($orientation)) && ($orientation != 1) )
|
||||
{
|
||||
switch($orientation)
|
||||
{
|
||||
if ( (!empty($orientation)) && ($orientation != 1) ) {
|
||||
switch($orientation) {
|
||||
case 3:
|
||||
$image = imagerotate($image,180,0);
|
||||
break;
|
||||
|
@ -602,28 +615,24 @@ class albumHelper extends helper {
|
|||
$image = imagerotate($image,90,0);
|
||||
break;
|
||||
}
|
||||
imagejpeg($image, $foto, 90);
|
||||
}
|
||||
imagejpeg($image, self::renamePic($foto), 80);
|
||||
self::backUp($foto);
|
||||
echo '<script>document.location.reload(false);</script>';
|
||||
exit('Réorientation des photos...');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// redimension
|
||||
public static function redimension($foto) {
|
||||
$max_size = 960;// ex1280 dimension du plus petit côté
|
||||
$max_size = 960;// dimension du plus petit côté
|
||||
$infoto = @getimagesize($foto);
|
||||
$large = $infoto[0];
|
||||
$haut = $infoto[1];
|
||||
$type = $infoto[2];
|
||||
// seules les images/jpeg sont redimensionnées
|
||||
if (($type == 2) && ($large > $max_size) && ($haut > $max_size)) {
|
||||
$imar = substr(strrchr($foto, '/'), 1);
|
||||
$urlimar = str_replace($imar,'',$foto);
|
||||
$backup = $urlimar.'backup';
|
||||
self::makeDir($backup);
|
||||
$extension = strrchr($imar,'.');
|
||||
$namimar = str_replace($extension,'',$imar);
|
||||
$redimg = $urlimar.$namimar.'_t960.jpg';
|
||||
$backimg = $backup.'/'.strtolower(str_replace('.jpeg','.jpg',$imar));
|
||||
$src = imagecreatefromjpeg($foto);
|
||||
imageinterlace($src, true);
|
||||
if ($large > $haut) {
|
||||
|
@ -633,18 +642,23 @@ class albumHelper extends helper {
|
|||
$im = imagecreatetruecolor($max_size, round(($max_size/$large)*$haut));
|
||||
imagecopyresampled($im, $src, 0, 0, 0, 0, $max_size, round($haut*($max_size/$large)), $large, $haut);
|
||||
}
|
||||
imagejpeg($im, $redimg, 80);
|
||||
imagedestroy($im);
|
||||
rename($foto,$backimg);
|
||||
if (strpos($foto, 't960.') == false) {
|
||||
imagejpeg($im, self::renamePic($foto), 80);
|
||||
imagedestroy($im);
|
||||
self::backUp($foto);
|
||||
} else {
|
||||
imagejpeg($im, $foto, 80);
|
||||
imagedestroy($im);
|
||||
}
|
||||
echo '<script>document.location.reload(false);</script>';
|
||||
exit(0);
|
||||
exit('Redimension des photos...');
|
||||
}
|
||||
}
|
||||
|
||||
// contrôle des photos
|
||||
public static function controle($foto) {
|
||||
$tn_tmp = substr(strrchr($foto, '/'), 1);
|
||||
$url_picture = str_replace('/'.$tn_tmp,'',$foto);
|
||||
$minidos = substr(strrchr($url_picture, '/'), 1);
|
||||
$tn_tmp = basename($foto);
|
||||
$minidos = substr(strrchr(dirname($foto), '/'), 1);
|
||||
$mini = 'site/file/cache/'.$minidos.'/'.$tn_tmp;
|
||||
if (!file_exists($mini)) {
|
||||
$valid = array('-', '_','.');
|
||||
|
@ -652,7 +666,7 @@ class albumHelper extends helper {
|
|||
$nommage = self::formate($foto);
|
||||
$foto = rename($foto,$nommage);
|
||||
echo '<script>document.location.reload(false);</script>';
|
||||
exit(0);
|
||||
exit('Renommage des photos...');
|
||||
} else {
|
||||
self::reorientation($foto);
|
||||
self::redimension($foto);
|
||||
|
@ -661,6 +675,7 @@ class albumHelper extends helper {
|
|||
return $foto;
|
||||
clearstatcache();
|
||||
}
|
||||
|
||||
// Thumbnailer
|
||||
public static function makeThumbnail($foto) {
|
||||
if ( is_file($foto) && substr(mime_content_type($foto), 0, 5) == 'image' ) {
|
||||
|
@ -671,9 +686,8 @@ class albumHelper extends helper {
|
|||
$size_img = filesize($foto);
|
||||
$dossiercache = 'site/file/cache';
|
||||
self::makeDir($dossiercache);
|
||||
$par = substr(strrchr($foto, '/'), 1);
|
||||
$url_par = str_replace('/'.$par,'',$foto);
|
||||
$cache = substr(strrchr($url_par, '/'), 1);
|
||||
$par = basename($foto);
|
||||
$cache = substr(strrchr(dirname($foto), '/'), 1);
|
||||
self::makeDir($dossiercache.'/'.$cache);
|
||||
$extension = strrchr($par,'.');
|
||||
$vignette = str_replace($extension,'',$par);
|
||||
|
@ -682,14 +696,12 @@ class albumHelper extends helper {
|
|||
if (!file_exists($miniature)) {
|
||||
list($width, $height, $type, $attr) = getimagesize($foto);
|
||||
|
||||
if ($height > $tnhaut)
|
||||
{
|
||||
if ($height > $tnhaut) {
|
||||
$convert = $tnhaut/$height;
|
||||
$height = $tnhaut;
|
||||
$width = ceil($width*$convert);
|
||||
}
|
||||
if ($width > $tnlarge)
|
||||
{
|
||||
if ($width > $tnlarge) {
|
||||
$convert = $tnlarge/$width;
|
||||
$width = $tnlarge;
|
||||
$height = ceil($height*$convert);
|
||||
|
@ -698,25 +710,21 @@ class albumHelper extends helper {
|
|||
$largeur = $width;
|
||||
$hauteur = $height;
|
||||
|
||||
if($type == 1)
|
||||
{
|
||||
if($type == 1) {
|
||||
$img_in = imagecreatefromgif($foto);
|
||||
}
|
||||
elseif($type == 2)
|
||||
{
|
||||
elseif($type == 2) {
|
||||
$img_in = imagecreatefromjpeg($foto);
|
||||
}
|
||||
elseif($type == 3)
|
||||
{
|
||||
elseif($type == 3) {
|
||||
$img_in = imagecreatefrompng($foto);
|
||||
}
|
||||
elseif($type == 18)
|
||||
{
|
||||
elseif($type == 18) {
|
||||
$img_in = imagecreatefromwebp($foto);
|
||||
}
|
||||
imageinterlace($img_in, true);
|
||||
|
||||
$img_out = imagecreatetruecolor($largeur, $hauteur) or die ('Impossible de créer un flux d\'image GD');
|
||||
$img_out = imagecreatetruecolor($largeur, $hauteur) or die ('Unable to create a GD image stream');
|
||||
imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
|
||||
|
||||
imagewebp($img_out, $miniature, 80);
|
||||
|
@ -725,8 +733,7 @@ class albumHelper extends helper {
|
|||
return $miniature;
|
||||
clearstatcache();
|
||||
}
|
||||
else {echo 'This is not an image';}
|
||||
else { die ('This is not an image'); }
|
||||
} // makeThumbnail
|
||||
|
||||
} // albumHelper
|
||||
|
||||
|
|
Loading…
Reference in New Issue