private static function remoteToLocalImage($url, $path, $lim = false, $saveas = '', $quality = 75) { $im = @getimagesize($url); if (!!$im) { require_once 'Master/base/libraries/Images/SimpleImage.php'; $type = $im['mime']; $width = $im[0]; $height = $im[1]; $minWidth = static::MIN_WIDTH; $minHeight = static::MIN_HEIGHT; $maxWidth = static::MAX_WIDTH; $maxHeight = static::MAX_HEIGHT; if (!!$lim) { $lim = (object) $lim; if (isset($lim->minWidth)) { $minWidth = $lim->minWidth; } if (isset($lim->minHeight)) { $minHeight = $lim->minHeight; } if (isset($lim->maxWidth)) { $maxWidth = $lim->maxWidth; } if (isset($lim->maxHeight)) { $maxHeight = $lim->maxHeight; } } if ($width > $minWidth && $height > $minHeight && strpos($type, 'image') === 0) { $ext = static::getExt($type); if (!!$ext) { $content = Remote::pull($url); if (!!$content) { $name = !!$saveas ? $saveas : Bella::createId(32); $name .= $ext; $file = $path . $name; $save = @file_put_contents($file, $content); if (!!$save) { if ($width > $maxWidth || $height > $maxHeight) { $sm = new SimpleImage(); $sm->load($file); $sm->fillTo($maxWidth, $maxHeight); $sm->save($file, false, $quality); } return $name; } } } } } return false; }