[Seaside] html images

David Shaffer cdshaffer at acm.org
Sun Jul 9 16:08:50 UTC 2006

Frank Sukhu wrote:

>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.,
>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
>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.

As a general practice I avoid Option 1.  It is wasteful to go through
the process of having Squeak read your image from a file, convert it to
a Form, then convert it back to some external representation.  The only
reason you might want to do this is if you need to know the dimensions
of the image or to process it in some way or if you already have the
image in a Form in your squeak Image...capital I to distinguish from the
other kind of image ;-)  Option 2 simply creates an IMG tag which refers
directly to the file's path (maybe served by Kom or apache).  You can
use any URL there:

html image: 'http://someserver.com/somePath/to/an/image.png'

If it works for you I suggest putting all of your images in a directory
served by a web server, then using the Seaside config tool set the
'Resource base URL' property to a URL which leads to this folder
(through this server) and then in your code do this:

html image resourceUrl: 'image.png'

Seaside will automatically add the resource base URL to build an
absolute URL for the image.  Hope that helps.


html image:

More information about the Seaside mailing list