#!/usr/bin/perl -w # tiletest.pl - Don Yang (uguu.org) # # Check that output of Kazari tiles properly by creating an HTML page # that uses the output image as background. # # ./kazari | pnmtopng -compression=9 | ./tiletest.pl > output.html # # Might not work on all browsers depending on their implementation of # RFC 2397. It does work on Chrome 3.0.195.38 and Firefox 3.5.7 # # 01/08/10 use strict; use MIME::Base64; # Read entire file into memory binmode STDIN; my $data = join '', ; # Guess a MIME type based on presence of magic strings my $type = "image/jpeg"; if( substr($data, 0, 4) eq "\x89PNG" ) { $type = "image/png"; } # Encode page my $url = encode_base64($data); $url =~ s/\s//gs; $url = "data:$type;base64,$url"; print <<"EOT"; Kazari EOT