Add fix for Jpegs

pull/116/head
Timothy Kautz 2 years ago
parent eafd72efd9
commit 5bf9c71081

@ -7,6 +7,7 @@ import CoreML
import Foundation import Foundation
import StableDiffusion import StableDiffusion
import UniformTypeIdentifiers import UniformTypeIdentifiers
import Cocoa
@available(iOS 16.2, macOS 13.1, *) @available(iOS 16.2, macOS 13.1, *)
struct StableDiffusionSample: ParsableCommand { struct StableDiffusionSample: ParsableCommand {
@ -97,11 +98,8 @@ struct StableDiffusionSample: ParsableCommand {
do { do {
let imageData = try Data(contentsOf: imageURL) let imageData = try Data(contentsOf: imageURL)
guard guard
let imgDataProvider = CGDataProvider(data: imageData as CFData), let nsImage = NSImage(data: imageData),
let loadedImage = CGImage( let loadedImage = nsImage.cgImage(forProposedRect: nil, context: nil, hints: nil)
pngDataProviderSource: imgDataProvider,
decode: nil, shouldInterpolate: false,
intent: CGColorRenderingIntent.defaultIntent)
else { else {
throw RunError.resources("Starting Image not available \(resourcePath)") throw RunError.resources("Starting Image not available \(resourcePath)")
} }

Loading…
Cancel
Save