Solution to problem : [Seaside] serve jpg image files from form objects

Martin Schubert martin.schubert at
Thu Jun 1 23:49:57 UTC 2006

Hello out there,
finally after hours on end i finally found (with the help of mb) the  
solution to the problem :
i subclassed Form with FormXTD and overwrote the method  
#asMIMEDocument with the following method:

	| aStream |
	aStream _ (RWBinaryOrTextStream on: '').
	JPEGReadWriter2 putForm: (self asFormOfDepth: self depth) onStream:  
	^MIMEDocument contentType: 'image/jpeg' content: aStream contents.

but this didn`t work. than i realized that the new method was never  
called but only the original method in Form. because the construct :  
FormXTD fromFileNamed: 'x.jpeg' created an instance of Form and not  
of FormXTD because the class method is invoked on Form class and not  
inherited to FormXTD. so i will finally restart learning the  
inheritance mechanism in smalltalk. so for a quick hack, just take  
the previous method and substitute the Form>>asMIMEDocument method  
with it.

good night

> Martin Schubert a écrit :
>> i want to serve a jpg-file which is stored in a Form object.
>> so i do : aForm _ (Form fromFileNamed: 'wave.jpg')
> Method #fromFileNamed: is smart enough to decode various picture  
> formats
> and turn them into bitmaps. That's why it can understand your jpeg  
> file. However
> after this was executed, the knowledge that its source was jpeg is  
> lost.
> Not so smart.
>> this doesn`t work, and when i am acceptin the following, seaside   
>> seems to convert the jpg file to gif or wracks up the picture  
>> file  somehow :
>>     html imageWithDocument: aForm
>>         mimeType: 'image/jpeg'
>>         fileName: root name,'Picture', '.jpg'.
> The above creates a document handler. When invoked for the  
> rendering, this document handler
> needs to encode the bitmap into a MIME document. For some reason,  
> the GIF encoding
> is selected by Seaside. See Form>>asMIMEDocument.
> A possible solution would be to subclass Form so that it remembers  
> the encoding of
> its source, re-implementing #asMIMEDocument to take this into account.
> Another solution may be to use the Canvas api, where the image tag  
> is handled quite
> differently.
> Michel.
> _______________________________________________
> Seaside mailing list
> Seaside at

More information about the Seaside mailing list