Imagick / imagick

🌈 The Imagick PHP extension 🌈
http://pecl.php.net/imagick
Other
548 stars 141 forks source link

PHP Imagick::readImageFile NEF filehandle detected as TIFF #685

Open t-rutter opened 3 months ago

t-rutter commented 3 months ago

Try to read an open filehandle results in imagemagick detect the fiel as a TIFF and then only reads the low-res preview. ` $filename='_X000001.NEF'; $preview='_X000001.jpg' $fh = fopen("/src-dir/$filename", "r"); $im->readImageFile($fh); $imageinfo = $im->identifyImage(); $im->resizeImage(1024, 768, Imagick::FILTER_LANCZOS, 1); $im->setImageFormat('jpg'); $im->writeImage("/dst-dir/$preview"); $im->clear(); $im->destroy();

// do other stuff with source file

fclose($fh); ` results in $imageinfo showing format = "TIFF (Tagged Image File Format)" and the output jpg is super blurry as it end being scaled up from the NEF preview a tiny 160x120px, instead of the full size NEF 3280x4928

mnogueron commented 1 month ago

I'm encountering the same issue with NEF pictures within the Memories app of Nextcloud. They are using readImageBlob which picks the TIFF thumbnail instead of the source file (for ref: https://github.com/pulsejet/memories/issues/1054)

Danack commented 1 month ago

Hi, I won't be able to fix this in Imagick. Imagick is a thin wrapper around ImageMagick and so Imagick doesn't do any of the image processing itself.

I'd suggest reporting the issue at https://github.com/ImageMagick/ImageMagick

But also:

  1. Try to replicate the issue using the command line ImageMagick tools. If you can do that, the maintainers of ImageMagick are far more likely to look at the issue quickly.

  2. If you can't reproduce via the command line, making an example standalone C problem is another way of getting the ImageMagick maintainers to look at the problem. There's an example stub program you could base something on here: https://github.com/Imagick/imagemagicktest/blob/0be293bb3bf2b4bc6def249d585fb13f6572db1a/svgtest.c

If those fail, and the ImageMagick maintainers don't do anything, then post an example file here (I guess zipped up to get past githubs upload rules).