【问题标题】:How To Handle the Image in Android,IOS and Websites?Android、IOS、网站图片如何处理?
【发布时间】:2019-08-04 21:58:27
【问题描述】:

我查看了许多网站和 android 应用程序,例如 swiggy、多米诺骨牌等。

如何处理图像重量轻(体积小,质量更好,对所有设备都反应灵敏)。

它们使用什么类型的图像,例如 jpg、png 等...

【问题讨论】:

  • 这和MySql和MongoDB有什么关系?
  • 只保存图片 url 或类似 base64 转换格式的格式
  • 压缩您的图像并将其大小减小到 100kb 以下。有很多工具在压缩时不会影响分辨率。我认为最喜欢的格式是 jpg/png。现在在您的应用程序 (iOS) 中使用 NSCache 来处理图像。
  • 基于 android 和 php 的网站怎么样?

标签: php android ios image


【解决方案1】:

GitHub 上有许多可用的压缩库。我个人用过 实现'id.zelory:compressor:2.1.0'。 使用也很简单。

File compressedFile= null;
        try {
                        compressedFile = new Compressor(this).compressToFile(file);
                        compressedFileUri = Uri.fromFile(compressedFile);
                        UploadImage(compressedFileUri);
                        imageButton.setImageURI(compressedFileUri);
                    } catch (IOException e) {
                        e.printStackTrace();
                        Log.e("EditProfile","image compression error",e.getCause());
                    }

file 这里是要压缩的文件。 compressedFileUri 现在可以用作压缩文件的引用,并且可以作为多部分文件或 base64 上传。 (我使用了firebase,所以它变得更简单了)它将我的文件从400 kb 转换为80 kb 并保持质量。

【讨论】:

  • 如果你喜欢这个答案,你可以点赞它以显示有用性。
猜你喜欢
  • 2016-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-22
  • 2012-07-30
  • 2021-05-03
相关资源
最近更新 更多