添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I need help.
I’m trying to extract Metadata from a .PNG file especially the comment . I need to read and write this to the PNG file.

Anyone can shed some light on this…

Regards,

Hey Bill,

Try the shell command: mdls <POSIX_Path>

Type man mdls in the Terminal for more info.

That may suffice for the read portion of your macro.

When I want the 900lb gorilla of image info tools I trot out the shell program exiftool .

http://www.sno.phy.queensu.ca/~phil/exiftool/

-Chris

If you are speaking of the metadata embedded in the PNG ( not Finder/Spotlight comments) you can also get them with ImageMagick :

identify -verbose <myfile.png>

The comment should be listed under “Properties”.

#####PS:

You can also preformat the output, for example:

identify -format 'Comment of file "%f" is: %[comment]\n' <myfile.png>

produces…

Comment of file "myfile.png" is: A new test comment

This might be handy for batch-exporting to a text file.

Format reference here.

To write a comment you can use:

convert <myfile.png> -set comment "A new comment" <myfile-out.png>

More info here.

Hey Bill,

Just out of curiosity – why can't you use exiftool?

Next – how about being more more specific about exactly what metadata you're trying to get.

EXIF data?

IPTC data?

Exactly what tag or tag names?

Once we know that there's a greater chance we can help.

-Chris

Hey Bill,

Just out of curiosity – why can't you use exiftool?

Next – how about being more more specific about exactly what metadata you're trying to get.

No It's very fine and very powerful I am going to be using it.. I was looking for a easier way..
Exiftool is good I'm poor on programing.. Though I'll figure it out.. LOL..

When I get stuck I'll be back... For the moment my health isn't the best. Need plenty of rest..

Thank you again Ccstone :smiley:

Hey Bill,

Well, this is why you need to give us more details, so we can help you.  :sunglasses:

This should get you started.

# Get info with tag-names rather than just descriptions.
exiftool -s ~/"Downloads/test.jpg"
# Read Description:
exiftool -Description ~/"Downloads/test.jpg"
# Write Description:
exiftool -Description='My New Description' ~/"Downloads/test.jpg"
# Read IPTC Caption-Abstract:
exiftool -Caption-Abstract ~/"Downloads/test.jpg"
# Write IPTC Caption-Abstract:
exiftool -Caption-Abstract='My New Caption-Abtract' ~/"Downloads/test.jpg"
# Write IPTC Caption-Abstract and PREVENT the original from being backuped up by exiftool.
exiftool -overwrite_original_in_place -Caption-Abstract='My New Caption-Abtract' ~/"Downloads/test.jpg"

Holler if you need more help.

-Chris

How can I execute these in Execute a Shell Script I have tried and always have message.

Directly in terminal no problem....
I think I'm missing something.. I'm sure... "I'm no programmer" :slight_smile:

Thank you very much,

“command not found” indicates the shell is not finding the command, which happens because the PATH is not set correctly.

See the wiki troubleshooting section.

peternlewis:

"command not found" indicates the shell is not finding the command, which happens because the PATH is not set correctly.

Have tried almost everything...
Hi all, I am getting the following error: I installed home-brew - pngquant and I believe I set the path for home-brew correctly /usr/local/bin any help is appreciated error message follows: MACRO ERROR on 2017-02-27 09:18:37 This info was pulled from the KM Engine Log for the Last Macro error that occured. Macro: Trying Action: Search Variable ‘pqScriptOut’ Using Regular Expression (case sensitive) Status: cancelled Error: Search Variable failed to match (?m)-color image as (.*?)$ If you did install exiftool not with Homebrew, then find out the path(s) of your exiftool by executing this in the Terminal:

type -a exiftool

…and use the correct path as shown in the posts.

If you did install exiftool not with Homebrew, then find out the path(s) of your exiftool by executing this in the Terminal:

Thank you @peternlewis and @Tom Have it working now...

Hey Bill,

This stuff confuses all shell scripting newbies.

Unix systems (and others) use an environment variable ($PATH) to keep track of where to look for executables when they are called by name.

A basic path might look like this:

/usr/bin:/bin:/usr/sbin:/sbin

Mine on the other hand has had several things added to it.

/opt/local/bin:/opt/local/sbin:/Users/myUserName/perl5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

If you want to be able to call exiftool by name it MUST be within the path, so Unix can see it.

Here's where my copy of exiftool is installed:

/usr/local/bin/exiftool

You can always call a Unix exe by using its full-path.

/usr/local/bin/exiftool -s ~/Downloads/test.jpg

I have a Keyboard Maestro variable called ENV_PATH set to:

/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

That lets Keyboard Maestro see everything in the given paths, and it doesn't change my system $PATH variable.

So I can call exiftool from Keyboard Maestro without monkeying around.

exiftool -s ~/Downloads/test.jpg

Alternatively you can set the path when you call your shell script:

export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin$PATH;
exiftool -s ~/Downloads/test.jpg

This is what I used to do before I started using Keyboard Maestro's ENV_PATH variable.

Hopefully I've clarified things a bit instead of adding to the confusion.

-Chris

I have a Keyboard Maestro variable called ENV_PATH set to:

/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

That lets Keyboard Maestro see everything in the given paths, and it doesn't change my system $PATH variable.

So I can call exiftool from Keyboard Maestro without monkeying around.

OMG! WOW! Thank you @ccstone This helps so much! It's like magic.. :slight_smile:
Now I'm flying now... Whoohoo!

I'm flying now... oops I hit a wall....

File name has space or spaces Shell don’t like spaces I have searched for a fix and I was unsuccessful.
From my understanding I should replace the space with & right?

Much appreciated,
Bill_Mabey:

File name has space or spaces Shell don't like spaces I have searched for a fix and I was unsuccessful.

Then quote the file names or paths:

exiftool ~/"my file/path with/spaces/my image.png"
        
  • order:views order:latest order:likes
  • status:open status:closed status:archived status:noreplies status:single_user
  • category:foo tag:foo user:foo group:foo badge:foo
  • in:likes in:posted in:watching in:tracking in:private in:bookmarks in:first in:pinned in:unpinned
  • posts_count:num before:days_or_date after:days_or_date
  • For more information, see the wiki Searching the Forum for Answers section.