File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 2727 com.illposed.osc/javaosc-core {:mvn/version " 0.8" :exclusions [org.slf4j/slf4j-api org.slf4j/slf4j-log4j12]}
2828
2929 org.babashka/cli {:mvn/version " 0.7.52" }
30+ org.babashka/http-client {:mvn/version " 0.4.23" }
3031
3132 ; ; silence log warnings
3233 org.slf4j/slf4j-nop {:mvn/version " 1.7.36" }}
Original file line number Diff line number Diff line change 22^{:nextjournal.clerk/visibility #{:hide-ns }}
33(ns images
44 (:require [nextjournal.clerk :as clerk]
5- [clojure.java.io :as io])
5+ [clojure.java.io :as io]
6+ [babashka.http-client :as http])
67 (:import [java.net URL]
78 [java.nio.file Paths Files]
89 [java.awt.image BufferedImage]
1718; ; `java.io.InputStream`, or any resource that a `java.net.URL` can
1819; ; address.
1920
20- ; ; For example, we can fetch a photo of _De zaaier_, Vincent van
21- ; ; Gogh's famous painting of a farmer sowing a field from Wiki
22- ; ; Commons like this:
23- (ImageIO/read (URL. " https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/The_Sower.jpg/1510px-The_Sower.jpg" ))
21+ ; ; For example, we can fetch a photo of _De zaaier_, Vincent van Gogh's famous
22+ ; ; painting of a farmer sowing a field from Wiki Commons like this. Since Wiki
23+ ; ; Commons requires a User-Agent header to be set when requesting the image, we
24+ ; ; use babashka.http-client.
25+ (ImageIO/read
26+ (-> (http/get " https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/The_Sower.jpg/1510px-The_Sower.jpg"
27+ {:as :stream })
28+ :body ))
2429
2530; ; We've put some effort into making the default image rendering
2631; ; pleasing. The viewer uses the dimensions and aspect ratio of each
You can’t perform that action at this time.
0 commit comments