0

On this website, for example when you drop in an image, it is turned into a proper base64 format: http://base64image.org/

In my Swift app, here is what I have to generate a base64 string from an image:

let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)

This gives me something similar, but it has spaces and line breaks. How do I get an output just like the output from the website above?

Katie H
  • 2,283
  • 5
  • 30
  • 51
  • 2
    Include some sample output from the code and the website for the same image so we can see the difference and understand your problem – luk2302 Dec 21 '15 at 23:22

1 Answers1

1
let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions([]) // Don't ask for line breaks

If you remove the request for line breaks, does it match what you're expecting?

Rob Napier
  • 286,113
  • 34
  • 456
  • 610