Last change
on this file since 490 was
490,
checked in by ehb, 7 years ago
|
|
-
Property svn:executable set to
*
|
File size:
715 bytes
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | $notes = "usage: $0 width files |
---|
4 | output base64 encoded images suitable for css or html img src= |
---|
5 | "; |
---|
6 | |
---|
7 | $gap = $ENV{ "GENAPP" } || die "$0: error env variable GENAPP must be defined\n"; |
---|
8 | |
---|
9 | $wid = shift || die $notes; |
---|
10 | die $notes if @ARGV < 1; |
---|
11 | |
---|
12 | use File::Basename; |
---|
13 | |
---|
14 | while ( $f = shift ) { |
---|
15 | my ( $base, $path, $ext ) = fileparse( $f, qr/\.[^.]*/ ); |
---|
16 | |
---|
17 | die "$0: $f not found\n" if !-e $f; |
---|
18 | |
---|
19 | $cmd = "identify $f | awk '{ print \$2 \"x\" \$3 }'\n"; |
---|
20 | $res = `$cmd`; |
---|
21 | my ( $t, $w, $h ) = $res =~ /^([^x]+)x([^x]+)x([^x]+)$/; |
---|
22 | $t = lc( $t ); |
---|
23 | print "$f: $t $h $w\n"; |
---|
24 | |
---|
25 | $cmd = "convert -resize $wid $f - | base64 -w 0"; |
---|
26 | $b64 = `$cmd`; |
---|
27 | |
---|
28 | print "$f: \"data:image/$t;base64,$b64\"\n"; |
---|
29 | } |
---|
30 | |
---|
Note: See
TracBrowser
for help on using the repository browser.