我正在嘗試讀取和比較文件夾中的大量圖像文件。但我無法讀取圖像文件。使用Perl讀取和比較文件夾中的圖像
代碼片段:
use strict;
use warnings;
use Image::Compare;
opendir my $ref_dir, "./" or die "Cannot open directory: $!";
my @ref_files = readdir $ref_dir;
closedir $ref_dir;
print $#ref_files;
my($cmp) = Image::Compare->new();
$cmp->set_image1(
img => './'.$ref_files[0], #one instance - reading first file in the folder
type => 'bmp',
);
的代碼拋出下面的錯誤 - 「無法讀取文件‘./’。圖像數據:‘無法打開./:權限被拒絕’在C: /Perl64/site/lib/Image/Compare.pm line 162。「
如果我直接提供文件名 - img =>'./image.bmp',代碼就可以正常工作。所以它不能是一個權限問題。
檢查** **許可的'$ ref_files [0]'文件。 – AbhiNickz
它直接將文件名作爲字符串提供。所以這不是一個許可問題。 – Maximus