title: Groovy - decoding Base64 Image String to File
body: <p>I'm having a bit of a problem trying to decode and Image in base64 format to an actual file in Groovy.</p>
  
  <p>The String in Base64 I understand is valid because I'm try it in an  tag and works as expected.</p>
  
  <p>This is my code:</p>
  
  <pre><code>private generateImages(ThemeInfo theme){
          createThemeResourcesFolders("$resourcesPath/images/theme/$theme.name")
          generateImage(Base64.decodeBase64(theme.logo), theme, "logo.png")
          generateImage(Base64.decodeBase64(theme.favIcon), theme, "favicon.ico")
  }
  
  private generateImage(byte[] imageByteArray, ThemeInfo theme, String name){
          new File("$resourcesPath/images/theme/$theme.name/$name").withOutputStream {OutputStream stream -&gt;
              stream.write(imageByteArray);
          }
  }
  </code></pre>
  
  <p>I get no exception and the files are generated but wrong because it doesn't really show the images. Any idea of what it can be?</p>
  
  <p>Thanks in advance!</p>
  
  <p>PS: this is the string image in base64 if you want to check: <a href="https://dl.dropboxusercontent.com/u/5944885/base64Image.html" rel="nofollow">https://dl.dropboxusercontent.com/u/5944885/base64Image.html</a></p>