file = $file; if (!file_exists($this->file)) { echo 'ERROR : File does not exist!'; } else { //substr(strtolower($this->file), 0, -4) // $this->base_name = basename($this->file, substr(strtolower($this->file), -4)); // $this->base_name = substr(strtolower($this->file), -4); $this->fname = basename($this->file); $this->ext = strtolower(substr($this->fname, strrpos($this->fname, ".")+1)); $this->base_name = substr($this->fname, 0, strrpos($this->fname, ".")); // $this->base_name = str_replace($this->ext, "", basename($this->file)); // echo "EXT = ".$this->ext."
"; // echo "FNAME = ".$this->fname."
"; // echo "BASENAME = ".$this->base_name."
"; // $this->ext = substr(strtolower(basename($this->file)), -3); $this->size = getimagesize($this->file); // Get the image dimensions and mime type $this->quality = 80; // GET SRC switch ($this->ext) { case 'jpg': $this->SRC = imagecreatefromjpeg($this->file); break; case 'png': $this->SRC = imagecreatefrompng($this->file); break; case 'gif': $this->SRC = imagecreatefromgif($this->file); break; } // $w = $size[0] / $scale; // Width divided // $h = $size[1] / $scale; // Height divided } } Function Resize($width, $height) { /* // Cacul des nouvelles dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } */ $this->DST = imagecreatetruecolor($width, $height); // Create a blank image imagecopyresampled($this->DST, $this->SRC, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1]); // Resample the original } Function ResizeOmni($width, $height) { $this->DST = imagecreatetruecolor($width, $height); // Create a blank image imagecopyresampled($this->DST, $this->SRC, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1]); // Resample the original } Function WriteFile($path, $addstring='') { // echo "Writing image : ".$path.$this->base_name.$addstring.$this->ext."
"; switch ($this->ext) { case 'jpg': $f_name = $this->base_name.$addstring.".jpg"; imagejpeg($this->DST, $path.$f_name, $this->quality); break; case 'png': $f_name = $this->base_name.$addstring.".png"; imagepng($this->DST, $path.$f_name); break; case 'gif': $f_name = $this->base_name.$addstring.".gif"; imagegif($this->DST, $path.$f_name); break; } Return $f_name; } } ?>