画像の種類(png、jpg、gif、webp、svg)に関係なく、特定の画像を圧縮するCLIツール?

画像の種類(png、jpg、gif、webp、svg)に関係なく、特定の画像を圧縮するCLIツール?

画像を最適化するためのツールがたくさんあることを知っています。

  • パンククエンタイゼーション
  • 最適化
  • jpegoptim
  • アニメスティック
  • エキシプツール
  • エク

ただし、それらはすべて特定のファイル形式にのみ適用されます。どの画像タイプが渡されても正しい圧縮を適用するコマンドラインはありますか?何か似ているhttps://compressor.ioしかし、CLIはそうです。

「最適化」とは、視覚的にほぼ同じに保ちながら、ファイル全体のサイズを小さくすることを意味します(@Philipposに感謝します)。

ベストアンサー1

SVGを中間形式で使用しても問題ない場合はinkscape便利です。

しかし、ImageMagickを探しているかもしれませんconvert

マニュアルページから:

convert-im6.q16(1)         General Commands Manual        convert-im6.q16(1)

NAME
       convert  -  convert between image formats as well as resize an image,
       blur, crop, despeckle, dither, draw on, flip,  join,  re-sample,  and
       much more.

SYNOPSIS
       convert-im6.q16 [input-option] input-file [output-option] output-file

OVERVIEW
       The   convert-im6.q16   program  is  a  member  of  the  ImageMagick-
       ims6.q16(1) suite of tools.  Use it to convert between image  formats
       as  well  as resize an image, blur, crop, despeckle, dither, draw on,
       flip, join, re-sample, and much more.

       For more information about the convert command, point your browser to
       file:///usr/share/doc/imagemagick-6-common/html/www/convert.html  (on
       debian  system  you  may  install  the  imagemagick-6   package)   or
       https://www.imagemagick.org/script/convert.php.

使用しているファイル形式に関連する圧縮を使用します(jpegはpngとは異なる方法で圧縮されます)。以下を使用して、他の種類の圧縮を選択できます。-compressなし、BZip、FAX、Group4、JPEG、JPEG2000、ロスレス、LZW、RLE、またはZipを表示して指定します。

-qualityJPEG、PNG、MIFF、およびMPEGエンコーダで使用される圧縮レベルを設定するには、このオプションを使用します。-sampling-factorクロマチャンネルをダウンサンプリングするためにJPEG、MPEG、YUVエンコーダで使用されるサンプリング要素を設定するには、このオプションを使用します。

おすすめ記事