我有一个imagerotate()的问题,在上传图片后它没有进行正确的旋转,所以我需要它旋转回去,BD库启用了。 有一个功能代码
function resample($jpgFile, $width, $newcopy, $orientation) {
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($jpgFile);
$height = (int) (($width / $width_orig) * $height_orig);
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($jpgFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Fix Orientation
switch($orientation) {
case 3:
$image_p = imagerotate($image_p, 180, 0);
break;
case 6:
$image_p = imagerotate($image_p, -90, 0);
break;
case 8:
$image_p = imagerotate($image_p, 90, 0);
break;
}
// Output
imagejpeg($image_p, $newcopy, 90);
echo "Rotated Image Copied to Destination.<BR>";}
&#13;
图片添加代码
$insert_image = mysql_query("INSERT INTO `".dbprefix."_gallery` (`user_id`,`title`,`description`,`image`,`views`, `date`,`category`) VALUES ('$userdata[id]','".$_POST['image_title']."', '".$_POST['image_description']."', '".$generate_name ."_".$generate_name_extra ."_".$_FILES['image_file']['name']."','0','".time()."','".$_POST['image_cat']."')");
$select_last = mysql_query("SELECT * FROM `".dbprefix."_gallery` ORDER BY `id` DESC LIMIT 1");
$selected = mysql_fetch_assoc($select_last);
move_uploaded_file($tmp_name, $_SERVER['DOCUMENT_ROOT']."/files/gallery/".$generate_name ."_".$generate_name_extra ."_".$_FILES['image_file']['name']);
$jpgFile = $_SERVER['DOCUMENT_ROOT']."/files/gallery/".$generate_name ."_".$generate_name_extra ."_".$_FILES['image_file']['name'];
$exif = exif_read_data($jpgFile, 0, true);
$ort = $exif['IFD0']['Orientation'];
$width = $exif['IFD0']['ImageWidth'];
$thumbnail = 'files/gallery/asd.jpeg';
$success = $main->resample($jpgFile, $width, $thumbnail, $ort);
&#13;
它没有上传旋转的图片,我做错了什么?