             vDSP_vfltu8(&u8Alpha, 1, &floatAlpha, 1, vDSP_Length(u8Alpha.count))
             vDSP_minvi(&floatAlpha, 1, &minValue, &minIndex, vDSP_Length(u8Alpha.count))
             if minValue < 255.0 {
-                channels = 4
                 alpha = u8Alpha
             } else {
                 hasalpha = false

        var bitmapInfo = CGBitmapInfo.byteOrder32Big.rawValue
        if hasalpha {
             bitmapInfo |= CGImageAlphaInfo.last.rawValue
        }
        let cgImage = CGImage(width: out_width, height: out_height, bitsPerComponent: 8, bitsPerPixel: 8 * channels, bytesPerRow: out_width * channels, space: colorSpace, bitmapInfo: CGBitmapInfo.init(rawValue: bitmapInfo), provider: dataProvider, decode: nil, shouldInterpolate: true, intent: CGColorRenderingIntent.defaultIntent)
        let outImage = UIImage(cgImage: cgImage!)

        Waifu2x.interrupt = false
        var hasalpha = image.cgImage?.alphaInfo != CGImageAlphaInfo.none
        debugPrint("With Alpha: \(hasalpha)")
        let channels = 4
        var alpha: [UInt8]! = nil
        if hasalpha {
            var u8Alpha = image.alpha()
