-
Notifications
You must be signed in to change notification settings - Fork 0
Image guidelines
Andreas Venturini edited this page May 5, 2020
·
4 revisions
Prior to committing images please read this guide:
- Only use JPEGs for photographs, do not use JPEGs for icons and logos
- Crop images so that any unnecessary content is removed
- Use ImageMagick with the following commands for all JPEG images prior to committing them to the repository:
convert -strip -sampling-factor 4:2:0 -interlace line -quality 70 input.jpg output.jpg
You can use the following if you want to convert multiple images within the current directory
while IFS= read -r file; do
convert -strip -sampling-factor 4:2:0 -interlace line -quality 70 $file $file
done < <(find . -type f -name "*.jpg")
You may alter the quality if the output is unacceptable for a given image (however you should avoid values > 90).
- Do not use PNGs for photographs, only use PNGs for icons and logos
- Crop PNGs so that only the required content remains (e.g. remove transparent borders if any).
- Use Pngcrush with the following commands for all PNGs prior to committing them to the repository:
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text -reduce input.png ./output/output.png
You can use the following if you want to convert multiple PNGs within the current directory
while IFS= read -r file; do
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text -reduce $file ./output/$file
done < <(find . -type f -name "*.png")
Use https://github.com/svg/svgo to optimize svg's w/ multipass option, e.g.:
svgo --multipass app/assets/images/logo.svg
Note: In case dimensions or width/height parameters are required the optimization might remove them, so be sure to add them back if relevant.