Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi, I'm trying to use Image Resizer and am goofing up on the syntax 
somewhere:

(defn update-profile [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl  (str /member/ member-id)
original-file-path(str (img-path) / (:filename file))
new-file-name   (add-timestamp (:filename file))
new-name-filepath (str (img-path) / new-file-name)]
  (upload-file (img-path) (update-in file [:filename] add-timestamp))
  (- new-name-filepath
((resize-fn 100 100)))
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)
  ))

I get the following error:

java.lang.IllegalArgumentException
No matching method found: read
Reflector.java:80clojure.lang.Reflector.invokeMatchingMethod
Reflector.java:207clojure.lang.Reflector.invokeStaticMethodutil.clj:10
image-resizer.util/buffered-imageresize.clj:31
image-resizer.resize/resize-fn[fn]members.clj:101
sikhpyar.routes.members/update-profile2members.clj:168
sikhpyar.routes.members/fncore.clj:94compojure.core/make-route[fn]
core.clj:40compojure.core/if-route[fn]core.clj:25
compojure.core/if-method[fn]core.clj:107compojure.core/routing[fn]
core.clj:2443clojure.core/somecore.clj:107compojure.core/routing

Does anyone have any experience with this lib and the correct way to employ 
it, I'm not making much progress from the readme docs. Thanks.

-- 
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.


Re: Image Resizer lib exception error

2014-02-25 Thread Moritz Ulrich

Just from the looks of the exception, you might need to pass an
input-stream or reader instead of a path.

The Dude (Abides) writes:

 Hi, I'm trying to use Image Resizer and am goofing up on the syntax 
 somewhere:

 (defn update-profile [firstname lastname email file]
   (let [member-id (session/get :member-id) 
 redirecturl  (str /member/ member-id)
 original-file-path(str (img-path) / (:filename file))
 new-file-name   (add-timestamp (:filename file))
 new-name-filepath (str (img-path) / new-file-name)]
   (upload-file (img-path) (update-in file [:filename] add-timestamp))
   (- new-name-filepath
 ((resize-fn 100 100)))
   (memberdb/update-member member-id firstname lastname email (str 
 new-file-name))
   (resp/redirect redirecturl)
   ))

 I get the following error:

 java.lang.IllegalArgumentException
 No matching method found: read
 Reflector.java:80clojure.lang.Reflector.invokeMatchingMethod
 Reflector.java:207clojure.lang.Reflector.invokeStaticMethodutil.clj:10
 image-resizer.util/buffered-imageresize.clj:31
 image-resizer.resize/resize-fn[fn]members.clj:101
 sikhpyar.routes.members/update-profile2members.clj:168
 sikhpyar.routes.members/fncore.clj:94compojure.core/make-route[fn]
 core.clj:40compojure.core/if-route[fn]core.clj:25
 compojure.core/if-method[fn]core.clj:107compojure.core/routing[fn]
 core.clj:2443clojure.core/somecore.clj:107compojure.core/routing

 Does anyone have any experience with this lib and the correct way to employ 
 it, I'm not making much progress from the readme docs. Thanks.


-- 
Moritz Ulrich


pgpzSjHvaFY_D.pgp
Description: PGP signature


Re: Image Resizer lib exception error

2014-02-25 Thread Michael Klishin
2014-02-25 16:46 GMT+04:00 Moritz Ulrich mor...@tarn-vedra.de:

 Just from the looks of the exception, you might need to pass an
 input-stream or reader instead of a path.


which can be instantiated with

http://clojuredocs.org/clojure_core/clojure.java.io/input-stream

and

http://clojuredocs.org/clojure_core/clojure.java.io/reader

-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
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.


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi Moritz and Michael, thanks for the pointer in the right direction. 
Almost there except for 1 point I think. The whole operation is made of 2 
functions, one to upload/resize/save and the other to provide a unique 
filename by original filename + timestamp.

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename .)
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  - timestamp (.substring filename ext-position))
 (str filename - timestamp

(defn update-profile2 [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl   (str /member/ member-id)
originalfile  (str (img-path) / (:filename file))
new-file-name (add-timestamp (:filename file))
photofile (str (img-path) / new-file-name)]
  (upload-file (img-path) *(update-in file [:filename] new-file-name))*
  (resize (file (with-open [rdr (clojure.java.io/reader photofile)])) 100 
100)
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)))

I checked output of new-file-name and photofile, they do provide the new 
file name alone or with full path.

Where I'm still goofing up is applying new-file-name to the update-in 
function, prob cause its 6am :) Been at it too long, likely missing the 
obvious.

If I can update the filename to *new-file-name*, the *with-open reader *should 
read the file so it can be resized.

Pardeep.

-- 
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.


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi Moritz and Michael, thanks for the pointer in the right direction. 
Almost there except for 1 point I think. The whole operation is made of 2 
functions, one to upload/resize/save and the other to provide a unique 
filename by original filename + timestamp.

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename .)
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  - timestamp (.substring filename ext-position))
 (str filename - timestamp

(defn update-profile2 [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl   (str /member/ member-id)
originalfile  (str (img-path) / (:filename file))
*new-file-name* (add-timestamp (:filename file))
photofile (str (img-path) / new-file-name)]
  (upload-file (img-path) *(update-in *file [:filename] *new-file-name*))   
--- this is where I'm stuck, changing the name of the uploaded file
  (resize (file (with-open [rdr (clojure.java.io/reader photofile)])) 100 
100)
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)))

I checked output of new-file-name and photofile, they do provide the new 
file name alone or with full path.

Where I'm still goofing up is applying *new-file-name* to the 
*update-in*function, prob cause its now 6am :) 

If I can update the filename to *new-file-name *value, the *with-open*reader 
should read the file so it can be resized.

Pardeep.

-- 
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.


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
I got the file naming fixed with:

(upload-file (img-path) (assoc-in file [:filename] new-file-name))

The last part is reading in the uploaded file so it can be resized with 
Image Resizer. I wrote the code as:

(with-open [rdr (clojure.java.io/reader (str (img-path) / 
new-file-name))])

As a test on an existing pic, if I put the wrong file path or file name, 
sure enough it shows the error of either not existing. If I put the correct 
path and file name, I get a null exception.

Is my syntax correct or off. Going back to clojure docs to look again.

-- 
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.