PHP Classes

C_MEMORY Parameter

Recommend this page to a friend!

      GIF images into animated GIF with native PHP class  >  All threads  >  C_MEMORY Parameter  >  (Un) Subscribe thread alerts  
Subject:C_MEMORY Parameter
Summary:How to use
Messages:28
Author:Felipe
Date:2006-06-17 13:31:00
Update:2006-09-25 20:42:31
 
  1 - 10   11 - 20   21 - 28  

  1. C_MEMORY Parameter   Reply   Report abuse  
Picture of Felipe Felipe - 2006-06-17 13:31:00
First i want to thank you for this class.. its perfect!

I take today the update and in this new version have one more parameter. The last parameter of GifMerge have the mode, that can be C_FILE or C_MEMORY .. C_FILE its ok.. all i need to indicate a gif file at array. But, how can i use C_MEMORY? Have you an example to us?

Best regards,

Felipe.

  2. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2006-06-19 12:52:51 - In reply to message 1 from Felipe
'C_MEMORY' flag must be use:

$image = imageCreateFromGif("image.gif");
....
any image manipulations...
....
/* Must be get the binary data from imageGif() into a variable */
ob_start();
imageGif($image);
$frames[$i] = ob_get_contents();
ob_end_clean();
....
imageDestroy($image);
$gif = new GifMerge($frames, ...., 'C_MEMORY');

This solution is idal for generating various image or animation effects
on the fly without saving modified images.

========================================================================

'C_FILE' flag must be use:
/* Must be get the relative image paths */
for($i = 0; ; ;)
{
$frames[$i] = "queue/upload/frames$i.gif";
}
$gif = new GifMerge($frames, ...., 'C_FILE');

========================================================================

GifMerge class will be use the retrievaled data from the frames
array by this flag.
The default is 'C_FILE'

  3. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of renaud renaud - 2006-06-27 20:01:27 - In reply to message 2 from László Zsidi
Hi !

Aways the same message:

Welcome to the GifMerge 1.0e debugger...
<br>
--------------------------------------------
<br>
<br>
<br />
<b>Notice</b>: Undefined variable: global_color_table_size in <b>d:\easyphp1-8\www\pub-creator\gifmerge\GifMerge.class.php</b> on line <b>178</b><br />
Skipping Graphic Control Extension.
<br>Transparent color not found!

I just let the example.php as it was, nothing else.
An idea ?
Thanks a lot

  4. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2006-06-28 04:29:26 - In reply to message 3 from renaud
Hi,

corrected this error.

  5. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of renaud renaud - 2006-06-28 11:08:44 - In reply to message 4 from László Zsidi
Thanks a lot and congratulations for your wonderful class.
Have a nice day !

  6. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of renaud renaud - 2006-06-28 18:12:10 - In reply to message 5 from renaud
Excuse me again, it seems I have a problem with the delay...
My delay comes from a variable:

$delay = $_GET['interval'];//in my example 2 s

then

for($i = 1; $i<= $nb_im; $i++)
{

$dossier="ban_temp/gif";
$nom = "banniere".$i."".$ip.".gif";
$frames[$i] = "".$dossier."/".$nom."";
$interval[$i] = $delay * 1000; //conversion in milliseconds
$x[$i] = 0;
$y[$i] = 0;

}
$gif = new GifMerge($frames, 1, 1, 1, -10, $interval, 2, $x, $y, 'C_FILE');

echo $gif -> getAnimation();

But the delay is not really 2 seconds...
in the class file, I see:
var $dly = 50;
And if I change this parameter, I also change the delay...so what is the difference between this parameter and the $interval variable ?

Thanking you in advance.



  7. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2006-06-29 04:34:38 - In reply to message 6 from renaud
Hi,

If the delay parameter is missing or equal with zero move 0,05 second
interval time into frame delay from $dly constant there is no other different between the $dly constant and delay parameter.

Replay of the animated gif can be slacked if you use more frames.
Try to use integer variable 'round($delay * prefix)' and try to keep frames
under 30-40 for the optimal delay.

  8. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of renaud renaud - 2006-06-29 07:58:42 - In reply to message 7 from László Zsidi
Hi and thanks for your reply. In fact I only use 2 or 3 frames maxi. And sorry I dont understand how I can put delay of 1 or 2 seconds.
$dly in the class file or $__d ?

  9. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2006-06-29 10:54:38 - In reply to message 8 from renaud
Hi,

The $__d is a constructor variables and $dly is a class constans.

For 1 seconds set the delay interval to 1000, 2 seconds -> 2000, etc...

  10. Re: C_MEMORY Parameter   Reply   Report abuse  
Picture of László Zsidi László Zsidi - 2006-06-30 04:11:42 - In reply to message 8 from renaud
Hi,

First, sorry my bad english I try to draw other way and I hope you understand me:)

There's no different between delay variable in the constructor and delay constans in the class.

When you call the constructor the main function try to fill up the local variables with the passed values, arrays, transparent color, delays, etc...

for($i = 0; $i < count($images); $i++)
{
$dl[$i] ? $this->delay = $dl[$i] : $this->delay = $this->dly;
$xpos[$i]? $this->x = $xpos[$i] : $this->x = 0;
$ypos[$i]? $this->y = $ypos[$i] : $this->y = 0;
$this->start_gifmerge_process($images[$i]);
}

In this cycle try to fill $this->delay variable with passed delay value that come from delay array.

Example:
If your frame array have three elements
$frame[0] = "1.gif";
$frame[1] = "1.gif";
$frame[2] = "1.gif";
and delay array have three delay values
$delay[0] = 500;
$delay[1] = 500;
$delay[2] = 5000;
the generated animated gif have three frames with delays as 0.5 seconds, 0.5 second, 5 seconds.

In this example the delay values are greater than zero so during preparation of local variables fill up $this->delay variable with these delay values above.

If your frame array have three elements
$frame[0] = "1.gif";
$frame[1] = "1.gif";
$frame[2] = "1.gif";
and delay array have three delay values, but filled with zero
$delay[0] = 0;
$delay[1] = 0;
$delay[2] = 0;
the generated animated gif have three frames with delays as 0.05 seconds, 0.05 second, 0.05 seconds.

In this example the delay variables equal with zero so during preparation of local variables fill up $this->delay variable with value of $dly constant.






 
  1 - 10   11 - 20   21 - 28