Portrait image saved as a landscape image orientation
AnsweredHi,
I am capture portrait image in My android device and then upload this image via my web page by below HTML form coding, the uploaded portrait image saved as a landscape image in cloudinary server. Please help me.
<input class="input-file" id="fileInput" name="fileInput" type="file" accept="image/x-png, image/gif, image/jpeg, image/png">
php Coding
if (isset($_FILES['fileInput']) && $_FILES['fileInput']['name'] != '') {
$date = new DateTime();
//$timestamp = $date -> getTimestamp();
$timestamp = time();
if ($logoURL != "") {
$myArray = explode('business_logo_', $logoURL);
$originalFile = explode('.', $myArray[1]);
$fileName = 'business_logo_' . $originalFile[0];
} else {
$fileName = 'business_logo_' . $_SESSION['user_id'] . '_' . $_SESSION['business_id'] . '_' . $timestamp;
}
$sig = "public_id=" . $fileName . "×tamp=" . $timestamp . "" . $secret;
$sign = sha1($sig);
$postArgs['timestamp'] = $timestamp;
$postArgs['public_id'] = $fileName;
$postArgs['signature'] = sha1($sig);
$postArgs['file'] = '@' . $_FILES['fileInput']['tmp_name'];
$uploadURL = $cloudNaryURL."". $key . "&signature=" . $sign;
// echo "Post argument : " . $postArgs . "<br/> Uploading URL : " . $uploadURL;
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_VERBOSE, 0);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_URL, $uploadURL);
//most importent curl assues @filed as file field
curl_setopt($ch1, CURLOPT_POSTFIELDS, $postArgs);
$response1 = curl_exec($ch1);
//echo $response1;
$cloudnarryResponse = json_decode($response1);
//echo "The testing URL " . $cloudnarryResponse -> secure_url;
$secure_url = $cloudnarryResponse -> secure_url;
//echo "<br>The img URL : $updateMyprofileInfourl";
if ($cloudnarryResponse -> secure_url) {
$updateMyprofileInfourl = "" . $updateMyprofileInfourl . "" . urlencode($cloudnarryResponse -> secure_url);
uploadReal($updateMyprofileInfourl);
} else {
echo "The urlstring is null ";
}
} else {
//echo 'It has not file to ulooad';
$updateMyprofileInfourl = $updateMyprofileInfourl . "" . urlencode($logoURL);
uploadReal($updateMyprofileInfourl);
}
This above coding am using for image uploading form
-
Certain browsers automatically rotate images based on the camera orientation info. You can set the 'angle' transformation parameter to 'exif' either for dynamic transformations or as incoming transformation while uploading. See the following article for more details
http://support.cloudinary.com/entries/23342872-Why-was-the-image-I-uploaded-rotated-by-90-degrees-
In addition, it is recommended to use our PHP client library that handles signature generation, upload calls and transformation generation:
https://github.com/cloudinary/cloudinary_php
-1 -
Dear Nadav
I'm trying to access the link that you provided https://support.cloudinary.com/hc/en-us/articles/202520622-Why-was-the-image-I-uploaded-rotated-by-90-degrees- but I received "You're not authorized to access this page.
May I know how can I access to the page as I'm facing the same orientation issue.
Thanks,
Regards,
Andrew
0 -
Hi Lam,
Thank you for notifying us about the issue you are experiencing when trying to access this link. We will look into it.
In the meanwhile, please find below the content of the article you were trying to access:
Cloudinary does not rotate the images in default upon upload, we display the original image. Your local viewer is probably rotating these images automatically. In order to solve this you can use the EXIF-based auto rotation (camera information). Setting the 'angle' parameter ('a' for URLs) to 'exif' does the trick.
The a_exif transformation can also be applied as an incoming transformation while uploading (so the file stored in Cloudinary is already auto rotated), so you can automatically rotate images based on camera orientation info, by setting the 'angle' parameter to 'exif' or adding 'a_exif' to transformation URLs. (e.g., :angle => :exif in Ruby on Rails and similarly in other development frameworks).
For example: The original image (scaled down):
http://res.cloudinary.com/demo/image/upload/w_320/exif_sample.jpg
The resulting image with automatic rotation:
http://res.cloudinary.com/demo/image/upload/w_320,a_exif/exif_sample.jpg-1
Post is closed for comments.
Comments
3 comments