public function ensure($image, $formats, $storages)
    {
        $storage = $this->getImageStorage($image);
        $format = $this->getImageFormat($image);

        $storages = is_string($storages) ? array($storages) : $storages;
        $formats = is_int($formats) ? array($formats) : $formats;
        if (in_array($format, $formats)) {
            if (in_array($storage, $storages)) {
                return $image;
            } else {
                $file = $this->getFileOptionForSaving($storages);
                $image = $this->loadToString($image);
                return $this->saveFromString($image, array('file' => $file));
            }
        } else {
            $file = $this->getFileOptionForSaving($storages);
            $resource = $this->load($image);
            return $this->save($resource, array('file' => $file, 'format' => $formats[0]));
        }
    }
public function ensure($image, $formats, $storages)
    {
        $storage = $this->getImageStorage($image);
        $format = $this->getImageFormat($image);

        $storages = is_string($storages) ? array($storages) : $storages;
        $formats = is_int($formats) ? array($formats) : $formats;
        if (in_array($format, $formats)) {
            if (in_array($storage, $storages)) {
                return $image;
            } else {
                $file = $this->getFileOptionForSaving($storages);
                $image = $this->loadToString($image);
                return $this->saveFromString($image, array('file' => $file));
            }
        } else {
            $file = $this->getFileOptionForSaving($storages);
            $resource = $this->load($image);
            return $this->save($resource, array('file' => $file, 'format' => $formats[0]));
        }
    }
public function ensure ( $ image , $ formats , $ storages ) { $ storage = $ this -> getImageStorage ( $ image ) ; $ format = $ this -> getImageFormat ( $ image ) ; $ storages = is_string ( $ storages ) ? array ( $ storages ) : $ storages ; $ formats = is_int ( $ formats ) ? array ( $ formats ) : $ formats ; if ( in_array ( $ format , $ formats ) ) { if ( in_array ( $ storage , $ storages ) ) { return $ image ; } else { $ file = $ this -> getFileOptionForSaving ( $ storages ) ; $ image = $ this -> loadToString ( $ image ) ; return $ this -> saveFromString ( $ image , array ( 'file' => $ file ) ) ; } } else { $ file = $ this -> getFileOptionForSaving ( $ storages ) ; $ resource = $ this -> load ( $ image ) ; return $ this -> save ( $ resource , array ( 'file' => $ file , 'format' => $ formats [ 0 ] ) ) ; } }
Ensure certain image storages und formats

@param string       $image
@param array|int    $formats
@param array|string $storages
@return string
Ensure certain image storages und formats