links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to work with GIF files in Squeak
Last updated at 9:16 pm UTC on 25 August 2016
Question: How do you store a GIF file in Squeak? What class does a GIF file belong to?
Answer: From: How to save a parts bin Sent: Wednesday, January 07, 2004 11:33 PM
To: squeak-dev@lists.squeakfoundation.org
A ".gif" file doesn't belongs to a class.
A String naming a GIF file can be opened as a FileStream.
The GIF data can be read from a FileStream.
The GIF data from the FileStream can be used to create a Form.
The Form can be written to a FileStream.

Question: How do you find out information about a GIF file in Squeak? Such as the date when it is produced, the author who created it.
Question: How to read it in other applications in Squeak.
Answer: To find out the answer to this and other questions in Squeak:
        GIFReadWriter formFromFileNamed: 'myFile.gif'
       GIFReadWriter putForm: someForm onFileNamed: 'anotherFile.gif'.
      myForm openAsMorph

Question: I have a picture named "person.gif" in disk. Now I want to read it into Squeak and save it as an instance object of a class "Photo".
Answer:From: goran.krampe Sent: Monday, January 12, 2004 4:54 AM

First I searched for a class ("find class" in browser) with "gif" in them. Found "GIFReadWriter", then looked at the class side (to see how to create one) - not much there. Ok, let's look up the inheritance - looked in ImageReadWriter. Found method formFromFileNamed:. Ok, tested to do inspect it on this:
ImageReadWriter formFromFileNamed: 'image.gif'
Where I had 'image.gif' in the working directory. Ok, it worked and I can see an instance of a ColorForm. Ok, so the class Form and ColorForm etc are the classes for bitmap images in Squeak. This is the instance you would hold in an instvar in your "Photo" class.

Let's see how to see the darn thing on the screen. I knew that there are Morph classes for this so I quickly found SketchMorph and ImageMorph, don't remember the details on differences. Anyway, ImageMorph has a method to change the Form that it shows - so let's just create one, smack in the Form and show the morph in the world:
| aForm |
aForm := ImageReadWriter formFromFileNamed: 'BuildingSBlog.gif'.
ImageMorph new newForm: aForm; openInWorld

Question: How can export a ".gif" file for the current project interface just like that a morph can be exported a ".gif" file.

Answer: From: Ned Konz, To export, the current project:
writer _ GIFReadWriter on: (FileStream newFileNamed: Project current name, '.gif').
writer nextPutImage: Project current thumbnail; close.

How can I export an animated GIF file? (of all projects).

See also:
Screen dump
FAQ: How can I give my Morphic world a wallpaper?
Graphics Conversion