Skip to content

Instantly share code, notes, and snippets.

@jwheare
Created February 1, 2011 11:52
Show Gist options
  • Save jwheare/805753 to your computer and use it in GitHub Desktop.
Save jwheare/805753 to your computer and use it in GitHub Desktop.
Convert an image to faux sepia tone.
<?php
@$data = file_get_contents($_GET['image']);
if (!$data) {
header("HTTP/1.1 400 Bad Request");
exit;
}
@$img = imagecreatefromstring($data);
if (!$img) {
header("HTTP/1.1 400 Bad Request");
exit;
}
function output_handler($output) {
$expires = 60*60*24*30;
header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $expires) . ' GMT');
header('Cache-control: public, max-age=' . $expires);
header('Content-type: image/png');
header('Content-Length: ' . strlen($output));
return $output;
}
imagefilter($img, IMG_FILTER_GRAYSCALE);
imagefilter($img, IMG_FILTER_COLORIZE, 90, 60, 40);
ob_start("output_handler");
imagepng($img);
ob_end_flush();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment