certain photos from FB fail to import on Lychee
ilias-sp opened this issue · comments
Detailed description of the problem
Cant import certain photos from Facebook, from personal experience this error shows up pretty frequently lately.
Steps to reproduce the issue
try to import from link
the FB photo from this FB permalink
Output of the diagnostics (Settings => Diagnostics)
Log reads:
2019-10-18 16:39:25 - error - Lychee\Modules\Import::url (64) - Photo type not supported (https://scontent.fath5-1.fna.fbcdn.net/v/t1.0-9/71691495_2725437720808144_2303621540459053056_n.jpg?_nc_cat=100&_nc_oc=AQlx2IqpHUDMnXF3B75ysALyMlSwDWVBzURSNbCti7odM-U4EFWpmq0w_X0AV72RpIw&_nc_ht=scontent.fath5-1.fna&oh=83145d89f8177c741ccbfbde3ea1c4c0&oe=5E21A18E)
Browser and system
Not relevant to the problem.
i wasnt aware that the Lychee project has moved to this repository, so i made a fix and a pull request towards the old repository. i am copying the analysis from that pull request here:
hello!
i am recently experiencing frequent errors when trying to import pictures directly from Facebook, Lychee cant detect the mime type of the given picture file.
this happens because for the given photo, exif_imagetype
complains that:
PHP Notice: exif_imagetype(): Read error!
For the same image, the getimagesize
can detect the mime type, please see below:
[http_offline@greenhat-30 TEST]$ cat mime_type_detect.php
<?php
$url = 'https://scontent.fath5-1.fna.fbcdn.net/v/t1.0-9/72110633_114060826671623_3491471948204998656_n.jpg?_nc_cat=103&_nc_oc=AQllCq08DT0Y9KCgZiio9he1sc_KUDMpVTIaEUZBfG5kMRPIXxdDXIMUOmwia2vaPI0&_nc_ht=scontent.fath5-1.fna&oh=9d3ba6b8b9907ed6727a1adcaa59f8ef&oe=5E231DB1';
var_dump(exif_imagetype($url));
var_dump(getimagesize($url));
[http_offline@greenhat-30 TEST]$ php mime_type_detect.php
PHP Notice: exif_imagetype(): Read error! in /php_basedir/TEST/mime_type_detect.php on line 5
bool(false)
array(7) {
[0]=>
int(720)
[1]=>
int(720)
[2]=>
int(2)
[3]=>
string(24) "width="720" height="720""
["bits"]=>
int(8)
["channels"]=>
int(3)
["mime"]=>
string(10) "image/jpeg"
}
[http_offline@greenhat-30 TEST]$
based on the above evidence, i added an extra step in the Import.php
Module , plus an array in Photo.php
.
here is a link to another FB photo that Lychee fails to import: picture example. right click on the image, to get the actual link to picture (this link has an expiration date, FB changes them periodically)
Please check and let me know what you think?
I don't see why we would not merge this into the v3. Also if you would be kind enough to double check the problem on the v4 (the lychee-laravel repo), that would be great. 👍 😃