[Seaside] On Forms, PNGs, WAFiles, and ByteArrays

Robert Sirois watchlala at hotmail.com
Mon Jan 11 16:39:56 UTC 2010


Cool, thank you. I actually ended up getting a little help from a mentor, and he basically showed me the code you just wrote :) I'll have to look up Smagick, but if nothing else, this will be fine for the time being.

Thanks,
RS

> Date: Mon, 11 Jan 2010 07:06:35 +0100
> Subject: Re: [Seaside] On Forms, PNGs, WAFiles, and ByteArrays
> From: philippe.marschall at gmail.com
> To: seaside at lists.squeakfoundation.org
> 
> 2010/1/11 Robert Sirois <watchlala at hotmail.com>:
> > I wrote a simple form to upload images to the server, and I would like to
> > create thumbnails for them automatically.
> >
> > The way I ended up doing it is as follows:
> >
> > saveEntry
> >     | aForm newForm |
> >
> >     " add original file under name blahblahPng or whatever the image type is
> > "
> >     UGFileLibrary addFileNamed: title,'Png' contents: uploadedFile contents.
> >
> >     aForm := (PNGReadWriter createAFormFrom: uploadedFile contents) first.
> >
> >     " create thumbnail and save under name blahblahThumbPng "
> >     newForm := aForm scaledToSize: (Point x: 50 y: 50).
> >
> >     " what I would have liked to do here is add the thumbnail to the file
> > library "
> >
> >     " add item to art section "
> >     UGArt addImage: (
> >         (UGArtItem
> >             title: title path: title,'Png') artist: self session user;
> > imageForm: aForm; thumbForm: newForm; yourself
> >     ).
> >
> > As you can see, I ended up using WAImageTag #form: rather than a url from
> > the file library (or server directory, preferably). So what I would like to
> > know are two things:
> >
> > 1) Forms are big? So throwing them around is cumbersome?
> > 2) Is there a way to convert a Form back to a PNG without the whole mime
> > thing?
> 
> I haven't tried it but something along those lines should work:
> 
> UGThumbnailLibrary
>   addFileNamed: title,'Png'
>   contents: (ByteArray streamContents: [ :stream |
>     (PNGReadWriter on: stream) nextPutImage: (aForm scaledToSize:
> (Point x: 50 y: 50))])
> 
> And then simply linking it with:
> 
> html image url: UGThumbnailLibrary / (title,'Png')
> 
> Note that WAFileLibrary is not intended for production purposes. We
> recommend you store them on the file system and let Apache do it's
> magic. I can also recommend Smagick for doing the thumbnail. If you
> are on Seaside 3.0 you have the option to let the server save uploads
> directly to the disk without it hitting the image.
> 
>  [1] http://www.squeaksource.com/SqueakAddOns.html
> 
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/196390706/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100111/0da104fe/attachment.htm


More information about the seaside mailing list