Frequently Asked Questions (FAQ) Quick answers to common questions Martin Geisler {@link mailto:mgeisler@users.sourceforge.net mgeisler@users.sourceforge.net} {@toc} What does PEL stand for? PEL is an acronym for "PHP Exif Library". Sound simple enough, doesn't it? But did you realise that PEL is an acronym consisting of two acronyms, one of which is recursive! So "PEL" actually stands for "PHP Hypertext Preprocessor Exchangeable image file format Library". Pyh! What's the business with EXIF vs. Exif? Well, since Exif is an acronym for "Exchangeable image file format" and thus you would expect it to be spelled "EXIF", just like "JPEG" which is an acronym for Joint Photographic Experts Group. But the Exif standards spell Exif as "Exif" and so does PEL, at least since version 0.9. But should they ever decide to update their acronym to "EXIF" then PEL will revert... Luckily it does not affect the acronym PEL itself :-) Why does PEL require PHP version 5? The support for object-oriented programming was completely overhauled with the introduction of PHP 5 in July 2004. The changes included both semantic changes and syntaxtical changes to the PHP language. The semantic change was the use of object references per default. This change means that when you do getEntry(PelTag::IMAGE_DESCRIPTION); $object_a->setValue('This is my new description.'); $object_b = $ifd->getEntry(PelTag::IMAGE_DESCRIPTION); ]]> then $object_a and $object_b will both reference the same element. In particular, you will see that $object_b->getValue() returns the string just stored in $object_a (since they are the same object). With PHP 4 you would have gotten two different objects, which is generally not what you want. The syntaxtical changes from PHP 5 to PHP 4 include the addition of access modifiers to object fields (the private, protected, and public keywords), object constants, constructors named __construct(), interfaces and abstract classes, and exceptions. PEL uses all these new features to the fullest, which means that PHP 4 doesn't understand the code. If your provider is still using PHP 4, then you should ask them to upgrade. PHP 5 has been declared stable since July 2004 and all major PHP applications ({@link http://www.wordpress.org WordPress}, {@link http://gallery.menalto.com/ Gallery}, {@link http://phpwiki.sourceforge.net/ PhpWiki}, {@link http://www.phpmyadmin.net/ phpMyAdmin}, etc...), have been upgraded to work with PHP 5, so an upgrade should not bring you any problems, just more features and better performance. Why do I get fatal errors from PHP? If you get a fatal error when trying to use PEL, then your installation of PHP might be too old. PEL requires PHP version 5. Please see the question "{@tutorial faq.pkg#why-php5}" for more information. What does "<literal>Call to a member function <function>f</function> on a non-object</literal>" (where <function>f</function> is <literal>getTiff()</literal> or <literal>setValue()</literal>) mean? This is the error PHP gives when you call a method on a variable which is not an object. PEL uses objects to represent the entire structure of a JPEG image, and many of the methods defined on those objects return other objects. In particular, the method {@link PelJpeg::getExif()} returns a {@link PelExif} object and {@link PelIfd::getEntry()} returns a {@link PelEntry} object. But both methods can return null if no such section or entry exist. The correct way to use them is thus something along the lines of: getExif(); if ($exif != null) { $tiff = $exif->getTiff(); /* Do something with the TIFF data. */ } else { /* Sorry --- no Exif data found. */ } ]]> The same principle applies to the return values of {@link PelIfd::getEntry()} and all other methods which return objects. Does PEL handle IPTC entries? No, PEL only deals with Exif data, and no such extension is planned. Try taking at look at the {@link http://www.ozhiker.com/electronics/pjmt/ PHP JPEG Metadata Toolkit} which should handle IPTC along with a huge number of other metadata formats. Why does Gettext not work? PEL uses Gettext for localization, and thus your system must fulfill a few requirements: PHP must have support for the {@link http://www.php.net/manual/en/ref.gettext.php Gettext extension}. Most installations of PHP already has this, but please double-check with {@link http://www.php.net/manual/en/function.phpinfo.php phpinfo} before asking for help on the mailinglist. The system must be setup to generate locales for the languages into which PEL has been translated. Again, most commercial webhosts would have their systems configured to deal with all locales, but if you're installing PEL on your own server you'll probably have to reconfigure it. How to configure the locales differ from system to system. With the {@link http://www.debian.net/ Debian GNU/Linux} distribution you should run dpkg-reconfigure locales and then select all locales that you want your system to support. Restart your webserver after changing the locale setup to make the changes effective. How to deal with broken images? By default PEL will try to load as much from an image as possible and continue dispite any errors found. The Exif standard mandates certain formats and lengths for some entries, and sometimes these requirements are violated. The strictness of PEL is controlled by the the method {@link Pel::setStrictParsing()}. The default is non-strict parsing. In this mode, PEL will not throw exceptions for parse errors but instead store them for later inspection via the {@link Pel::getExceptions()} method. With an argument of true to {@link Pel::setStrictParsing()} you make PEL throw exceptions upon parse errors. This may all sound very complex, but it is actually fairly simple for most uses: have PEL load your images in non-strict mode and check for errors afterwards, if necessary. Please note that even if PEL is in non-strict mode it might throw exceptions while parsing an image, for example if the image cannot be recognized a JPEG or TIFF image. So it is always necessary to wrap calls to PEL in a try-catch block. Can I use PEL for a commercial application? Yes, no problem as long as you do not distribute your application under another license than the GNU GPL. As you should know, PEL is licensed to you under the conditions of the GNU GPL. The license deals only with the distribution of PEL and any derivative works based on PEL, the license has nothing to say over how you may use PEL. So if you do not distribute your code, then you can use it for whatever you want, including writing a website (commercial or not) that integrates PEL. Please see {@link http://www.gnu.org/licenses/gpl-faq.html#GPLRequireSourcePostedPublic this question} in the GPL FAQ. My question is not answered here! Please ask your questions on the {@link http://lists.sourceforge.net/lists/listinfo/pel-devel PEL Development List}. If an answer is found, then the FAQ will be updated.