Jump to content

PHP GD2 Gif Issue


Recommended Posts

I have a script that saves a full size and a cropped version that is re-sized to 200x200. The full size saves just fine the cropped and re-sized version is all messed up.

 

Example:

 

issue.png

 

Here is the cropped and re-size code:

 

$new_cropped_image_resource = imagecreatetruecolor(200, 200);
      switch($photo["ext"]){
    
	    case "gif":
	      $cropped_image = imagecreatefromgif($processing_image_temp_name_cropped);
	    break;

	    case "jpg":
	      $cropped_image = imagecreatefromjpeg($processing_image_temp_name_cropped);
	    break;

	    case "png":
	      $cropped_image = imagecreatefrompng($processing_image_temp_name_cropped);
	    break;

      }
      list($cropped_width, $cropped_height) = getimagesize($processing_image_temp_name_cropped);
      imagecopyresampled($new_cropped_image_resource,$cropped_image,0,0,0,0,200,200,$cropped_width,$cropped_height);
      switch($photo["ext"]){
    
	    case "gif":
	      imagegif($new_cropped_image_resource, $processing_image_temp_name_cropped);
	    break;

	    case "jpg":
	      imagejpeg($new_cropped_image_resource, $processing_image_temp_name_cropped, 100);
	    break;

	    case "png":
	      imagepng($new_cropped_image_resource, $processing_image_temp_name_cropped);
	    break;

      }

 

Any ideas? I'm stuck :/

 

Thanks for any help :)

-Shane

Link to comment
Share on other sites

So I decided to test and see if another gif would work. It did!!!

 

The first gif I made in paint, just a normal image. it failed when cropped and looked as shown in that photo.

 

The other 3 tests were random images i made in paint again the same way just this time they were all different sizes and colors and worked just fine. Weird that one photo just refused to re-size w/o issue.

 

Any ideas why?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.