~libravatar/libravatar/master

« back to all changes in this revision

Viewing changes to static/cdn/generate_all_sizes.sh

  • Committer: Francois Marier
  • Date: 2011-05-26 11:43:11 UTC
  • Revision ID: git-v1:1745d3c2d975c30525651559d1f0e20e38878fc7
Move js and css to -www and split images between -www and -cdn-common

Javascript and CSS files should be tied to the web application version
and not depend on mirrors to be up to date.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# This script needs imagemagick (apt-get install imagemagick)
 
4
#
 
5
# Copyright (C) 2010  Francois Marier <fmarier@gmail.com>
 
6
#
 
7
# Copying and distribution of this file, with or without modification,
 
8
# are permitted in any medium without royalty provided the copyright
 
9
# notice and this notice are preserved.  This file is offered as-is,
 
10
# without any warranty.
 
11
 
 
12
if [ "z$1" = "z" -o "z$2" = "z" ] ; then
 
13
        echo "Usage: $0 <original_image> <output_extension>"
 
14
        echo "       (e.g. $0 nobody.png png)"
 
15
        exit 1;
 
16
fi
 
17
 
 
18
ORIG_IMAGE=$1
 
19
EXTENSION=$2
 
20
 
 
21
for s in {1..512} ; do
 
22
        convert $ORIG_IMAGE -resize ${s}x${s} ${s}.$EXTENSION
 
23
 
 
24
        # Make sure all files are losslessly optimized
 
25
        if [ "$EXTENSION" = "png" ] ; then
 
26
                optipng -q ${s}.$EXTENSION
 
27
        elif [ "$EXTENSION" = "jpg" ] ; then
 
28
                jpegoptim -q -p --strip-all ${s}.$EXTENSION
 
29
        fi
 
30
done