jpg woes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

jpg woes

Smalltalkman

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.

 

I would appreciate some guidance.

 

 


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: jpg woes

Michael van der Gulik-2


On Tue, Jul 21, 2009 at 4:58 PM, Brian Mason <[hidden email]> 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/

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners