So I am creating a responsive website that has the option of uploading images to the page. The php script basically resizes the the image and stores a thumb file path in the
1) Not sure if there's anything you can do about that, you upload the image the user selected. In an application I would possibly downsize the image before transmission.
2) Whatever you are looking at to view the photo (or generate thumbnails) is probably not respecting the orientation flag in the photo.
You may want to look in to the exif_read_data() function, and look at the ['Orientation']
value that is returned in the array. Typically, a phone or camera that has orientation sensors store the image at one orientation or the other, and then add appropriate orientation flags to the exif data in the picture. It is then up to the image viewer or image processor to determine whether to rotate the raw picture before displaying or processing the image.
There are some great examples in the comments of that page.
Function built from one of the examples on that page:
<?php
function getOrientedImage($imagePath){
$image = imagecreatefromstring(file_get_contents($imagePath));
$exif = exif_read_data($imagePath);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
}
return $image;
}
?>
Also, regarding the upload time, if the device is using cell towers to transmit the data, your upload speeds are probably a fraction of your download speeds. For comparisons sake, most social networking apps resize the image before uploading, whereas your web page probably doesn't. Since phones take 8 megapixel or greater photos, that adds up to a lot of data.