user945754
user945754

Reputation:

Clojure GUI for cropping images

I'm making a GUI for selecting regions to crop from images. I have been using Seesaw and cans select rectangular regions, but cannot find a way to set an image to the background of seesaw.canvas. This suggests using icons on labels. Can I make a label paintable and then use it as a canvas? Is there a way to overlap a label and a canvas or somehow use a panel that gives a background to its contents?

I think Quil has this functionality, but I'm not sure how to build a GUI around its draw, setup, sketch form if I want add widgets.

Existing solutions would appreciated as well, as long as I can decompose them. Using GIMP or Photoshop isn't an option for the workflow I want: multiple crops per photo, of different kinds on each page and different metadata added depending on the type of image outlined. Any suggestions for libraries for working with metadata for photos? I was planning on using a shell interface to exiftool, but a more portable option may be better.

Upvotes: 2

Views: 495

Answers (1)

Dave Ray
Dave Ray

Reputation: 40005

You can draw a java.awt.Image (or sub-class) to a canvas with seesaw.graphics/image-shape:

(require '[seesaw.graphics :as g])

(defn paint-canvas [c g2d]
  (g/draw g2d (g/image-shape my-image 0 0) (g/style)))

It seems like that should do it.

Also note that labels (and all Seesaw widgets) are paintable. Just set the :paint option like on a canvas and paint away.

Upvotes: 2

Related Questions