/* *************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
- * Copyright (c) 2001-2012 *
+ * Copyright (c) 2001-2014 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
} else {
// enlever le timestamp eventuel
$source=preg_replace(',[?][0-9]+$,','',$source);
+ if (strpos($source,"?")!==false
+ AND strncmp($source,_DIR_IMG,strlen(_DIR_IMG))==0
+ AND file_exists($f=preg_replace(',[?].*$,','',$source))){
+ $source = $f;
+ }
$fichier = $source;
}
* Une ressource de type Image GD.
* @param string $fichier
* Le path vers l'image (ex : local/cache-vignettes/L180xH51/image.jpg).
- * @param string $qualite
+ * @param int $qualite
* Le niveau de qualité du fichier résultant : de 0 (pire qualité, petit
* fichier) à 100 (meilleure qualité, gros fichier). Par défaut, prend la
* valeur (85) de la constante _IMG_GD_QUALITE (modifiable depuis
* @param array $valeurs
* Un tableau des informations (tailles, traitement, path...) accompagnant
* l'image.
- * @param string $qualite
+ * @param int $qualite
* N'est utilisé que pour les images jpg.
* Le niveau de qualité du fichier résultant : de 0 (pire qualité, petit
* fichier) à 100 (meilleure qualité, gros fichier). Par défaut, prend la
}
// Transforme une image a palette indexee (256 couleurs max) en "vraies" couleurs RGB
+// Existe seulement pour compatibilite avec PHP < 5.5
// http://doc.spip.org/@imagepalettetotruecolor
- function imagepalettetotruecolor(&$img) {
+if (!function_exists("imagepalettetotruecolor")) {
+function imagepalettetotruecolor(&$img) {
if ($img AND !imageistruecolor($img) AND function_exists('imagecreatetruecolor')) {
$w = imagesx($img);
$h = imagesy($img);
$img = $img1;
}
}
+}
// http://doc.spip.org/@image_tag_changer_taille
function _image_tag_changer_taille($tag,$width,$height,$style=false){
else
// imagick (php4-imagemagick)
if ($process == 'imagick') {
+
$vignette = "$destination.".$format_sortie;
- $handle = imagick_readimage($image);
- imagick_resize($handle, $destWidth, $destHeight, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
- imagick_write($handle, $vignette);
+
+ $imagick = new Imagick();
+ $imagick->readImage($image);
+ $imagick->resizeImage($destWidth, $destHeight, Imagick::FILTER_LANCZOS, 1 );//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
+ $imagick->writeImage($vignette);
+
if (!@file_exists($vignette)) {
spip_log("echec imagick sur $vignette");
return;
return $img;
}
-//
-// Produire des fichiers au format .ico
-// avec du code recupere de :
-//
-//////////////////////////////////////////////////////////////
-/// phpThumb() by James Heinrich <info@silisoftware.com> //
-// available at http://phpthumb.sourceforge.net ///
-//////////////////////////////////////////////////////////////
+/**
+ * Produire des fichiers au format .ico
+ * avec du code recupere de :
+ * phpThumb() by James Heinrich <info@silisoftware.com>
+ * available at http://phpthumb.sourceforge.net
+ *
+ * Class phpthumb_functions
+ */
class phpthumb_functions {
-// http://doc.spip.org/@GetPixelColor
- function GetPixelColor(&$img, $x, $y) {
+
+ /**
+ * @param ressource $img
+ * @param int $x
+ * @param int $y
+ * @return array|bool
+ */
+ public static function GetPixelColor(&$img, $x, $y) {
if (!is_resource($img)) {
return false;
}
return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
}
-// http://doc.spip.org/@LittleEndian2String
- function LittleEndian2String($number, $minbytes=1) {
+
+ /**
+ * @param int $number
+ * @param int $minbytes
+ * @return string
+ */
+ public static function LittleEndian2String($number, $minbytes=1) {
$intstring = '';
while ($number > 0) {
$intstring = $intstring.chr($number & 255);
}
return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
}
-// http://doc.spip.org/@GD2ICOstring
- function GD2ICOstring(&$gd_image_array) {
+
+ /**
+ * @param array $gd_image_array
+ * @return string
+ */
+ public static function GD2ICOstring(&$gd_image_array) {
foreach ($gd_image_array as $key => $gd_image) {
$ImageWidths[$key] = ImageSX($gd_image);