iOS Tweet Uncompressed Image with Transparency - objective-c

I'm working on an application that handles image editing, and I'm at the point where I'm trying to integrate twitter. So far it has worked great and I can send a tweet from within the app and attach the image the user is editing. The drawback that I've noticed, is that the image gets auto-compressed. This means that the PNG the user is editing, if it has transparency, no longer will have transparency. This isn't good. Is there a way around this? I would like to be able to send a tweet and attach my PNG image WITH transparency, basically keep it from converting to a JPG once sent.
Here's the code I have so far. Very self-explanatory and straightforward.
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
[tweetSheet addImage:self.workingImage];
[self presentModalController:tweetSheet animated:YES completion:nil];
self.workingImage is the image the user is working on.
EDIT: I've updated the above code to work on iOS6, and seem to have the exact same problem (which isn't too surprising I guess). It looks like once the image is on Twitter, it is in JPG format. Is there any way to keep in PNG format?
I'd hate to lose all of this simple code only to go down the route of using a 3rd party image hosting site.
EDIT 2: I've now converted all of my code to no longer use the alpha channel. This means that I no longer care if the image is in the format of PNG or JPEG, because all 3 RGB channels will always exist. Posting a tweet still compresses the image before posting it, no matter what quality the original image was.
I even posted an image to twitter using the app, had it compressed by twitter, saved the image and tried to repeat using the newly compressed image, yet twitter still compressed!
I'm lost on this. Will twitter (or even facebook) compress images no matter what? Will my only option be a third party image hosting site? I'd hate to lose all of the nice social features the iOS6 framework has built into it to instead use a third party site...

It's a twitter side problem. It compress your image regardless. Maybe you should consider uploading the .png to your own server then post a link of it within the tweet.
you can also use other image hosting services..

Related

Adding a UIImage from a UIGraphics Context to a Tweet

I have a game that I've been working on for iOS. We let our users tweet the results of their games and I thought it'd be fun to add a badge or something to the tweet to show details.
I create an image using UIKit. Then, I attach that image in iOS 6.0 with -[SLComposeViewController addImage:] or in iOS 5.* with [TWTweetComposeViewController addImage:] but neither of them will attach an the image.
If I use Facebook or Weibo, the image attaches fine. With Twitter, no luck at all.
Has anybody had any luck attaching an image to a tweet?
If you're receiving NO for the return value of TWTweetComposeViewController, the documentation says: YES if successful. NO if image does not fit in the currently available character space or the view was presented to the user.

Making Images Viewed By UIWebView Smaller

i have a list of entries from a database and I'm feeding them in to HTML to a UIWebView that is making a list of the database entries on the page.
(Much Easyer/Better then extending UITableView Cells)
My Problem is with UITableView i was able to grab an image on a server as NSData and with UIImageJpegRepresentation set the quality for the image a bit lower to be better on the iPhone's cellular downloads.
Now i can go and grab an image from the server as NSData Compress the image then convert it to base 64string and spit it into the WebView but is there any other way to do this?
TLDR: How can i decrease the size of images seen in a HTML Page?
I fixed this by feeding the page i was going to visit to a web service. The web service then returns a set of images compressed at lower quality.
Because the only pages the app is going to visit were my own with user avatars and stuff i was able to profile what images would be needed.
On the iPhone i rebuilt the webpage with the set of those smaller images in a UIWebView.
So in the end i downloaded less cellular data and problem is solved.

iOS: storing thumbnail images in Core Data

I need to take some images from the iPhone / iPad photo library from within my app and store them in a Core Data entity, and display them as small thumbnail images (48x48 pixels) in a UITableViewCell, and about 80x80 pixels in a detail UIView. I've followed the Recipes sample app, where they use UIImageJPEGRepresentation(value, 0.1) to convert to NSData and store the bytes inside Core Data, and it doesn't end up taking much space, which is good. But when retrieve the data, using UIImage *uiImage = [[UIImage alloc] initWithData:value]; and display it as a thumbnail image with "Aspect Fit", it looks terrible and grainy. I tried changing the image quality variable in the JPEG compression, but even setting it to 0.9 doesn't help.
Is that normal? Is there a better way to compress the image that doesn't cause so much grainee-ness? Since I just want to show a small thumbnail, and then a slightly bigger thumbnail, I feel Core Data would be great for storing this, since it should (theoretically) also support iCloud. But if it's going to look terrible, then I'll have to reconsider.
Two things, are you resizing the image to the right size? Have you tried UIImagePNGRepresentation()? That should compress it without losing quality.
If UIImagePNGRepresentation (which is lossless) is giving you bad images, then the problem is in your image resizing code. Core Data is just giving you what you back what you put in, so if you get bad images out, it's because you put bad images in.
Is one of your iPhone/iPad retina and the other isn't? If so, perhaps the problem is that you don't really want 48x48 pixel images, you want 48x48 point (which means you'll need 2x images 96x96 for retina quality display).

Is there any best way to show pdf in iphone other than UIWebview in objective-c?

Can you please suggest me, best way to show pdf files in iphone since i had used UIWebview, it took 3 - 4 mins to render in webview. Also i faced _WebtryThreadLock error.
Srini
It sounds like you may have some large vector calculations going on in your PDF. You can try re-constructing your PDF with flat images instead of vectors.
Code-wise QLPreviewController should be able to do what you want with a PDF, however it may use a UIWebView underneath. UIDocumentInteractionController also has a preview mode, but I suspect that it is using a QLPreviewController itself for it's preview.
You can also use the low level PDF functions, though this will be more difficult to do. Look at CGPDFDocument and it's related APIs in apple's documentation for more here.

How to display two pages in one scrollview page with zooming from PDF?

I want show per page pdf in portait mode and display two pages when rotate to landscape mode on ipad . I had search on internet and can't find any solution. I thought two possible way.
1.Using webview but I don't know how to display two page in one webview in a webview.
2.Using CGPDF API read from two page and merge to one pdf file. But I think this may be very slow and not sure if this could do it .
or any other way could solve this problem? Thanks!!
I don't think you will have much success with using a UIWebView there. There's however nothing stopping you from putting two CATiledLayers into a UIView and display them next to each other. In fact, that's exactly what I did in my iOS PDF parsing framework.
Just set the contentView as the containerView, that includes both tiled layers, and they work perfectly together. Keep an eye on your memory though, I wouldn't allow them both rendering pdf at the same time, that most likely crashes your app due to low memory. (Drawing a PDF is really resource intensive)