Search code examples
racketjpeglibjpeglibjpeg-turbo

racket: manipulating jpeg files


I'm trying to manipulate jpeg files in racket lang. I failed to find any racket library with good cross-platform support (linux, mac osx, win10). Does exist any?

Actions I want to perform are read exif, scale images and store it to database.


Solution

  • There are several external libraries that you can use to do image (and video) manipulation. However Racket actually comes bundled with a good amount of image manipulation tools (that work on jpg, png, bitmap, etc.). Most notably the pict library and the racket/draw library. I highly recommend you use those for most standard image manipulation tasks (e.g. scaling, transformations, etc.). You can even use the sql library (which also comes with Racket to store your files to a database.

    If you want to use the racket/draw class, you can create a bitmap% object which allows you to save to and load from files. You can also use a bitmap-dc% to do basic drawing operations.

    The pict library is a nice functional API for image manipulation. And you can use the bitmap function to get a bitmap from a file, as well as convert a bitmap% object to a pict object. The pict->bitmap function lets you go the other way, converting a pict object to a bitmap.

    Racket Draw/Pict Example