bsmall2 Learning Racket

BatchConvertImages

Before posting pictures to Diaspora*, pixelfed, or writefreely I often select the worthwhile parts in Gimp. After selecting the worthwile part of a pictures, if the part is still larger than 700 pixels (for Diaspora*) or 1400 pixels (for pixelfed) I try to re-size the snippet before uploading. Re-sizing seems like a decent, or “ethical”, thing to do. I haven't been able to donate to some of the servers that make my free SNS accounts possible, and I hope to avoid burdening any viewers. Resizing before uploading lessens burdens on servers and devices (I imagine). Besides the general ethical reasons, some servers have volume limits, so keeping image sizes down should let me share more photos before approaching my limits.

I re-size the image in Gimp before exporting the photo to an “edited” folder. The photo manager shotwell organizes photos in year/month/day directories. So one day a program could go through the directories created by Shotwell, find all the edited pictures, and organize them in a useful way. In the meantime, I just want save a step in Gimp. With this Racket script I can just save selections to the “edited” directoy without the extra step of resizing the image canvas. It will save time to avoid working with menus…

DrRacket Screenshot: Resize jpg files script

This time I got the script working in DrRacket first, then made an executable script in Emacs…

Read more...

With Racket's path utilities I was able to get this script working a lot faster than I was able to get an earlier Guile script working. (fn:1) Why are command-line arguments treated as vectors? That's a mystery for later. In the meantime this script is useful, and it is the first step toward getting all my teaching materials generated through Racket scripts. DrRacket on windows may provide a way to ease teachers towards independence with free software. Once people can do everything with free applications, like DrRacket, Gimp, Firefox, and Inkscape: they won't feel dependent on a proprietary OS.

DrRacket Screenshot: jpgs->svgs

Maybe it's just because of all the hours spent with the Racket Language since I made the Guile Scheme script, but Racket seemed to let me develop a batch conversion script much faster. Previous experience with `build-path` helped a lot, I never saw anything similar in the Guile documentation so a lot of time went into developing string-based utilities to manipulat paths. I imagine this Racket version could work in DrRacket on a Windows OS, if ImageMagick's `convert` and the `potrace` utility are installed.

Emacs script and shell buffers

Read more...