如果方向关闭,我使用以下代码旋转上传的jpeg图像.我只是对从iPhone和Android上传的图片有问题.
if(move_uploaded_file($_FILES['photo']['tmp_name'], $upload_path . $newfilename)){
chmod($upload_path . $newfilename, 0755);
$exif = exif_read_data($upload_path . $newfilename);
$ort = $exif['IFD0']['Orientation'];
switch($ort)
{
case 3: // 180 rotate left
$image->imagerotate($upload_path . $newfilename, 180, -1);
break;
case 6: // 90 rotate right
$image->imagerotate($upload_path . $newfilename, -90, -1);
break;
case 8: // 90 rotate left
$image->imagerotate($upload_path . $newfilename, 90, -1);
break;
}
imagejpeg($image, $upload_path . $newfilename, 100);
$success_message = 'Photo Successfully Uploaded';
}else{
$error_count++;
$error_message = 'Error: Upload Unsuccessful<br />Please Try Again';
}
Run Code Online (Sandbox Code Playgroud)
我在从jpeg读取EXIF数据的方式上做错了吗?它不是按照预期旋转图像.
当我运行var_dump($ exif)时会发生这种情况; …
当我使用以下代码时,它最终会出现outofmemory异常.做了研究之后,Render脚本看起来像个好人.我在哪里可以找到类似操作的示例代码以及如何将其集成到我的项目中.
public Bitmap rotateBitmap(Bitmap image, int angle) {
if (image != null) {
Matrix matrix = new Matrix();
matrix.postRotate(angle, (image.getWidth()) / 2,
(image.getHeight()) / 2);
return Bitmap.createBitmap(image, 0, 0, image.getWidth(),
image.getHeight(), matrix, true);
}
return null;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AndroidJniBitmapOperations库。但我是一名初级开发人员,对 NDK、JNI 世界一无所知。
我成功解决了一些错误,例如“UnsatisfiedLinkError”,但现在当我尝试构建时遇到了一个新错误:
错误:未定义对“AndroidBitmap_unlockPixels”的引用
另外,我在 CPP 文件中发现了一些错误:
1.“参数‘prmeterName’的类型不正确,其类型应为‘jint’。
2.“添加外部'C'”
但我不确定最后两个是否重要。
帮助我更新这个库,因为它很重要并且多次讨论过,例如:here。
库本身的链接: https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations
到目前为止我所做的一切是: https: //github.com/LiorA1/MyRevApp