Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howto:compress_or_resize_images_in_bash [2016/11/23 07:38] – created yehuda | howto:compress_or_resize_images_in_bash [2022/01/03 16:03] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 20: | Line 20: | ||
see more options: https:// | see more options: https:// | ||
+ | |||
+ | ====== Resize image to minimal rate ====== | ||
+ | |||
+ | How about using ImageMagick' | ||
+ | |||
+ | Copy & Paste snippet (bash syntax) -- please notice the ^ after the size specification: | ||
+ | <code bash> | ||
+ | for file in *.jpg; do | ||
+ | echo -n Converting ${file}... | ||
+ | | ||
+ | echo done | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | In addition, if you want to crop the resulting file to a quadratic shape around the center, you can use this script. The SIZE parameter in the first line specifies (surprise, surprise) the final size of the thumbnail. | ||
+ | <code bash> | ||
+ | SIZE=180 | ||
+ | for file in *.jpg; do | ||
+ | echo -n Converting ${file}... | ||
+ | | ||
+ | | ||
+ | echo done | ||
+ | done | ||
+ | rm temp.png | ||
+ | </ | ||
+ | |||
+ | The script is not very optimized, as it runs two commands (identify and convert -crop) on the thumbnail. But as the thumbnail is only small, I think the speed is reasonable. | ||
+ | |||
+ | from: https:// |