Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Image class and animated gifs
  • I'm having trouble with animated gifs and the Image library. I'm using the imagemagick driver (since gd doesn't support animated gif's afaik) but the output() method only seems to read out the first frame. public function action_get(){
    $id = self::alphaID($this->param('id'),true);
    $image = Model_Image::find($id);
    $path = APPPATH.'files/'.$image->short_name;
    $config = array();
    $img = Image::load($path);
    $img->output();
    die(); //die since headers already out
    } Is there something easy I'm missing? Can anyone confirm animated gif support in the Image->output() method?
  • Sorry, no experience in this area. Pop into IRC sometime this week (the weekend is usually quieter), perhaps someone can help you there.
  • Relevant info: FuelPHP 1.2
    I've tracked the issue down to the following:
    Line 34 imagemagick.php
    Originally, the extension was hardcoded on the image_temp:
    $this->image_temp = $this->config.substr($this->config.md5(time() * microtime()), 0, 32).'.png';
    The extension var is available here, so this will work:
    $this->image_temp = $this->config.substr($this->config.md5(time() * microtime()), 0, 32).'.'.$this->image_extension; Then, the convert method is called, but the first frame is specifically referenced:
    $this->exec('convert', '"'.$image_fullpath.'"[0] "'.$this->image_temp.'"'); You can get around this easily with:
    $this->exec('convert', '"'.$image_fullpath.'" "'.$this->image_temp.'"'); However, resizing gif's isn't pretty, and rarely goes well, and making thumbs is a very common request. So, I ask the community, how would this best be patched: 1) Edit Image class to support animated gif readout (for example $image->output_animated() or $image->load_animated() which would fetch the original gif
    2) Disregard all of this and just use File class to output animated gifs in apps
    3) Try and integrate full support for resizing and other manipulations on animated gifs (can be resource intensive)
    4) Open for suggestions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion