PHPackages                             ankitpokhrel/alt - 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. ankitpokhrel/alt

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

ankitpokhrel/alt
================

Automatic alternative (alt) text for images using object detection with pre-trained model.

v0.0.0(7y ago)82398[1 issues](https://github.com/ankitpokhrel/alt/issues)MITPHPPHP ^7.1.3

Since Mar 11Pushed 1y ago3 watchersCompare

[ Source](https://github.com/ankitpokhrel/alt)[ Packagist](https://packagist.org/packages/ankitpokhrel/alt)[ RSS](/packages/ankitpokhrel-alt/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

alt [![Build Status](https://camo.githubusercontent.com/4dc0ed8327f04754af87042e9449fd589123aeee268a9651f7136f9f6ecffb22/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616e6b6974706f6b6872656c2f616c742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ankitpokhrel/alt)
=========================================================================================================================================================================================================================================================================================================================

[](#alt-)

> This project is no longer maintained.

*Automatic alternative (alt) text for images using object detection with pre-trained model.*

### Overview

[](#overview)

A very simple PHP library to generate alternative (alt) text for images using pre-trained tensorflow model to detect objects in an image. These texts can provide context about image to visitors who are unable to see images in their browser for whatever reasons. Alt texts can also be picked up by screen readers to convert it to speech, thus, providing additional context to visually impaired people and enhancing our user experience.

> This nifty little tool is inspired by [facebook alt text generation](https://code.fb.com/ios/under-the-hood-building-accessibility-tools-for-the-visually-impaired-on-facebook/) process.

### Example

[](#example)

[![Image may contain: cup, potted plant, laptop](tests/images/workplace.jpg)](tests/images/workplace.jpg)
*Image may contain: cup, potted, laptop*[![Image may contain: 6 person, cup, laptop](tests/images/people.jpg)](tests/images/people.jpg)
*Image may contain: 6 person, cup, laptop*[![Image may contain: 5 person, car, motorcycle](tests/images/street.jpg)](tests/images/street.jpg)
*Image may contain: 5 person, car, motorcycle*[![Image may contain: 1 person, car, bus, truck, traffic light](tests/images/london.jpg)](tests/images/london.jpg)
*Image may contain: 1 person, car, bus, truck, traffic light*[![Image may contain: chair, couch](tests/images/home.jpg)](tests/images/home.jpg)
*Image may contain: chair, couch*[![Image may contain: pizza, dining table](tests/images/pizza.jpg)](tests/images/pizza.jpg)
*Image may contain: pizza, dining table*[![Image may contain: dog](tests/images/dog.jpg)](tests/images/dog.jpg)
*Image may contain: dog*[![Image may contain: bird](tests/images/birds.jpg)](tests/images/birds.jpg)
*Image may contain: bird*### Installation

[](#installation)

> Requires: PHP 7.1.3+, [OpenCV](https://opencv.org/), [PHP OpenCV](https://github.com/php-opencv/php-opencv)
> Model used: [SSDLite COCO v2](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md)

Pull the package via composer.

```
$ composer require ankitpokhrel/alt
```

### Usage

[](#usage)

```
$alt = new \Alt\Alt('/path/to/image.ext');

echo $alt->alt(); // Image may contain: 6 person, cup, laptop

$alt->setImage('/path/to/image.ext')->alt(); // Image may contain: car, motorcycle
```

### Threshold

[](#threshold)

The classification threshold is set to `30` by default. You can adjust it as your need.

```
$alt->setThreshold(25);
```

### Prefix

[](#prefix)

By default the alt is prefixed with `Image may contain: `. You can change this as below:

```
$alt->setPrefix('Image has: ');
```

### Countable

[](#countable)

If you want to display the count of an object, you can do so by setting `countable` array. `person` is countable by default.

```
$alt->setImage('/path/to/image.ext')->alt(); // Image may contain: 5 person, dog, cup

// Adding dog as countable
$alt->setCountable(['person', 'dog'])->alt(); // Image may contain: 5 person, 2 dog, cup
```

### Default text

[](#default-text)

Default text is used if the model is not able to predict any objects within a given threshold. Default default text is `No photo description available.`.

```
$alt->setDefaultText('Some scenery.');
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

2618d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07f2aef5d1e12e750ce5f46b0f7d845fc134b911511fb6b46eddda8a1a783152?d=identicon)[ankitpokhrel](/maintainers/ankitpokhrel)

---

Top Contributors

[![ankitpokhrel](https://avatars.githubusercontent.com/u/2364546?v=4)](https://github.com/ankitpokhrel "ankitpokhrel (8 commits)")

---

Tags

autotextdeep-neural-networkmade-in-nepalobject-detectionopencvphp-libraryphp-opencvphp7single-shot-detection

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ankitpokhrel-alt/health.svg)

```
[![Health](https://phpackages.com/badges/ankitpokhrel-alt/health.svg)](https://phpackages.com/packages/ankitpokhrel-alt)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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