Hi every one Recently I achieved thumbnail image(png) creation from the pdf and you can see the Thumbnail creation from PDF post Now my problem is, It is taking time to create a thumbnail images when compared to download thumbnails from the server through wifi.Is there any better way to create the thumbnails bit faster.
I notice you have the interpolation quality set to high. If you set it to low, it will likely render faster.
Related
I want to allow the user to select a photo, without limiting the size, and then edit it.
My idea is to create a thumbnail of the large photo with the same size as the screen for editing, and then, when the editing is finished, use the large photo to make the same edit that was performed on the thumbnail.
When I use UIGraphicsBeginImageContext to create a thumbnail image, it will cause a memory issue.
I know it's hard to edit the whole large image directly due to hardware limits, so I want to know if there is a way I can downsample the large image to less then 2048*2048 wihout memory issues?
I found that there is a BitmapFactory Class which has an inSampleSize option which can downsample a photo in Android platform. How can this be done on iOS?
You need to handle the image loading using UIImage which doesn't actually load the image into memory and then create a bitmap context at the size of the resulting image that you want (so this will be the amount of memory used). Then you need to iterate a number of times drawing tiles from the original image (this is where parts of the image data are loaded into memory) using CGImageCreateWithImageInRect into the destination context using CGContextDrawImage.
See this sample code from Apple.
Large images don't fit in memory. So loading them into memory to then resize them doesn't work.
To work with very large images you have to tile them. Lots of solutions out there already for example see if this can solve your problem:
https://github.com/dhoerl/PhotoScrollerNetwork
I implemented my own custom solution but that was specific to our environment where we had an image tiler running server side already & I could just request specific tiles of large images (madea server, it's really cool)
The reason tiling works is that basically you only ever keep the visible pixels in memory, and there isn't that many of those. All tiles not currently visible are factored out to the disk cache, or flash memory cache as it were.
Take a look at this work by Trevor Harmon. It improved my app's performance.I believe it will work for you too.
https://github.com/coryalder/UIImage_Resize
In my website, I have a library contain all image of user, I want to display all image in this library. How can I do it?
I have solution but I can’t do it. This’s my solution. I’ll create thumbnail for each image and display it in library. Size of thumbnail is very small, so I don’t worry about performance. If I create thumbnail in my server. It must download, read and resize these images, then it return for my website. This way I feel not good. I have many images, each customer have about hundreds images, size of each image about 1mb or 2mb. I think have no server can handle it. Another way is create thumbnail on client by jQuery, but I can’t do it and my friend talk with me. jQuery don’t handle it. How can I do it for my solution? Hope you understand what I mean
I think you can use pagination if you would like to return million images in a page
so for instance 50 images per page to keep up with your web performance
You need to generate thumbnails on server and show thumbnails in the gallery. When a user clicks on a thumbnail in the gallery, show the full image.
I think your first idea is better. Because you don't want to show the images in actual size and you want to make them smaller. So using their thumbnail is a good solution. If you think this could add some complexity you can make the thumbnails for each image when user uploads them and in your view just use the thumbnails.
I am new to iOS, and I am trying a image on a view. The image in question is large, and fetched from a URL, so to load the view it takes quite some time (almost 5-10 sec).
I don't want to display a place holder and to do some asynchronous call to update the image;
instead, I want image processing similar to how it is implemented in the Facebook iOS app: the big image display hazy at first, slowly becoming the original image as it loads. Does anyone know how this can be achieved in iOS?
The 'hazy' image you talk about is a 'progressive' jpeg. You can re-format any arbitrary image to a progressive jpeg (on the server side), then use the Image I/O methods to display partial versions. There are a variety of techniques you could use - see this prior post for more pointers.
You can download and display a thumbnail image view first or just display a temporary loading image while you are downloading the big image. Take a look at ASIHTTP for asynchronous image downloading. There are several other frameworks available as well and tons of sample code if you take time to google.
I'm trying to code myself the Apple Photo.app for iOS.
All is good but when I select an album to see all my pictures it's a bit slow to load all my pictures. All my thumbnail are saved in a database. I manage them with Core Data.
So when I select an album I create a specific request and add all my thumbnail in a scrollview. But I have to wait to see all my thumbnail.
In Photos.app when I select an album all pictures are directly loaded.
How has Apple improved that ?
Thanks a lot !
I am assuming that you are using UITableViewCells with 4 images in each, and that you are recycling the cells.
JPEGs take a lot of decompression CPU cycles. There was a specific mention of this at Apple's recent developer conference. Most likely this is what is slowing you down.
Solution: use PNGs and make sure they are absolutely optimized for the size and resolution that is are the minimum requirements for the thumbnail images. Core data should be fast enough to provide smooth scrolling for thousands of thumbnail images.
I am using CGContextDrawPDFPage class to render PDF in my app without any trouble. But, the amount of time taken to load the book is a bit more and the time taken to render the page is proportional to the number of pages in the PDF.
In my case, the PDF can contain anywhere between 500 to 1000 pages. Due to this, the loading time of my PDF is getting increased. It is almost taking 10 seconds to render the first page which is really bad from a user experience aspect. And this time is being taken only during the loading of the book for the first time. In my opinion the delay is due to the fact that i am trying to read the entire PDF at once.
Is there a way in which i can read the PDF part by part so that the initial time to render the PDF is faster.
Thanks.
Have you run Instruments to see where the time is spent?
I suggest you use heavy pre-caching to solve the problem. In my experience, analyzing the PDF (for aspect ratio stuff, annotation, etc) takes some time. Drawing is slow too.
I solved this with pre-generating images on the fly, and showing them whenever possible. Of course this is tricky too, e.g. don't ever try to render on and off screen at the same time, memory usage while drawing a complex pdf is off-scale and performing two operations at the same time may just crash your app.