本文整理汇总了PHP中app\Image::highResolutionFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::highResolutionFile方法的具体用法?PHP Image::highResolutionFile怎么用?PHP Image::highResolutionFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Image
的用法示例。
在下文中一共展示了Image::highResolutionFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UploadImage
public static function UploadImage($oriFilePath, $fileName, User $user, $diskName = null)
{
$fs = Storage::disk($diskName);
$fileContent = $fs->get($oriFilePath);
$mimeType = $fs->mimeType($oriFilePath);
if (!str_is('image/*', $mimeType)) {
$fs->delete($oriFilePath);
throw new RequestValidationException(RequestValidationException::FileIsNotImage);
}
$fileModel = self::saveFileByFileContent($fileContent, $fileName, $mimeType, $user, $diskName);
$fs->delete($oriFilePath);
$image = Image::make($fileContent);
$thumbnail = Image::make($fileContent)->widen(300)->encode($fileModel->mime);
$thumbnailFileModel = FileManager::saveFileByFileContent($thumbnail->encoded, $fileModel->name . '-thumbnail.' . $fileModel->ext, $thumbnail->mime(), $user);
if ($image->getWidth() > 1500) {
$highResolution = Image::make($fileContent)->widen(1500)->encode($fileModel->mime);
$highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
} else {
$highResolution = Image::make($fileContent)->widen($image->getWidth())->encode($fileModel->mime);
$highResolutionFileModel = FileManager::saveFileByFileContent($highResolution->encoded, $fileModel->name . '-high-resolution.' . $fileModel->ext, $highResolution->mime(), $user);
}
$imageModel = new ImageModel();
$imageModel->width = $image->getWidth();
$imageModel->height = $image->getHeight();
$imageModel->file()->associate($fileModel);
$imageModel->thumbnailFile()->associate($thumbnailFileModel);
$imageModel->highResolutionFile()->associate($highResolutionFileModel);
$imageModel->save();
return $imageModel;
}