How to determine JPG size in pixels?

  • Thread starter Thread starter dchow
  • Start date Start date
D

dchow

Is there a way to determine the size of a JPG file in pixels? I need
to put product pictures on a spreadsheet programmatically. I would
like their size to be as close as possible. So I have to know their
size to determine how much to scale.
 
I expect the data is buried in the JPG file somewhere, but I wouldn't bet on any Excel experts
knowing much about graphics files. Have you posted this in a newsgroup that deals with graphics
(I don't think MS has any, but I could be wrong)?
 
Hi,
You can get the picture height & width like this.

Sub Macro2()
Dim MyPic As IPictureDisp
Set MyPic = LoadPicture("C:\Documents and Settings\jaf\My Documents\My
Pictures\020108-M-8634P-502.jpg")
Debug.Print MyPic.Width, MyPic.Height
End Sub

Or you can assign a height & width like this.

LoadPicture([filename], [widthDesired As Long], [heightDesired As Long],
[flags As LoadPictureConstants = Default]) As IPictureDisp
 
Back
Top