412
412
$clut = $this->colorTable;
415
if (file_exists($input)) {
416
$gd = imagecreatefrompng($input);
418
throw new Exception("Unable to apply color-table: $input does not exist.");
422
throw new Exception("Unable to apply color-table: $input is not a valid image.");
425
} catch(Exception $e) {
426
logErrorMsg($e->getMessage(), true);
414
if (file_exists($input)) {
415
$gd = imagecreatefrompng($input);
417
throw new Exception("Unable to apply color-table: $input does not exist.");
421
throw new Exception("Unable to apply color-table: $input is not a valid image.");
428
424
$ctable = imagecreatefrompng($clut);
430
426
for ($i = 0; $i <= 255; $i++) {
460
456
public function display()
463
//header("Cache-Control: public, max-age=" . $lifetime * 60);
464
$headers = apache_request_headers();
458
//header("Cache-Control: public, max-age=" . $lifetime * 60);
459
$headers = apache_request_headers();
461
// Enable caching of images served by PHP
462
// http://us.php.net/manual/en/function.header.php#61903
463
$lastModified = 'Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($this->outputFile)).' GMT';
464
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($this->outputFile))) {
465
// Cache is current (304)
466
header($lastModified, true, 304);
468
// Image not in cache or out of date (200)
469
header($lastModified, true, 200);
471
header('Content-Length: '.filesize($this->outputFile));
473
if ($this->format == "png") {
474
header("Content-Type: image/png");
476
header("Content-Type: image/jpeg");
479
// Filename & Content-length
480
$exploded = explode("/", $this->outputFile);
481
$filename = end($exploded);
482
header("Content-Disposition: inline; filename=\"$filename\"");
466
// Enable caching of images served by PHP
467
// http://us.php.net/manual/en/function.header.php#61903
468
$lastModified = 'Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($this->outputFile)).' GMT';
469
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($this->outputFile))) {
470
// Cache is current (304)
471
header($lastModified, true, 304);
473
// Image not in cache or out of date (200)
474
header($lastModified, true, 200);
476
header('Content-Length: '.filesize($this->outputFile));
478
if ($this->format == "png") {
479
header("Content-Type: image/png");
481
header("Content-Type: image/jpeg");
484
// Filename & Content-length
485
$exploded = explode("/", $this->outputFile);
486
$filename = end($exploded);
487
header("Content-Disposition: inline; filename=\"$filename\"");
489
if (!readfile($this->outputFile)) {
490
throw new Exception("Unable to read tile from cache: $filename");
484
if (!readfile($this->outputFile)) {
485
throw new Exception("Unable to read tile from cache: $filename");
494
} catch (Exception $e) {
495
logErrorMsg($error, true);