UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 13: Instafilter image loading upside down

Forums > 100 Days of SwiftUI

I have just completed the Instafilter project. The only problem is that when I run it in the simulator and select the first image from the default photo gallery (Image of pink flowers) it loads upside down. If I select any other image from the photo library, it loads right side up. I don't know if this is just some kind of bug in the simulator, but I wondered if anybody else has run into this problem?

Also, after following all of the instructions for the project, I was running into an error when trying to save my filtered photos back to the library. I think the error was "Data Unavailable" or something like that. But I seem to have fixed it by adding another record to my info.plist file for "Privacy - Photo Library Usage Description." I'm not sure if that just wasn't a requirement at the time when this tutorial was created, but I'm wondering if that is what gives my app access to the photo library on the device? If so, it seems strange that I was still able to select photos from the library before adding that line to Info.plist and only ran into a problem when trying to save an image back to the library. Can anybody explain this behavior?

You can see my code for this project (and all of my other projects) on My Github Account

3      

Hi @FlyOstrich,

I have the same problem concerning the rotation of the images. It also occurs for images selected from my own library. Concerning the error upon saving, I didn't have that, because I added the entry into the info.plist beforehand, as indicated in the tutorial. Maybe Paul had updated the tutorial (I was following the book version) in the meantime.

Cheers, Patrick

Update: I just saw that there is already a solution to the rotation problem in the forum: https://www.hackingwithswift.com/forums/100-days-of-swiftui/day-67-instafilter-image-orientation/1706

3      

Hi

To solve the issue with Image not loading correct way up. If you edit the image somehow (eg crop it slightly) then try and reload it it work it should be right way up.

In this video How to save images to the user’s photo library, part of 100 days of SwiftUI - Instrafilter. Paul says

This is where you can add a whole range of configuration options for your project, but right now there’s one specific option we need. You see, writing to the photo library is a protected operation, which means we can’t do it without explicit permission from the user. iOS will take care of asking for permission and checking the response, but we need to provide a short string explaining to users why we want to write images in the first place.

To add your permission string, right-click on any of the existing options then choose Add Row. You’ll see a dropdown list of options to choose from – I’d like you to scroll down and select “Privacy - Photo Library Additions Usage Description”. For the value on its right, please enter the text “We want to save the filtered photo.”

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.