Problems with ImageInfo(

I am attempting to use ImageInfo( but I am not getting any results. I’d like to see if others are having any issues with it. When I run the code below, I do get a Message with the date of the GetAddress.png file, but the next Message is empty.
Can we see what others might get? (Do use an actual path to a real image file.)

Local LImageInfo
LImageInfo = imageinfo("~/Desktop/GetAddress.png")
if LImageInfo=""
    Message "No image!"
EndIf

Message datepattern(filedate("~/Desktop/GetAddress.png"),"mm/dd/yy")
Message ":"+dumpdictionary(LImageInfo)+":"

I get a recent date for the first message. The 2nd message is only ::

I have a feeling that there will be differences amongst the responses. macOS 10.15.7

I ran your code, substituting the name of a .png file I had on my desktop, and got the same result. If I replace ~/ with /Users/dthmpsn1/ I get a lot of information. ImageInfo( is a custom function that uses the UNIX sips command to get the information. The bug appears to be in the unixshellstring( function. It’s escaping the ~ character.

1 Like

If I substitute /Users/rameeti/ I too get the results I needed.

Thank you Dave. I might have guessed you’d figure it out.

I’m thinking that this is the same problem as noted by Jim Cook at ImageDimensions

I just went to some trouble so that the ~ symbol isn’t escaped if it is the first character in the string. Having gone to that trouble, I’m now thinking that is not correct, probably ~ shouldn’t be escaped at all, ever? Anyone know off the top of their head (looking at you Dave)?

Hmm, I just googled using tilde in shell script and I am still not sure. I’m not sure there is a 100% right answer for all situations. Maybe I’ll just leave in my new fix of escaping the ~ symbol unless it is the first character.

I can’t imagine I would ever put a tilde in a file or folder name. Actually, I just did it to see if it could be done, and then dropped the file onto a Terminal window to see what the path looked like. The ~ was escaped, so it can happen, and Murphy’s Law says you were right to go to the trouble.

1 Like

I just did a Finder search and found a good number of documents with tildes. Most had it as their first character, but many had it within the name of the file.

I’m not even going to dream about the trouble one could get into by putting a tilde at the beginning of a file or folder name. Or what if someone named a folder tilde? :astonished:

I have 3 folders with ~ as the first character and 2 of those folders are in
rameeti/Library/Containers/com.apple.new/Data/~

Well, that wouldn’t actually cause a problem with imaginfo(, or I think anything in Panorama X once you get the version with the fixed unixshellstring( command. But I’m not sure what Terminal.app will do if you cd to rameeti/Library/Containers/com.apple.new and then issue a command for that folder. However, what happens in Terminal.app is not my problem! :upside_down_face:

Robert, you can avoid writing the tilde or any detailed user path by use of Panorama’s info( function:

dumpdictionary(imageinfo(info("desktopfolder")+"GetAddress.png"))

I came upon this by trying an example in the Help file. As that is likely to be done by others (hopefully often), I will continue to use the ~ as it is a legitimate character with a life outside of the Unix world.

I find it just a part of life, and a bit humorous, that Dave would never use it and I have often used it in the naming of files and within folders.

And Jim gets to make it all work. :wink:

KJM: I do appreciate your thoughts though as it could have been that I was needing it to work before the ‘fix’ was released.

I guess it wasn’t already clear that you could also get it work by hard coding the path, probably something like

"/Users/Rameeti/Desktop/GetAddress.png"

Kurt’s solution will work with files in the desktop folder, or you could use the more general:

info("userfolder")+"Desktop/GetAddress.png"

The one thing that won’t work until the new release is using the shortcut of ~ instead of info("userfolder"). Because internally ~ gets escaped to \~, the system doesn’t then expand that to the path to the user folder. However, for cases where you are using the ~ symbol in a file or folder name this escaping is a good thing, and will allow you to access those files and folders.