JBZoo\Utils\Image::isJpeg PHP Method

isJpeg() public static method

public static isJpeg ( string $format ) : boolean
$format string
return boolean
    public static function isJpeg($format)
    {
        $format = strtolower($format);
        return 'image/jpg' === $format || 'jpg' === $format || 'image/jpeg' === $format || 'jpeg' === $format;
    }

Usage Example

Beispiel #1
0
 /**
  * Create image resource
  *
  * @param string $format
  * @return resource
  *
  * @throws Exception
  */
 protected function _imageCreate($format)
 {
     if (Helper::isJpeg($format)) {
         $result = imagecreatefromjpeg($this->_filename);
     } elseif (Helper::isPng($format)) {
         $result = imagecreatefrompng($this->_filename);
     } elseif (Helper::isGif($format)) {
         $result = imagecreatefromgif($this->_filename);
     } else {
         throw new Exception('Invalid image: ' . $this->_filename);
         // @codeCoverageIgnore
     }
     return $result;
 }