| 1 |
#!/usr/bin/php -d extension_dir=./objdir/api/php |
| 2 |
<?php |
| 3 |
|
| 4 |
# ExactImage PHP Example |
| 5 |
# Copyright (C) 2008 - 2010 Rene Rebe, ExactCODE GmbH |
| 6 |
|
| 7 |
ini_set("include_path", "./objdir/api/php/"); |
| 8 |
//ini_set("extension_dir", "./objdir/api/php/"); // does not work here |
| 9 |
|
| 10 |
// load the module |
| 11 |
include("ExactImage.php"); |
| 12 |
|
| 13 |
$image = newImage(); |
| 14 |
|
| 15 |
if (decodeImageFile ($image, "testsuite/281-4.2.04.tif")) |
| 16 |
{ |
| 17 |
print "image decoded all fine.\n"; |
| 18 |
} |
| 19 |
else { |
| 20 |
print "something went wrong ...\n"; |
| 21 |
exit; |
| 22 |
} |
| 23 |
|
| 24 |
if (encodeImageFile ($image, "test.jpg", 80, "")) |
| 25 |
{ |
| 26 |
print "image written all fine.\n"; |
| 27 |
} else { |
| 28 |
print "something went wrong writing the image ...\n"; |
| 29 |
exit; |
| 30 |
} |
| 31 |
|
| 32 |
# advanced use, use in memory locations |
| 33 |
$image_bits=`cat testsuite/tif/5.1.13.tif`; |
| 34 |
|
| 35 |
if (decodeImage ($image, $image_bits)) |
| 36 |
{ |
| 37 |
print "image read from RAM.\n"; |
| 38 |
} else { |
| 39 |
print "something went wrong decoding the RAM\n"; |
| 40 |
exit; |
| 41 |
} |
| 42 |
|
| 43 |
# image properties |
| 44 |
|
| 45 |
print "Width: " . imageWidth ($image) . "\n"; |
| 46 |
print "Height: " . imageHeight ($image) . "\n"; |
| 47 |
print "Xres: " . imageXres ($image) . "\n"; |
| 48 |
print "Yres: " . imageYres ($image) . "\n"; |
| 49 |
|
| 50 |
print "Channels: " . imageChannels ($image) . "\n"; |
| 51 |
print "Channel depth: " . imageChannelDepth ($image). "\n"; |
| 52 |
|
| 53 |
# setable as well |
| 54 |
|
| 55 |
imageSetXres ($image, 144); |
| 56 |
imageSetYres ($image, 144); |
| 57 |
|
| 58 |
print "Xres: " . imageXres ($image) . "\n"; |
| 59 |
print "Yres: " . imageYres ($image) . "\n"; |
| 60 |
|
| 61 |
|
| 62 |
deleteImage($image); |
| 63 |
|
| 64 |
?> |