[REBOL] Re: resizing JPG images
From: d4marcus:dtek:chalmers:se at: 25-Oct-2001 20:26
For saving jpegs, I suppose you need View/Pro to do it all from Rebol. You
would save/bmp the image, then call cjpeg or some similar tool.
On Mon, 22 Oct 2001, Jose Manuel Alvarez wrote:
> The application I have in mind is a photo album where you publish thumbnails
> of all your jpg pictures
It's probably not what you want, but this simple photoalbum app generates
thumbnails as you call it. It's unacceptable on a slow computer though.
REBOL [
Title: "Thumbnail creator / photoalbum"
Date: 24-Oct-2001
Author: "Marcus Petersson"
File: %thumbnail.r
]
to-thumbnail: func [
img [image! file!] tsize [pair! integer!] "Size or height"
/local sx sy y
] [
y: integer? tsize
tsize: to-pair tsize
img: load img
either image? img [
sx: img/size/x / to-decimal tsize/x
sy: img/size/y / to-decimal tsize/y
sx: img/size / either y [sy] [max sx sy]
layout [img: image img sx]
] [
layout [img: image tsize black]
]
to-image img
]
photoalbum: func ["View pictures using thumbnails"
images [block!] "Block of filenames"
tsize [pair! integer!] "Thumbnail size"
/local l thumbs im width
] [
width: 0
thumbs: copy [origin 1x1 space 2x2 backcolor white across]
l: length? images
repeat i l [
append thumbs compose/deep [
image (im: to-thumbnail images/:i tsize)
(to-string last split-path pick images i) [
im: pick images (i)
if error? try [rv im] [print ["Cannot display" im]]]
]
width: width + im/size/x
if width > (system/view/screen-face/size/x / 2) [
width: 0 append thumbs 'return]
]
view/new layout thumbs
do-events
]
rv: func [f [file! word! image!] b [block! unset!] /local t] [
any [value? 'b b: copy []]
insert b [origin 0x0 pad 1x1 image #"q" [unview] f]
either image? f [t: ""] [t: f f: load f]
view/new/title layout b reform [t mold to-paren f/size]
]
help photoalbum
photoalbum request-file 80
halt
Marcus
------------------------------------
If you find that life spits on you
calm down and pretend it's raining