zofe / rapyd-laravel

deprecated rewritten in rapyd-livewire
MIT License
866 stars 297 forks source link

intervention extention #114

Open larylinz opened 9 years ago

larylinz commented 9 years ago

Could you implement 'heighten' to image.php? It woud be handy to change the size of pictures and constraining aspect ratio.

add to image.php:

/**
 * shortcut to ImageManager heighten
 * @param $width
 * @param $filename
 * @return $this
 */
public function heighten($height, $filename = null)
{
    $this->heighten[] = array('height'=>$height,  'filename'=>$filename);

    return $this;
}

and within <protected function imageProcess()>:

        if (count($this->heighten)) {
            foreach ($this->heighten as $heighten) {
                $this->image->heighten($heighten["height"]);
                $this->image->save($heighten["filename"]);
            }
        }

Thank you!

zofe commented 9 years ago

there is a closure (probably undocumented) that you can use to get full access to the intervention image library:

so if this is not enough for you:

$form->add('photo','Photo', 'image')->move('uploads/demo/')->fit(240, 160)->preview(120,80);
$form->add('photo','Photo', 'image')->move('uploads/demo/')->resize(240, 160)->preview(120,80);

you can do..

$form->add('photo','Photo', 'image')->move('uploads/demo/')->image(function ($image) {
 // $image is an instance of \Intervention\Image\ImageManagerStatic 
 // with uploaded image, you can do here something different...  
// remember to do also:  $image->save('filename');
})->preview(120,80);