|  | 
  Alexandru Geo - 2017-04-13 19:47:21Hi , i'm trying to generate a gif file but i don't know how to do it , i tried with file_put_contents but the file is size 0.. nothing generated
  Patrick Van Bergen - 2017-04-13 20:43:10 - In reply to message 1 from Alexandru GeoHi Alexandru,
 The builder class has a saveToFile() function.
 
 Can you try something like this:
 
 use movemegif\domain\FileImageCanvas;
 use movemegif\GifBuilder;
 
 // just for debugging
 error_reporting(E_ALL);
 ini_set('display_errors', 1);
 
 // include movemegif's namespace
 require_once __DIR__ . '/../php/autoloader.php';
 
 // no width and height specified: they will be taken from the first frame
 $builder = new GifBuilder();
 $builder->setRepeat();
 
 for ($i = 1; $i <= 8; $i++) {
 
 $builder->addFrame()
 ->setCanvas(new FileImageCanvas(__DIR__ . '/horse/' . $i . '.png'))
 ->setDuration(8);
 }
 
 $builder->saveToFile('horse.gif');
 
 
 
 If that doesn't help, show me some of your code.
 
 greetings,
 
 Patrick
  Alexandru Geo - 2017-04-13 21:33:38 - In reply to message 2 from Patrick Van BergenThank you for your time and answer , i found another way to do it, or is quiet similar , 
 file_put_contents('image.gif', $builder->getContents());
 
 your solutions is better !
 this is a part of code
 
 $builder = new GifBuilder(200, 200);
 $builder->setRepeat();
 
 // background image
 $builder->addFrame()
 ->setCanvas(new FileImageCanvas(__DIR__ . '/14937240_1232839050105927_2392147432229343625_n.jpg'))
 ->setDuration(100);
 
 
 
 // dogs runs from left to the right
 $imageIndex = 0;
 for ($x = -140; $x <= 480; $x += 10) {
 
 $builder->addFrame()
 // load single frame from GIF file, and autodetect transparency color
 ->setCanvas(new FileImageCanvas(__DIR__ . '/faza1/' . $imageIndex . '.gif'))
 // number of 1/100 seconds per frame
 ->setDuration(5)
 // position this frame on the bottom half of the image
 // when done painting one frame of the dog, restore the state to just before the dog was drawn
 ->setDisposalToOverwriteWithPreviousFrame()
 ;
 
 // next dog image
 if (++$imageIndex == 26) {
 $imageIndex = 0;
 }
 }
 
 $builder->output();
 file_put_contents('imagine.gif', $builder->getContents());
  Alexandru Geo - 2017-04-13 22:19:07 - In reply to message 1 from Alexandru GeoIs any chance to make transition effects between two images ? something like cross fade between images ?
 EXAMPLE:http://apps.jra.ro/new/bun/example/efect.php
 
  Patrick Van Bergen - 2017-04-14 06:02:23 - In reply to message 4 from Alexandru GeoThat would be nice :)
 No plans for such a thing at the moment, but I'll keep it in mind.
 
 greets,
 
 Patrick
  Alexandru Geo - 2017-04-15 09:20:54 - In reply to message 5 from Patrick Van BergenOther think, if you gonna include this file , whick one generate the gif animation you will have problems with the header response , you can check on https://validator.w3.org/ the response will be 500 , and you cand add something like header("HTTP/1.1 200 OK");http_response_code(201); to change de response ,
 |