imagick
imagick copied to clipboard
Insufficient image data
When trying to create object from any remote url (example) like this
$img = new Imagick($url);
getting error:
ImagickException: insufficient image data in file `/var/tmp/magick-7jkS0zvlJB3I3wQsy60LOS67y0TvMvca' @ error/jpeg.c/ReadJPEGImage_/1104
But all works fine when using readImageBlob:
$img = new Imagick();
$img->readImageBlob(file_get_contents($url));
That happens only on MacOS (11.2.2 w/ m1) and doesnt happen on Ubuntu (20.04)
Imagick ver.: 7.0.11 PHP ver.: 8.0.2
That sounds like a bug. But to set your expectations, not one I plan to investigate soon.
If you can replicate it on the command line, using the ImageMagick convert tool, then you could probably open a bug at https://github.com/ImageMagick/ImageMagick for those people to look at, and it would probably fix the issue when doing the same inside Imagick.
If you can't replicate it on the command line, you might be able to find out what it is by either using dtruss or dtrace or some equivalent tool on MacOS to trace the system calls, and find where the difference is. You might also be able to find the difference by listening to the network traffic using either Tcpdump or Wireshark or similar.
But this isn't going to be a priority for me to look at, as I recommend avoiding reading images remotely directly in ImageMagick/Imagick as..... it sometimes fails and then you've got no real information on how to fix it.
If you use curl or similar to download the files locally first, any failure at the network level is going to be way easier to investigate...
it has always been like this on mac