Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

convert image to base64 in swift ui

   func convertImageToBase64(image: UIImage) -> String? {
    let imageData = image.jpegData(compressionQuality: 1)
    return imageData?.base64EncodedString(options: 
    Data.Base64EncodingOptions.lineLength64Characters)
   }
Comment

convert image to base64 swift Ui

//Use image name from bundle to create NSData
let image : UIImage = UIImage(named:"imageNameHere")!
//Now use image to create into NSData format
let imageData:NSData = UIImagePNGRepresentation(image)!

//OR next possibility

//Use image's path to create NSData
let url:NSURL = NSURL(string : "urlHere")!
//Now use image to create into NSData format
let imageData:NSData = NSData.init(contentsOfURL: url)!

let dataDecoded : Data = Data(base64Encoded: strBase64, options: .ignoreUnknownCharacters)!
let decodedimage = UIImage(data: dataDecoded)
yourImageView.image = decodedimage
Comment

PREVIOUS NEXT
Code Example
Swift :: uilabel set fon siz 
Swift :: declaring optionals swift 
Swift :: swiftui tabview background color 
Swift :: swiftui textfield focus 
Swift :: swiftui tutorial 
Swift :: how to recieve hex value from NSData swift 
Swift :: save file with % swift 
Swift :: swift extension Array where type 
Swift :: Single Line Comment 
Swift :: sort list ios swift 
Swift :: swift dictionary 
Swift :: how to loop in swift 
Swift :: how to present a uiview after an array of cards is empty swift 
Swift :: Swift Use of Hash Function 
Swift :: after redirect from another viewcontroller in swift 5 make full view view controller 
Swift :: Log httpurlresponse swift 
Swift :: auto layout issue in tableview 
Swift :: parsing to double any data type in swift 
Swift :: ios swift local storage with icloud 
Swift :: Swift Check Subset of a Set 
Swift :: swift concurrency datatask before ios 15 
Swift :: Trailing Closure Swift 
Swift :: swift 5 for loop with index <= 
Swift :: Type Constraints in Swift Generics 
Swift :: swift class init 
Swift :: xcode combine calayer into an image 
Ruby :: ruby filename from path 
Ruby :: how to check ruby version 
Ruby :: PG::DatatypeMismatch: ERROR: column "price" cannot be cast automatically to type numeric HINT: You might need t 
Ruby :: ruby each char with index 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =