gpt4 book ai didi

image - 如何生成拇指图像?

转载 作者:行者123 更新时间:2023-12-02 23:58:26 24 4
gpt4 key购买 nike

我有一个大约有 20000 张图像的文件夹,我需要为它们生成缩略图。

完成这项工作最快的方法是什么?

我知道我可以使用一些图像调整大小库来做到这一点。但我想知道也许已经有一个工具或代码片段可以完成这项工作。

最佳答案

imagemagick 转换工具。它是一个命令行工具,在 Linux 和 Windows 中都能很好地工作。

用于转换单个图像:

convert dragon.gif    -resize 50%  half_dragon.gif

或者,如果您更喜欢固定大小的缩略图(此处为 4096 像素):

convert dragon.gif    -resize 4096@  pixel_dragon.gif

或者最常见的用途 - 调整为给定大小:

convert dragon.gif    -resize 64x64  resize_dragon.gif

对于大量图像,可以快速调整大小:

The resize operator can also be applied to images immediately after being read, before it is added to the current image sequence and the next image is read.

所以,

convert dragon.gif'[64x64]'    read_dragon.gif

可能是您问题的正确答案。

这些示例取自 resize section imagemagick.org 网站的;您可以在那里找到许多其他示例。

为了转换 while 图像库,您可以编写一个小的 shell 脚本,例如:

for file in `ls`;
do
convert $file -resize 4096@ thumb_$file
done

对于大量文件,您可能需要使用 Linux 的 find -exec 来克服 ls 会产生的非常长的参数列表。

关于image - 如何生成拇指图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2012183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com