d91ab6665c0bd02a16d9e88c3ba407f0aea3cbed
[yaffs-website] / lsolesen / pel / tutorials / PEL / faq.pkg
1 <refentry id="{@id}">
2   <refnamediv>
3     <refname>Frequently Asked Questions (FAQ)</refname>
4     <refpurpose>Quick answers to common questions</refpurpose>
5   </refnamediv>
6   <refsynopsisdiv>
7     <authorblurb>
8       <para>
9         <author>
10           <firstname>Martin</firstname>
11           <surname>Geisler</surname>
12         </author>
13         {@link mailto:mgeisler@users.sourceforge.net
14         mgeisler@users.sourceforge.net}
15       </para>
16     </authorblurb>
17   </refsynopsisdiv>
18
19   {@toc}
20
21 <refsect1 id="{@id pel-acronym}">
22
23   <title>What does PEL stand for?</title>
24
25   <para>PEL is an acronym for "PHP Exif Library".  Sound simple
26   enough, doesn't it?</para>
27
28   <para>But did you realise that PEL is an acronym consisting of two
29   acronyms, one of which is recursive!  So "PEL" actually stands for
30   "PHP Hypertext Preprocessor Exchangeable image file format Library".
31   Pyh!</para>
32 </refsect1>
33
34
35 <refsect1 id="{@id exif-vs-exif}">
36
37   <title>What's the business with EXIF vs. Exif?</title>
38
39   <para>Well, since Exif is an acronym for "Exchangeable image file
40   format" and thus you would expect it to be spelled "EXIF", just like
41   "JPEG" which is an acronym for Joint Photographic Experts
42   Group.</para>
43
44   <para>But the Exif standards spell Exif as "Exif" and so does PEL,
45   at least since version 0.9.  But should they ever decide to update
46   their acronym to "EXIF" then PEL will revert...  Luckily it does not
47   affect the acronym PEL itself :-)</para>
48
49 </refsect1>
50
51
52 <refsect1 id="{@id why-php5}">
53   <title>Why does PEL require PHP version 5?</title>
54
55   <para>The support for object-oriented programming was completely
56   overhauled with the introduction of PHP 5 in July 2004.  The changes
57   included both semantic changes and syntaxtical changes to the PHP
58   language.</para>
59
60   <para>The semantic change was the use of object references per
61   default.  This change means that when you do</para>
62
63   <programlisting role="php">
64     <![CDATA[
65 $object_a = $ifd->getEntry(PelTag::IMAGE_DESCRIPTION);
66 $object_a->setValue('This is my new description.');
67 $object_b = $ifd->getEntry(PelTag::IMAGE_DESCRIPTION);
68     ]]>
69   </programlisting>
70
71   <para>then <literal>$object_a</literal> and
72   <literal>$object_b</literal> will both reference <emphasis>the
73   same</emphasis> element.  In particular, you will see that
74   <literal>$object_b->getValue()</literal> returns the string just
75   stored in <literal>$object_a</literal> (since they are the same
76   object).  With PHP 4 you would have gotten two different objects,
77   which is generally not what you want.</para>
78
79   <para>The syntaxtical changes from PHP 5 to PHP 4 include the
80   addition of access modifiers to object fields (the private,
81   protected, and public keywords), object constants, constructors
82   named <literal>__construct()</literal>, interfaces and abstract
83   classes, and exceptions.  PEL uses all these new features to the
84   fullest, which means that PHP 4 doesn't understand the code.</para>
85
86   <para>If your provider is still using PHP 4, then you should ask
87   them to upgrade.  PHP 5 has been declared stable since July 2004 and
88   all major PHP applications ({@link http://www.wordpress.org
89   WordPress}, {@link http://gallery.menalto.com/ Gallery},
90   {@link http://phpwiki.sourceforge.net/ PhpWiki},
91   {@link http://www.phpmyadmin.net/ phpMyAdmin}, etc...), have been
92   upgraded to work with PHP 5, so an upgrade should not bring you any
93   problems, just more features and better performance.</para>
94
95 </refsect1>
96
97
98 <refsect1 id="{@id fatal-php4-errors}">
99
100   <title>Why do I get fatal errors from PHP?</title>
101
102   <para>If you get a fatal error when trying to use PEL, then your
103   installation of PHP might be too old.  PEL requires PHP version 5.
104   Please see the question "{@tutorial faq.pkg#why-php5}" for more
105   information.</para>
106
107 </refsect1>
108
109
110 <refsect1 id="{@id call-on-non-object}">
111   <title>What does "<literal>Call to a member function
112   <function>f</function> on a non-object</literal>" (where
113   <function>f</function> is <literal>getTiff()</literal> or
114   <literal>setValue()</literal>) mean?</title>
115
116   <para>This is the error PHP gives when you call a method on a
117   variable which is not an object.</para>
118
119   <para>PEL uses objects to represent the entire structure of a JPEG
120   image, and many of the methods defined on those objects return other
121   objects.  In particular, the method {@link PelJpeg::getExif()}
122   returns a {@link PelExif} object and {@link PelIfd::getEntry()}
123   returns a {@link PelEntry} object.</para>
124
125   <para>But both methods can return <literal>null</literal> if no such
126   section or entry exist.  The correct way to use them is thus
127   something along the lines of:</para>
128
129   <programlisting role="php">
130     <![CDATA[
131 $exif = $jpeg->getExif();
132 if ($exif != null) {
133   $tiff = $exif->getTiff();
134   /* Do something with the TIFF data. */
135 } else {
136   /* Sorry --- no Exif data found. */
137 }
138     ]]>
139   </programlisting>
140
141   <para>The same principle applies to the return values of
142   {@link PelIfd::getEntry()} and all other methods which return
143   objects.</para>
144
145 </refsect1>
146
147
148 <refsect1 id="{@id IPTC-entries}">
149
150   <title>Does PEL handle IPTC entries?</title>
151
152   <para>No, PEL only deals with Exif data, and no such extension is
153   planned.  Try taking at look at the
154   {@link http://www.ozhiker.com/electronics/pjmt/ PHP JPEG Metadata
155   Toolkit} which should handle IPTC along with a huge number of other
156   metadata formats.</para>
157
158 </refsect1>
159
160
161 <refsect1 id="{@id missing-Gettext}">
162
163   <title>Why does Gettext not work?</title>
164
165   <para>PEL uses Gettext for localization, and thus your system must
166   fulfill a few requirements:</para>
167
168   <orderedlist>
169
170     <listitem>
171       <para>PHP must have support for the
172       {@link http://www.php.net/manual/en/ref.gettext.php Gettext
173       extension}.  Most installations of PHP already has this, but
174       please double-check with <function>
175       {@link http://www.php.net/manual/en/function.phpinfo.php
176       phpinfo}</function> before asking for help on the
177       mailinglist.</para>
178     </listitem>
179
180     <listitem>
181       <para>The system must be setup to generate locales for the
182       languages into which PEL has been translated.  Again, most
183       commercial webhosts would have their systems configured to deal
184       with all locales, but if you're installing PEL on your own
185       server you'll probably have to reconfigure it.</para>
186
187       <para>How to configure the locales differ from system to system.
188       With the {@link http://www.debian.net/ Debian GNU/Linux}
189       distribution you should run</para>
190
191       <programlisting>
192         dpkg-reconfigure locales
193       </programlisting>
194
195       <para>and then select all locales that you want your system to
196       support.</para>
197
198       <para>Restart your webserver after changing the locale setup to
199       make the changes effective.</para>
200
201     </listitem>
202
203   </orderedlist>
204
205 </refsect1>
206
207
208 <refsect1 id="{@id error-handling}">
209
210   <title>How to deal with broken images?</title>
211
212   <para>By default PEL will try to load as much from an image as
213   possible and continue dispite any errors found.  The Exif standard
214   mandates certain formats and lengths for some entries, and sometimes
215   these requirements are violated.</para>
216
217   <para>The strictness of PEL is controlled by the the method
218   {@link Pel::setStrictParsing()}.  The default is non-strict parsing.
219   In this mode, PEL will not throw exceptions for parse errors but
220   instead store them for later inspection via the
221   {@link Pel::getExceptions()} method.</para>
222
223   <para>With an argument of <literal>true</literal> to
224   {@link Pel::setStrictParsing()} you make PEL throw exceptions upon
225   parse errors.</para>
226
227   <para>This may all sound very complex, but it is actually fairly
228   simple for most uses: have PEL load your images in non-strict mode
229   and check for errors afterwards, if necessary.</para>
230
231   <para>Please note that even if PEL is in non-strict mode it might
232   throw exceptions while parsing an image, for example if the image
233   cannot be recognized a JPEG or TIFF image.  So it is always
234   necessary to wrap calls to PEL in a try-catch block.</para>
235
236 </refsect1>
237
238
239 <refsect1 id="{@id commercial-use}">
240
241   <title>Can I use PEL for a commercial application?</title>
242
243   <para>Yes, no problem as long as you do not distribute your
244   application under another license than the GNU GPL.</para>
245
246   <para>As you should know, PEL is licensed to you under the
247   conditions of the GNU GPL.  The license deals
248   <emphasis>only</emphasis> with the distribution of PEL and any
249   derivative works based on PEL, the license has nothing to say over
250   how you may use PEL.</para>
251
252   <para>So if you do not distribute your code, then you can use it for
253   whatever you want, including writing a website (commercial or not)
254   that integrates PEL.  Please see
255   {@link http://www.gnu.org/licenses/gpl-faq.html#GPLRequireSourcePostedPublic
256   this question} in the GPL FAQ.</para>
257
258 </refsect1>
259
260
261 <refsect1 id="{@id unanswered-question}">
262
263   <title>My question is not answered here!</title>
264
265   <para>Please ask your questions on the
266   {@link http://lists.sourceforge.net/lists/listinfo/pel-devel PEL
267   Development List}.  If an answer is found, then the FAQ will be
268   updated.</para>
269
270 </refsect1>
271
272
273 </refentry>