View previous topic :: View next topic |
Author |
Message |
Mithrilhall Newbie
Joined: 30 Dec 2005 Posts: 1
|
Posted: Fri Dec 30, 2005 3:53 pm Post subject: Trouble cropping an animated gif |
|
|
Does anyone know how to crop an animated gif?
This is the code I'm using:
Code: |
$imgfile = "E:\Program Files\Images\weather2.gif";
require 'class.cropcanvas.php';
$cc = new canvasCrop();
$cc->loadImage($imgfile);
$cc->cropByPercent(15, 50, ccCENTER);
$cc->saveImage('resized.gif', 90);
$cc->flushImages();
|
|
|
Back to top |
|
 |
amnuts Site Admin

Joined: 01 Sep 2002 Posts: 662 Location: East Sussex, England
|
Posted: Thu Jan 05, 2006 4:02 am Post subject: |
|
|
When the class was written the gif capability was generally taken out of PHP because of the patent issues, and as a result of that the class was not written with gif images in mind - only jpg and png. Now that the patent has expired, gif is making its was back in to the GD library with PHP.
If you want to include gif support then you'd need to make a few changes to the class - or create an extension class, of course!
In the saveImage method, find this line:
Code: | if ($ext == 'png') $saved = $func($this->_imgFinal, $filename);; |
and change it to be:
Code: | if ($ext == 'png' || $ext == 'gif') $saved = $func($this->_imgFinal, $filename); |
In the showImage method find this block:
Code: | else if ($type == 'jpg' || $type == 'jpeg')
{
echo @ImageJPEG($this->_imgFinal, '', $quality);
return true;
} |
and add this after it:
Code: | else if ($type == 'gif')
{
echo @imagegif($this->_imgFinal);
return true;
} |
I've no idea how it'll handle animated gifs, sorry.
Andy |
|
Back to top |
|
 |
V@no Light Poster

Joined: 10 Apr 2003 Posts: 30
|
Posted: Tue Mar 14, 2006 11:06 pm Post subject: |
|
|
Keep in mind, the lattest GD version can only handle first frame of animated gif images...
so, basicaly you will endup with non-animated image if you let GD manipulate it... |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|