jenssegers / jenssegers/imagehash
ImageHash does not work on remote directories in macOS Catalina
- Dominant language
- PHP
- Stars
- 2.1k
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
I am using the following code to obtain the HEX hash:
```
isDir() || $file->isDot() || !in_array($file->getExtension(), $allowedExtensions, true)) {
continue;
}
$path = $file->getFilename();
echo $path . PHP_EOL; // this is working
$hash = $hasher->hash($path);
$fileList[$path] = $hash->toHex();
}
return $fileList;
}
$hasher = new ImageHash(new DifferenceHash());
$files = getPhotoDuplicate($hasher, '/Volumes/MyUSB/Some/Folder/Here/');
print_r($files);
?>
```
Actually the code is quite straightforward, which loops through a directory containing a thousand images.
The same code works on local directory (e.g. same directory `.`), but not on remote USB-connected directory. The same set of images is used. The error is as follow:
```
PHP Fatal error: Uncaught Intervention\Image\Exception\NotReadableException: Image source not readable in /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php:346
Stack trace:
#0 /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php(66): Intervention\Image\AbstractDecoder->init('1000202606_1583...')
#1 /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/ImageManager.php(54): Intervention\Image\AbstractDriver->init('1000202606_1583...')
#2 /Volumes/MyUSB/Some/Folder/Here/vendor/jenssegers/imagehash/src/ImageHash.php(35): Intervention\Image\ImageManager->make('1000202606_1583...')
#3 /Volumes/MyUSB/Some/Folder/Here/photo_duplicate.php(17): Jenssegers\ImageHash\ImageHash->hash('1000202606_1583...')
#4 /Volumes/MyUSB/Some/Folder/Here/photo_duplicate.php(24): getPhotoDuplicate(Object(Jenssegers\ImageHash\ImageHash), '/Volumes/MyUSB...')
#5 {main}
thrown in /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php on line 346
Fatal error: Uncaught Intervention\Image\Exception\NotReadableException: Image source not readable in /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php:346
Stack trace:
#0 /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDriver.php(66): Intervention\Image\AbstractDecoder->init('1000202606_1583...')
#1 /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/ImageManager.php(54): Intervention\Image\AbstractDriver->init('1000202606_1583...')
#2 /Volumes/MyUSB/Some/Folder/Here/vendor/jenssegers/imagehash/src/ImageHash.php(35): Intervention\Image\ImageManager->make('1000202606_1583...')
#3 /Volumes/MyUSB/Some/Folder/Here/photo_duplicate.php(17): Jenssegers\ImageHash\ImageHash->hash('1000202606_1583...')
#4 /Volumes/MyUSB/Some/Folder/Here/photo_duplicate.php(24): getPhotoDuplicate(Object(Jenssegers\ImageHash\ImageHash), '/Volumes/MyUSB...')
#5 {main}
thrown in /Volumes/MyUSB/Some/Folder/Here/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php on line 346
```
Is this a bug? or did I miss something?
Using PHP 7.4.10, GMP 6.2.0 on macOS Catalina 10.15.6
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with photo_duplicate.php and the stack trace through vendor/jenssegers/imagehash/src/ImageHash.php and Intervention Image. Reproduce the failure with the mounted directory, then compare the image source passed for local and remote files. Done means JPEGs in the mounted directory can be hashed without the NotReadableException while local-directory behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100