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? Thanks! RS Hotmail: Free, trusted and rich email service. Get it now. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
2010/1/11 Robert Sirois <[hidden email]>:
> 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 [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
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: [hidden email] > To: [hidden email] > > 2010/1/11 Robert Sirois <[hidden email]>: > > 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 > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |