Extension:CommonsMetadata/pt-br

A extensão CommonsMetadata procura extrair metadados de páginas do Wikimedia Commons e de todos os outros projetos da Wikimedia. Ela adiciona informações extras à API imageinfo com base em predefinições e categorias inseridas na descrição da imagem. A extensão é usada por várias outras extensões e ferramentas (como o visualizador de mídias, o editor visual, o MobileFrontend e o serviço de conteúdo móvel — MCS) para fornecer caixas de diálogo ou seleções de imagens aprimoradas.

No momento, a extensão destina-se a ser uma solução temporária que eventualmente será substituída pelo Wikidata no Commons.

Motivation & design choices
See https://lists.wikimedia.org/pipermail/wikitech-l/2013-August/071593.html

The assumptions of this extension are the following.


 * At some point in the future, wikidata will take over handling metadata at commons. In order to avoid disruptive changes, which will soon need to be changed again, the extension should work with commons metadata as it currently is (so not introducing new parser functions). Hence screen scraping.


 * The content of many of the fields on a commons description page include rich formatting (In particular: Links, italics, bold. In some cases more complex things like embedded images)
 * As a result, extension outputs parsed html (wikitext sucks, plain text doesn't capture the data)
 * Futhermore, the data tends to be formatted for human display, rather than (for example) machine formatted dates. When the date field says something like "circa 1600s", its hard to convert that to a precise date (otoh, many examples can be).
 * To carry that forward, also apply formatting to exif metadata, which is controlled on wiki (For example, commons links the camera name to a wikipedia article)


 * If we can't extract info from the description page, but the file has the author tagged in exif/XMP/iptc metadata, we should use that as a fallback.
 * Ideally such a system would be as commons-inspecific as possible, with the commons and non-commons part separated.


 * Commons description pages have multilingual descriptions. Lots of users probably just want one language.
 * In this implementation, it applies per language conventions to dates and things. Additionally for explicitly multi-lingual fields (description), there is an option to return all, or just a single language. Even in single language mode, some things are still language specific (like the thousands seperator on numbers)

Testando
Ao testar com imagens remotas (como as do Commons caso o  esteja ativado), é possível definir  para forçar o CommonsMetadata a analisar a página de descrição da imagem e extrair os metadados (se o repositório remoto também possuir o CommonsMetadata instalado, ele próprio retornará um output pela API).

Uso
Use a API imageinfo e inclua  entre as propriedades de informação de imagem especificadas pelo.

Exemplo:


 * https://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=extmetadata&iilimit=10&titles=File%3ACommon%20Kingfisher%20Alcedo%20atthis.jpg

Veja este exemplo em ação na caixa de areia da API:


 * https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&prop=imageinfo&format=json&iiprop=extmetadata&iilimit=10&titles=File%3ACommon%20Kingfisher%20Alcedo%20atthis.jpg

Dados retornados
No momento, essa extensão fornece os seguintes itens no campo  da resposta (os nomes dos campos foram escolhidos à medida do possível para estarem de acordo com o formato IPTC-IIM, utilizado nos cabeçalhos EXIF):

Data based on machine-readable data in the Information template:


 * ImageDescription - image description
 * Artist - author name (might contain complex HTML, multiple authors etc)
 * Credit - source
 * DateTimeOriginal - time of creation (space-separated ISO 8601 timestamp whenever possible, but can be any other textual description of a date, possibly with HTML mixed in)
 * ObjectName - title (for a book/painting; otherwise just the file name)
 * Permission - contents of the Permission field of the template. Can be a lot of things (license template, OTRS id, details on how to attribute...)
 * AuthorCount - the number of templates with authors (e.g. Book, Photograph...). The number of actual authors might be higher if a template describes multiple authors in a single string.

Data based on machine-readable data in the Location template:


 * GPSLatitude - latitude
 * GPSLongitude - longitude
 * GPSMapDatum - coordinate type (only  supported for now)

Data based on machine-readable data in the license template:


 * LicenseShortName - short human-readable license name
 * LicenseUrl
 * UsageTerms
 * Copyrighted -  or   (for public domain images)

For multi-licensed images these values are currently unreliable.


 * Attribution - custom attribution that should replace Artist + Credit (can also originate from the Information template)
 * AttributionRequired - booleanish (T86726), tells whether there is a legal requirement to attribute
 * NonFree - booleanish, true means the image is not under a free license. (Used for non-Commons images only.)

Other data: Based on parsing category names, probably won't work for images not hosted on Commons. (Based on the nuke template, probably not reliable outside Commons.) It contains a deletion reason, but it is phrased to be applicable for a log entry, so it might be misleading (e.g. past tense when actually it is not yet decided whether the image will be deleted).
 * CommonsMedadataExtension - contains the metadata parser version number; mostly for internal use
 * License - a best guess at the license of the image (mostly for internal use by MediaViewer, might change; LicenseShortName is probably more reliable)
 * Categories - a -separated list of the categories of the image.
 * Assessments - a -separated list of the assessments of the image (currently five values are supported: poty, potd, featured, quality, valued).
 * Restrictions - reuse restrictions such as trademarks or personality rights; an array of keywords (the class names from this table, without the  prefix). See also the restrict-* icons in MediaViewer.
 * DeletionReason - if set, the template is being considered for deletion.