basePath()); $file_name = basename($image); $width = null; if (array_key_exists('width', $options)) { $width = $options['width']; $file_name = sprintf('w%u-%s', $width, $file_name); } $height = null; if (array_key_exists('$height', $options)) { $height = $options['$height']; $file_name = sprintf('h%u-%s', $height, $file_name); } $full_path = sprintf('%s/%s', $folder, $file_name); if (!array_key_exists('force', $options) && is_readable($full_path)) { return Image::make($full_path); } //http://image.intervention.io/getting_started/ $img->resize($width, $height, static function (Constraint $constraint) { $constraint->aspectRatio(); })->save(sprintf('%s/%s', $folder, $file_name)); return $img; } }