socalnate Posted October 26, 2007 Share Posted October 26, 2007 So how do you crop other types of formats using php like for a gif or a png file? Nathan Quote Link to comment https://forums.phpfreaks.com/topic/74942-solved-image-cropping-various-pngs-gifs-and-jpegs/ Share on other sites More sharing options...
SammyGunnz Posted October 26, 2007 Share Posted October 26, 2007 GD library Quote Link to comment https://forums.phpfreaks.com/topic/74942-solved-image-cropping-various-pngs-gifs-and-jpegs/#findComment-378956 Share on other sites More sharing options...
bespoke Posted October 26, 2007 Share Posted October 26, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/74942-solved-image-cropping-various-pngs-gifs-and-jpegs/#findComment-378970 Share on other sites More sharing options...
socalnate Posted October 27, 2007 Author Share Posted October 27, 2007 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. 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); } Quote Link to comment https://forums.phpfreaks.com/topic/74942-solved-image-cropping-various-pngs-gifs-and-jpegs/#findComment-379019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.