Re: [android-developers] Re: Image is being oriented differently once uploaded to server, why?

2015-04-13 Thread Daniel Chacon
Yea that i had found and attempted to implement within my existing code,
but everything works fine within the phone/device, but not when uploaded.

int rotate = 0;
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 10;
getContentResolver().notifyChange(fileUri, null);
File imageFile = new File(fileUri.getPath());
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;
}

final Bitmap bitmap =
BitmapFactory.decodeFile(fileUri.getPath(),options);
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
Bitmap rotImage = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix,true);
imgThumb.setImageBitmap(rotImage);
}
catch (Exception e)
{
e.printStackTrace();
}

On Mon, Apr 13, 2015 at 1:21 AM, catafest  wrote:

> I think it's a stack effect over ftp client ...See the first answer of
> Matt Gibson , from your link tutorial ...
>  - Found at this link: http://stackoverflow.com/questions/24629584/image-
> orientation-changes-while-uploading-image-to-server ...
> 
>
> 
> also you need to set the property of image, also will be set by default -
> and size .
>
> On Sunday, April 12, 2015 at 8:00:41 AM UTC+3, 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.
>>
>>
>>
>>  --
> 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.
>

-- 
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.


[android-developers] Re: Image is being oriented differently once uploaded to server, why?

2015-04-12 Thread catafest
I think it's a stack effect over ftp client ...See the first answer of Matt 
Gibson , from your link tutorial ...
 - Found at this link: 
http://stackoverflow.com/questions/24629584/image-orientation-changes-while-uploading-image-to-server
 
... 


also you need to set the property of image, also will be set by default - 
and size .

On Sunday, April 12, 2015 at 8:00:41 AM UTC+3, 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.
>
>
>
>

-- 
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.


[android-developers] Re: Image is being oriented differently once uploaded to server, why?

2015-04-12 Thread Doug Gordon
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.


[android-developers] Re: Image is being oriented differently once uploaded to server, why?

2015-04-11 Thread Dan Cha
Can someone tell me if this line in the code actually rewrites the image 
with the new settings or is this merely in memory and not touching the 
original image.. 

It would be great to fix the orientation and resize the image before being 
stored, so that the upload image is already the appropriate file size.


On Sunday, April 12, 2015 at 12:00:41 AM UTC-5, 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.