Animated GIF output for PHP/GD

php.internals

Jaakko Hyvätti

23 years ago
Hi! Some of yo might remember me from php3 times.. I just implemented animated gif output support with the bundled GD library. Patch works with both php-4.3.2 and php-4.3.3RC1. I keep the patch updated at http://www.iki.fi/hyvatti/sw/, but hopefully it will get included in PHP at some time. (Please Please Please!) I will be using it in production server soon here. Jaakko ---------- http://www.iki.fi/hyvatti/sw/ http://www.iki.fi/hyvatti/sw/php-4.3.2-gifanim.diff is a patch to php-4.3.2 and php-4.3.3RC1 to implement LZW compressed GIF images and GIF89a animations. Can be used when LZW properly licensed from Unisys or where otherwise legal. For most of the world, the Unisys patent is not valid and for example in the US the patent expires June 20th 2003. The configuration part of the patch might not be as beautiful as it could, I hope someone of the developer could help here. I hope this gets included in future releases of PHP. The patch essentially copies gd_lzw_out.c file from gd1.5.tar.gz to php-4.3.2/ext/gd/libgd/gd_gif_out.c with minor modifications, and patches other places in php source to include compilation of this file. The animation part of this patch implements three new functions, imagegifanimbegin(), imagegifanimadd(), and imagegifanimend(). With these functions, animated gif images can be created on the fly with php. The documentation for the functions is included in http://www.iki.fi/hyvatti/sw/php-doc-anim.diff, which is relative to current phpdoc CVS. The docs need maybe work if they have syntax mistakes but they should include all usage information. The part of patch that only implements GIF output without animatios is http://www.iki.fi/hyvatti/sw/php-4.3.2-gif.diff. I am in no way promoting GIF format over such superior formats as PNG, MNG or JPEG, but for some todays applications GIF format still has its uses. For example PNG and MNG are not supported in any 3G mobile terminals and GIF89A is the only way to create animations for visually attractive content. Even Mozilla project does not include MNG support for their code by default any more, so GIF89A is the only option.
-- Jaakko.Hyvatti@iki.fi http://www.iki.fi/hyvatti/ +358 40 5011222 echo 'movl $36,%eax;int $128;movl $0,%ebx;movl $1,%eax;int $128'|as -o/bin/sync

Ilia A.

23 years ago
Jaakko, Thanks for the patch, but there are a few things you should be aware of. While the LZW patent in US expires tomorrow, in Europe and possibly other parts of the world the patent will still be in force for another year. Which means non licensed users of GIF format in EU (I am guess you are in EU ;)) would be violating the LZW patent. Ilia

(Marcus Börger)

23 years ago
Hello Ilia, Thursday, June 19, 2003, 7:38:45 PM, you wrote: IA> Jaakko, IA> Thanks for the patch, but there are a few things you should be aware of. While IA> the LZW patent in US expires tomorrow, in Europe and possibly other parts of IA> the world the patent will still be in force for another year. Which means non IA> licensed users of GIF format in EU (I am guess you are in EU ;)) would be IA> violating the LZW patent. Same for japan. And in germany there was already a case showing that unisys will enforce their patent rights.
-- Best regards, Marcus mailto:helly@php.net

Moriyoshi Koizumi

23 years ago
"Ilia A." <ilia@prohost.org> wrote:
> Jaakko, > > Thanks for the patch, but there are a few things you should be aware of. While > the LZW patent in US expires tomorrow, in Europe and possibly other parts of > the world the patent will still be in force for another year. Which means non > licensed users of GIF format in EU (I am guess you are in EU ;)) would be > violating the LZW patent.
Agreed. So how about uncompressed GIF support? :) Moriyoshi

Derick Rethans

23 years ago
On Fri, 20 Jun 2003, Moriyoshi Koizumi wrote:
> "Ilia A." <ilia@prohost.org> wrote: > > > Jaakko, > > > > Thanks for the patch, but there are a few things you should be aware of. While > > the LZW patent in US expires tomorrow, in Europe and possibly other parts of > > the world the patent will still be in force for another year. Which means non > > licensed users of GIF format in EU (I am guess you are in EU ;)) would be > > violating the LZW patent. > > Agreed. So how about uncompressed GIF support? :)
How bloat... "If you implement something, do it good, or don't do it at all" (Old Dutch wisdom) regards, Derick
-- "Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails." ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ -------------------------------------------------------------------------

Ilia A.

23 years ago
On June 19, 2003 01:42 pm, you wrote:
> Agreed. So how about uncompressed GIF support? :)
What would be the point, the whole idea behind GIFs (imho) is to have small images at a more or less reasonable quality. Uncompressed gifs are virtually pointless. Ilia

Moriyoshi Koizumi

23 years ago
"Ilia A." <ilia@prohost.org> wrote:
> On June 19, 2003 01:42 pm, you wrote: > > Agreed. So how about uncompressed GIF support? :) > > What would be the point, the whole idea behind GIFs (imho) is to have small > images at a more or less reasonable quality. Uncompressed gifs are virtually > pointless.
Yeah, I wasn't serious. Moriyoshi

Jaakko Hyvätti

23 years ago
Hi all, Out of some.. 191 (UN members).. countries in the world, today Unisys holds a patent on LZW in 7 of them. After tomorrow, only in 6: Canada, United Kingdom, France, Germany, Italy, and Japan (http://www.unisys.com/about__unisys/lzw/index.htm). How worried would people be if the 6 countries would have been: Djibouti, Marshall Islands, Tonga, Kiribati, Fiji, and Grenada. I guess nobody would care if some unfortunate citizens of those countries accidentally violated local laws by downloading something. What's my point? Never mind. Anyway, I think I'll just maintain the patch for my uses and we'll see in 2004.. Unless Kiribati Patent Office happens to find the long lost Unisys patent application, and then the world is again held hostage.. Seriously, there are number of php mirror servers in those countries and maybe that is reason enough not to include gif compression in PHP. I would have hoped it to not be. Maybe --enable-lzw configuration flag which is not enabled by default would be enough? And uncompressed gif format is used if this is not enabled. Btw. I think even uncompressed (ungif) format is useful, as it still allows animations in browsers, and it is also ok where bandwidth is not a problem but cpu time is. Also complex images tend not to compress well anyway. Regards, Jaakko
-- Jaakko.Hyvatti@iki.fi http://www.iki.fi/hyvatti/ +358 40 5011222 echo 'movl $36,%eax;int $128;movl $0,%ebx;movl $1,%eax;int $128'|as -o/bin/sync

Derick Rethans

23 years ago
On Thu, 19 Jun 2003, [ISO-8859-1] Jaakko Hyvätti wrote:
> Anyway, I think I'll just maintain the patch for my uses and we'll see in > 2004.. Unless Kiribati Patent Office happens to find the long lost Unisys > patent application, and then the world is again held hostage..
Yup, and the same is most likely going to happen with software patents in Europe :( Derick
-- "Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails." ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ -------------------------------------------------------------------------