Jump to content

[SOLVED] Image cropping various png's, gifs, and jpegs.


Recommended Posts

I'm fairly new to the image manipulation options in PHP, but there's a ton of stuff you can do with them.

 

You might want to rephrase your question;  it's a little hard to understand.  To build off what Sammy said above me, here is a more specific resource on php.net that explains the cropping process:  http://us2.php.net/imagecopy

My problem was about people uploading different types of images but there's no function that will imagecreatefrom(any supported types).  So you have to tell php what KIND of image you have to manipulate BEFORE you crop it.  Also, I was confused because 99% of the examples I saw on the Internet that dealt with image cropping didn't show you how to deal with different image types.  They only specified imagecreatefromjpeg so I thought that you could only crop an image if the image was jpeg to begin with.  If you try to send the function imagecreatefromjpeg a gif file it will output an error because you didn't specify the correct function for that image.  Anyway, I they should create by default a function "imagecreatefromany" to auto-detect the type of image.  I have no doubt this has confused other people as well.  ;D

 

if ($type = "1") {

$src = imagecreatefromgif($uploaded_thumb);

}

elseif ($type = "2") {

$src = imagecreatefromjpeg($uploaded_thumb);

}

elseif ($type = "3"){

$src = imagecreatefrompng($uploaded_thumb);

}

elseif ($type = "6"){

$src = imagecreatefromwbmp($uploaded_thumb);

}

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.