getting size of image of image view

I’m trying to get the size of the image displayed by the image view. Not the actual size of the file but the size as it is being displayed in my app. I’m need to find the top left corner of the image being displayed. I have the image view set to display proportional but sometimes the image is smaller than the image view size. Sometimes the height is fits but the width is smaller, other times vice versa.

I tried this:

set imgSize to size of image of image view “img1” of window “mainWin”

but got an error.

Hi,

Try the handler below after loading your image file (here indicated as “theFile”):


on get_imageDimension(theFile)
	try
		tell application "Image Events"
			launch
			set tmpImage to open theFile
			set {tmpImageX, tmpImageY} to dimensions of tmpImage
			close tmpImage
		end tell
		return {tmpImageX, tmpImageY}
	on error error_message
		display dialog error_message
	end try
end get_imageDimension

Good luck!

archseed :slight_smile:

Assuming that you have already confirmed that the image view has an image in it…

set {theImageWidth, theImageHeight} to call method "size" of (call method "image" of imageView1)

Perfect! Thanks!

I was using set imageSize to call method “size” of image of image view “imgviewname”

Is there a method that would allow me to get the bounds of the image of an image view?