I only want the name of the image in the dialog box and not the path to the image.
set selectedFile to (choose file with prompt "Please select an image..." of type {"gif", "png", "jpg", "jpeg", "tif", "tiff", "icns"} without invisibles)
try
tell application "Image Events"
launch
set openedFile to open (selectedFile as alias)
set dimensionsList to the dimensions of openedFile
set fileWidth to the first item of dimensionsList
set fileHeight to the second item of dimensionsList
close openedFile
end tell
display dialog "" & selectedFile & return & return & "Width: " & fileWidth & " Height: " & fileHeight & ¬
" pixels." buttons {"OK"} cancel button "OK" default button 1
end try
set selectedFile to (choose file with prompt "Select an image..." of type {"gif", "png", "jpg", "jpeg", "tif", "tiff", "icns"} without invisibles)
try
tell application "Image Events"
launch
set openedFile to open (selectedFile as alias)
set dimensionsList to the dimensions of openedFile
set fileWidth to the first item of dimensionsList
set fileHeight to the second item of dimensionsList
set theName to name of openedFile
close openedFile
end tell
display dialog theName & return & return & "Width: " & fileWidth & " Height: " & fileHeight & " pixels." buttons {"OK"} ¬
cancel button "OK" default button 1
end try
I doubt that the type specification in the first line works reliably
set selectedFile to (choose file with prompt "Select an image..." of type {"public.gif", "public.png", "public.jpg", "public.jpeg", "public.tif", "public.tiff", "com.apple.icns"} without invisibles)
.