"Quick and easy way to get an image from a URL" ZnEasy getPng: 'http://www.pharo.org/files/pharo.png'.
"Turn bytes into an image inside Pharo" (PNGReadWriter on: 'http://www.pharo.org/files/pharo.png' asUrl retrieveContents readStream) nextImage. "Store image bytes as Base64 and recreate the image" | base64 | base64 := ZnBase64Encoder new encode: 'http://www.pharo.org/files/pharo.png' asUrl retrieveContents. (PNGReadWriter on: (ZnBase64Encoder new decode: base64) readStream) nextImage. > On 17 May 2015, at 08:55, Leonardo Silva <leonardo.humbe...@gmail.com> wrote: > > > On Sat, May 16, 2015 at 5:28 PM, Merwan Ouddane <merwanoudd...@gmail.com> > wrote: > You can encore your image in base64 > anImage := 'holidays.png' asFileReference readStream binary. > encodedImage := Base64MimeConverter mimeEncode: anImage. > > > Then you can decode it with: > ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: > encodedImage). > > > Is this what you were searching for ? > > Yes, this is cool! > I understand that encodedImage is a ReadWriteStream. So, I use 'encodedImage > contents' to get the code as string. > Then I assigned the code to a variable, like that: > > classVariable := > 'iVBORw0KGgoAAAANSUhEUgAAAmAAAAIHCAIAAAC3HdQEQUJUQQJEcEAFRVE...' > > But I don't know how to transform it back. I tried the following: > > test := ReadWriteStream on: classVariable. > ImageReadWriter formFromStream: (Base64MimeConverter mimeDecodeToBytes: test). > > But it doesn't work. It gives me an 'Error: image format not recognized' > > Do you know what I am missing here ? > > Thank you >