WayOOP Posted May 25, 2012 Share Posted May 25, 2012 Sup guys, I'm new here Well, I made a simple page for personal image upload but I have a huge problem creating the thumb. My code: move_uploaded_file($_FILES['file']['tmp_name'], $path.$name.".jpg"); $getimg = imagecreatefromjpeg($path.$name.".jpg"); $width = imagesx($getimg); $height = imagesy($getimg); if ($height > $width) $cut = $height/2; else $cut = 0; $new_height_mini = (130*$height)/$width; if ($new_height_mini > 90) $new_height_mini = 90; $create_mini = imagecreatetruecolor(130, $new_height_mini); imagecopyresampled($create_mini, $getimg, 0, 0, 0, $cut, 130, $new_height_mini, $width, $height); $pathm = "../../".$pathm; imagejpeg($create_mini, $pathm.$name.".jpg"); The idea is to create a thumb with 130px width and 90px height even when the source height is bigger than original width to show it wide on my page (so I tried to crop it). What is happening and what I want (random image with height>width from Google Images): Thumb with the black space: How I want it to be: Original image: Thank you and sorry for the giant pictures Quote Link to comment 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.