Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/bin/sh
  2. # Generate bunch of favicons, the original should preferrably be 500x500 png image
  3.  
  4. if [ $# -ne 1 ]; then
  5. echo USAGE: $0 favicon-original.png
  6. exit 1
  7. fi
  8.  
  9. ORIGINAL=$1
  10.  
  11. # IE is still braindead so still use favicon.ico
  12. convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 ${ORIGINAL} output-16x16.ico
  13. convert -resize x32 -gravity center -crop 32x32+0+0 -flatten -colors 256 ${ORIGINAL} output-32x32.ico
  14. convert output-16x16.ico output-32x32.ico favicon.ico
  15. rm output-16x16.ico output-32x32.ico
  16. # Then, HTML needs to specify size="XxY" as largest size due to browser bugs
  17. echo '<link rel="shortcut icon" href="/favicon.ico" sizes="32x32" />'
  18.  
  19. # Apple favicons
  20. for SIZE in 180 152 144 120 114 76 72 60 57
  21. do
  22. convert -resize x${SIZE} ${ORIGINAL} apple-touch-icon-${SIZE}x${SIZE}.png
  23. echo "<link rel=\"apple-touch-icon\" sizes=\"${SIZE}x${SIZE}\" href=\"apple-touch-icon-${SIZE}x${SIZE}.png\" />"
  24. done
  25.  
  26. # Normal favicons
  27. for SIZE in 192 160 96 32 16
  28. do
  29. convert -resize x${SIZE} ${ORIGINAL} favicon-${SIZE}x${SIZE}.png
  30. echo "<link rel=\"icon\" type=\"image/png\" sizes=\"${SIZE}x${SIZE}\" href=\"favicon-${SIZE}x${SIZE}.png\" />"
  31. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement