January 2017
Intermediate to advanced
565 pages
13h 46m
English
Let's now write some Clojure code and create a file in src/thumbnails/image.clj.
Let's try to do this the Clojure way. First of all, write the namespace declaration and evaluate it:
(ns thumbnails.image
(:require [clojure.java.io :as io])
(:import [javax.imageio ImageIO]
[java.awt.image BufferedImageOp]
[org.imgscalr Scalr Scalr$Mode]))Now open up a REPL and write the following code:
(def image-stream (io/input-stream "http://imgs.xkcd.com/comics/angular_momentum.jpg"))(def image (ImageIO/read image-stream)) image (.getWidth image)
We now have an image instance and you can call all of the Java methods in the REPL. This is one of Clojure's core concepts, you can play with the REPL and check your code before really writing ...
Read now
Unlock full access