Ipad image orientation
Permalink Browser Info Environment
Hi John
Is it possible to add some code that will auto orientate images that are uploaded with an exif orientation tag embedded,
In particular Ipad images,
The code (and explanation) below was created to overcome the problem of orientation tags not being recognised,
I have no idea if this could be implemented, but it would be very helpful if it could,
Regards
Dave
Is it possible to add some code that will auto orientate images that are uploaded with an exif orientation tag embedded,
In particular Ipad images,
The code (and explanation) below was created to overcome the problem of orientation tags not being recognised,
When the new update came out from Apple for iOS6 it provided the ability for iPad, iPod, and iPhones to be able to upload files from the device through Safari. Obviously this will open up an array of implementations where at one point it was just not possible. The issue comes when a photo is uploaded it will be dependent on the location of the "button" when the photo was taken. Imagine if you will that you have your iPhone turned with the button at the top and you take a photo. The photo when uploaded to your server might be "upside down". The following code will ensure that all uploaded photos will be oriented correctly upon upload: <?php $image = imagecreatefromstring(file_get_contents($_FILES['image_upload']['tmp_name'])); $exif = exif_read_data($_FILES['image_upload']['tmp_name']); 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:
Viewing 15 lines of 21 lines. View entire code block.
I have no idea if this could be implemented, but it would be very helpful if it could,
Regards
Dave
Type: | Discussion |
---|---|
Status: | Archived |
It would indeed be useful and I think appropriate to be included in the concrete5 core,
When images are uploaded to Facebook (and some other sites) the exif data is read and the image is presented as the up-loader intended, of course this is happening in the background without the up-loaders knowledge,
The problem arises when the same image is uploaded to a concrete site and the image is not presented in the "intended" orientation..
The up-loader does not accept that the image was uploaded in the wrong orientation because "It works on Facebook!",
Anyway thank you for considering my proposal,
Regards
Dave
When images are uploaded to Facebook (and some other sites) the exif data is read and the image is presented as the up-loader intended, of course this is happening in the background without the up-loaders knowledge,
The problem arises when the same image is uploaded to a concrete site and the image is not presented in the "intended" orientation..
The up-loader does not accept that the image was uploaded in the wrong orientation because "It works on Facebook!",
Anyway thank you for considering my proposal,
Regards
Dave
Your post arrived as I was writing a post about this on the Leaders forum.
http://www.concrete5.org/developers/pro-accounts/community-leaders-...
I think the issue is sufficiently global that we continue discussion there.
http://www.concrete5.org/developers/pro-accounts/community-leaders-...
I think the issue is sufficiently global that we continue discussion there.
Front End File Uploader v2.0 update:
While many new features have been added for version 2.0, image rotation is not one of them.
Nevertheless, the code has been structured to facilitate anyone wanting to experiment with image rotation by overriding the helper 'packages/jl_front_end_uploader/helpers/extended_image.php'.
Within the override, returning true from auto_rotate_support() will add an option to the block edit dialog and result in extended_create() being called to process uploads when image rotation is subsequently selected from the edit dialog.
It is up to anyone experimenting to code the body of extended_create() to rotate images.
While many new features have been added for version 2.0, image rotation is not one of them.
Nevertheless, the code has been structured to facilitate anyone wanting to experiment with image rotation by overriding the helper 'packages/jl_front_end_uploader/helpers/extended_image.php'.
Within the override, returning true from auto_rotate_support() will add an option to the block edit dialog and result in extended_create() being called to process uploads when image rotation is subsequently selected from the edit dialog.
It is up to anyone experimenting to code the body of extended_create() to rotate images.
Maybe the place to implement this would be within the c5 image helper, because I can see it being useful to more than just this addon.
A risk of following any such data is that it gets followed too many times :(, so I will need to be sure that could not happen.
I will add this to my list of things to look into next time I upgrade Front End File Uploader.