Creating thumbnails [view]
[1/4] from: Steven::White::ci::bloomington::mn::us at: 22-Apr-2004 15:39
Good Day, Fountain of REBOL Knowledge, The following script reads a big jpeg file and displays it on the screen as a 96x96 thumbnail. When I hit the button, it saves that image to disk as a 96x96 png thumbnail. I mention this to show that the idea can be done (as of course you know). _*_*_* REBOL [ ] view layout [ thumbnail: image 96x96 %ships_1024.jpg button 300x25 "save/png to-image thumbnail" [save/png %shipspng.png to-image thumbnail alert "done"] ] _*__*_ Now, I want to do the same thing, but not in an interactive manner, not with a screen. I want a script that will automatically make a bunch of thumbnails for a bunch of pictures without any human intervention. Can I do that? It seems I can't use the "image" key word outside of a layout. If I use "to-image," I don't see how I can specify the size. I know how to find all the files in a directory, and how to loop through them, etc, but I am missing that piece to read a jpeg file, turn it into a thumbnail, and write it, outside of a VIEW layout. I have looked at the cookbook example "HTML Thumbnail Photo Directory Maker," but that also uses an image within a layout. Thank you. Steven White City of Bloomington 1800 W Old Shakopee Rd Bloomington MN 55431-3096 USA 952-563-4882 (voice) 952-563-4672 (fax) [steven--white--ci--bloomington--mn--us]
[2/4] from: carl:cybercraft at: 23-Apr-2004 9:16
On 23-Apr-04, Steven White wrote:
> Good Day, Fountain of REBOL Knowledge, > The following script reads a big jpeg file and displays it on the
<<quoted lines omitted: 21>>> that also uses an image within a layout. > Thank you.
Hi Steve. You can turn a layout into an image just by a... to-image layout [box red] so if the layout has your picture in, then you've grabbed it without needing to view the layout. Add to that an origin of 0x0 to get rid of the border and your problem becomes quite simple... for n 1 3 1 [ file: %ships_ picture: load rejoin [file n %.jpg] thumbnail: to-image layout [ origin 0.0 image 96x96 picture ] save/png rejoin [file n %.png] thumbnail ] That's not tested though - but I think it'd work, assuming you've numbered your files without padding... -- Carl Read
[3/4] from: atruter:labyrinth:au at: 23-Apr-2004 7:59
Hi Steve, If your JPEG's come from a digital camera and you are happy with 160x120 EXIF thumbnails, then take a look at the EXIF scripts by Piotr Gapinski (http://www.rebol.org/cgi-bin/cgiwrap/rebol/search.r?find=exif). Regards, Ashley
[4/4] from: maximo:meteorstudios at: 22-Apr-2004 18:06
use to-image outside of the ui ;-) here is a complete app which has external path specs, so that you don't have to fiddle in the code to adapt it to different paths just change the apps and it will do its magic on the directorie's content. of course, the directories should be different, otherwise you'll end up with both thumbnails and source image in the dir, and running the application will duplicate your thumbnails with interesting filenames ;-) ;---------------------------------------------- rebol  in-dir: %/d/imgsrc/ out-dir: %/d/imgdest/ imgs: read in-dir foreach file imgs [ filename: replace copy file %.jpg %_thumbnail.png in-path: append copy in-dir file out-path: append copy out-dir filename save/png out-path to-image layout [ origin 0x0 image 96x96 in-path ] ] ;-------------------------------------------------- -MAx --- You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun.
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted