Alamofire以哪种格式编码图像? [英] Alamofire encodes image in which format?
本文介绍了Alamofire以哪种格式编码图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用alamofire将图像分为多部分发送到服务器。
I am using alamofire to send Image to server with multipart.
multipartFormData.append(UIImageJPEGRepresentation(self.imageDet[0].image!,0.5)!, withName: "filestream", mimeType: "image/jpeg")
我从服务器端获取了字节格式的图像。
I have the image in byte format from server side.
以下是我在服务器端收到的字节的示例
Here is an example of the bytes I receive at the server side
����JFIFHH��XExifMM*�i&�������8Photoshop 3.08BIM8BIM%��ُ�� ���B~����"��
���}!1AQa"q2���#B��R��$3br�
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������
���w!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������C
如何将以下数据转换回图像?
How can I convert the following data back to image?
推荐答案
图像以JPEG编码并且对流当您编写 UIImageJPEGRepresentation(...)时,以二进制格式(
。 Data
或 NSData
)发送
然后将该二进制数据发送到服务器。
The images are encoded in JPEG and converted in binary form (Data
or NSData
) when you write UIImageJPEGRepresentation(...)
.
Then this binary data is sent to the server.
这篇关于Alamofire以哪种格式编码图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文