UIImage
ImageFileType
ประเภทของภาพที่ระบบ Support
enum ImageFileType: String {
case png = ".png"
case jpg = ".jpg"
case gif = ".gif"
case video = ".video"
case unknow = ""
}
| Name | Description |
|---|
| png | ภาพประเภท PNG |
| jpg | ภาพประเภท JPEG |
| gif | ภาพประเภท GIF |
| video | วีดีโอ |
| unknow | ภาพประเภทอื่นๆ |
Method Overview
| Name | Description | Return |
|---|
| init() | การ Initial UIImage ด้วย base64 หรือ URL | void |
| jpgData() | การแปลงภาพให้เป็น Data ที่เป็นภาพประเภท JPEG | Optional(Data) |
| base64() | การแปลงภาพให้เป็น base64 | Optional(String) |
| rotate() | การหมุนภาพได้แบบอิสระด้วยมุม Radians หรือ Degree | Optional(UIImage) |
Method Details
convenience init?(base64: String)
การ Initial UIImage ด้วย base64
Parameters
| Name | Description | Type |
|---|
| base64 | base64 ของภาพที่ต้องการทำมาสร้าง UIImage | String |
convenience init?(url: URL)
การ Initial UIImage ด้วย URL
Parameters
| Name | Description | Type |
|---|
| url | url ของภาพที่ต้องการทำมาสร้าง UIImage | URL |
func jpgData(compressionQuality: CGFloat = 0.5) -> Data?
การแปลงภาพให้เป็น Data ที่เป็นภาพประเภท JPEG
Parameters
| Name | Description | Type |
|---|
| compressionQuality | คุณภาพของภาพที่ต้องการหลังจากทำการ Compress แล้ว | CGFloat |
Returns
| Type | Description |
|---|
| Optional(Data) | Return Data ของภาพประเภท JPEG หลังจากทำการ Compress แล้ว |
func base64(type: ImageFileType = .png) -> String?
การแปลงภาพให้เป็น base64
Parameters
| Name | Description | Type |
|---|
| type | ประเภทของภาพที่ต้องการแปลงเป็น base64 | ImageFileType |
Returns
| Type | Description |
|---|
| Optional(String) | Return String base64 ของภาพ |
func rotate(radians: Float) -> UIImage?
การหมุนภาพได้แบบอิสระด้วยมุม Radians
Parameters
| Name | Description | Type |
|---|
| radians | มุมที่ต้องการหมุนภาพ | Float |
Returns
| Type | Description |
|---|
| Optional(UIImage) | Return UIImage ของภาพที่ทำการหมุนแล้ว |
func rotate(degree: Float) -> UIImage?
การหมุนภาพได้แบบอิสระด้วยมุม Degree
Parameters
| Name | Description | Type |
|---|
| degree | มุมที่ต้องการหมุนภาพ | Float |
Returns
| Type | Description |
|---|
| Optional(UIImage) | Return UIImage ของภาพที่ทำการหมุนแล้ว |