ImageDimensions function is not returning any results

Hey guys,

I am having a problem getting the imagedimensions( function to give me any results. I am dragging a .jpg to a drag receiver, renaming it, then trying to get the dimensions. It is being renamed (code not shown), but I can’t get the size. Consider the following code:

dropimagesfromfinder |||field="ImagePath" currentrecord=oneimage HFS=yes message=no|||

local photoRect,lht,lwdth
photoRect=imagedimensions(“Macintosh HD:Users:me:Pictures:mypicture.jpg”)
message photoRect
message lht
message lwdth

The first message is blank; the rest are 0. The path is correct and the picture with the new name exists. Am I missing something?


Change your code to use a UNIX path instead of an HFS path. You can get the correct UNIX path into your procedure by highlighting the file in the Finder and dragging it into your procedure or you can convert the existing HFS path using the unixpath( function as shown below:

photoRect=imagedimensions(unixpath(“Macintosh HD:Users:me:Pictures:mypicture.jpg”))

Thanks Gary, I think that worked. I was thrown off by the first line of code. I thought setting the HFS option to “yes” would work throughout the procedure. I’m not sure why it doesn’t.

That option is an option on the dropimagesfromfinder statement, it doesn’t affect anything but that one statement. The rest of the procedure knows nothing about the options set in other statements.

Most (all?) older file access functions will accept either HFS or UNIX file paths. This is to maintain compatibility with older programs written on the older system. For new code, I recommend switching to UNIX file paths. In most cases, I’ve even gone back and switched older code to use UNIX file paths, I think it is simpler that way.

The imagedimension( function is new to Panorama X, so there is no need for backwards compatibility. Any code that uses this function must be new. So it only works with UNIX paths.

I’m trying to use imagedimensions( with a UNIX path and still I get nothing but 0.

The path is correct. I can display the image, retrieve imageinfo(, use Reveal inFinder - with or without Unixpath. But on imagedimensions(, v( and h( always come up as zero.

What format is the image in? I tried it with a JPEG, PNG, and a TIFF, and I got the correct dimensions each time.

It’s a JPEG.

After posting, I quit Panorama. In order to answer you I decided to copy the procedure I was testing with so I relaunched and ran it. This time it worked. I returned to a form where I want it to display and where I knew a path error needed to be corrected and it stopped working again - in the procedure too.

I fixed the path error, quit and relaunched and now it’s working everywhere.

As in Panorama 6 there must be a residual effect with a path error that is only cleared by quitting the program.