简体   繁体   English

从ios中的ios设备摄像头上传图像无法正确上传

[英]image not uploading properly when uploading from ios device camera in php

I am creating a project in codeigniter in which user can upload his profile image. 我正在codeigniter中创建一个项目,用户可以在其中上传他的个人资料图像。 I am using image library to upload it. 我正在使用图片库上传。 When I am uploading image using camera in IOS device, image uploaded with some greyed out area. 当我在IOS设备中使用相机上传图像时,图像上传时带有一些灰色区域。 Code in library is 库中的代码为

function createImage($iMageName,$folderName){
$width = 500; $height = true;
$data=base64_decode($iMageName);
$f = finfo_open();
$mime_type = finfo_buffer($f, $data, FILEINFO_MIME_TYPE);
$image = imagecreatefromstring($data);
$height = $height === true ? (ImageSY($image) * $width / ImageSX($image)) : $height;
$output = ImageCreateTrueColor($width, $height);
$imgThumb=uniqid().strtotime(date("Y-m-d H:i:s")).'.jpg';
$imageName=$folderName.$imgThumb;
$fullpath=FCPATH.$imageName;
ImageCopyResampled($output, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
imagejpeg($output, $fullpath, 90);
return $imageName;
}

Working fine for web and android device but problem in ios device, see uploaded image 适用于网络和Android设备,但ios设备存在问题,请参见上载的图片 在此处输入图片说明

I have also face the same issue. 我也面临同样的问题。 Problem will occurs in following condition: 在以下情况下将发生问题:

  1. file size. 文件大小。 Please validate the file size. 请验证文件大小。

  2. Please write the below code and check that it's working. 请编写以下代码,并检查其是否有效。

      function createImage($iMageName,$folderName){ ini_set ('gd.jpeg_ignore_warning', 1); $width = 500; $height = true; $data=base64_decode($iMageName); $f = finfo_open(); $mime_type = finfo_buffer($f, $data, FILEINFO_MIME_TYPE); $image = @imagecreatefromstring($data); $height = $height === true ? (ImageSY($image) * $width / ImageSX($image)) : $height; $output = @ImageCreateTrueColor($width, $height); $imgThumb=uniqid().strtotime(date("Ymd H:i:s")).'.jpg'; $imageName=$folderName.$imgThumb; $fullpath=FCPATH.$imageName; @ImageCopyResampled($output, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image)); imagejpeg($output, $fullpath, 90); return $imageName; } 

Thanks , This will helpfull for you 谢谢,这对您有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM