iOS how to handle image upscaling,downscaling,image stretching and other issues - ios

I have an image which is completely red but there is a small line which is white in color and mid of the screen.But the line disappears as its getting downscaled I believe.
so if I my imageview width is 20 by 20.my 1x image should be 20* 20 and my 2x image should be 40 by 40 and my 3x image should be 60 by 60.
if I want to vector way then I can use pdf images which is of 20 by 20 and keep it 1x and it will be get scaled up to 40 for 2x and 60 for 3x.
Please correct me if I am wrong.
When I try to show image on bigger imageview of width and height as 300 by 200 then sometimes image gets stretched. how can I avoid that ? Have to maintain the image aspect ratio width and height w.r.t imageview.
I have heard using aspect fit content mode can solve the image stretch issue.
somebody please clarify me as other answers in stack overflow leads to bit more confusion.
Cheers

Related

Resize an image using an image cropper in Umbraco 7.6

Update: I'll make some crops for the Umbraco's image cropper (Umbraco.ImageCropper) in Umbraco 7.6. The users uploads images over the 4MB (some images are over the 7MB). Now I'll crop resize this images to improve page speed.
I've seen that some of the images are taken in landscape and others in portrait. For a image gallery I'll have the original height and width ratio but with a max width of 500 pixels with a variable height.
I've tried to place the height empty and place to zero but both gives me an error:
I can only make crops with a fixed width and height. Now my questions are:
Could I give the crop a variable height dependent on the original size of the image?
Could I just resize the image to a fixed width?

Image 1x, 2x and 3x issues on different device in iOS

I have 1x, 2x and 3x images in image assets file like below mentioned image.
But, it were placed 1x image for all devices like below mentioned image.
Am using Xcode 7.3 and iOS 9.3. I created imageview using auto layout. And set Align centre x to superview and Align centre Y to superview.
Any advice / input would be appreciated! Thanks.
This is fine. 3x doesn't mean that your imageview will show three time bigger. It's uses three time bigger resolution. That means if your imageview's size is 50x50 then iphone 6 plus (5.5 inch) requires image with resolution 150x150. If you set 50x50 resolution image to this display then it will not show perfact. That's it. It doesn't mean that 3x image will display 3 time larger then original imageview.
Then also you need your imageview of your size of your image then set UIViewContentModeScaleAspectFill content mode to your imageview with same constraints specified in question!
As #Lion answered this question very well, using 3X does not means your image height and width will increase 3 times.
If you want to resize your image view for bigger device so all you need is to use appropriate autolayout constrains.
follow this if you want to change origin and size of image view with device size(aspect ratio)
And when your size of imageview resize, use the 2/3 times bigger image as imageview for 2X/3X resolution.
Autolayout: origin and size should change according to width and height factor
Check these devices
iPhone 4 and prior #1X
iPhone 4S,5,5S,5C,6,6S,7,7S #2x
iPhone 6+,6S+,7+,7S+ #3x
suppose after applying constraints for bigger screen your image view's size is (50,50) then use a image of size 150,150 for 3X resolution
Make sure your content mode is UIViewContentModeScaleAspectFill and there are no height/width constraints for your UIImageView

Image size for universal app ios?

I have a question about using images for universal apps on IOS.
I've created a universal app that works on all iphone devices and ipads. I've placed all the content via storyboard. On a View I have two buttons one on the top space area that is 40 points high and as wide as the view, one on the bottom area also 40 points high and as wide as the view and an image that is a square (A x A) in the middle of the view, the image is constrained by horizontal and vertical (For it to stay always aligned in the middle of the view).
(I understand that if I use an image that is 100 points by 100 points image at 1x, I need to create two other images at 200 points by 200 points for 2x and 300 by 300 for 3x.)
1) So if I constrain the UIImage container by height and width equal to 100 by 100, it will be 100 by 100 points in all devices. But I want it to use as much space as possible. That would mean that on iphone 5 - 6s+ it would always be 100 by 100, it would look smaller on every growing screen. It would also mean that I would need to make it bigger for Ipad (Storyboard changing to regular regular to change UIImage container size for ipad, ex. increase it to 300 x 300). Put once I make it bigger, the image I have will be to small for that size therefore turn blurry or pixelated.
Right?
2) If I would like to be able to use as much space as possible I thought of using the following method. Constraining the UIImage to be equal width as the view but reducing its multiplier to 0.9 or 0.8 (Therefore making it smaller then the view width) and placing an aspect ratio of 1:1(To maintain it square). That way taking advantage of most of the view space that is free, and In all the devices it would always seem filling the same space. However the problem would be that the image would have to be different sizes. (Ex. iphone 5 = 150 x 150, on iphone 6 = 250 x 250, on iphone 6+ = 320 x 320 ans on ipad 600 x 600).
so If I make an image that in 2x that is 150 x 150, when its used on the iphone 6 it would be distorted or pixelated and the same for for the rest.
So can someone help me understand what I should do? or link a tutorial?
Please help!!
I've found that the best way to solve this problem would be to make a much larger image and let the constraints resize it. That way, you've covered your bases if new resolutions are developed, or with the current varying sizes. A much larger image would not look bad if it was compressed into a smaller space, but you might lose some details.

Maintain image quality in iOS Application

I am trying to create a photo application but I am having a tough time formatting my photos so that they show clearly.
I have an imageview size 320 * 500, and an image size 3648*2736 px (Which of course I can scale down).
imageView.contentMode=UIViewContentModeScaleAspectFit;
With imageView.contentMode=UIViewContentModeScaleAspectFit; I changed the image size to 700* 525px (IMGA) and one 500 * 325(IMGB).
In this mode
IMGA fills the entire image view but is somehow a little distorted/not crisp
IMGB does not fill the entire image view Top and Bottom but the width is perfect and the image is crisp.
UIViewContentModeScaleAspectFill
With UIViewContentModeScaleAspectFill
the image is made for fit into the uiimageview but again distorted even if the image is scaled down vs being scaled up.
I see many apps with crisp large images . and I am hoping that someone helps me with measuring/ contentmode to get my images better.
Or correct my resizing
P.S I have been looking at this link to try help but I'm still missing my goal.
Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

How to work with Ipad images? Xcode

I am creating an Ipad app and no matter what height I set my ImageView to be it is always too big.
For example I have an ImageView that's about 20 pixels tall and has all of the constraints that I need to keep it where I want it to be. When I play this 20 pixel tall ImageView on the Ipad simulator the ImageView covers about half of the Ipad screen.
How can I work with Ipad images if even a 1x1 pixel image view takes up a signifiant amount of the screen? (Yes, I made the 1x1 image just to see if it would still be insanely large)
Under Auto Layout, if you don't set the size of the image view absolutely, it will size itself to match the size of the image assigned to it. That is probably what is happening to you.

Resources