【问题标题】:Batch resize images within folders and keep folders structure?批量调整文件夹中的图像大小并保持文件夹结构?
【发布时间】:2016-02-03 15:19:23
【问题描述】:

我有一个高清图片文件夹,+2000px 宽度:

+ /img/
   +- /bikes/: few images here (jpg,png,svg)
   +- /cars/ : few images here
   +- /cats/ : few images here
   +- /dogs/ : few images here
   +- /...

我想将整个图像调整为 200 像素宽的图像(相同的比例),但保留文件夹结构。

怎么做?

【问题讨论】:

  • Google 搜索 imagemagick resize recursive 似乎产生了不错的结果
  • stackoverflow.com/questions/10802606/… 我认为将图像大小调整为 200 px 宽度的 size 参数是 -resize 200x
  • 您是要覆盖原始图像,还是使用新名称创建新的、更小的文件?
  • @MarkSetchell:我的意思是在与-small 相同的文件夹中或在并行文件夹树中创建新的。

标签: imagemagick mogrify


【解决方案1】:

你可以这样做,但请先备份!

find . -depth -type d \! -name '.' -exec bash -c 'cd $0 || exit; mkdir thumbs 2> /dev/null; shopt -s nullglob; mogrify -path thumbs -resize 200x *.jpg *.svg *.png ' {} \;

这将在每个目录中为您提供一个名为 thumbs 的子目录,其中包含较小的版本

【讨论】:

  • 它有效。我通过添加 -format png 绕过了 svg 文件的一个错误,我的命令现在是:find . -depth -type d \! -name '.' -exec bash -c 'cd $0 || exit; mkdir thumbs 2> /dev/null; shopt -s nullglob; mogrify -path thumbs -resize 128x -format png *.jpg *.svg *.png *.tif' {} \;
猜你喜欢
  • 1970-01-01
  • 2012-12-27
  • 1970-01-01
  • 2022-11-30
  • 1970-01-01
  • 2017-10-10
  • 1970-01-01
  • 2019-03-16
  • 1970-01-01
相关资源
最近更新 更多