X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Flsolesen%2Fpel%2Fexamples%2Fdump-image.php;fp=vendor%2Flsolesen%2Fpel%2Fexamples%2Fdump-image.php;h=ad8ce836fd1061b933fee9a905fb91cf4e9fe152;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/lsolesen/pel/examples/dump-image.php b/vendor/lsolesen/pel/examples/dump-image.php new file mode 100644 index 000000000..ad8ce836f --- /dev/null +++ b/vendor/lsolesen/pel/examples/dump-image.php @@ -0,0 +1,97 @@ +#!/usr/bin/php +\n", $prog); + print("Optional arguments:\n"); + print(" -d turn debug output on.\n"); + print(" -s turn strict parsing on (halt on errors).\n"); + print("Mandatory arguments:\n"); + print(" filename a JPEG or TIFF image.\n"); + exit(1); +} + +if (! is_readable($file)) { + printf("Unable to read %s!\n", $file); + exit(1); +} + +/* + * We typically need lots of RAM to parse TIFF images since they tend + * to be big and uncompressed. + */ +ini_set('memory_limit', '32M'); + +$data = new PelDataWindow(file_get_contents($file)); + +if (PelJpeg::isValid($data)) { + $img = new PelJpeg(); +} elseif (PelTiff::isValid($data)) { + $img = new PelTiff(); +} else { + print("Unrecognized image format! The first 16 bytes follow:\n"); + PelConvert::bytesToDump($data->getBytes(0, 16)); + exit(1); +} + +/* Try loading the data. */ +$img->load($data); + +print($img); + +/* Deal with any exceptions: */ +if (count(Pel::getExceptions()) > 0) { + print("\nThe following errors were encountered while loading the image:\n"); + foreach (Pel::getExceptions() as $e) { + print("\n" . $e->__toString()); + } +}