File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -259,14 +259,19 @@ class ImageCompressor {
259259 if let img = UIGraphicsGetImageFromCurrentImageContext ( ) {
260260 let imageData = img. jpegData ( compressionQuality: compressionQuality)
261261 UIGraphicsEndImageContext ( )
262- let filePath = Utils . generateCacheFilePath ( outputExtension)
263- do {
264- try imageData? . write ( to: URL ( fileURLWithPath: filePath) , options: . atomic)
265- let returnablePath = ImageCompressor . makeValidUri ( filePath)
266- return returnablePath
267- } catch {
268- exception = NSException ( name: NSExceptionName ( rawValue: " file_error " ) , reason: " Error writing file " , userInfo: nil )
269- exception? . raise ( )
262+ let isBase64 = options. returnableOutputType == . rbase64
263+ if isBase64 {
264+ return imageData!. base64EncodedString ( options: [ ] )
265+ } else {
266+ let filePath = Utils . generateCacheFilePath ( outputExtension)
267+ do {
268+ try imageData? . write ( to: URL ( fileURLWithPath: filePath) , options: . atomic)
269+ let returnablePath = ImageCompressor . makeValidUri ( filePath)
270+ return returnablePath
271+ } catch {
272+ exception = NSException ( name: NSExceptionName ( rawValue: " file_error " ) , reason: " Error writing file " , userInfo: nil )
273+ exception? . raise ( )
274+ }
270275 }
271276 }
272277 } else {
You can’t perform that action at this time.
0 commit comments