干预:两次调整图像大小?

1 php laravel laravel-5 intervention laravel-5.2

我想使用Intervention两次调整图像大小.

我现在有这个:

$img = Image::make($image_url);

$img_path = public_path() . '/images/';

$img->fit(500, 250);
$img->save($img_path . '/img_250.jpg');

$img = Image::make($image_url);

$img->fit(100, 100);
$img->save($img_path . '/img_100.jpg');
Run Code Online (Sandbox Code Playgroud)

如您所见,我首先要将原始图像的大小调整为500x250,然后我想再次将原始图像(不是500x250图像)调整为100x100.

没有Image::make()两次打电话有没有办法做到这一点?

小智 6

这是答案:

http://image.intervention.io/api/reset

// create an image
$img = Image::make('public/foo.jpg');

// backup status
$img->backup();

// perform some modifications
$img->resize(320, 240);
$img->invert();
$img->save('public/small.jpg');

// reset image (return to backup state)
$img->reset();

// perform other modifications
$img->resize(640, 480);
$img->invert();
$img->save('public/large.jpg');
Run Code Online (Sandbox Code Playgroud)