PHP Classes

Take width/height from first added frame

Recommend this page to a friend!

      Move Me GIF  >  All threads  >  Take width/height from first added frame  >  (Un) Subscribe thread alerts  
Subject:Take width/height from first added frame
Summary:Instead of setting the gif size take it from first frame
Messages:5
Author:André Dias
Date:2016-10-16 15:03:58
 

  1. Take width/height from first added frame   Reply   Report abuse  
Picture of André Dias André Dias - 2016-10-16 15:03:58
In the example we have:

$builder = new GifBuilder(307, 230);

And then a loop to include 8 png files. So I need a call to getimagesize before starting to create the gif. Is it possible to adjust the class to take the first frame widht/height instead of asking for it explicitly in the class constructor?

  2. Re: Take width/height from first added frame   Reply   Report abuse  
Picture of Patrick Van Bergen Patrick Van Bergen - 2016-10-16 18:22:43 - In reply to message 1 from André Dias
Good point, André. The library should not have to ask this.

I can easily solve this by having GifBuilder take the dimensions of the first frame for its overall dimensions, but I don't like that solution, because the frames may very well differ in size and position.

Another solution would be something like GifBuilder::createFromImage(), but that would suggest more than that it's actually doing.

Let me think about this for a few days. I'll get back to you on this.

  3. Re: Take width/height from first added frame   Reply   Report abuse  
Picture of André Dias André Dias - 2016-10-16 18:43:22 - In reply to message 2 from Patrick Van Bergen
Thanks for the reply.

I see your point, but currently how the library handles different frame sizes? If it always cuts the frames to fit the constructor size AFAICS the solution of taking the first frame size would be the same.

I believe a better name function would be GifBuilder::startFromImage() so it would be more obvious that this is the first frame.

  4. Re: Take width/height from first added frame   Reply   Report abuse  
Picture of Patrick Van Bergen Patrick Van Bergen - 2016-10-21 19:42:37 - In reply to message 3 from André Dias
I went for the option of taking the dimensions of the first frame, when no width and height are specified in GifBuilder's constructor. It seemed most natural.

The example of horse.php was updated to show the changes. Its frames are all same sized.

Thanks for your feedback, André!

  5. Re: Take width/height from first added frame   Reply   Report abuse  
Picture of André Dias André Dias - 2016-10-21 20:13:06 - In reply to message 4 from Patrick Van Bergen
Thanks for the update and for sharing your wonderful class.