$now - (24*60*60)) { if (!is_file("c64_palette.gif")) { print "error: no c64_palette.gif, dying\n"; exit(1); } # works with IM 6.0.x # $command = "(". # "convert -scale '50%x100%' -map c64_palette.gif -resize '160x200' ". # "$tmpfile.gif $tmpfile-mapped.gif && ". # "composite -compose Src -gravity center $tmpfile-mapped.gif ". # "background.gif -matte $tmpfile-comp.gif && ". # "convert $tmpfile-comp.gif -sample '200%x100%' $tmpfile-out.gif ". # ") < /dev/null 2>&1"; # works with IM 6.2.x $command = "(". "convert +dither -scale '50%x100%' -remap c64_palette.gif -resize '160x200' ". "$tmpfile.gif $tmpfile-mapped.gif && ". "convert -size 160x200 xc:black ". "-gravity center $tmpfile-mapped.gif -composite $tmpfile-comp.gif && ". "convert $tmpfile-comp.gif -sample '200%x100%' $tmpfile-out.gif ". ") < /dev/null 2>&1"; exec($command, $out, $err); if ($err) { print "error: convert failed: ".join("
\n", $out); print "

command: $command

"; exit($err[0]); } if (is_file("$tmpfile-mapped.gif")) { unlink ("$tmpfile-mapped.gif"); } if (is_file("$tmpfile-comp.gif")) { unlink ("$tmpfile-comp.gif"); } } // don't need the source file any more if (is_file("$tmpfile.gif")) { unlink ("$tmpfile.gif"); } // redirect to the new output file //header("Location: c64ize.php?f=$inhash-$insize"); print '

C=64-ized!

Right-click on the image to save it, or mangle another image.

'; } function show_file($tmpfile) { global $tmpdir, $now; //"$tmpdir/c64-$inhash-$insize-out.gif" // sanitize $tmpfile = preg_replace("[^-a-fA-F0-9]", "_", $tmpfile); // output an already-built file header("Content-Type: image/gif"); header("Content-Disposition: inline; filename=c64ized.gif"); header("Content-Transfer-Encoding: binary"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", $now + (24*60*60)) . " GMT"); //header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); readfile("$tmpdir/c64-$tmpfile-out.gif"); } ?>