source: genapp/bin/image2img.pl @ 472

Last change on this file since 472 was 472, checked in by ehb, 7 years ago
  • Property svn:executable set to *
File size: 695 bytes
Line 
1#!/usr/bin/perl
2
3$notes = "usage: $0 width files
4output img src= for base64 encoded images
5";
6
7$gap = $ENV{ "GENAPP" } || die "$0: error env variable GENAPP must be defined\n";
8
9$wid = shift || die $notes;
10die $notes if @ARGV < 1;
11
12use File::Basename;
13
14while ( $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/png;base64,$b64\"\n";
29}
30
Note: See TracBrowser for help on using the repository browser.