-
Notifications
You must be signed in to change notification settings - Fork 33
Metadata
Simple Inkscape Scripting can read and write all of the metadata appearing in Inkscape's File → Document Properties… dialog box in both the Metadata and License tabs. All document metadata is available via the metadata
object.
Variable: metadata
(type SimpleMetadata
)
metadata
provides a large number of properties:
Property: title
(type str
)
Property: raw_date
(type str
)
Property: date
(type datetime.datetime
)
Property: creator
(type str
)
Property: rights
(type str
)
Property: publisher
(type str
)
Property: identifier
(type str
)
Property: source
(type str
)
Property: relation
(type str
)
Property: language
(type str
)
Property: keywords
(type [str]
)
Property: coverage
(type str
)
Property: description
(type str
)
Property: contributors
(type str
)
Property: license
(type str
or dict
)
Inkscape represents metadata using the Dublin Core Metadata Initiative (DCMI) schema. The DCMI Metadata Terms webpage specifies the intended content of each of the above. Less formal but more readable is The University of Texas Libraries' webpage with descriptions and examples of Dublin Core.
Both the date
and raw_date
properties correspond to DCMI's date term. The difference is that raw_date
is an ordinary string while date
is a Python datetime.datetime
). A common use case is to timestamp a document with
metadata.date = datetime.datetime.now().astimezone()
which stores the current date, time, and time zone in DCMI's preferred date/time format. metadata.date
can be manipulated easily with Python's datetime
, such as to extract the day, month, or year or to compute deltas from other dates.
keywords
is read and written as a list of Python strings, not as a single string.
The following script assigns values to all of the metadata appearing on Inkscape's Metadata tab:
import datetime
now = datetime.datetime.now()
metadata.title = 'This, Too, is Not a Pipe'
metadata.date = now.astimezone()
metadata.creator = 'John Doe'
metadata.rights = 'Copyright (C) %d John Doe' % now.year
metadata.publisher = 'Awesome Artwork, Inc.'
metadata.identifier = '10.5555/12345678'
metadata.source = 'https://collections.lacma.org/node/239578'
metadata.relation = 'isVersionOf "La Trahison des Images"'
metadata.language = 'fr.BE'
metadata.keywords = [
'tobacco pipe',
'painting',
'cursive writing'
]
metadata.coverage = 'Lessines, Belgium'
metadata.description = 'Painting of a tobacco pipe on a solid' \
' background with the French phrase,' \
' "Ce n\'est pas non plus un tuyau" handwritten beneath it'
metadata.contributors = 'Fred Nerk'
The most complex field is license
, which specifies the legal terms under which the document is licensed to users. The simpler way to specify a license is to assign one of the following strings or aliases, representing common artwork licenses, to metadata.license
:
License name | Alias | Link to description |
---|---|---|
CC Attribution |
by |
http://creativecommons.org/licenses/by/4.0/ |
CC Attribution-ShareAlike |
by-sa |
http://creativecommons.org/licenses/by-sa/4.0/ |
CC Attribution-NoDerivs |
by-nd |
http://creativecommons.org/licenses/by-nd/4.0/ |
CC Attribution-NonCommercial |
bc-nc |
http://creativecommons.org/licenses/by-nc/4.0/ |
CC Attribution-NonCommercial-ShareAlike |
by-nc-sa |
http://creativecommons.org/licenses/by-nc-sa/4.0/ |
CC Attribution-NonCommercial-NoDerivs |
by-nc-nd |
http://creativecommons.org/licenses/by-nc-nd/4.0/ |
CC0 Public Domain Dedication |
zero |
http://creativecommons.org/publicdomain/zero/1.0/ |
FreeArt |
lal |
http://artlibre.org/licence/lal |
Open Font License |
OFL |
http://scripts.sil.org/OFL |
The more complex but powerful way to specify a license is with a Python dict
containing zero or more of the following keys:
-
url
(typestr
) is a URL pointing to human-readable license text. -
permits
(type[str]
) is a list of URLs, each pointing to an explanation of one action the recipient of the document is permitted to do. For example, http://creativecommons.org/ns#DerivativeWorks indicates that the recipient can distribute derivative works. -
requires
(type[str]
) is a list of URLs, each pointing to an explanation of one action the recipient of the document is required to do. For example, http://creativecommons.org/ns#Attribution indicates that the recipient must attribute the document's creator or copyright holder. -
prohibits
(type[str]
) is a list of URLs, each pointing to an explanation of one action the recipient of the document is prohibited from doing. For example, http://creativecommons.org/ns#CommercialUse indicates that the recipient may not use the document for commercial purposes.
Reading metadata.license
always returns a dict
. For example, if the license is assigned using
metadata.license = 'CC Attribution-ShareAlike'
then metadata.license
will appear as the following dict
when read:
{
'url': 'http://creativecommons.org/licenses/by-sa/4.0/',
'permits': [
'http://creativecommons.org/ns#Reproduction',
'http://creativecommons.org/ns#Distribution',
'http://creativecommons.org/ns#DerivativeWorks'
],
'requires': [
'http://creativecommons.org/ns#Notice',
'http://creativecommons.org/ns#Attribution',
'http://creativecommons.org/ns#ShareAlike'
]
}
The license metadata appears in the GUI as merely a radio-button selection and a URI, but in fact the full license information is embedded in the SVG file.