Re: image dimensions
Re: image dimensions
- Subject: Re: image dimensions
- From: "Arthur J Knapp" <email@hidden>
- Date: Thu, 16 Nov 2000 16:50:15 -0500
>
Subject: Re: image dimensions
>
From: John McAdams <email@hidden>
>
I should be more specific. Is there a way to get horizontal and
>
vertical measurements for a Photoshop image in plain AppleScript
>
without opening the file in an image editing program?
Disclaimer: The following has NOT been extensively tested, use
at your own risk.
on Dimensions_8BPS(a_file)
-- a_file = alias or file spec
try
set f_ref to open for access a_file
on error m number n
-- your error trap code here
--
error m number n
end try
try
-- File signature
--
set header to (read f_ref for 4)
considering case
if (header is not equal to "8BPS") then
error "" & a_file & " is not a Photoshop file"
end if
end considering
-- move file marker to byte 15
--
read f_ref for 10
-- bytes 15-18 and 19-22
--
set {x, y} to (read f_ref for 8 as integer)
-- close
--
close access f_ref
on error m number n
-- your error trap code here
--
try
close access f_ref
end try
error m number n
end try
-- { Width, Height } in pixels
--
return {x, y}
end Dimensions_8BPS
Dimensions_8BPS(choose file)
--> i.e.: {105, 159}
--
{
Arthur J Knapp, of STELLARViSIONs ;
http://www.STELLARViSIONs.com ;
mailto:email@hidden ;
"... but I could be anyone"
"No you couldn't, sir ..."
}