从术语来看,将目录中的所有图像渲染到一个浏览器窗口中有什么好命令?
寻找这样的事情:
python -m SimpleHTTPServer 8080
但是,而不是列表...
...想要查看在单个浏览器窗口中呈现的所有图像,它们以自然尺寸自然流动,只是向下滚动以查看有多少图像,以便以其自然呈现状态查看它们。
我找到了一个perl CGI脚本来执行此操作:
#!/usr/bin/perl -wT
# myscript.pl
use strict;
use CGI;
use Image::Size;
my $q = new CGI;
my $imageDir = "./";
my @images;
opendir DIR, "$imageDir" or die "Can't open $imageDir $!";
@images = grep { /\.(?:png|gif|jpg)$/i } readdir DIR;
# @images = grep { /\.(?:png|gif|jpg|webm|web|mp4|svg)$/i } readdir DIR;)
closedir DIR;
print $q->header("text/html"),
$q->start_html("Images in the directory you specified."),
$q->h1("Images in the directory your specified.");
foreach my $image (@images) {
my ($width, $height) = imgsize("$image");
print $q->a({-href=>$image},
$q->img({-src=>$image,
-width=>$width,
-height=>$height})
);
}
print $q->end_html;
要在MacOS上运行,您需要安装以下模块:
cpan CGI
cpan Image::Size
将清单放到包含要预览的图像的目录中。
…然后说 perl -wT myscript.pl > output.html
打开生成output.html
的图像,以在单个浏览器窗口中以其自然尺寸查看所有图像。
与此问题和答案相关:如何从终端在Mac上运行此简单的Perl CGI脚本?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句