Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Imagemagick identify
  • Hello! I do not found possibility to get information about image (picture) through Image class.
    Therefore I made own little extension. 1. core\classes\image add this code:
    public static function identify(){
                return static::instance()->identify();
            }
    

    2. core\classes\image\imagemagick add this code:
    public function identify($parameter=null){
                $imagemagick_data = $this->exec('identify', $this->image_temp);
            list($full_image_path, $format, $resolution, $geometry, $depth, $class, $file_size, $info1, $info2) = explode(' ', $imagemagick_data[0]);
            list($width, $height) = explode('x',$resolution);
            $parameter = strtolower($parameter);
            switch ($parameter) {
                case 'image_path': $data = $full_image_path;
                    break;
                case 'format':     $data = $format;
                    break;
                case 'resolution': $data = $resolution;
                    break;
                case 'width':      $data = $width;
                    break;
                case 'height':     $data = $height;
                    break;
                case 'geometry':   $data = $geometry;
                    break;
                case 'depth':      $data = $depth;
                    break;
                case 'class':      $data = $class;
                    break;
                case 'full_data':  $data = $imagemagick_data[0];
                    break;
                case 'file_size':  $data = $file_size;
                default :          $data = $resolution;
                    break;
            }
            return $data;
            }
    

    That's all. And now you can use it.
    Example:
    Image::load('1.jpg')->identify(); by default returns resolution Image::load('1.jpg')->identify('width'); returns width of image Image::load('1.jpg')->identify('format'); returns format of image, in that case it is 'JPG' Image::load('1.jpg')->identify('file_size'); returns file size
    http://tny.cz/2424f382 OR
    http://pastie.org/4178285

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!