Making thumbnails in Clojure
clojure, java
Solution
See http://docs.oracle.com/javase/1.5.0/docs/api/javax/imageio/ImageIO.html
javax.imageio.ImageIO/read expects a URL, File, InputStream or ImageInputStream. Not a string.
Doing `(javax.imageio.ImageIO/read (as-file input))` solves the problem.
Problem
I'm running the following command in my terminal to run the code stored in the following file: ``` java -cp clojure.jar clojure.main thumbmaker.clj ``` Where the content of thumbmaker.clj is (this code has been referenced at several places): ``` (import javax.imageio.ImageIO) (import java.awt.image.BufferedImage) (use '[clojure.java.io :only [as-file input-stream output-stream] :as io]) (defn make-thumbnail-generic [input new-filename width] (let [img (javax.imageio.ImageIO/read input) imgtype (java.awt.image.BufferedImage/TYPE_INT_ARGB) width (min (.getWidth img) width) height (* (/ width (.getWidth img)) (.getHeight img)) simg (java.awt.image.BufferedImage. width height imgtype) g (.createGraphics simg)] (.drawImage g img 0 0 width height nil) (.dispose g) (defn make-thumbnail-from-file [filename new-filename width] (make-thumbnail-generic filename new-filename width)) (make-thumbnail-from-file "thumb.png" "test.png" 100) ``` And I'm getting the following error: Exception in thread "main" java.lang.IllegalArgumentException: No matching method found: read (thumbmaker.clj:0) I have checked the import and use statements in the REPL independently and they seem to be accepted pretty fine. I checked the Java reference for ImageIO and the read function is there. I've gone through the Java-Interop writeup and this seems to be very much the standard way, so I can't figure out why the read is not working.