[Seaside] Re: html images

German Arduino gsa at arsol.net
Sun Jul 9 13:45:35 UTC 2006


Frank Sukhu wrote:
> Greetings,
> 
> I have some code that generates html with an embedded image <IMG>.  I have
> tried two ways of doing this:
> 
> Option 1.   html imageWithForm: (ImageReadWriter formFromFileNamed: fn).
> 
> Option 2.   html image: fn.
> 
> where 'fn' is the pathname of the jpg file in my filesystem, e.g.,
> "/foo/bar.jpg".
> 
> 
> When I use Option 1, the resulting image is very grainy - almost unusable.
> Option 2 produces good results.  I am trying to figure out why this is the
> case.
> 
> Why is it that ImageReadWriter produces such a poor image when compared to
> the exact file being served by the httpserver?
> 
> I would appreciate any clues or pointers.
> 
> Thanks,
> Frank

AFAIK ImageReadWriter use Form which returns ever a gif from its method 
asMIMEDocument.

I you change such method by:

asMIMEDocument
| aStream rw |

	aStream := RWBinaryOrTextStream on: String new.
	rw := PNGReadWriter on: aStream.
	rw nextPutImage: self.
	rw close.
	aStream reset.
	^MIMEDocument contentType: 'image/png' content: aStream contents

you will get the png correctly showed.

HTH.
gsa.



More information about the Seaside mailing list