1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ImageMagickで全てのJPGをWebPに変換するシェルスクリプト

1
Last updated at Posted at 2019-07-24

JPG to WebP。
ImageMagicで、作業ディレクトリ内にある全てのJPGをWebPに変換するシェルスクリプトです。

パフォーマンス改善のために今後よく使いそうなのでメモ。

ソースコード

jpg2webp.sh
# !/bin/sh

for file in *; do
	if [ ${file##*.} = "jpg" ]; then
		echo "Processing: ${file}"
		convert ${file} ${file//.jpg/.webp}
	fi
done

変換元のJPGも保持されるので、ご安心ください😌

実行例

実行コマンド

$ bash jpg2webp.sh

Processing: shell.jpg

実行結果

スクリーンショット 2019-07-24 19.25.59.png

前準備

  • ImageMagick
  • cwebp

を使えるようにする必要があります。

未インストールの場合は、下記の記事などを参考に各ツールを使えるようにしてください。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?