Can't get size() to adapt to an image

Sorry for the newbie question, but here goes: I am trying to get the display size() to adjust to the loaded image. My code is the following:

void setup() { img = loadImage("Typist.jpg");
size(img.width,img.height); //set the window size to match the image }

where "Typist.jpg" is in a "data" folder. I get the following error:

"The size of this image could not be determined from your code. Use only numbers (not variables) for the size() command. Read the size() reference for more details"

If I put numbers in in place of .width and .height it works just fine. I see lots of examples where code just like that works. Any suggestions? Thanks.

Answers

Sign In or Register to comment.