如何使用 PerlMagick 从现有图像对象而不是文件路径 "read"?

How do I "read" from an existing image object instead of a file path with PerlMagick?

以下代码使用 100x100 的图块作为源图像生成 300x100 的图像:

for (my $i = 0; $i < 3; $i++) {
    $image->Read("filepath/100x100.png");
}

$result = $image->Montage(geometry=>'100x100',tile=>'3x1');

如何在只从磁盘读取一次的情况下获得相同的结果

从文档中看并不明显,但是您可以像这样将 clones 添加到图像序列中:

$image->Read("filepath/100x100.png");
$image->[1] = $image->[0]->Clone();
$image->[2] = $image->[0]->Clone();

$result = $image->Montage(geometry=>'100x100',tile=>'3x1');