Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Getting width and height from Image obtained through ImageLoader?

$
0
0

Hi, I'm new to processing and playing around with an idea of making some generative art through google image searches (I used tumblr in this example). Everything works well except that I don't know how to get width and height info from the Image object obtained through ImageLoader (line 38), I guess it's a java image?

import at.mukprojects.imageloader.*;
import at.mukprojects.imageloader.tumblr.*;
import at.mukprojects.imageloader.image.*;

String apiKey = “apiKey";
String apiSecret = "apiSecret";

ImageLoader loader1;
ImageList list1;
Image img1;
int x;
int y;

void setup() {
  size(800, 450);
  loadImages();
}

void draw() {
  if (mousePressed) {
    x = mouseX;
    y = mouseY;
    newimage();
  }
}

//load images in list
void loadImages() {
  loader1 = new TumblrImageLoader(this, apiKey, apiSecret);
  list1 = loader1.start("copybara", false, 60 * 1000);
}

//get one image
void newimage() {
  img1 = list1.getRandom();
  try {
    image(img1.getImg(), x, y);
    //What I would like to do: image(img1.getImg(), x, y,img1.width/3,img1.height/3);
  }
  catch(Exception e) {
    img1 = null;
    println("no image");
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles