Skip to content

Instantly share code, notes, and snippets.

@iqiancheng
Last active October 21, 2025 09:23
Show Gist options
  • Select an option

  • Save iqiancheng/970ec0aed97a7491ea71c07e4e54c3c0 to your computer and use it in GitHub Desktop.

Select an option

Save iqiancheng/970ec0aed97a7491ea71c07e4e54c3c0 to your computer and use it in GitHub Desktop.

Revisions

  1. iqiancheng revised this gist Oct 21, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion png_to_jpg_compress.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    find . -maxdepth 1 -type f -iname '*.png' -print0 | xargs -0 -I{} sh -c 'magick "$1" -background white -alpha remove -alpha off -strip -quality 85 "${1%.png}_q85.jpg"' _ {}
    ```

    说明
    说明
    • 使用 -background white -alpha remove -alpha off 处理透明背景,避免黑底;如需其他颜色,把 white 改成你想要的颜色值(如 “#1e1e1e”)。
    • -strip 会移除元数据以进一步减小体积;若需保留 ICC/EXIF,删除 -strip。
    • 质量 75 是偏中高的网页常用档位;需要更高或更小体积,调节 -quality。
  2. iqiancheng revised this gist Oct 21, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions png_to_jpg_compress.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,6 @@ find . -maxdepth 1 -type f -iname '*.png' -print0 | xargs -0 -I{} sh -c 'magick
    ```

    说明
    • 使用 -background white -alpha remove -alpha off 处理透明背景,避免黑底;如需其他颜色,把 white 改成你想要的颜色值(如 “#1e1e1e”)。
    • -strip 会移除元数据以进一步减小体积;若需保留 ICC/EXIF,删除 -strip。
    • 质量 75 是偏中高的网页常用档位;需要更高或更小体积,调节 -quality。
    • 使用 -background white -alpha remove -alpha off 处理透明背景,避免黑底;如需其他颜色,把 white 改成你想要的颜色值(如 “#1e1e1e”)。
    • -strip 会移除元数据以进一步减小体积;若需保留 ICC/EXIF,删除 -strip。
    • 质量 75 是偏中高的网页常用档位;需要更高或更小体积,调节 -quality。
  3. iqiancheng revised this gist Oct 21, 2025. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion png_to_jpg_compress.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,9 @@
    ```bash
    # 把当前目录下所有 PNG 转成 75% 质量的 JPG,并在原文件名后加 _quality75.jpg
    find . -maxdepth 1 -type f -iname '*.png' -print0 | xargs -0 -I{} sh -c 'magick "$1" -background white -alpha remove -alpha off -strip -quality 85 "${1%.png}_q85.jpg"' _ {}
    ```
    ```

    说明
    • 使用 -background white -alpha remove -alpha off 处理透明背景,避免黑底;如需其他颜色,把 white 改成你想要的颜色值(如 “#1e1e1e”)。
    • -strip 会移除元数据以进一步减小体积;若需保留 ICC/EXIF,删除 -strip。
    • 质量 75 是偏中高的网页常用档位;需要更高或更小体积,调节 -quality。
  4. iqiancheng renamed this gist Oct 21, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. iqiancheng created this gist Oct 21, 2025.
    5 changes: 5 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@

    ```bash
    # 把当前目录下所有 PNG 转成 75% 质量的 JPG,并在原文件名后加 _quality75.jpg
    find . -maxdepth 1 -type f -iname '*.png' -print0 | xargs -0 -I{} sh -c 'magick "$1" -background white -alpha remove -alpha off -strip -quality 85 "${1%.png}_q85.jpg"' _ {}
    ```