Android 移动应用程序的图像大小最佳实践

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10585025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:15:02  来源:igfitidea点击:

Image Size Best Practices for Mobile Application

androidiosimagemobile-website

提问by cetioren

I am building a mobile application that will target iPhone/iPad and Android phones. The application will involve users taking photos and uploading to my server and later on the users will be able to look at those photos on their mobile devices (although not necessarily their own photos so an Android user might be looking at a photo taken with an iPhone).

我正在构建一个面向 iPhone/iPad 和 Android 手机的移动应用程序。该应用程序将涉及用户拍照并上传到我的服务器,然后用户将能够在他们的移动设备上查看这些照片(尽管不一定是他们自己的照片,因此 Android 用户可能正在查看用 iPhone 拍摄的照片) )。

Which sizes should I save the photos to be able to cover the most use cases? iPads are 1.333 W/H, most mobile phones are 1.5 or 1.333 W/H with some rare 1.666 W/H. Specifically:

我应该保存哪些尺寸的照片才能覆盖大多数用例?iPad 为 1.333 W/H,大多数手机为 1.5 或 1.333 W/H,少数为 1.666 W/H。具体来说:

iPad: 1024x768, iPad3: 2048x1536, iPhone and some other phones: 960x640, 480x320, 800x480.

iPad:1024x768,iPad3:2048x1536,iPhone 和其他一些手机:960x640、480x320、800x480。

To be able to keep it manageable, I need to decide on a few certain image sizes and save the photos in those sizes. I am not really looking for help on the technical side. I can do image scaling on the server side etc. I am looking for recommendations / best practices / lessons learned about image sizes before I go too far into building it.

为了使其易于管理,我需要决定一些特定的图像尺寸并将照片保存为这些尺寸。我并不是真的在寻求技术方面的帮助。我可以在服务器端进行图像缩放等。我正在寻找有关图像大小的建议/最佳实践/经验教训,然后再深入构建它。

  • Which sizes should I save the photos in to cover the most use cases?
  • Do you recommend any client side scaling before uploading to server to save on transfer time (for example scaling down 2048x1536 iPad photos) or should I always transfer originals?
  • How should I handle incompatible image sizes (showing a picture taken with an iPad on an Android device for example)? Should I pre-cut those images on my server before sending to client or should I let the client phone handle image resizing?
  • There is also the issue of UI. There will be other things on the page other than the photo maybe a button or two for navigation. Should I go for something smaller than the full screen size while keeping the same aspect ratio when saving pictures?
  • 我应该将照片保存在哪些尺寸以覆盖大多数用例?
  • 您是否建议在上传到服务器之前进行任何客户端缩放以节省传输时间(例如缩小 2048x1536 iPad 照片),还是我应该始终传输原件?
  • 我应该如何处理不兼容的图像尺寸(例如,在 Android 设备上显示用 iPad 拍摄的照片)?我应该在发送到客户端之前在我的服务器上预先剪切这些图像还是应该让客户端手机处理图像大小调整?
  • 还有UI的问题。除了照片之外,页面上还会有其他内容,可能是一两个按钮用于导航。我应该选择小于全屏尺寸的东西,同时在保存图片时保持相同的纵横比吗?

I know some of these questions don't have one answer and the answers are relative but I wanted to get some opinions. Thanks.

我知道其中一些问题没有一个答案,答案是相对的,但我想得到一些意见。谢谢。

回答by MattDavis

For Android, I think the best place for you to start would be here, it has a lot of information including standard screen sizes and how to display images while keeping them in the best possible quality.

对于 Android,我认为最适合您开始的地方是这里,它包含大量信息,包括标准屏幕尺寸以及如何在保持最佳质量的同时显示图像。

http://developer.android.com/guide/practices/screens_support.html

http://developer.android.com/guide/practices/screens_support.html

I'd also suggest doing as much image manipulation as possible on your server. Images are a pain to work with on Android due to memory constraints and fragmentation. Two phones may store pictures taken the same way with different orientations, and there is no simple way to handle rotations, though it can be done (thankfully, I've yet to encounter a phone that incorrectly records Exif data, but I wouldn't be surprised if they existed...). The more you rely on the phone to do, the more chances you have for error due to manufacturers putting wrappers around and otherwise customizing how it handles media.

我还建议在您的服务器上进行尽可能多的图像处理。由于内存限制和碎片,在 Android 上使用图像很痛苦。两部手机可能会存储以相同方式拍摄的不同方向的照片,并且没有简单的方法来处理旋转,虽然可以做到(谢天谢地,我还没有遇到过错误记录 Exif 数据的手机,但我不会如果它们存在,会感到惊讶......)。您越是依赖手机,您就越有可能出错,因为制造商会在周围放置包装纸并以其他方式自定义其处理媒体的方式。

As for how to display, ideally if your back end is already doing a bunch of different resizes, you can include your screen density when you request the images and send the best size based on the dev guide. If you want to keep differences to a minimum, at least support med or high density for phones, and extra high density for tablets.

至于如何显示,理想情况下,如果您的后端已经在进行一系列不同的调整大小,您可以在请求图像时包含您的屏幕密度,并根据开发指南发送最佳尺寸。如果您想将差异保持在最低限度,至少支持手机的中等或高密度,以及平板电脑的超高密度。

Just my two cents, I'm sure you'll have a lot of opinions. Good luck.

只是我的两分钱,我相信你会有很多意见。祝你好运。

回答by Gophermofur

I don't have a full answer for you, but I do have some thoughts...

我没有完整的答案给你,但我确实有一些想法......

1) I'd suggest reducing the image sizes before uploading. If I were using your application and I had to upload a 4 meg photo, everytime I wanted to use your application, I'd probably pass. And as we venture forward, we're hitting much better technology in terms of camera phones; Nokia has released a 41 megapixel camera, which I'm guessing will create rather large images. Users having to download a 4-6 MB image is also not a great idea. Just some thoughts from a user point of view.

1)我建议在上传前减小图像大小。如果我正在使用您的应用程序并且必须上传一张 4 兆的照片,那么每次我想使用您的应用程序时,我可能都会通过。随着我们不断向前发展,我们正在开发可拍照手机方面的更好技术;诺基亚发布了一款 41 兆像素的相机,我猜它会拍出相当大的图像。用户必须下载 4-6 MB 的图像也不是一个好主意。只是从用户角度的一些想法。

2) I wouldn't cut the images. You don't necessarily know what parts of the image aren't important, so how would you know where to crop it? Let the phone size the pictures accordingly and rely on the ability to zoom into pictures to see things at a larger size.

2)我不会剪切图像。您不一定知道图像的哪些部分不重要,那么您怎么知道在哪里裁剪呢?让手机相应地调整图片大小,并依靠放大图片的能力以更大的尺寸查看事物。

3) You could try to make a UI that hides buttons. If you have something really simple (like just going forward or backwards) you could rely on gesture controls (swiping) to move around your application. You can implement sliding drawers and menus that take up space temporarily, when in use, but give you the space back when you want to look at the main content (pictures, in your case). I've typically found that hiding buttons doesn't work well and people seem to want/search for buttons that let them navigate, but the Android gallery works just fine with menu + swiping only, so who really knows.

3)您可以尝试制作一个隐藏按钮的用户界面。如果你有一些非常简单的事情(比如向前或向后),你可以依靠手势控制(滑动)在你的应用程序中移动。您可以实现滑动抽屉和菜单,在使用时临时占用空间,但在您想查看主要内容(在您的情况下为图片)时,将空间返回给您。我通常发现隐藏按钮不能很好地工作,人们似乎想要/搜索让他们导航的按钮,但 Android 画廊只在菜单 + 滑动时工作得很好,所以谁知道呢。