close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

server setting for image rotation

Thread began 7/14/2022 6:20 am by jo271221 | Last modified 7/20/2022 9:23 pm by Ray Borduin | 56 views | 4 replies |

jo271221

server setting for image rotation

When a user uploads an image that is taken in portrait it shows in portrait on my website. I believe this is a setting on the server.

I found this but I am not certain if it is the best method and if it is, I do not know how to implement it. Can we address this in our private session?

//this is the byte stream that I upload.
public static byte[] getStreamByteFromImage(final File imageFile) {

Bitmap photoBitmap = BitmapFactory.decodeFile(imageFile.getPath());
ByteArrayOutputStream stream = new ByteArrayOutputStream();

int imageRotation = getImageRotation(imageFile);

if (imageRotation != 0)
photoBitmap = getBitmapRotatedByDegree(photoBitmap, imageRotation);

photoBitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);

return stream.toByteArray();
}



private static int getImageRotation(final File imageFile) {

ExifInterface exif = null;
int exifRotation = 0;

try {
exif = new ExifInterface(imageFile.getPath());
exifRotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
} catch (IOException e) {
e.printStackTrace();
}

if (exif == null)
return 0;
else
return exifToDegrees(exifRotation);
}

private static int exifToDegrees(int rotation) {
if (rotation == ExifInterface.ORIENTATION_ROTATE_90)
return 90;
else if (rotation == ExifInterface.ORIENTATION_ROTATE_180)
return 180;
else if (rotation == ExifInterface.ORIENTATION_ROTATE_270)
return 270;

return 0;
}

private static Bitmap getBitmapRotatedByDegree(Bitmap bitmap, int rotationDegree) {
Matrix matrix = new Matrix();
matrix.preRotate(rotationDegree);

return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

Sign in to reply to this post

Ray BorduinWebAssist

We can look into the image rotation issue in a screen share. Just make sure you have an image ready to work with. This is built in when using the webassist extensions for file upload and image display, but I know you have a custom implementation for cloud storage of images.

Sign in to reply to this post
Did this help? Tips are appreciated...

jo271221

PK, Please let me know of your earliest availability. Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

I have time tomorrow morning if you want to call at around 10am my time.

Sign in to reply to this post
Did this help? Tips are appreciated...

jo271221

Thank you! I will do that.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...