Do you need to have images be at 3x size in my Cloud Storage for iOS? - swift

I am loading images into my app from Firebase Storage and want them to have the highest resolution possible without loading a massive file size. In my app, I am displaying each image at 100x500. In Firebase storage should these be set to 300x1500 (3x the pixels they will be shown at) or does that not matter and saving them at 100x500 will have the same resolution as 300x1500?

I ran a test on my iPhone with 100x500, 300x1500, and then the max (same aspect ratio). The 100x500 was blurry and the 300x1500 and max both looked identical. Based on this, I'd say you do need to have the images as 3x size

Related

Should I resize images from camera / photo library before sending over network?

The images I am getting back from the photo library and camera are HUGE, and it takes a significant amount of time to send them over the network even in good conditions. I can't imagine a scenario in which I would need the full double-digit MB image, but maybe I'm missing something? Is it common practice to resize them before sending them over the network?
Yes it is common practice to alter an image's dimensions and compression so that it is appropriate for application.
As observed, by the default images from the camera are very large so that they can be displayed on large screens, printed to posters, zoomed and cropped etc without appearing unduly pixelated. So unless the app in question is a photo/image manipulating app, then resizing will almost certainly be beneficial in that it can improve networking, the app's memory foot-print and it's overall snappiness.
In terms of how to size and compress, while it is possible to store multiple versions of the image for each device that's being supported.
Practically, it seems that storing a single image at the dimensions required on the lowest resolution device but then only compressing it enough so that the higher resolution devices can scale up as needed without looking ugly seems to deliver reasonable results.
In terms of resizing, there are various posts on SO e.g. How do I resize the UIImage to reduce upload image size
I've also stuck gist for the UIImage extension I'm currently using to do this in my App over on GitHub here.
Have fun.
You can transform the image into data and then use this:
let imageData = image!.jpegData(compressionQuality: 0.5)!
It will make the quality less than usual with 50% to be able to save it quickly and smoothly

Why did the images increase in size after importing them into Unity?

I have a large set of jpg images with a total size of 10 mb, but when I import them into unity, their size increases several times! How do I keep the original size of the images?
Above answers are wrong, thus, I decided to explain it further here.
Be careful, size for disk is different from size in ram/gpu.
The one you found in import settings is the size on ram. The default one(without mip) should be the smallest size(almost) for app size.
Although it shows bigger size in import settings, your app will still compressed them again for the build app, and app installer.
Why the size in ram is so huge?
In graphic rendering, all the images(no matter jpg or png) will be read and decode. The decoded result will be all pixels array..etc, depending on your texture format(after decode), you will have different size in ram.
However, your source image is usually the highly compressed(encoded) image for disk storage. That's why you get a bigger size after importing to Unity. It counts on how many pixels in total.
You can still keep the original size, only if you keep it as separate resource and load it in runtime. as external resource in resource folder etc. However, it won't reduce the memory usage in RAM or GPU.
Any images which you imported to the project, will be resampled and encoded by their format. The size you see in import settings, which is also the size for ram.
JPEG or PNG is just a format for disk storage. The size you seen inside unity is the size in Ram for rendering. The larger the size, the more ram it needs too.
If you are looking for smaller app size, Unity's default compression will be the best(without mipmap). When you export as apk for example, it will recompress all the assets anyway.
Of course you can still keep the original image as external source and load it in runtime, but your overall app size with external source will be much huge, according to my experience.
As external image in resource folder won't be compressed together with the app assets.
you can click at image in unity ,the image has a propertie call Pixel per unit
you can adjust it to control size of image

Reduce image file size without resize and quality lose

In a site i am daily uploading around 100+ images that have taken from digital cameras, a single image file have an average file size of around 3MB. It needs high amount of disk space in server. If i can reduce the average size below 1MB i can upload more images in the current space.
I have tried many online image optimizers, but all of them can't helped me to reduce below at least 1.5MB.
jpeg-tools.com is a best site to optimize images, they accept a maximum of 20MB image files. You will never face any quality lose.

complication image is displaying too small

I have a watchkit application with an image. when I place the correctly sized (52x52 pixels for modular small 38mm) image into the correct place in the asset catalog the image displayed is very small, but when I just use a huge version of the image it is scaled down to the size I would expect:
any ideas/tips of how should I prepare/use correctly sized images for complications if I don't want to just go with the huge version?
source code: https://github.com/bazik123/Wristlight
ComplicationController.swift -> func imageNamed()
I had a similar issue and it ended up that the resolutions of my complication images were too high. I had them at 300 and reduced them to 72 using Preview and then they looked perfect!

CCSprite memory overflow

I need to create and show 10 images using cocos2d. Each will be placed above previous one and all will be visible simultaneously (all of them has transparent areas). Each image has resolution 2048x1536.
When I create 5 or less CCSprites the app run fine, but when I create 6 CCSprite - it crashes on device (iPad) with error "Data Formatters temporary unavailable".
I suppose it's lack of memory, but maybe someone knows any approach for for this situation
Thanks!
A transparent image of this size uses about 12mb ram (2048*1536*4 bytes).
You are lucky that you get 5 images of this size shown before your app crashes.. which usually happens at about 50mb ram usage.
Without more knowledge about what you want to do or need to display I can't give any advice what to do .. but you won't be able to show 10 images of this size.
edit: since you are using cocos/opengl you might be able to get more images shown by changing the image format to rgb4444. This will cut the memory need to the half but you also loose much quality on your images.