Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: resizing JPG images

From: carl:cybercraft at: 23-Oct-2001 0:55

On 22-Oct-01, Jose Manuel Alvarez wrote:
> What about resizing in a Core script without having to use View.
I don't think core can process images.
> If > View is the answer, how can I save the resized picture (sorry, but I > am View newbie !)
View can load JPGs (and GIFs and PNGs) but the only compressed image format it can save in is PNG. For instant, cut and paste the following five lines into the console... bay: load-thru/binary http://www.rebol.com/view/bay.jpg thumb-size: bay/size / 2 thumb-bay: to-image layout [origin 0x0 image bay thumb-size] save/png %thumb-bay.png thumb-bay view layout [image bay image thumb-bay] and they should save a quarter-sized version of the bay image to disk and then display both versions in a window. Don't be afraid of using PNGs for your thumbnails. As they're a loss-less image format they probably make better thumnails than JPGs.
> The application I have in mind is a photo album where you publish > thumbnails of all your jpg pictures > Thanks >> From: Cybarite <[cybarite--sympatico--ca]> >> Reply-To: [rebol-list--rebol--com] >> To: [rebol-list--rebol--com] >> Subject: [REBOL] Re: resizing JPG images >> Date: Sat, 20 Oct 2001 09:03:36 -0400 >> 10/20/01 7:52:23 AM, "Jose Manuel Alvarez" <[jmalv--hotmail--com]> >> wrote: >>> Does anybody have any sample code that show how to resize a JPG >> image to a >>> fixed pixel size >> Maybe this is what you want: >> view layout [image (bay-peg: load %bay.jpg) 500x800] >> This loads it once so that it can be used again >> view layout [image bay-peg 100x100] >> And the image can be loaded from the internet via >> bay-peg: load http://www.rebol.com/view/bay.jpg >> view layout [image bay-peg 500x423] >> and the better version might be to use the REBOL caching capability >> bay-peg: load-thru/binary http://www.rebol.com/view/bay.jpg >> (Strangely the load and load-thru are different in that load-thru >> needs the binary refinement otherwise you get a >> less-than-satisfactory result.)
-- Carl Read