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