/**
  * Get cleaned file name
  * 
  * @param string $path
  * @return null|string
  */
 public function getNormalizedFileName($path)
 {
     if ($path != '') {
         $name = pathinfo($path, PATHINFO_FILENAME);
         return StringMethods::removeDiacriticalMarks(str_replace('.', '_', str_replace(' ', '_', $name)));
     } else {
         return null;
     }
 }
 /**
  * Save an image
  * The resulting format will be determined by the file extension.
  *
  * @param null|string	$filename	If omitted - original file will be overwritten
  * @param null|int		$quality	Output image quality in percents 0-100
  * @return Image
  * @throws Exception
  */
 public function save($filename = null, $quality = null)
 {
     // Determine quality, filename, and format
     $quality = $quality ?: $this->quality;
     $filename = $filename ? StringMethods::removeDiacriticalMarks(str_replace(' ', '_', $filename)) : $this->filename;
     $info = $this->getOriginalInfo();
     $format = $this->_fileExt($filename) ?: $info['format'];
     // Create the image
     switch (strtolower($format)) {
         case 'gif':
             $result = imagegif($this->image, $filename);
             break;
         case 'jpg':
         case 'jpeg':
             imageinterlace($this->image, true);
             $result = imagejpeg($this->image, $filename, round($quality));
             break;
         case 'png':
             $result = imagepng($this->image, $filename, round(9 * $quality / 100));
             break;
         default:
             throw new Exception\Type('Unsupported format');
     }
     if (!$result) {
         throw new Exception\IO(sprintf('Unable to save image: %s', $filename));
     }
     $this->filename = $filename;
     return $this;
 }