Difference between revisions of "Cc-xmp-tag.pl"
Line 7: | Line 7: | ||
It's using the perl Image::ExifTool module, which means you need that installed on your system. On Debian derivatives you can install it like this: | It's using the perl Image::ExifTool module, which means you need that installed on your system. On Debian derivatives you can install it like this: | ||
− | < | + | <pre>apt-get install libimage-exiftool-perl</pre> |
== Usage examples == | == Usage examples == | ||
Line 13: | Line 13: | ||
There are a couple of sample .jpg files in the repository next to cc-xmp-tag.pl: example-alltags.jpg and example-notags.jpg. You can use them for testing if you like. | There are a couple of sample .jpg files in the repository next to cc-xmp-tag.pl: example-alltags.jpg and example-notags.jpg. You can use them for testing if you like. | ||
− | These XMP tags are supported: | + | These XMP tags are supported (don't worry about capitalization, they are set correctly): |
* '''AttributionName''': the name of the author of the work. | * '''AttributionName''': the name of the author of the work. | ||
Line 24: | Line 24: | ||
=== Reading XMP === | === Reading XMP === | ||
− | Use a variation of cc-xmp-tag.pl --read filename with a list of tags you want to read. | + | Use a variation of <code>cc-xmp-tag.pl --read filename</code> with a list of tags you want to read. For example: |
+ | |||
+ | * Read the AttributionName tag (prints out the contents of the tag or nothing). Note that this will not be very useful output for software to parse because if any of the tags are missing you won't know which tags the printed values belong to: | ||
+ | <pre>$ ./cc-xmp-tag.pl --read example-alltags.jpg AttributionName | ||
+ | Andrew Smith | ||
+ | $ ./cc-xmp-tag.pl --read example-notags.jpg AttributionName</pre> | ||
+ | * Read all the tags or multiple tags: | ||
+ | <pre>$./cc-xmp-tag.pl --read example-alltags.jpg ALL | ||
+ | Andrew Smith | ||
+ | http://littlesvr.ca | ||
+ | https://creativecommons.org/licenses/by-sa/4.0/ | ||
+ | True | ||
+ | My Title | ||
+ | This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>. | ||
+ | $ ./cc-xmp-tag.pl --read example-alltags.jpg License Title AttributionName | ||
+ | https://creativecommons.org/licenses/by-sa/4.0/ | ||
+ | My Title | ||
+ | Andrew Smith | ||
+ | $ ./cc-xmp-tag.pl --read example-notags.jpg License Title AttributionName | ||
+ | </pre> | ||
+ | |||
+ | === Writing XMP === | ||
+ | |||
+ | All the same tags are supported, though there's no need to set Marked and UsageTerms. Variations of <code>cc-xmp-tag.pl --read filename</code>: | ||
+ | |||
+ | * Set a couple of tags on an image that had none to begin with and check what was set: | ||
+ | |||
+ | <pre>$ ./cc-xmp-tag.pl --write example-notags.jpg AttributionName='Andrew Smith' License='BY-SA' | ||
+ | $ ./cc-xmp-tag.pl --read example-notags.jpg ALL | ||
+ | Andrew Smith | ||
+ | https://creativecommons.org/licenses/by-sa/4.0/ | ||
+ | True | ||
+ | This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.</pre> | ||
+ | |||
+ | Note that when writing the Licence you have to use the licence code, not the URL. When reading you get the URL. | ||
+ | |||
+ | Also note that the values you set are stored in XML - which means you aren't allowed to have ASCII control characters or '<', '>', '&'. You can't have single or double-quotes in attributes either but cc-xmp-tag.pl doesn't store values in attributes so I wouldn't worry about that (you're welcome O'Connors of the world). |
Revision as of 22:55, 1 April 2015
Note: this page will hopefully be moved to wiki.creativecommons.org at some point (once we have accounts on there).
Get the program from GitHub: https://github.com/creativecommons/seneca/tree/master/cc-xmp-tag/perl
The script cc-xmp-tag.pl was written to easily read and write Creative-Commons-related XMP metadata from media files.
It's using the perl Image::ExifTool module, which means you need that installed on your system. On Debian derivatives you can install it like this:
apt-get install libimage-exiftool-perl
Usage examples
There are a couple of sample .jpg files in the repository next to cc-xmp-tag.pl: example-alltags.jpg and example-notags.jpg. You can use them for testing if you like.
These XMP tags are supported (don't worry about capitalization, they are set correctly):
- AttributionName: the name of the author of the work.
- AttributionURL: the URL to the author's website. Ideally to a page specific to this particular work, or lacking that: another appropriate URL for the author.
- License: the URL pointing to the licence.
- Title: the title of the work.
- Marked: if this is true that means the work is not in the public domain. Set automatically when you write any other tags.
- UsageTerms: a human-readable note saying that a licence applies to this work. Set automatically when you write the Licence tag.
Reading XMP
Use a variation of cc-xmp-tag.pl --read filename
with a list of tags you want to read. For example:
- Read the AttributionName tag (prints out the contents of the tag or nothing). Note that this will not be very useful output for software to parse because if any of the tags are missing you won't know which tags the printed values belong to:
$ ./cc-xmp-tag.pl --read example-alltags.jpg AttributionName Andrew Smith $ ./cc-xmp-tag.pl --read example-notags.jpg AttributionName
- Read all the tags or multiple tags:
$./cc-xmp-tag.pl --read example-alltags.jpg ALL Andrew Smith http://littlesvr.ca https://creativecommons.org/licenses/by-sa/4.0/ True My Title This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>. $ ./cc-xmp-tag.pl --read example-alltags.jpg License Title AttributionName https://creativecommons.org/licenses/by-sa/4.0/ My Title Andrew Smith $ ./cc-xmp-tag.pl --read example-notags.jpg License Title AttributionName
Writing XMP
All the same tags are supported, though there's no need to set Marked and UsageTerms. Variations of cc-xmp-tag.pl --read filename
:
- Set a couple of tags on an image that had none to begin with and check what was set:
$ ./cc-xmp-tag.pl --write example-notags.jpg AttributionName='Andrew Smith' License='BY-SA' $ ./cc-xmp-tag.pl --read example-notags.jpg ALL Andrew Smith https://creativecommons.org/licenses/by-sa/4.0/ True This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
Note that when writing the Licence you have to use the licence code, not the URL. When reading you get the URL.
Also note that the values you set are stored in XML - which means you aren't allowed to have ASCII control characters or '<', '>', '&'. You can't have single or double-quotes in attributes either but cc-xmp-tag.pl doesn't store values in attributes so I wouldn't worry about that (you're welcome O'Connors of the world).