public static function copy($path, array $data = array()) { if (!File::exists($path)) { return false; } // Clear file status cache (prevents empty filesize). clearstatcache(); try { $resizer = new Resizer($path); } catch (Exception $e) { return false; } $image = new static(); $image->filename = md5(Str::random(32)) . '.' . $resizer->extension(); $image->original_filename = array_get($data, 'original_filename'); $image->type = $resizer->mime(); $image->filesize = File::size($path); $image->width = $resizer->width(); $image->height = $resizer->height(); $image->ratio = $resizer->ratio(); if (empty($image->original_filename)) { $image->original_filename = basename($path); if (false === strstr($image->original_filename, '.')) { $image->original_filename .= '.' . $resizer->extension(); } } Storage::upload($path, $image->pathFromSize()); if (!Storage::exists($image->pathFromSize())) { return false; } $image->sizes = array('original' => Storage::url($image->pathFromSize())); $image->save(); return $image; }