[Q] Reading a directory of images...

Brian Brown rbb at techgame.net
Tue Apr 8 15:48:33 UTC 2003


I used the following code in a workspace to read in a directory of GIF 
files and put them in the ImageImports collection... I read through the Swiki 
and FileList2 to figure out how the "Import" button worked...

Unfortunately, the images seems a bit corrupted... Is there some other 
way I should do this?

dirName _ (FileDirectory default pathName), slash, 'bryant', slash, 'images', slash.
dir _ FileDirectory on: dirName.

dir fileNames withIndexDo: [:fname :fid | (fname asLowercase endsWith: '.gif')
        ifTrue: [
                key _ fname sansPeriodSuffix.
                image _ Form fromFileNamed: dirName, fname.
                Smalltalk imageImports at: key put: image.]
    ]


Do I need to use GIFReaderWriter or something? Could I be running into Endianess problems?


Thanks!

Brian



More information about the Squeak-dev mailing list