populate UITableViewCell with JSON Base64? - iphone

Is it a good idea to return thumbnail images in base64 through JSON in a RESTful call for populating UITableViewCell's? Or should one really make n requests for n images (lazy loading)? What's better?
Thanks!

You always want to start showing results to a user as fast as possible.
If your UITableView's cells will contain both text and images, get the text values first and show that, with placeholders for the graphics. Then retrieve the images (one by one, or batched up).
Also, load the images a binary values, not base64 (because base64 encoding results in more bytes being transferred).

Check out this project, it has everything you want SDWebImage

Related

Slack Thumbnail url from Slack api for any file type like Image, Pdf, Audio, Video etc

I need to extract thumbnail url for any particular file.
while accessing the https://slack.com/api/files.list
I saw that for image thumbnail key asfiles : thumb_64, thumb_80, 360 type JSON keys
For pdf it is like
& similarly for other file type it has different different json key to find thumbnail.
So for every particular file type should i find thumbnail key manually. Any shortcut to find thumbnail key for all file type.
I need to pass my thumbnail url to some service no matter what kind of file it is.
Thanks!
The documentation for the file object type gives some information on this. But as you have already noticed, it doesn't mention PDF or other file types.
If a thumbnail is available for the file, the URL to a 64x64 pixel
will be returned as the thumb_64 prop.
The thumb_80 prop (when present) contains the URL of an 80x80 thumb.
Unlike the 64px thumb, this size is guaranteed to be 80x80, even when
the source image was smaller (it's padded with transparent pixels).
A variable sized thumb will be returned as thumb_360, with its longest
size no bigger than 360 (although it might be smaller depending on the
source size). Dimensions for this thumb are returned in thumb_360_w
and thumb_360_h.
In the case where the original image was an animated gif with
dimensions greater than 360 pixels, we also created an animated
thumbnail and pass it as thumb_360_gif.
Depending on the original file's size, you may even find a thumb_480,
thumb_720, thumb_960, or thumb_1024 property.
I did try looking through the Slack client's JS code (search for thumb_pdf in client-boot-imports.XXXX.min.js), and found a code block where it seems to be defining possible thumb_* keys. While it is not conclusive, you may look for these fields in the API response and fallback to a default image for each supported format.

iTextSharp: change the order of objects in existing PDF

I'm dealing with a corporate report generating system that generates documents with stamps and signatures.
The sad thing is that the system is not able to place images below existing text and tables, so the jpg-stamps overlapping text look really odd and unrealistic. The system does not support images with transparency channel either.
I'm trying to fix things by first printing reports to PDF and then manipulating images sending all them to back (below text and other vector content) using iTextSharp. Finally the results are sent to a hardware printer.
All the images are stored in resources (XObjects).
The problem is that I have no idea how to manipulate PDF-objects z-order (creation order) with iTextSharp.
The current version (a c# COM-object/assembly) works as follows:
Build the list of references to existing images (reference, image bytes, image CTM) in a page loop with parser.ProcessContent()
Execute KillIndirect() on any reference found
Replace them with writer.AddDirectImageSimple() and blank image (with transparent mask)
Insert previously stored image bytes as images (taking CTM into account) with stamper, in GetUnderContent mode.
I wonder if is there a more simple solution without blank images, excess references etc.

extract pdf formatting

hi guys working on a app which main work is pdf editing.
i understand Apple doesn't provide any api for editing the pdf. but my requirements are like that.
so i thought of extracting the whole contents of the pdf file and create a new pdf after editing. now i need to know how to extract the pdf formatting (header, footer, images, highlighting.,,)
im using Tj operators to extract the pdf text. which operators should i use to extract the other informations of pdf file.
thanks in advance.
Images are painted on the page using the Do operator. Its operand is the image name in the resources dictionary. The Do operator also paints form XObjects (self contained vector graphics) and these are stored also in the resources dictionary. The Subtype key in the image/form XObject dictionary gives you the object type: "Image" for images and "Form" for form XObjects.
The other elements are plain vector graphics and text, the PDF files do not have headers, footers, paragraphs, etc as standalone objects. What you see visually as a page header, inside the PDF file is just plain text painted at the top of the page.
Highlights can be plain semi-transparent yellow rectangles (these are no different from other rectangles on the page) or highlight annotations (these are available in page's Annots array).

is it possible to replace images in an array dynamically

hi i am new to iphone.what i am need is to place a 20 images names in an array . if i place those images in an array whether it is possible or not to change replace the first image by last means changing the positions of images dynamically if it is not possible pls suggest in what way i can done this. pls post any sample code thank u
Use NSMutableArray. It has methods like
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
It does not matter whether your objects are strings or images or whatever. It is possible to change the objects in a mutable array.

iphone uiimage tag - can you use strings?

quick question...
I have a series of buttons, each with a tag. I click the buttons which individually create a uiimageview based on the tag number. So this tag number, say 43 is passed and a new uiimageview is created using 43.png
All this is working nicely and I can remove the created images by clicking on them...
..but... I'm now wondering how I can remove all these created images all at once. So I have say 4 images which were all created as a result of clicking the buttons.
my question is this: can I use a string to identify these "created" images some how? I thought about using a tag for them starting with 99 maybe? so 991, 992, 993 etc. but this doesn't seem like good coding. In the past, and indeed in Flash, I used a tag of item1, item2... then in the code, I simply loop through ALL tags on the screen starting with "item" and remove them.
any ideas on the best way to tackle this??
Thanks
You could simply store a reference to all the created images as elements in an array kept as an attribute of the viewController.
Alternatively, this is the sort of problem that can be handled with a subclass. You can just create a subclass of UIImage with some sort of identifier attribute and use that to remove them.
Seems like you could just loop through the subviews array, look at the tag property of each one, convert each to a string, and use NSString startsWith: to remove those that match your pattern.
But I think it would be easier to just keep your own list of created images, and delete them when desired.