Want/need to get hi rez image uploads sorted, along with basic image manipulation tools.

I should benchmark image sharp to see if doing transforms on the fly is viable (along with finding out how it handles rotate - is the canvas resized automatically, what is the background fill it it's not).

I also need/want to put the design time into operators/language/macros, and an interpreter to parse them into image sharp calls.

Image Operators

Requirements

  • Must comfortably fit in a query string (avoid blocks, avoid whitespace significance)
  • Must be constructable from a push button interface (can use HTML5 inputs with minimal styling)
  • Should be constructable by a human with a text editor
  • Should be forgiving of technically invalid input (sensible defaults, clamp ranges, only invalid if contradictory, impossible, or conflicting)
  • Should do as little work as possible (e.g., spot an operation followed by it's inverse is a no-op and skip both)
  • May allow users to define macros/functions/shortcuts for common operations
  • May allow more than one output (e.g., rotate original and save as full size and thumbnail)
  • Must preserve original input
  • Must use consistent addressing (i.e., either top, left, width, height, or top, left, bottom, right)
  • Should allow percent as well as pixels
  • Should allow calculations (e.g., width/2)
  • May allow user variables (easy enough)
  • Should have useful set of system variables
  • Must apply operations left to right
  • Should report syntax errors with a location

Useful operations

  • crop(top, left, width, height)
  • resize(percent) // maintain aspect ratio
  • resize(width, height) // change aspect ratio
  • rotate(angle) // +ve clockwise, 0 pointing up

Implementation ideas

This is sounding like a basic expression parser. I'm not that worried about efficiency, so tokenize->ast->interpret should be fine (and I can always add caching later at various points). Tokens will be basic maths (including decimal (not floating point) numbers) ('+', '-', '*', '/', '(', ')') and identifiers/keywords (I'm not sure about idenifiers that aren't keywords yet).

I certainly want comments, so i can comment out chunks of code (How complicated are you expecting your stuff to get!), and really any pair of characters will do.

Time to have another flick though Crafting Interpreters, I guess.