Remove exif in AngularJS at upload - javascript

I have a web application (using AngularJS) in which users can upload a profile picture and before saving the image they can adjust they photo with some cropping tool.
The issue is that when I'm uploading photos taken with an iPhone in portrait mode, all this images are rotated 90 degrees. The only way that images are uploaded correctly is if the user takes the picture in landscape mode (iPhone oriented with volume buttons pointing down).
I need a solution to make this work, no matter phone orientation when taking pictures.
My example

Related

Ionic cropping an image without UI

Problem
I have been trying for awhile without success to crop an base64 image taken from the camera using the camera preview plugin to a 4:3 resolution without any cropping input being done by the user.
Most plugins I have tried so far force a UI but for my purpose it needs to crop to 4:3 to then be sent to a server all as the same resolution.
What i've tried
I have tried tweaking the ionic native plugin without success.
Also i've tried numerous different Cordova plugins that have been suggested from other forum posts such as:
Cropper.js
Croppr.js
Cordova Plugin Crop - without the ionic native side
iCrop
All of those as far as I know force a UI as well as don't allow you to specify an aspect ratio.
In our app we needed cropped pictures as well. However it turned out (especially on Android devices) that the way you can crop after taking a picture depends on brand, model and even the camera app.
In Ionic 3 the camera plugin has an option allowEdit. There are some side effects when you set this to true. For example some users cropped there pictures in a very weird aspect ration like: 1:15, so a very small width, and a very large height. Keep this in mind when you allow your users to edit their pictures.
To get consistent crops we have implemented the cropping server side. In order to speed things up we only resize the picture on the client and upload the resized picture to the server.

Image Reposition on Mobile Devices

I am currently working on a website which uses a banner image on a profile. However if a user uploads an image the position of the banner may not be correct and they may want to change it to display the correct position of the image they want. So I have been following this guide: http://w3lessons.info/2014/08/31/facebook-style-cover-image-reposition-using-jquery-php/
I have used this guide and it works without error when I am on desktop screen sizes like 20" and above... However when ever I try to change the image position on mobile it doesn't scale correctly and the image thumb nail is not cropped correctly. But it works when the website is on a desktop because the image banner is full size... There is a demo on the website with the guide if you want to check it out and see what I am on about. I tried to see changing the crop width and height to match the mobile size but that means when it resizes back to a desktop the image is only scaled for a mobile then.
The problem is to do with:
$default_cover_width = 918;
$default_cover_height = 276;
As the screen size changes the default cover size changes as well...
I was wondering if anyone could point me in the right direction so that I could get this working on a mobile device as well.
Thanks.

How can you move this buggy native crop box in a hybrid app?

We have an Ionic app that accesses $cordovaCamera like so:
$cordovaCamera.getPicture({ allowEdit: true });
There are more options passed in, etc., but the above is just showing that we're passing in the allowEdit flag. If anyone is unfamiliar, here's what the docs say:
allowEdit: Allow simple editing of image before selection. (Boolean)
This works perfectly. After I select a picture from the gallery or take a picture, it then goes to its native "edit" view, where the user can crop the image.
Here's the flow:
Take Photo > Edit (crop) > Upload to the interwebs
Select Photo > Edit (crop) > Upload to the interwebs
On Android, you can resize the crop field and move the crop field around.
On iOS, you can't move the crop field (unless you zoom in first), and you can't resize the crop field at all.
Is this just an iOS quirk we have to live with, or is there some way to get around this? This is happening in iOS 8.3.
Screenshots coming soon
Edit
Here's the video demonstrating the problem.
At 0:16 you'll see that it's impossible to move the crop box. (This is happening on an iPod Touch with iOS 8.2, but it is also happening on several iPhone 6 devices with both iOS 8.2 and 8.3). However, this does not occur on Android. Thus, it seems reasonable to believe this is native iOS issue rather than an Ionic/Cordova issue (or, it may be an issue with the way Ionic interacts with iOS).
At 0:22 you'll that once the user zooms in, then the user can actually move the crop box.
Another update (this is important)
Only when taking a photo does this bug occur. When you select an existing photo from your library, the crop tool works as expected...
iOS has a built in cropping tool if you enable allowsEditing on your UIImagePickerController
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setAllowsEditing:YES];
If you want a different cropping tool you are going to have to make your own or use an open source project.
Here are some projects:
https://github.com/dzenbot/DZNPhotoPickerController
https://github.com/ruslanskorb/RSKImageCropper
https://github.com/kishikawakatsumi/PEPhotoCropEditor
In our company hybrid mobile app we use ng-image crop. https://github.com/jodonnell-broadsoft/JsImageCrop
It allows users to take photos of images in android and ios using the camera plugin and then lets them crop the image (we use it for documents). We then upload the image to our server.
Here is what our final version looks like. Also it is super smooth and easy to use.
Once you include the ng-image crop, then inject the dependencies this is all the code you use
<div class="cropArea" ng-style="cropHeight">
<img-Crop image="image.uncropped" result-image="image.cropped" result-image-format="image/png" area-type="rectangle" on-change="console.log($scope.image.cropped)">
</img-Crop>
</div>

How to prevent scaling of images on mobile devices?

I've been having a lot of issues with displaying images on mobile devices. It has something to do with pixel ratios and scaling.
The idea is that I want to prevent billiniar filtering on my images. On desktop this is easy, just display the image at 1x, and it looks perfect.
There are some issues with desktop, such as when you try to scale up using the browser it filters the image, but you can at least upload a scaled version and it will look perfect.
Here is my test page: http://stage.samkeddy.com/test/
You can see that all but the second one are perfectly crisp.
But here is what it looks like on my phone: http://imgur.com/a/4rMKj
It's not even close to the right size. The image should be 70 pixels wide, but it comes out to either 53 or 63 pixels wide (one is page loaded, second is after double tapping).
I want my image to line up exactly with the pixels on my phone, is there a way to even achieve this?
Actually you should forget pixel in mobile device, like android, the screen density is barely same, a picture looks different at different density screen.
I suggest using some responsive design, use min-width parameter for a img tag, and the image from server side should big enough to prevent blur.
There are also some image service which provide scale function, you can add ?w=100&h=100 to thre image url for compressing a big picture to a small one.

How to disable auto rotate for a video preview in a Windows Phone 8.1 App using javascript/html5

I followed the tutorial below to create a Windows Phone 8.1 app for previewing the camera capture:
http://msdn.microsoft.com/en-us/library/windows/apps/Hh452789(v=win.10).aspx
However, there is an undesired behavior of this basic app. When the device is placed horizontally, with the top pointing to the left, the orientation of the preview is the same as the scene, which is fine. However, when the device rotates to the portrait position (top up), the preview auto rotates to a confusing orientation. Below is a picture demonstrating this behavior.
I guess what I want is the same behavior as the built-in Camera app of a Windows Phone, that the preview orientation always follows the camera (image panel) orientation. In other words, no matter how the device is rotated, the house roof tip should always point upward. Is that possible using the developer API? If so, what function or attributes should I use?
One potential solution I can think of is to disable auto rotate for the element that is used to hold the preview. However, I don't know how to do that. In addition, can one disable the auto rotate for only some elements in an app page instead of the entire page? I ask because I want to display some text over the video preview and I want the text to auto rotate for legibility.
MediaCapture _mediaCapture = new MediaCapture();
_mediaCapture.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
await _mediaCapture.InitializeAsync();
await _mediaCapture.StartPreviewAsync();
Check the phone orientation on orientation changed and set the MediaCapture .SetPreviewRotation(VideoRotation.Clockwise90Degrees) as you want.

Categories