Hmm, I made it a little further. Now I am trying to write a thumbnail to disk. I have copied the code from StackOverflow. I am using this function:
(defn make-thumbnail [filename path-to-new-file-including-file-name width]
(= (type path-to-new-file-including-file-name) java.lang.String)
(number? width)]}
(println " we will write thumbnails to here: " (str path-to-new-file-including-file-name))
(let [ext (fs/extension filename)
img (get-file-as-image filename)
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)
(pp/pprint simg)
(javax.imageio.ImageIO/write simg ext (io/as-file path-to-new-file-including-file-name))))
This line:
(println " we will write thumbnails to here: " (str path-to-new-file-including-file-name))
shows me this, which is the path I want:
we will write thumbnails to here: /Users/larry/tma_files/processed/b5838394-a86c-411f-b556-94b30c26a553IMG_1175_180.JPG
This line:
gives me:
#<BufferedImage BufferedImage@7ac84a5b: type = 2 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=ff000000 IntegerInterleavedRaster: width = 125 height = 93 #Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0>
I do not get any errors or exceptions, but nothing gets written to disk. Can anyone suggest why?
If I look here:
Writes an image using an arbitrary ImageWriter that supports the given format to a File. If there is already a Filepresent, its contents are discarded.
- Parameters:
im - a RenderedImage to be written.formatName - a String containg the informal name of the format.output - a File to be written to.- Returns:
false if no appropriate writer is found.
I am unsure what "false if no appropriate writer is found" means. I have added code to be sure that only jpeg, gif and png files get to this function.
Any suggestions why nothing gets written to disk?