title: Displaying base64 encoded image in rails
body: <p><strong>Update</strong>:</p>
  
  <p>I took the base64 string iOS was generating and decoded it to a binary file through a website. The image was encoded properly it seems.</p>
  
  <p>My problem then is with the rails side of things. I'm displaying the image using the following code but it's just showing a broken image.</p>
  
  <pre><code>&lt;td&gt;&lt;%= ('&lt;img src="data:image/jpg;base64,%s"&gt;' % Base64.encode64(user.imagestring)).html_safe %&gt;&lt;/td&gt;
  </code></pre>
  
  <hr>
  
  <p>I'm trying to encode a base64 string to send through JSON to my web service (Rails using Postgresql). I've converted a UIImage to NSData and am now converting it to a base64 string.</p>
  
  <p>I'm using the new <code>base64EncodedStringWithOptions</code> method. It converts to a long string but on my web service the image appears broken.</p>
  
  <p>I uploaded the image to an image to base64 converter website and it returns a slightly different string. </p>
  
  <p>Is the problem with the iOS encoder or am I doing something wrong?</p>
  
  <pre><code>UIImage *image = [UIImage imageNamed:@"image.png"];
  NSData *imageData = UIImagePNGRepresentation(image);
  NSString *blob = [imageData base64EncodedStringWithOptions:0];
  </code></pre>