Skip to content

Instantly share code, notes, and snippets.

@faustort
Forked from JesseRWeigel/commands.txt
Last active October 25, 2020 04:07
Show Gist options
  • Save faustort/78f21ce171c5f06c5b46d42bc8ac0123 to your computer and use it in GitHub Desktop.
Save faustort/78f21ce171c5f06c5b46d42bc8ac0123 to your computer and use it in GitHub Desktop.

Revisions

  1. faustort revised this gist Oct 25, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion commands-ImageMagick.txt
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% {} \;

    // This one actually compresses all the images in folder and subfolders
    (the real thing)
    find . -name "*.jpg" -exec mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% {} \;
    find . -name "*.jpg" -exec mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% -verbose {} \;

    // This command compresses a png with no visible loss of quality
    mogrify -filter Triangle -define filter:support=2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB *.png
  2. faustort renamed this gist Oct 25, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. Jesse R Weigel created this gist Apr 28, 2017.
    30 changes: 30 additions & 0 deletions commands.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // Must install ImageMagick first
    http://www.imagemagick.org/script/index.php

    //This compresses a jpg with no visible loss of quality. Add in your own file names for target.jpg and result.jpg
    convert -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% target.jpg result.jpg

    // This does the same as above but to an entire folder (will overwrite original files):
    mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% *.jpg

    //This does the same thing but to all subfolders as well (Be careful with this one it will overwrite all original files)
    //This one just tests the command and prints output
    find . -name "*.jpg" -exec echo
    mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% {} \;

    // This one actually compresses all the images in folder and subfolders
    (the real thing)
    find . -name "*.jpg" -exec mogrify -strip -interlace Plane -sampling-factor 4:2:0 -quality 85% {} \;

    // This command compresses a png with no visible loss of quality
    mogrify -filter Triangle -define filter:support=2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB *.png

    These commands were copied or adapted from the following sources:

    http://www.imagemagick.org/discourse-server/viewtopic.php?t=24134

    http://stackoverflow.com/questions/27267073/imagemagick-lossless-max-compression-for-png

    https://sangpo.wordpress.com/2009/01/24/recursive-batch-image-resizing-in-linux/

    http://stackoverflow.com/questions/7261855/recommendation-for-compressing-jpg-files-with-imagemagick