Commit c4f1c0fa authored by zefling's avatar zefling
Browse files

Mise à jour

parent 404774b6
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -274,3 +274,17 @@ function numerique($nom, array $nombreChiffre, array $nombre) {
	return $nom;
}


/**
 * version unicode de pathinfo
 * @param string $filepath chemin
 * @return $tableau d'infos
 */
function mb_pathinfo($filepath) {
    preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$filepath,$m);
    if($m[1]) $r['dirname']   = $m[1];
    if($m[2]) $r['basename']  = $m[2];
    if($m[5]) $r['extension'] = $m[5];
    if($m[3]) $r['filename']  = $m[3];
    return $r;
}
 No newline at end of file
+24 −15
Original line number Diff line number Diff line
@@ -69,12 +69,13 @@ class Image {
        $this->nom = $nom;
		
        $info = getimagesize((!empty($dossier) ? $dossier.DIRECTORY_SEPARATOR : '').$nom);
      
		$this->width_source  = $this->width_cible  = $info[0];
        $this->height_source = $this->height_cible = $info[1];
        $this->type          = $this->types[$info[2]];
		$this->mime          = $info['mime']; 
        
		$info = pathinfo((!empty($dossier) ? $dossier.DIRECTORY_SEPARATOR : '').$nom);
		$info = mb_pathinfo((!empty($dossier) ? $dossier.DIRECTORY_SEPARATOR : '').$nom);
        $this->dir_source      = $this->dir_cible      = $info['dirname'];
        $this->nom_base_source = $this->nom_base_cible = $info['filename'];
		$this->nom_ext_source  = $this->nom_ext_cible  = $info['extension'];
@@ -225,7 +226,7 @@ class Image {
	}
	
	public function sauver () {
		$this->generer($this->adresse_finale());
		return $this->generer($this->adresse_finale());
	}
    
	private function adresse_finale() {
@@ -239,11 +240,13 @@ class Image {
    private function generer($nom) {
				
		$image = null;
		$cible = $this->dir_source.DIRECTORY_SEPARATOR.$this->nom_base_source.'.'.$this->nom_ext_source;
		
		switch ($this->mime) {
			case 'image/jpeg' : 
			case 'image/pjpeg': $image = imagecreatefromjpeg($this->dir_source.DIRECTORY_SEPARATOR.$this->nom_base_source.'.'.$this->nom_ext_source); break;
			case 'image/png'  : $image = imagecreatefrompng ($this->dir_source.DIRECTORY_SEPARATOR.$this->nom_base_source.'.'.$this->nom_ext_source); break;
			case 'image/gif'  : $image = imagecreatefromgif ($this->dir_source.DIRECTORY_SEPARATOR.$this->nom_base_source.'.'.$this->nom_ext_source); break;
			case 'image/pjpeg': $image = imagecreatefromjpeg($cible); break;
			case 'image/png'  : $image = imagecreatefrompng ($cible); break;
			case 'image/gif'  : $image = imagecreatefromgif ($cible); break;
		}
		
		if($image != null) {
@@ -288,6 +291,7 @@ class Image {
				
			if ($dim_width > 0 && $dim_height > 0) {
				$dest = imagecreatetruecolor($dim_width, $dim_height);
				//imageinterlace ($dest);
				
				if ($this->width_cible != $this->height_cible || $this->width_source != $this->height_source || ($this->width_decoupe > 0 && $this->height_decoupe > 0)) {
					// redimensionner
@@ -300,6 +304,7 @@ class Image {
					);
				}
				
				try {
					switch (strtolower($this->nom_ext_cible)) {
						case 'jpeg' :
						case 'jpg'  : imagejpeg($dest, $nom, $this->qualite); break;
@@ -308,7 +313,11 @@ class Image {
					}
					imagedestroy($image);
					imagedestroy($dest);
				return true;
				} catch (Exception $e) {
					return false;
				}
				
				return is_file($cible);
			} else {
				return false;
			}
+5 −2
Original line number Diff line number Diff line
@@ -7,9 +7,12 @@ Licence : voir Licence.txt

########################################################################################################
*/
ini_set('memory_limit',       '256M');
ini_set('memory_limit',       '512M');
ini_set('magic_quotes_gpc',   0);
ini_set('max_execution_time', 6000);
ini_set('max_execution_time', 10000);
ini_set('display_errors',1);
error_reporting(E_ALL);
date_default_timezone_set('Europe/Paris');

/** ********************************************************************************************************************** /
* retroune le temps en microseconde
+8 −3
Original line number Diff line number Diff line
@@ -345,7 +345,8 @@ else {
			
			// sauvegarde de l'image finale
			
			$info = pathinfo($cache[$key]['chemin']);			
			$info = mb_pathinfo($cache[$key]['chemin']);
						
			$img = new Image ($info['filename'].'.'.$info['extension'], $info['dirname']);
			$img->dir_cible(_DIR_RENDU);
			
@@ -381,7 +382,9 @@ else {
				
				$img->ext_cible($format_img);
				$img->nom_cible($nom_format);
				$img->sauver();
				if (!$img->sauver()) {
					break;
				}
			}

			$stats_info[$i]['grande'][1] = get_microtime();
@@ -409,7 +412,9 @@ else {
				if ($miniature_format == '') $miniature_format = $format_img;
				$img->ext_cible($miniature_format);
				
				$img->sauver();
				if (!$img->sauver()) {
					break;
				}
				
				$stats_info[$i]['mini'][1] = get_microtime();
			}