PHPackages                             gbv/image-attribution - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. gbv/image-attribution

ActiveLibrary[Image &amp; Media](/categories/media)

gbv/image-attribution
=====================

Get information for image attribution from Wikimedia Commons

0.3.0(9y ago)6722[4 issues](https://github.com/gbv/image-attribution/issues)[1 PRs](https://github.com/gbv/image-attribution/pulls)MITPHPPHP &gt;=5.6

Since Aug 24Pushed 2y ago6 watchersCompare

[ Source](https://github.com/gbv/image-attribution)[ Packagist](https://packagist.org/packages/gbv/image-attribution)[ Docs](https://github.com/gbv/image-attribution)[ RSS](/packages/gbv-image-attribution/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (4)Used By (0)

image-attribution
=================

[](#image-attribution)

[![Latest Stable Version](https://camo.githubusercontent.com/9d5d7772dd5eeb91e487ae7a88c7a88bac2734bbae00fbbe8e9c51b86e7e6dda/68747470733a2f2f706f7365722e707567782e6f72672f6762762f696d6167652d6174747269627574696f6e2f762f737461626c65)](https://packagist.org/packages/gbv/image-attribution)

[![Build Status](https://camo.githubusercontent.com/4f9eba0e5b5fcd304fc1c28009e84e8f831fa63ae7f03d3db5058a3f1f9fbbba/68747470733a2f2f7472617669732d63692e6f72672f6762762f696d6167652d6174747269627574696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gbv/image-attribution)

This PHP library provides a method to retrieve information required for proper attribution of images from [Wikimedia Commons](https://commons.wikimedia.org/).

Motivation
----------

[](#motivation)

Wikimedia Commons contains images and other freely usable media files. Some files can be used without any conditions (public domain), others are licensed under an open content license. Depending on the particular license one has to give proper credit to the original author and/or name the specific license. Wikimedia Commons includes guidelines [how to give proper credit](https://commons.wikimedia.org/wiki/Commons:Credit_line) but there is no easy way to look up attribution requirements for a given image in machine-readable format.

There is a method to retrieve some license information via Wikimedia Commons API, but the API is difficult to find and query, its return format is too verbose, and the response is not usable without further processing. For instance licenses are spelled in several different ways ("CC-BY-SA-3.0", "CC BY-SA 3.0"...) and field values may contain HTML tags.

Requirements
------------

[](#requirements)

Requires PHP 5.6 or above and `allow_url_fopen` enabled.

Installation
------------

[](#installation)

Use composer:

```
$ composer require gbv/image-attribution
```

or just copy files `src/image-attribution.php` and `src/identify-open-content-license.php` by hand.

Usage
-----

[](#usage)

Use autoload:

```
require 'vendor/autoload.php';
```

or include the library file the old way:

```
require_once 'src/image-attribution.php';
```

Then make use of the function `commons_image_attribution`:

```
$attribution = commons_image_attribution("Loewe_frontal.JPG");
```

The image can be passed as file name, full image URL or URL of the image page. The value `null` will return a random image. If the image is found with a license, an array is returned with the following fields:

fieldcontent`src`URL of the image file`url`URL of the image description page`license`URI of the license or `null` if unknown`license_name`short name of the license or `null` if unknown`attribution`boolean value whether attribution is required, or `null` if unknown`sharealike`boolean value whether share-alike is required, or `null` if unknown`creator`creator of the image, or `null` if unknown`credit`credit string to give attribution with creator and license`description`image description as plain string, or `null` if unknown`date`date of the image as plain string, or `null` if unknown`restrictions`additional restrictions, such as "trademarked", or `null``name`(file)name of the image`mime`image mime type`size`image size in bytes`width`image width in pixels`height`image height in pixelsExamples
--------

[](#examples)

Directory `example` includes a web service (`index.php`) to query image attribution information as JSON. The service is deployed at  but may be slow or down from time to time. Please install at your own server if you need to use it frequently! To give an example:

-

Directory `bin` contains a command line script to get image attribution:

```
./bin/image-attribution Wikimedia-logo.svg

```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

3

Last Release

3571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2a9725ee91210e1e5eab44e4f734b678a0650a03116aee170be7b49edcbb2e4?d=identicon)[gbv](/maintainers/gbv)

---

Top Contributors

[![nichtich](https://avatars.githubusercontent.com/u/299856?v=4)](https://github.com/nichtich "nichtich (10 commits)")

---

Tags

licenseimagecommonsattributioncredit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gbv-image-attribution/health.svg)

```
[![Health](https://phpackages.com/badges/gbv-image-attribution/health.svg)](https://phpackages.com/packages/gbv-image-attribution)
```

###  Alternatives

[intervention/image

PHP Image Processing

14.3k203.8M2.5k](/packages/intervention-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k52.6M138](/packages/league-glide)[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k39.4M239](/packages/liip-imagine-bundle)[spatie/image

Manipulate images with an expressive API

1.4k58.5M176](/packages/spatie-image)[intervention/image-laravel

Laravel Integration of Intervention Image

1558.1M160](/packages/intervention-image-laravel)[intervention/gif

PHP GIF Encoder/Decoder

6125.4M14](/packages/intervention-gif)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
