Get pixels size of Image in InDesign

Hi,

Seems not possible from INDD dictionary to have access to the size in pixels of images.
A workaround (with calculation) can be to get size in pixels using geometric bounds and actual pip value (list)

Same missing info for profile embedded of image.
In this case actually I use sips and grep to extract it.

But INDD show these info in the link palette, so probably these info are not exposed in the DICT.

Anybody can confirm this?

Ame

That’s right – you can calculate it from the bounds and the pixel density.

Hi Sahne,

Thanks for the confirmation.

I post here the solution I implemented using SIPS:

set imgPathHfs to "Mountain Lion:Users:adminosx:Desktop:canon700.jpg"

-- ##################################################
-- Image ICC Profile
-- ##################################################
try
	set imgPathPosix to quoted form of (POSIX path of imgPathHfs)
	set imgProfile to (do shell script "/usr/bin/sips -g profile " & imgPathPosix & " | fgrep profile | sed  's/  profile: //g'") as string
on error msg number errnum
	set imgProfile to "NA"
end try


-- ##################################################
-- Image Width in Pixel
-- ##################################################
try
	set imgWidthPixel to (do shell script "/usr/bin/sips -g pixelWidth " & imgPathPosix & " | tail -n1 | cut -d' ' -f4") as integer
on error msg number errnum
	set imgWidthPixel to "NA"
end try


-- ##################################################
-- Image Height in Pixel
-- ##################################################
try
	set imgHeightPixel to (do shell script "/usr/bin/sips -g pixelHeight " & imgPathPosix & " | tail -n1 | cut -d' ' -f4") as integer
on error msg number errnum
	set imgHeightPixel to "NA"
end try

set imgInfo to {imgProfile, imgWidthPixel, imgHeightPixel}

Ame

you can get the information also with Image Events


set imgPathAlias to choose file
try
	set imgProfile to "NA"
	tell application "Image Events"
		launch
		tell (open imgPathAlias)
			set {imgWidthPixel, imgHeightPixel} to dimensions
			try
				set imgProfile to name of embedded profile
			end try
			close
		end tell
	end tell
	set imgInfo to {imgProfile, imgWidthPixel, imgHeightPixel}
on error error_message
	display dialog error_message
end try


Hi Stefan,

Yes,

as I know Images Events use SIPS as engine, so I prefer to use CLI that seems more “robust” with intensive collection of data.

Ame