pulsejet / memories

Fast, modern and advanced photo management suite. Runs as a Nextcloud app.
https://memories.gallery
GNU Affero General Public License v3.0
3.13k stars 83 forks source link

Very low quality on zoomed DNG #1054

Open mnogueron opened 7 months ago

mnogueron commented 7 months ago

Describe the bug I have the load high res on zoom setting enabled but I'm having issues when zooming on DNG picture. Some are very low quality (DNG: 6000x4000, preview: 256x171) and some others are alright (DNG: 4032x3024, preview: 1280x960).

After some digging, I found out that the issue seems to be coming from Imagick. I tried to replicate the code from getImageJpeg https://github.com/pulsejet/memories/blob/55ba434019d46bc59568087300562aa0794041f7/lib/Controller/ImageController.php#L416 straight into the PHP terminal:

$file_path = 'my_picture.DNG';
$blob = file_get_contents($file_path);
$image = new Imagick();
$image->readImageBlob($blob);
$image->setImageFormat('jpeg');
$image->setImageCompressionQuality(85);
$image->writeImage('preview-output.jpg');

Applied to both file, it generates the same output as what Memories gives me.

Exiftool gives me the following:

exiftool -json -preview:all my_picture.DNG
// Non working file
[{
  "SourceFile": "non_working_test.DNG",
  "JpgFromRaw": "(Binary data 1774170 bytes, use -b option to extract)",
  "PreviewImage": "(Binary data 53688 bytes, use -b option to extract)",
  "ThumbnailTIFF": "(Binary data 131544 bytes, use -b option to extract)"
}]
/// Working file
[{
  "SourceFile": "PXL_20230903_184954003.dng",
  "PreviewImage": "(Binary data 169066 bytes, use -b option to extract)"
}]

By extracting the previews for both files, it seems that Imagick uses PreviewImage in the case of my working DNG, but uses ThumbnailTIFF in the case of the non working DNG. (the extracted ThumbnailTIFF gives me the low quality preview of 256x171).

I've been trying to understand how Imagick handles the DNG load and conversion, but to no avail... It seems ImageMagick uses a delegates.xml file to delegate encoding/decoding for certain file type, and DNG is part of the config, but uses ufraw-batch which is deprecated and not installed on my system, but still loads without it. So I'm really confused as to what to do to prevent Imagick to pick the law quality Tiff preview in my DNGs...

To Reproduce Use the files (zipped for Github): non_working_test.DNG.zip PXL_20230903_184954003.dng.zip

Platform:

pulsejet commented 7 months ago

So I've no experience with this and can be little help here. Though I'd say one way to deal with this is to shoot both JPEG and DNG and have them in the same folder with the same name. Memories will then collapse them into one file so you can view the JPEG your camera generated and use the DNG in whatever dedicated software you use.