Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Swift - How to build a useful camera app that crops the photos to square?

Hi, Firstly, I'm sad there is no Swift camera content on the site. Hopefully, the community will have answers. I'm trying to build a camera app that is actually useful (not just a working camera app; I've built three of those from resources on the net). Some problems are: the size of the images the camera takes (iPhone 5/6) are way to big. I just need these photos to be "Instagram size" on the screen. Also, the size of the forward camera is different from the size of the rear camera, which screws up my ability to save and retrieve them. (I know I can have an imageView with .AspectFit, but that's not what I need). Here are some of my questions:

I need to crop the image (whether it is taken from the front or rear camera) to the same size, that being 170x170. So whether the camera is front, back, or Library, I need to squeeze the image down (with aspect) to a 170x170 square, and if the original is not square, I need to present the sort of view (like Instagram) to allow the user to make it square. Now, I'm not making an Instagram clone, but actually, that would answer a lot of my questions. If someone can explain to me how to do the thing Instagram does (regarding the size of the images, regardless of source), that would be great.

This will not only be helpful for me, but I guarantee it will be helpful to all Treehouse learners, as this topic is NOT covered well on the internet. There are some poor Stack Overflow examples, and poorer Apple Documentation, and only a couple Youtube videos that use Swift for a camera app, and they are poor too.

I would much appreciate the help. :)

Hi Tony,

I probably cant help much technically, as I am still learning, but I was originally doing an iOS course over on Udemy and one of the sessions on that was building an Instagram clone, Wondering if this would be any good to you.

It was something like the complete iOS 9 developer course by Rob Percival. It was a good course but it felt more like painting by numbers, which Is why I moved across to Treehouse.

Cheers, Marc

Hey Marc, Thanks for the reply and recommendation. I actually have taken that course and it's quite lacking. It doesn't discuss programing the camera or image, just saving and retrieving the images from a list of friends.

1 Answer

Ah fair enough Tony. I left that course just before that section so I never did it. Sorry I couldn't help more. Keep me posted as I'd be interested in doing something similar.