I've seen this happen in a number of places when uploading images. The 
basic issue is that there are two ways to save a "rotated" image: save the 
raster data in the correct orientation and without metadata, or save the 
raster data in its "native" orientation and set the metadata value to 
indicate the desired rotation. The problem is that some software 
implementations still do not look at the metadata field and just display 
the raw raster image. So the photo may appear rotated correctly in one 
place and not rotated in another!


On Sunday, April 12, 2015 at 1:00:41 AM UTC-4, Dan Cha wrote:
>
> So within my app, i have the ability to allow the user to take a pic, see 
> a thumbnail within the app and once the form is submitted, its uploaded to 
> the server.
>
> But something ive noticed lately is that (since im storing the image taken 
> in the users gallery within a folder specific to the app) if you view the 
> pic outside the app in the actually folder, it looks oriented correctly, if 
> i take it portrait its portrait, if i take the pic landscape, its stored in 
> landscape.
>
> Also when the user is presented the thumbnail, it also shows correct, but 
> for some reason when the image is uploaded to the server, it no longer has 
> the correct orientation.
>
> Im using ftp to upload the image with this code:
>
>             try
>             {
>                 int reply;
>                 String reply2;
>                 ftpClient.connect("ftp.site.com");
>                 ftpClient.login("site","pass");
>                 ftpClient.changeWorkingDirectory("/imgs/");
>                 ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
>                 BufferedInputStream buffIn = null;
>                 buffIn = new BufferedInputStream(new 
> FileInputStream(file));
>                 ftpClient.enterLocalPassiveMode();
>                 ftpClient.storeFile(destinFolder,buffIn);
>                 buffIn.close();
>                 reply = ftpClient.getReplyCode();
>                 if(!FTPReply.isPositiveCompletion(reply))
>                 {
>                     ftpClient.disconnect();
>                 }
>                 ftpClient.logout();
>             }
>
> I even changed my logic to this and still nothing, the image is always 
> uploaded in landscape. Even though the thumbnail and stored image on the 
> phone is portrait.
> Found at this link: 
> http://stackoverflow.com/questions/24629584/image-orientation-changes-while-uploading-image-to-server
>
>
>   int rotate = 0;
>                 try {
>                 getContentResolver().notifyChange(imageUri, null);
>                 File imageFile = new File(al_image_paths.get(i)); 
>                 ExifInterface exif = new ExifInterface(
>                         imageFile.getAbsolutePath());
>                 int orientation = exif.getAttributeInt(
>                         ExifInterface.TAG_ORIENTATION,
>                         ExifInterface.ORIENTATION_NORMAL);
>
>                 switch (orientation) {
>                 case ExifInterface.ORIENTATION_ROTATE_270:
>                     rotate = 270;
>                     break;
>                 case ExifInterface.ORIENTATION_ROTATE_180:
>                     rotate = 180;
>                     break;
>                 case ExifInterface.ORIENTATION_ROTATE_90:
>                     rotate = 90;
>                     break;
>                 }
>                 Log.v(Common.TAG, "Exif orientation: " + orientation);
>
>     Bitmap rotattedBitmap= BitmapFactory.decodeFile(al_image_paths.get(i));   
>         
>     Matrix matrix = new Matrix();
>         matrix.postRotate(rotate);
>         return Bitmap.createBitmap(rotattedBitmap, 0, 0, 
> rotattedBitmap.getWidth(), rotattedBitmap.getHeight(), matrix,       true);
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to