We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Getting image dimensions
Page Index Toggle Pages: 1
Getting image dimensions (Read 382 times)
Getting image dimensions
Jan 28th, 2008, 12:16am
 
Hello,

I'm trying to find a way of getting the dimensions of any given image in processing. There is no height nor width methods in the PImage object class, and was wondering if there's any hack I could use to get that information. Thanks!
Re: Getting image dimensions
Reply #1 - Jan 28th, 2008, 12:34am
 
Doesn't this do the trick?

Quote:


PImage a;  // Declare variable "a" of type PImage
a = loadImage("imagename.jpg"); // Load the image into the program
image(a, 0, 0); // Displays the image from point (0,0)

println(a.width); // gives you the image width
println(a.height); // gives you the image height


Re: Getting image dimensions
Reply #2 - Jan 28th, 2008, 9:39am
 
dek wrote on Jan 28th, 2008, 12:34am:
Doesn't this do the trick



Well what do you know, it does! Funny, I just never tried the obvious. Silly me...

Thank you very much!
Page Index Toggle Pages: 1