Last active
May 12, 2021 11:17
-
-
Save danielantelo/52f928d70d4d7da6f53b317780e4afc3 to your computer and use it in GitHub Desktop.
Revisions
-
danielantelo revised this gist
Mar 21, 2017 . 1 changed file with 18 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,14 @@ commandExists () { type "$1" &> /dev/null ; } installImageMagick() { if commandExists brew; then brew install imagemagick else apt-get install imagemagick fi } installJpegOptim() { if commandExists brew; then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null @@ -22,15 +30,21 @@ installOptiPng() { fi } resize() { RESIZE_PARAM='1200x640>' # resize different file types in parallel find . -name "*.jpg" -exec convert -resize $RESIZE_PARAM -verbose {} {} \; & find . -name "*.jpeg" -exec convert -resize $RESIZE_PARAM -verbose {} {} \; & find . -name "*.png" -exec convert -resize $RESIZE_PARAM -verbose {} {} \; } optimizePng() { # change -o5 to the desired levels of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o5 -strip all {} \; } optimizeJpg() { QUALITY=65 # optimize differen file types in parallel find . -name "*.jpg" -exec jpegoptim --max=$QUALITY -o -p --strip-all {} \; & find . -name "*.jpeg" -exec jpegoptim --max=$QUALITY -o -p --strip-all {} \; } if ! commandExists jpegoptim; then @@ -41,4 +55,5 @@ if ! commandExists optipng; then installOptiPng fi resize optimizeJpg & optimizePng -
danielantelo revised this gist
Mar 20, 2017 . 1 changed file with 5 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,25 +22,15 @@ installOptiPng() { fi } optimizePng() { # change -o5 to the desired levels of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o5 -strip all {} \; } optimizeJpg() { # change -m65 to the desired quality level find . -name "*.jpg" -exec jpegoptim --max=65 -o -p --strip-all {} \; find . -name "*.jpeg" -exec jpegoptim --max=65 -o -p --strip-all {} \; } if ! commandExists jpegoptim; then @@ -51,5 +41,4 @@ if ! commandExists optipng; then installOptiPng fi optimizeJpg & optimizePng -
danielantelo revised this gist
Mar 17, 2017 . 1 changed file with 14 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,26 +6,32 @@ commandExists () { installJpegOptim() { if commandExists brew; then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install jpegoptim else apt-get install jpegoptim fi } installOptiPng() { if commandExists brew; then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install optipng else apt-get install optipng fi } resizeImages() { if commandExists sips; then # change your desired max height here for the different image types find . -type f -name '*.png' -exec sips -Z 640 {} \; find . -type f -name '*.jpg' -exec sips -Z 640 {} \; find . -type f -name '*.jpeg' -exec sips -Z 640 {} \; fi # @TODO use something else when sips is not available } optimizePng() { # change -o4 to the desired levels of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o4 -strip all {} \; @@ -34,14 +40,16 @@ optimizePng() { optimizeJpg() { # change -m65 to the desired quality level find . -name "*.jpg" -exec jpegoptim -m65 -o -p --strip-all {} \; find . -name "*.jpeg" -exec jpegoptim -m65 -o -p --strip-all {} \; } if ! commandExists jpegoptim; then installJpegOptim fi if ! commandExists optipng; then installOptiPng fi resizeImages optimizePng & optimizeJpg -
danielantelo revised this gist
Mar 17, 2017 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,12 +27,12 @@ installOptiPng() { } optimizePng() { # change -o4 to the desired levels of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o4 -strip all {} \; } optimizeJpg() { # change -m65 to the desired quality level find . -name "*.jpg" -exec jpegoptim -m65 -o -p --strip-all {} \; } @@ -45,4 +45,3 @@ if ! commandExists optipng; then fi optimizePng & optimizeJpg -
danielantelo revised this gist
Mar 17, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,12 +26,12 @@ installOptiPng() { fi } optimizePng() { # change -o3 to the level of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o3 -strip all {} \; } optimizeJpg() { # change -m65 for quality level of th output file find . -name "*.jpg" -exec jpegoptim -m65 -o -p --strip-all {} \; } @@ -44,5 +44,5 @@ if ! commandExists optipng; then installOptiPng fi optimizePng & optimizeJpg -
danielantelo created this gist
Mar 17, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ #!/bin/bash commandExists () { type "$1" &> /dev/null ; } installJpegOptim() { if commandExists brew; then # macOS install ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install jpegoptim else # ubuntu install apt-get install jpegoptim fi } installOptiPng() { if commandExists brew; then # macOS install ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null brew install optipng else # ubuntu install apt-get install optipng fi } optimizePNG() { # change -o3 to the level of optimisation, the higher the number the slower it will go find . -name "*.png" -exec optipng -o3 -strip all {} \; } optimizeJPG() { # change -m65 for quality level of th output file find . -name "*.jpg" -exec jpegoptim -m65 -o -p --strip-all {} \; } if ! commandExists jpegoptim; then installJpegOptim fi if ! commandExists optipng; then installOptiPng fi optimizePNG & optimizeJPG