editor: heic
parent
0074647b21
commit
515f0c48eb
|
@ -13,6 +13,7 @@ This file is manually updated. Please file an issue if something is missing.
|
||||||
- Fix stretched images in viewer ([#176](https://github.com/pulsejet/memories/issues/176))
|
- Fix stretched images in viewer ([#176](https://github.com/pulsejet/memories/issues/176))
|
||||||
- Editor: Restore metadata after image edit ([#174](https://github.com/pulsejet/memories/issues/174))
|
- Editor: Restore metadata after image edit ([#174](https://github.com/pulsejet/memories/issues/174))
|
||||||
- Editor: Fix loss of resolution after edit
|
- Editor: Fix loss of resolution after edit
|
||||||
|
- Editor: Allow editing all image formats (HEIC etc.)
|
||||||
|
|
||||||
## v4.6.1, v3.6.1 (2022-11-07)
|
## v4.6.1, v3.6.1 (2022-11-07)
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ return [
|
||||||
|
|
||||||
['name' => 'Image#info', 'url' => '/api/image/info/{id}', 'verb' => 'GET'],
|
['name' => 'Image#info', 'url' => '/api/image/info/{id}', 'verb' => 'GET'],
|
||||||
['name' => 'Image#setExif', 'url' => '/api/image/set-exif/{id}', 'verb' => 'PATCH'],
|
['name' => 'Image#setExif', 'url' => '/api/image/set-exif/{id}', 'verb' => 'PATCH'],
|
||||||
|
['name' => 'Image#jpeg', 'url' => '/api/image/jpeg/{id}', 'verb' => 'GET'],
|
||||||
|
|
||||||
['name' => 'Archive#archive', 'url' => '/api/archive/{id}', 'verb' => 'PATCH'],
|
['name' => 'Archive#archive', 'url' => '/api/archive/{id}', 'verb' => 'PATCH'],
|
||||||
|
|
||||||
|
|
|
@ -135,11 +135,11 @@ class ApiBase extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a file with ID from user's folder
|
* Get a file with ID from user's folder.
|
||||||
*
|
*
|
||||||
* @param int $fileId
|
* @param int $fileId
|
||||||
*
|
*
|
||||||
* @return File|null
|
* @return null|File
|
||||||
*/
|
*/
|
||||||
protected function getUserFile(int $id)
|
protected function getUserFile(int $id)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ class ApiBase extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if node is a file
|
// Check if node is a file
|
||||||
if (!($file[0] instanceof File)) {
|
if (!$file[0] instanceof File) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Memories\Controller;
|
namespace OCA\Memories\Controller;
|
||||||
|
|
||||||
|
use OCA\Memories\AppInfo\Application;
|
||||||
use OCA\Memories\Exif;
|
use OCA\Memories\Exif;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
@ -96,25 +97,35 @@ class ImageController extends ApiBase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a full resolution PNG for editing from a file.
|
* @NoAdminRequired
|
||||||
|
*
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*
|
||||||
|
* Get a full resolution JPEG for editing from a file.
|
||||||
*/
|
*/
|
||||||
public function getPNG(string $id)
|
public function jpeg(string $id)
|
||||||
{
|
{
|
||||||
$file = $this->getUserFile((int) $id);
|
$file = $this->getUserFile((int) $id);
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the image info
|
// check if valid image
|
||||||
$info = $this->timelineQuery->getInfoById($file->getId(), true);
|
$mimetype = $file->getMimeType();
|
||||||
|
if (!\in_array($mimetype, Application::IMAGE_MIMES, true)) {
|
||||||
|
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the image
|
// Get the image
|
||||||
$path = $file->getStorage()->getLocalFile($file->getInternalPath());
|
$path = $file->getStorage()->getLocalFile($file->getInternalPath());
|
||||||
$image = Exif::getPNG($path, $info['exif']);
|
$image = new \Imagick($path);
|
||||||
|
$image->setImageFormat('jpeg');
|
||||||
|
$image->setImageCompressionQuality(95);
|
||||||
|
$blob = $image->getImageBlob();
|
||||||
|
|
||||||
// Return the image
|
// Return the image
|
||||||
$response = new Http\DataDisplayResponse($image, Http::STATUS_OK, ['Content-Type' => 'image/png']);
|
$response = new Http\DataDisplayResponse($blob, Http::STATUS_OK, ['Content-Type' => $image->getImageMimeType()]);
|
||||||
$response->cacheFor(0);
|
$response->cacheFor(3600 * 24, false, false);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,17 @@ export default class ImageEditor extends Mixins(GlobalMixin) {
|
||||||
private imageEditor: FilerobotImageEditor = null;
|
private imageEditor: FilerobotImageEditor = null;
|
||||||
|
|
||||||
get config(): FilerobotImageEditorConfig & { theme: any } {
|
get config(): FilerobotImageEditorConfig & { theme: any } {
|
||||||
|
let src: string;
|
||||||
|
if (["image/png", "image/jpeg", "image/webp"].includes(this.mime)) {
|
||||||
|
src = this.src;
|
||||||
|
} else {
|
||||||
|
src = generateUrl("/apps/memories/api/image/jpeg/{fileid}", {
|
||||||
|
fileid: this.fileid,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
source: this.src,
|
source: src,
|
||||||
|
|
||||||
defaultSavedImageName: this.defaultSavedImageName,
|
defaultSavedImageName: this.defaultSavedImageName,
|
||||||
defaultSavedImageType: this.defaultSavedImageType,
|
defaultSavedImageType: this.defaultSavedImageType,
|
||||||
|
|
|
@ -586,7 +586,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
get canEdit() {
|
get canEdit() {
|
||||||
return ["image/jpeg", "image/png"].includes(this.currentPhoto?.mimetype);
|
return this.currentPhoto?.mimetype?.startsWith("image/");
|
||||||
}
|
}
|
||||||
|
|
||||||
private openEditor() {
|
private openEditor() {
|
||||||
|
|
Loading…
Reference in New Issue