How to show Blurred image before downloading(like in whatsapp) in ios? - ios

I am making a Chat application for image sending and downloading. I want to do some animation like in WhatsApp. So, how to show the blurred image? My image is downloaded from server. Please help me.

Scale the image down to a very small size like say 8x8 pixels. Send that data to the client. It should not be more than 4 * 8 * 8 = 256 B or 0.25 KB in size, so sending it to the client will not be a problem no matter how slow the client's connection speed is.
Then scale the received 8x8 image to the resolution of the preview box (e.g. 256x256). You shouldn't need to upsample the 8x8 image if the preview box is a UIImageView (see the link below). This downsampling and successive upsampling of an image "blurs" the image.
To understand how you can resample/rescale an image in iOS, check this link. I am not an iOS developer and cannot help you much in performing this task specifically for iOS.

I think that process is done using the server... As I know, there are 2 copies for a single image..
one image with full quality
other image is a thumbnail of original image.. (low size in capacity )
So.. before downloading the original picture client app calls for the URL of the thumbnail & it downloads very quickly since its size is less..
Meanwhile you can use an async function to download original file in the same time..
That is the process...
Hope it will be help for you!!

Related

How iiifhosting site processing images to up/down scale to make it compatible to iiif?

My question is regarding IIIF. I am using iiifhosting.com but now i want to setup my own server. I want to know how iiifhosting.com processing my images to high resolution?
I have uploaded an image of 2000x1000 and when i get info.json i got width: 11658, height: 6112. Check this url.
http://bafdev.iiifhosting.com/iiif//e6ebb551407a5c64903d100ab8ba9199bb264d1c17cdcf0a9e745cd6c5aea432/info.json
When i try to get full image and save it its just only 1000x524
http://bafdev.iiifhosting.com/iiif//e6ebb551407a5c64903d100ab8ba9199bb264d1c17cdcf0a9e745cd6c5aea432/full/full/0/default.jpg
I want to know how iiifhosting doing this? Any clue?
1- iiifhosting is not upscaling images. It only shows image information which image have. There is no conversion in image to high resolution. In info.json you are getting image info how much width height it has and tiles sizes. Tile sizes formula is (smallest dimension) * 1/2n > endpoint.iiif.min_tile_size
endpoint.iiif.min_tile_size is which you set in cantaloupe.properties file default is 512x512
2- http://bafdev.iiifhosting.com/iiif//e6ebb551407a5c64903d100ab8ba9199bb264d1c17cdcf0a9e745cd6c5aea432/full/full/0/default.jpg
Regarding your second point there is restriction to get full resolution image on iiif hosting so you cant get full image of their client files. Therefore they are serving maximum of 1000x1000 image.
Second thing is if iiifhosting client have 2gb images (very high res) and you request 100 images on your site than it will overwhelm image server.

Size of document increases on iOS device compare to the Android/Windows device

There is one very interesting issue I face at the moment in my iOS application.
The image size got increased by the random number of percentage.
What I have observed is as below
When I choose the same image from the photo library and try to send the image by converting it to data, though the multipart form data API.
The image size also got increased in multiple times of the original image size.
I use the below code to convert the image into data bytes
img.jpegData(compressionQuality: 1.0)
The data length is around 90 MB.
The original image is available here.
Does anyone know where is the issue and how to resolve it?

Image optimisation using the Kingfisher library in iOS when loading an image?

I'm loading images on a list from a server. The UIImageView size is very small (40 x 40), So ideally an image with a size of 40 x 40 or a little larger should be loaded in it. However, the server guy is sending an image of a much larger size (1920 x 1200).
When I diagnosed the view controller memory I noticed that it increases as the image is loading.
So my question is
Will the Kingfisher library download a smaller size version of the image?
Will it abort the image loading if the image size is too big?
Is there any way by which can I specifically achieve the above task.
Kingfisher: https://github.com/onevcat/Kingfisher
Will the Kingfisher library download a smaller size version of the
image?
Nor Kingfisher nor any other library will download a smaller version of an image. The server has to send you a smaller version of it. (different url, or same url with a parameter)
Will it abort the image loading if the image size is too big?
I don't know how the library implements the downloading but unless you are talking about unreasonably big files (way bigger than the resolution you expect (1920x1200)) it will not be aborted. And even then, it probably won't be aborted but instead the app might be killed by the system when displaying super high resolution images (again, way bigger than 1920 x 1200)
Is there any way by which can I specifically achieve the above task.
If you want to display many many images at once and are worried about their sizes, its better to create thumbnails of them.
You can use Kingfisher to
1) first download the image
2) then resize the image
3) then show and cache it if you need
Check this page to see a ton of code snippets for that library.
https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet

iOS ideal image resolution

I'm having a real hard time understanding this, but let's say I have an iOS app for both iPad and iPhone and I want to download an image from a server and display it in full screen.
I have read that the iPad pro has a resolution of 2732x2048 and if we want to display an image in fullscreen we would need to download the image with this size right? However, I also read that the image should never be over 300KB. I was not able to bring an image with this size under 2MB (I used JPEGmini for example to reduce size).
And I don't think that iPhone user would need to download such a huge image, so my question is: what resolution should my images be on the server and how can I manage to keep them in a rational file size. Also should I upload multiple images for different devices? If so, how many and at what resolutions?
Isn't the problem merely that you are holding incompatible beliefs? This is the belief that is giving you trouble:
I also read that the image should never be over 300KB.
Let go of it.
Clearly it is right to say that the image should be no larger than needed for display. But an image to be shown as a 3x scale image on the iPad pro needs to be 2732x2048. So that's that.
(You could, alternatively, use an image 2/3 of that size and show it as a 2x scale image. It wouldn't look quite as good as the 3x scale image, but it might be acceptable.)
On a smaller device, yes, you should scale down the image in code, so that you are not holding in memory an image larger than needed for display. But in this case, you need the large image for display.

iOS optimize image download speed from own server

I have a gallery and detailed view controllers in my application, when a user taps a thumbnail in the gallery I redirect them to the detailed controller and begin to asynchronously download original-sized image, which is 640x640 px and it takes like 5-6 seconds to download. Is there a way to optimize the image download speed?
For example Instagram does this in around 0.2-1.0 second, like incredibly fast. My thinking is that they use some kickass compression on the server side and then unarchive the image they got in the Application. Are there any ways to do something like that?
Thanks in advance.
Solved it, I had to change the image format to .jpeg from .png, the compression rate of 40%, the quality is pretty good and the image size changed to 45kb from 600kb, which increased the speed.

Resources