1,4 → 1,20 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe de manipulation des fichiers images JPEG. |
* |
* @internal Mininum PHP version : 5.2 |
* @category CEL |
* @package Services |
* @subpackage Bibliothèques |
* @version 0.1 |
* @author Mathias CHOUET <mathias@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @author Aurelien PERONNET <aurelien@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org> |
*/ |
Class ImageRecreation { |
|
private $droits = 0755; |
54,7 → 70,6 |
foreach ($this->formats as $format) { |
$this->creerEtStockerMiniatureFichierImageSelonFormat($id, $infos_image_originale, $format); |
}; |
|
} |
} |
|
123,7 → 138,6 |
if ($format == 'O') { |
// format original : rien à faire |
$image_redimensionnee = $infos_image_originale['image']; |
|
} else { |
if ($this->estUnFormatRogne($format)) { |
if ($this->mode == self::MODE_IMAGEMAGICK) { |
144,7 → 158,6 |
$image_redimensionnee = $this->creerMiniature($infos_image_originale, $format); |
} |
} |
|
return $image_redimensionnee; |
} |
|
186,7 → 199,6 |
} |
|
public function stockerFichierEtCreerMiniatures($fichier, $id) { |
|
$infos_image_originale_stockee = $this->stockerFichierOriginal($fichier, $id); |
if($infos_image_originale_stockee) { |
$formats = $this->getFormats(); |
200,16 → 212,13 |
$this->logger('CEL_bugs',$erreur); |
return false ; |
} |
|
return true ; |
} |
|
public function creerEtStockerMiniatureFichierImageSelonFormat($id ,$infos_image_originale, $format = 'O') { |
$image_redimensionnee = $this->creerMiniatureImageSelonFormat($infos_image_originale, $format); |
|
$taux_compression = $this->renvoyerTauxCompressionPourPoids($infos_image_originale['poids_octets']); |
$this->ecrireImageSurDisque($image_redimensionnee, $id, $format, $taux_compression); |
|
return true; |
} |
|
225,7 → 234,6 |
$infos_image_originale['largeur'], |
$infos_image_originale['hauteur'] |
); |
|
return $image_redimensionnee; |
} |
|
475,7 → 483,6 |
foreach($formats as $format) { |
$nom_fichier_sans_extension = trim($nom_fichier_sans_extension, '_'.$format); |
} |
|
$id_image = str_replace('_', '', $nom_fichier_sans_extension); |
|
// suppression des 0 devant |
503,7 → 510,7 |
$img = new Imagick($chemin_image_a_stocker); |
|
// l'utilisation d'image magick préserve les métadonnées lors d'une recompression |
$img->setformat("jpeg"); |
$img->setformat('jpeg'); |
$img->setImageCompression(imagick::COMPRESSION_JPEG); |
$img->setCompressionQuality($compression); |
$img->writeImage($chemin_image_a_stocker); |
516,7 → 523,6 |
$image_blanche = imagecreatetruecolor($cote, $cote); |
$blanc = imagecolorallocate($image_blanche, 255, 255, 255); |
imagefilledrectangle($image_blanche, 0, 0, $cote, $cote, $blanc); |
|
return $image_blanche; |
} |
|
592,9 → 598,6 |
|
$chemin_image = $informations_image['chemin']; |
|
//if ($largeur_vignette > $largeur_image_originale || $hauteur_vignette > $hauteur_image_originale) |
// die("Target dimensions must be smaller or equal to source dimensions."); |
|
// parameters for the edge-maximizing crop algorithm |
$r = 1; // radius of edge filter |
$nk = 9; // scale count: number of crop sizes to try |
679,20 → 682,6 |
if ($ycrop < 0) $ycrop = 0; |
if ($ycrop+$hcrop > $hauteur_image_originale) $ycrop = $hauteur_image_originale-$hcrop; |
|
/*if (self::MODE_DEBUG) { |
// debug |
$currfile = '/home/aurelien/web/file_tmp/'."image$k.jpg"; |
|
$currimg = clone $img; |
$c= new ImagickDraw(); |
$c->setFillColor("red"); |
$c->circle($xcenter, $ycenter, $xcenter, $ycenter+4); |
$currimg->drawImage($c); |
$currimg->cropImage($wcrop, $hcrop, $xcrop, $ycrop); |
$currimg->writeImage($currfile); |
$currimg->destroy(); |
}*/ |
|
$beta = 0; |
for ($c=0; $c<$n; $c++) { |
$i = mt_rand(0,$wcrop-1); |
737,5 → 726,4 |
|
return $image_sortie; |
} |
} |
?> |
} |