[Newbies] jpg woes

Michael van der Gulik mikevdg at gmail.com
Tue Jul 21 05:19:03 UTC 2009


On Tue, Jul 21, 2009 at 4:58 PM, Brian Mason <bmason at itassociates.com>wrote:

>  Greetings,
>
>
>
> I am trying to take an image off the new and save it to a file.  This is
> what I have so far:
>
>
>
> (FileStream newFileNamed: 'test.jpg')
>
>                 nextPutAll: ('http://freetalklive.com/images/amondson.jpg'
> asUrl retrieveContents) getContentFromStream;
>
>                 close
>
>
>
> The image exists, is found, and the file is written.  There is something
> wrong with the format of the local jpg.
>

Your stream needs to be "binary". Don't ask me more than about this; I only
discovered it through trial, error and reading the code for
HTTPSocket>>httpJpeg:

image := 'http://freetalklive.com/images/amondson.jpg'  asUrl
retrieveContents.
f := (FileStream newFileNamed: 'test.jpg').
f binary.
f nextPutAll: image content.
f close.

or for your style of coding:

(FileStream newFileNamed: 'test.jpg') binary;

                nextPutAll: ('http://freetalklive.com/images/amondson.jpg'
asUrl retrieveContents) content;

                close.


Gulik.

-- 
http://gulik.pbwiki.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20090721/bea039b1/attachment.htm


More information about the Beginners mailing list