Skip to content

Instantly share code, notes, and snippets.

@nbertagnolli
Created February 23, 2020 18:27
Show Gist options
  • Save nbertagnolli/66402c10bf1f35acff7a10d0cb49997b to your computer and use it in GitHub Desktop.
Save nbertagnolli/66402c10bf1f35acff7a10d0cb49997b to your computer and use it in GitHub Desktop.
Update image size in Xcode Model
func updateClassifications(for image: UIImage) {
classificationLabel.text = "Classifying..."
// Add this line before orientation to update the image size using the function in ResizeImage.swift
let resizedImage = resizeImage(image: image, targetSize: trainedImageSize)
// Previous:
// let orientation = CGImagePropertyOrientation(image.imageOrientation)
// The new line just has image changed to resizedImage
let orientation = CGImagePropertyOrientation(resizedImage.imageOrientation)
// Previous:
// guard let ciImage = CIImage(image: image) else { fatalError("Unable to create \(CIImage.self) from \(image).") }
// The new line just has the image variable changed to resizedImage
guard let ciImage = CIImage(image: resizedImage) else { fatalError("Unable to create \(CIImage.self) from \(resizedImage).") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment