I have no background with Java so I tend to suffer pain when dealing with 
it. I am trying to create a thumbnail for an image, but my code dies on the 
:post assertion of this function: 

(defn get-file-as-image [filename]
  {:pre [(= (type filename) java.lang.String)
         (fs/exists? filename)
         (fs/file? (io/as-file filename))]
   :post [(do (pp/pprint %) true)
          (= (type %) BufferedImage)]}
  (javax.imageio.ImageIO/read (io/as-file filename)))

"fs" refers to: 
https://github.com/Raynes/fs/blob/master/src/me/raynes/fs.clj

The :pre assertions are all apparently true, so the file exists and returns 
as a file when run through (io/as-file). 

I looked here for the documentation on javax.imageio.ImageIO/read:

http://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html#read(java.io.File)

It reads:

"Returns a BufferedImage as the result of decoding a supplied File with an 
ImageReader chosen automatically from among those currently registered. The 
File is wrapped in an ImageInputStream. If no registeredImageReader claims 
to be able to read the resulting stream, null is returned."

I added the pprint into my :post and it prints nil. So I assume the problem 
is this: 

"If no registeredImageReader claims to be able to read the resulting 
stream, null is returned."

What does it mean to register an ImageReader? 







-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to