1

This is in regards to the pictures taken through the iPhone's camera. No matter what, I can't understand why image sizes are in the order of 1000s and image scale always 1.0.

For example, I printed out an image's details and this is what I got:

<UIImage: 0x134def110> size {3024, 4032} orientation 3 scale 1.000000

What does 3024x4032 mean? And why is the scale 1.0, when my screen size is really 375x667? Orientation 3 means the image is roated 90º counterclockwise. So if the original image is 375x500 (in pixels), after rotation it should be 500x375. Then why does the size shown not change accordingly?

And on a similar note, how would I get the size of the image in pixels from this size that's printed out? Because no matter what the size of the camera preview, if the ratio of the camera preview is 4:3, the resulting size of the image (image.size.width and image.size.height) is always 3024x4032.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
user1056585
  • 682
  • 1
  • 7
  • 21
  • Your phone has a 12 megapixel camera. The image has to be scaled to display it in a UIImageView but the scaling isn't applied to the UIImage itself, so it isn't reflected in the dimensions or scale of the UIImage – Paulw11 Mar 13 '17 at 03:38
  • Also, your screen size is 375x667 **logical points** (so you have an iPhone 6, 6s or 7), but since its a Retina display, it renders at 2x, so you have 750 x 1334 physical pixels. This is a good read to understand this : https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions – Losiowaty Mar 13 '17 at 08:03
  • Answered down below, let me know if it helps or not! – owlswipe Mar 13 '17 at 10:50

2 Answers2

4

What does 3024x4032 mean?

Those are the dimensions of the image. I think you're missing one point: the iPhone's camera can take photographs with a much higher resolution than its screen size. Just because an image is shown on the screen, it doesn't mean the image dimensions are that size.

Jim
  • 72,985
  • 14
  • 101
  • 108
2

Size: An uncropped, landscape 12.2MP photo (that's default size when shot on the iPhone 7 rear camera) is 3024 * 4032 pixels, so that's where that number comes from. Extra crispy in case you want to frame it and hang it up on your wall! See source.

Scale: Generally 1.0 (or 100%), it's the magnitude of which you've reduced your image file size. So if you wanted a 50% smaller file, you could scale the image down to 0.5 (50%), obviously losing some quality in the process.


tl;dr: those dimensions are the scale of the photo in storage, not the dimensions at which it's rendered on the phone.

owlswipe
  • 19,159
  • 9
  • 37
  • 82
  • Thanks for the answer. So the 3024 * 4032 makes sense. But then what scale would I multiply my crop area (origin (x,y) and width,height) if the image scale is 1.0 so that my crop area is in the same scale as the image? My crop are would naturally be defined in terms of the screen size. Do I have to compute the scale of the image using the screen dimensions and multiply the crop area arguments with that scale? – user1056585 Mar 14 '17 at 02:10
  • @user1056585 To crop the image while maintaining the 4:3 aspect ratio (I assume that's what you're trying to do, correct me if I'm wrong, please!) you just need to divide the width and height of the image by the same value: no need to worry about scale (which will adjust automatically). There are many ways to do such scaling down transformations, see [this tutorial](http://nshipster.com/image-resizing/). And let me know if this fully answers your question or not, forgive me if I misunderstood your follow up question. – owlswipe Mar 14 '17 at 03:36
  • No actually, I don't mind sacrificing the 4:3 ratio while cropping it. In fact the reason I'm trying to crop is: I'd like a cameraoverlayview that covers the full screen. To do this, I need to scale up the camera preview first so it covers the full height, and still maintain the 4:3. This means the width is larger than the screen width. So after capturing the image, I'd like to crop out that extra width from the image from each side. Does that make sense? – user1056585 Mar 14 '17 at 15:31
  • @user1056585 Oh I see! Just use [this UIImage cropping code](http://stackoverflow.com/a/39310866/5700898) and crop your image to [2268 * 4032](http://www.online-tech-tips.com/smartphones/view-photos-widescreen-169-iphone/). Let me know if that helps or not! – owlswipe Mar 14 '17 at 19:11
  • Right, so to get that 2268, I'll need some sort of scaling factor right? To scale up the desired width of 375 with? In this case 2268/375. How do you come up with that scaling factor? Has the iphone camera always been taking pictures with 3024*4032 resolution? – user1056585 Mar 15 '17 at 00:28
  • @user1056585 Nope, you don't need a scaling factor, you just need to crop out the sides (scaling just adjusts the resolution I believe). Again, to crop the sides out see that link from my last comment. And no—the iPhone hasn't always been taking photos at 3024*4032, that's just what comes out of a 12 megapixel camera shooting at a 4:3 aspect ratio (which is the aspect ratio the iPhone and most phones have been using as far back as I can recall). – owlswipe Mar 15 '17 at 04:48