mirror of
https://github.com/sakaljurgis/actions-api.git
synced 2026-11-06 16:08:01 +00:00
add imagic
This commit is contained in:
1 parent
f44d21a9be
commit
3e6f9ba0c2
3 files changed
+27
-6
No files matched your search
@@ -17,12 +17,27 @@ class ImageService
|
||||
$imageData = base64_decode($base64ImageData);
|
||||
$ext = explode('/', $mimeType)[1];
|
||||
|
||||
Storage::put('public/images/' . $imageId . '.' . $ext , $imageData);
|
||||
$relativePath = Storage::url('public/images/' . $imageId . '.png');
|
||||
$imagePath = 'public/images/' . $imageId . '.' . $ext;
|
||||
Storage::put($imagePath , $imageData);
|
||||
$relativeUrl = Storage::url($imagePath);
|
||||
$filesystemPath = Storage::path($imagePath);
|
||||
|
||||
$resolution = [];
|
||||
try {
|
||||
$image = new \Imagick($filesystemPath);
|
||||
$resolution = $image->getImageGeometry();
|
||||
} catch (\ImagickException $e) {
|
||||
//do nothing
|
||||
}
|
||||
// resize to thumbnail
|
||||
// $image->thumbnailImage(200, 200);
|
||||
// $thumbPath = 'public/images/' . $imageId . '-thumb.' . $ext;
|
||||
// Storage::put($thumbPath , $image->getImageBlob());
|
||||
|
||||
return [
|
||||
'url' => asset($relativePath),
|
||||
'url' => asset($relativeUrl),
|
||||
'id' => $imageId,
|
||||
...$resolution,
|
||||
// todo - size, width, height, thumb, etc
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user