[racket] Thumbnailing

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Oct 6 08:44:08 EDT 2011

At Thu, 6 Oct 2011 08:31:39 -0400, Sam Tobin-Hochstadt wrote:
> On Thu, Oct 6, 2011 at 8:16 AM, Paulo J. Matos <paulo at matos-sorge.com> wrote:
> > On 05/10/11 15:26, Stephen Bloch wrote:
> >>>
> >>> I am wondering if there's anything in place already to create an image
> >>> thumbnail. This is basically resizing an image.
> >>
> >> In the student graphics libraries (2htdp/image and picturing-programs,
> >> which is derived from 2htdp/image), you can use "scale" to scale an image up
> >> or down by a specified ratio.  For that matter, if you want to scale the x
> >> and y dimensions differently, you can use "scale/xy".  I believe this is a
> >> constant-time operation; the number-crunching comes later, when you render
> >> it to a bitmap for display on the screen or saving to a PNG file.
> >>
> >>
> >
> > Thanks, I can't seem find a way to open image files (jpeg, png, bmp, etc).
> > Is there anything like that in Racket currently? Or do we need ffi to
> > libjpeg, libpng, etc.?
> 
> See the various options to `load-bitmap' here:
> 
> http://docs.racket-lang.org/draw/bitmap_.html?q=png#%28meth._%28%28%28lib._rack
> et/draw..rkt%29._bitmap~25%29._load-file%29%29


With `2htdp/image', though, probably you just want `bitmap':

http://docs.racket-lang.org/teachpack/2htdpimage.html?q=bitmap#(form._((lib._2htdp/image..rkt)._bitmap))


And then `save-bitmap' to write an image to a PNG file:

http://docs.racket-lang.org/teachpack/2htdpimage.html?q=save-image&q=bitmap#(def._((lib._2htdp/image..rkt)._save-image))





Posted on the users mailing list.