     let width: Int = Int(size.width)
        let height: Int = Int(size.height)

        assert(pixels.count == Int(width * height))

        var provider: CGDataProvider?
        pixels.withUnsafeBufferPointer { p in
            if let address = p.baseAddress {
                let data = Data(bytes: UnsafePointer(address), count: pixels.count * MemoryLayout<Pixel>.size)
                provider = CGDataProvider(data: data as CFData)
            }
        }

        let cgim = CGImage(
            width: width,
            height: height,
            bitsPerComponent: bitsPerComponent,
            bitsPerPixel: bitsPerPixel,
            bytesPerRow: width * Int(MemoryLayout<Pixel>.size),
            space: rgbColorSpace,
            bitmapInfo: bitmapInfo,
            provider: provider!,
            decode: nil,
            shouldInterpolate: true,
            intent: CGColorRenderingIntent.defaultIntent
        )

        self.init(cgimage: cgim!)
    }

    /// Initializes a new Image using another image.
    /// - parameter c4image: An Image around which the new image is created.
    convenience public init(c4image: Image) {
        let cgim = c4image.cgImage
        self.init(cgimage: cgim, scale: c4image.scale)
    }

    /// Initializes a new copy of the receiver.
    /// - parameter zone: This parameter is ignored. Memory zones are no longer used by Objective-C.
    /// - returns: a new instance that’s a copy of the receiver.
    public func copy(with zone: NSZone? = nil) -> Any {
        let uiimage = UIImage(cgImage: self.contents)
        let img = Image(uiimage: uiimage, scale: scale)
        img.frame = self.frame
        img.constrainsProportions = self.constrainsProportions
        img._originalSize = _originalSize
        return img
    }

    // MARK: Properties

    /// Returns the UIImageView of the object.
    /// - returns: A UIImageView object.
    open var imageView: ImageView {
        return self.view as! ImageView // swiftlint:disable:this force_cast
    }

    /// Returns a UIImage r