andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Trouble cropping an animated gif

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
Mithrilhall
Newbie


Joined: 30 Dec 2005
Posts: 1

PostPosted: Fri Dec 30, 2005 3:53 pm    Post subject: Trouble cropping an animated gif Reply with quote

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
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Jan 05, 2006 4:02 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
V@no
Light Poster


Joined: 10 Apr 2003
Posts: 30

PostPosted: Tue Mar 14, 2006 11:06 pm    Post subject: Reply with quote

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...Sad
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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