@@ -433,7 +433,7 @@ class Image extends ImageAutodoc implements \ArrayAccess
433
433
*
434
434
* @internal
435
435
*/
436
- private $ nicknameToCanonical = [
436
+ private static $ nicknameToCanonical = [
437
437
"csvload " => "VipsForeignLoadCsv " ,
438
438
"matrixload " => "VipsForeignLoadMatrix " ,
439
439
"rawload " => "VipsForeignLoadRaw " ,
@@ -724,19 +724,19 @@ public static function newFromFile(
724
724
*/
725
725
public static function findLoad (string $ filename ): string
726
726
{
727
- $ result = null ;
728
-
729
- try {
730
- # added in php-vips-ext 1.0.5
727
+ # added in 1.0.5 of the binary module
728
+ if (version_compare (phpversion ("vips " ), "1.0.5 " ) >= 0 ) {
731
729
$ result = vips_foreign_find_load ($ filename );
732
- } catch (Exception $ e ) {
730
+ } else {
731
+ $ result = null ;
732
+
733
733
# fallback: use the vips-loader property ... this can be much slower
734
734
try {
735
- $ image = newFromFile ($ filename );
735
+ $ image = Image:: newFromFile ($ filename );
736
736
# Unfortunately, vips-loader is the operation nickname, rather
737
737
# than the canonical name returned by vips_foreign_find_load().
738
738
$ loader = $ image ->get ("vips-loader " );
739
- $ result = $ nicknameToCanonical [$ loader ];
739
+ $ result = Image:: $ nicknameToCanonical [$ loader ];
740
740
} catch (Exception $ e ) {
741
741
}
742
742
}
@@ -776,20 +776,20 @@ public static function newFromBuffer(
776
776
*/
777
777
public static function findLoadBuffer (string $ buffer ): string
778
778
{
779
- $ result = null ;
779
+ # added in 1.0.5 of the binary module
780
+ if (version_compare (phpversion ("vips " ), "1.0.5 " ) >= 0 ) {
781
+ $ result = vips_foreign_find_load ($ filename );
782
+ } else {
783
+ $ result = null ;
780
784
781
- try {
782
- # added in php-vips-ext 1.0.5
783
- $ result = vips_foreign_find_load_buffer ($ buffer );
784
- } catch (Exception $ e ) {
785
785
# fallback: use the vips-loader property ... this can be much slower
786
786
try {
787
- $ image = newFromBuffer ($ buffer );
787
+ $ image = Image:: newFromBuffer ($ buffer );
788
788
# Unfortunately, vips-loader is the operation nickname, rather
789
789
# than the canonical name returned by
790
790
# vips_foreign_find_load_buffer().
791
791
$ loader = $ image ->get ("vips-loader " );
792
- $ result = $ nicknameToCanonical [$ loader ];
792
+ $ result = Image:: $ nicknameToCanonical [$ loader ];
793
793
} catch (Exception $ e ) {
794
794
}
795
795
}
0 commit comments