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