简体   繁体   中英

How to find the width and height of an image with quil in clojure

I am trying to find the width of a loaded image in clojure. In processing I would do this,

    PImage img=loadImage("image.jpg");
    int x=img.width;
    int y=img.height;

I tried to do this same in clojure but it won't work

   (defn loadwebimg []
     (let [filelst (map (fn [f] (.getName f)) (.listFiles (File. (str datadir))))
           imgf (first (shuffle filelst))
           webimg (load-image (str datadir imgf))
           ]
      (image webimg 0 0) 
      (println webimg.height))

If webimg is an object when you would use the . special form to read its fields like you do for the file objects you use above it.

as user100464 points out:

(println webimg.height)

would become

(println (. webimg height)

or

(println (.height webimg))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM