Jump to content

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


socalnate

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);

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.