1: <?php
2: /**
3: ##DOC-SIGNATURE##
4:
5: This file is part of WideImage.
6:
7: WideImage is free software; you can redistribute it and/or modify
8: it under the terms of the GNU Lesser General Public License as published by
9: the Free Software Foundation; either version 2.1 of the License, or
10: (at your option) any later version.
11:
12: WideImage is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU Lesser General Public License for more details.
16:
17: You should have received a copy of the GNU Lesser General Public License
18: along with WideImage; if not, write to the Free Software
19: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20:
21: * @package Internal/Mappers
22: **/
23:
24: namespace WideImage\Mapper;
25:
26: /**
27: * Mapper class for GIF files
28: *
29: * @package Internal/Mappers
30: */
31: class GIF
32: {
33: public function load($uri)
34: {
35: return @imagecreatefromgif($uri);
36: }
37:
38: public function save($handle, $uri = null)
39: {
40: // This is a workaround for a bug, for which PHP devs claim it's not
41: // really a bug. Well, it IS.
42: // You can't pass null as the second parameter, because php is
43: // then trying to save an image to a '' location (which results in an
44: // error, of course). And the same thing works fine for imagepng() and
45: // imagejpeg(). It's a bug! ;)
46: if ($uri) {
47: return imagegif($handle, $uri);
48: }
49:
50: return imagegif($handle);
51: }
52: }
53: