2022-05-06 08:29:34 +02:00
|
|
|
//
|
|
|
|
// UIImage.swift
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-5-6.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
extension UIImage {
|
|
|
|
|
|
|
|
public func resized(size: CGSize) -> UIImage {
|
|
|
|
return UIGraphicsImageRenderer(size: size).image { context in
|
|
|
|
self.draw(in: CGRect(origin: .zero, size: size))
|
|
|
|
}
|
|
|
|
}
|
2022-05-07 05:42:10 +02:00
|
|
|
|
2022-05-06 08:29:34 +02:00
|
|
|
}
|
2022-11-22 08:58:31 +01:00
|
|
|
|
|
|
|
extension UIImage {
|
|
|
|
public func normalized() -> UIImage? {
|
|
|
|
if imageOrientation == .up { return self }
|
|
|
|
UIGraphicsBeginImageContext(size)
|
|
|
|
draw(in: CGRect(origin: CGPoint.zero, size: size))
|
|
|
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
|
|
|
UIGraphicsEndImageContext()
|
|
|
|
return image
|
|
|
|
}
|
|
|
|
}
|