简体   繁体   中英

Mobile picture for user profiles

I have a mobile application which is supposed to work on android as well as ios on any device. When using the app, a user is able to choose a picture or to take a picture using his own device and to upload the picture to my server to complete his profile. Server-side, no problem, I'm able to resize it etc.

However I really have no idea how to handle this in term of size.

To be clear, users should be able to see each other picture (almost fullscreen ~80%) using any device.

How would you handle this? I'm not asking for code, but more for a methodology/algo

My first idea would be to:

  • Mobile-side

    • Let the user decide the image orientation and the ability to crop it before sending
  • Server-side

    1. Define custom fixed resolutions for ldpi, mdpi, hdpi, xhdpi (don't know which one yet)
    2. When receiving the picture, store it on the disk / database for each fixed resolution. However if the image size > resolution, scale it down before saving it. So very big image would be scaled for each resolution and a very small image would be the same for each

So I'd be able to display the right picture to each user depending on his device

Is this approach correct? If it is, how can I decide the resolutions for ldpi, mdpi, etc ?

I believe you are overthinking this, All you really need to do is to let the user upload their image or whatever and do everything you need to on the server side.

When your app receives the picture back from the server though just create a scaled bitmap to whatever size you so desire to display them at.

So it would be Bitmap.createScaledBitmap(bitmap, [yourWidth],[yourHeight]). The way the image appears in terms of quality of course will depending on the resolution that you are sending/saving that image at from your server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM