Avoiding the path in the dialog box?

Hi all,

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

Thanks for any help.

Tom

Operating System: Mac OS X (10.6)

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

Yeah, I was thinking about the type specification too. I might eliminate it. :confused:

Thanks for your help! :smiley:

Tom

this should work


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)
.

I bet it will work. :smiley:

Thanks again, Stefan.

Tom