Skip to content

Instantly share code, notes, and snippets.

@YuCJ
Last active December 17, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YuCJ/3a3dfbd951381af5599bc4e2f809e13f to your computer and use it in GitHub Desktop.
Save YuCJ/3a3dfbd951381af5599bc4e2f809e13f to your computer and use it in GitHub Desktop.

Optimizing Resource

Optimizing Images

Ref:

https://developers.google.com/speed/docs/insights/OptimizeImages (Will be deprecated at May 2019) https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/image-optimization

Use:

http://www.imagemagick.org/Usage/basics/#mogrify https://formulae.brew.sh/formula/imagemagick

brew update; brew install 

desktop

jpg 壓成寬 1440

convert *.jpg -sampling-factor 4:2:0 -strip -resize 1440 -quality 85 -interlace JPEG -set filename:fname 'desktop-%t-%wx%h' +adjoin '%[filename:fname].jpg'
convert *.png -strip -resize 1440x960 -quality 60 -set filename:fname 'desktop-%t-%wx%h-fg' +adjoin '%[filename:fname].png'

tablet

壓 1024

convert *.jpg -sampling-factor 4:2:0 -strip -resize 1024 -quality 85 -interlace JPEG -set filename:fname 'tablet-%t-%wx%h' +adjoin '%[filename:fname].jpg'
convert *.png -strip -resize 1024x1024 -set filename:fname 'tablet-%t-%wx%h-fg' +adjoin '%[filename:fname].png'

mobile

壓 768

convert *.jpg -sampling-factor 4:2:0 -strip -resize 768 -quality 85 -interlace JPEG -set filename:fname 'mobile-%t-%wx%h' '%[filename:fname].jpg'
convert *.png -strip -resize 170x170 -set filename:fname '%t'  'compressed/%[filename:fname].png'

Optimizing Sound

Use ffmpeg: https://formulae.brew.sh/formula/ffmpeg

brew update; brew install ffmpeg
ffmpeg -i 05-work-early.mp3 -codec:a libmp3lame -b:a 128k m/05-work-early.mp3
ffmpeg -i 09-poisoned.mp3 -codec:a libmp3lame -b:a 128k m/09-poisoned.mp3
ffmpeg -i 12-about-salary.mp3 -codec:a libmp3lame -b:a 128k m/12-about-salary.mp3
ffmpeg -i 20-special.mp3 -codec:a libmp3lame -b:a 128k m/20-special.mp3
ffmpeg -i 24-future-ending.mp3 -codec:a libmp3lame -b:a 128k m/24-future-ending.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment