开发者

Image compression for Facebook iOS SDK

This may be a non-issue but I am trying to figure out where the Facebook album photo image compression happens, before 开发者_运维问答or after upload. I am sending a UIimage to a Facebook album that ends up being around 43 kb jpeg at 640X480 in Facebook, similar to my other uploaded photos from other sources. If I attach the same UIImage to a email it is a 461 kb jpeg at 640x480.

The Facebook upload is taking a while and I would like to speed it up so I have 2 questions.

  1. Where does the compression occur, on Facebook server or on my device in the facebook SDK?

  2. If it is happening on the server how do I compress a UIImage on my device before upload without resizing (resample to 100X80 or something) like you are allowed to do with a jpeg. I have tried to use UIImageJPEGRepresentation but the Facebook SDK gives me a error if it is sent NSData instead of a UIImage.


After a little more digging I replaced this section of code:

       NSData* imageData = UIImagePNGRepresentation((UIImage*)dataParam);
    [self utfAppendBody:body
                   data:[NSString stringWithFormat:
                         @"Content-Disposition: form-data; filename=\"%@\"\r\n", key]];
    [self utfAppendBody:body
                   data:[NSString stringWithString:@"Content-Type: image/png\r\n\r\n"]];

in FBRequest.m with this section of code:

      NSData* imageData = UIImageJPEGRepresentation((UIImage*)dataParam, 1);
      [self utfAppendBody:body
                     data:[NSString stringWithFormat:
                           @"Content-Disposition: form-data; filename=\"%@\"\r\n", key]];
      [self utfAppendBody:body
                     data:[NSString stringWithString:@"Content-Type: image/jpeg\r\n\r\n"]];

and found it loads in about half the time. Guess I will make a post on git

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜