开发者

ImageMagik/UNIX: How to recursively process a nested directory of photos?

Question: How do I recursively process, using Imagemagik (convert), a nested directory of photos?

I have the following directory structure:

开发者_JAVA百科
/
..2008/
....a.jpg
....b.jpg
..2009/
.....c.jpg

And I want to run the following ImageMagik command on each file, to clean/resize up the images, and then save the resulting image out as the exact same filename as the original file. Basically, I want to replace the original file with the generated resized file created.

// from unix command line    
convert FILENAME.jpg -resize 100x100 -sharpen 1.5 -strip -profile "*" -sampling-factor 4x1 -quality 80 FILENAME.jpg;


Try using find -exec. For instance:

find dirname -type f -iname "*.jpg" -exec convert \{\} -resize 100x100 -sharpen 1.5 -strip -profile "*" -sampling-factor 4x1 -quality 80 \{\} \;

By the way, I don't recommend in-place editing. It's generally a bad idea, especially with storage so cheap. Why not be safe?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜