PHPackages                             andrewgjohnson/linebreaks4imagettftext - 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. andrewgjohnson/linebreaks4imagettftext

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

andrewgjohnson/linebreaks4imagettftext
======================================

linebreaks4imagettftext is a function to automatically insert line breaks into your text while using PHP’s imagettftext() function

v1.1.2(1mo ago)560.3k↓33.9%1MITPHPPHP &gt;=5.3.0CI passing

Since Jun 4Pushed 1w ago1 watchersCompare

[ Source](https://github.com/andrewgjohnson/linebreaks4imagettftext)[ Packagist](https://packagist.org/packages/andrewgjohnson/linebreaks4imagettftext)[ Docs](https://linebreaks4imagettftext.agjgd.org)[ GitHub Sponsors](https://github.com/andrewgjohnson)[ Patreon](https://www.patreon.com/agjgd)[ RSS](/packages/andrewgjohnson-linebreaks4imagettftext/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (4)Versions (10)Used By (1)

linebreaks4imagettftext
=======================

[](#linebreaks4imagettftext)

[![MIT License](https://camo.githubusercontent.com/04922227901ae9b0742e739b586a385fdacbb439766ee50870ea8db097378794/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3033363664362e706e673f636f6c6f72423d303336366436267374796c653d666c61742d737175617265)](https://github.com/andrewgjohnson/linebreaks4imagettftext/blob/master/LICENSE)[![Current Release](https://camo.githubusercontent.com/fcb6c1b36a3064f45cfe8024bfd9a4edacac5ce639117f96bf277aed787a6c5c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616e64726577676a6f686e736f6e2f6c696e65627265616b7334696d616765747466746578742e706e673f636f6c6f72423d303336366436267374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562)](https://github.com/andrewgjohnson/linebreaks4imagettftext/releases)[![Contributors](https://camo.githubusercontent.com/bf40400f775f93897d900da68544ddb319923099a6acd833b8725cf614bd1522/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f616e64726577676a6f686e736f6e2f6c696e65627265616b7334696d616765747466746578742e706e673f636f6c6f72423d303336366436267374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562)](https://github.com/andrewgjohnson/linebreaks4imagettftext/graphs/contributors)[![Packagist Downloads](https://camo.githubusercontent.com/65bb9a34d1f2118eac0a938b94ab38210e14c88d86c1becde2fdb8a98a81d25b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e64726577676a6f686e736f6e2f6c696e65627265616b7334696d616765747466746578742e706e673f636f6c6f72423d303336366436267374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d7061636b6167697374)](https://packagist.org/packages/andrewgjohnson/linebreaks4imagettftext/stats)[![Issues](https://camo.githubusercontent.com/9995bcc6d9e31097596d150ab2bfd1cc52abf117289c27624c312549dc19e0c9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f616e64726577676a6f686e736f6e2f6c696e65627265616b7334696d616765747466746578742e706e673f636f6c6f72423d303336366436267374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562)](https://github.com/andrewgjohnson/linebreaks4imagettftext/issues)[![Patreon](documentation/images/patreon-badge.png)](https://patreon.com/agjopensource)

[![](documentation/images/avatar.png)](https://linebreaks4imagettftext.agjgd.org/)

Description
-----------

[](#description)

**linebreaks4imagettftext** is a function to automatically insert line breaks into your text while using PHP’s imagettftext() function.

[![Patreon - Become a Patron](https://camo.githubusercontent.com/24c60c4550632628010d5c53c8cf9abc46d101caea3a76f057bff8884850c3b5/68747470733a2f2f7261737465722e736869656c64732e696f2f62616467652f50617472656f6e2532302d6265636f6d6525323061253230506174726f6e2d4644333334412e706e673f7374796c653d666f722d7468652d6261646765266c6f676f3d70617472656f6e266c6f676f436f6c6f723d464433333441)](https://patreon.com/agjopensource)

**linebreaks4imagettftext** is an [agjgd](https://agjgd.org) project.

Example
-------

[](#example)

```
// You can use linebreaks4imagettftext() to add line breaks ("\n") to long strings to help format text when using imagettftext()
$string = 'This is a long sentence that could not fit on a single line.';
$stringWithLineBreaks = \AndrewGJohnson\AgjGd\linebreaks4imagettftext(20, 0, $font, $string, imagesx($im) * 0.8);

// This will work but there will be no line breaks so your text will likely overflow horizontally
imagettftext($im, 20, 0, imagesx($im) * 0.1, 0, $color, $font, $string);

// This will work and you will not have to worry about text overflowing regardless of string length
imagettftext($im, 20, 0, imagesx($im) * 0.1, 0, $color, $font, $stringWithLineBreaks);

```

There are [other examples](https://github.com/andrewgjohnson/linebreaks4imagettftext/tree/master/examples) included in the GitHub repository and on [linebreaks4imagettftext.agjgd.org](https://linebreaks4imagettftext.agjgd.org/examples/).

Usage
-----

[](#usage)

### With Composer

[](#with-composer)

This project offers support for the [Composer](https://getcomposer.org/) dependency manager. You can find the linebreaks4imagettftext package online on [packagist.org](https://packagist.org/packages/andrewgjohnson/linebreaks4imagettftext).

#### Install using Composer

[](#install-using-composer)

Either run this command:

```
composer require andrewgjohnson/linebreaks4imagettftext

```

or add this to the `require` section of your composer.json file:

```
"andrewgjohnson/linebreaks4imagettftext": "1.*"

```

### Without Composer

[](#without-composer)

To use without Composer add an [include](http://php.net/manual/function.include.php) to the [`linebreaks4imagettftext.php` source file](https://raw.githubusercontent.com/andrewgjohnson/linebreaks4imagettftext/master/source/AndrewGJohnson/AgjGd/linebreaks4imagettftext.php).

```
include_once 'source/AndrewGJohnson/AgjGd/linebreaks4imagettftext.php';

```

Help Requests
-------------

[](#help-requests)

Please post any questions in the [discussions area](https://github.com/andrewgjohnson/linebreaks4imagettftext/discussions) on GitHub if you need help.

If you discover a bug please [enter an issue](https://github.com/andrewgjohnson/linebreaks4imagettftext/issues/new) on GitHub. When submitting an issue please use our [issue template](https://github.com/andrewgjohnson/linebreaks4imagettftext/tree/master/.github/ISSUE_TEMPLATE).

Contributing
------------

[](#contributing)

Please read our [contributing guidelines](https://github.com/andrewgjohnson/linebreaks4imagettftext/blob/master/.github/CONTRIBUTING.md) if you want to contribute.

You can contribute financially by becoming a [patron](https://patreon.com/agjopensource) at [patreon.com/agjopensource](https://patreon.com/agjopensource) to support linebreaks4imagettftext and [other agjgd.org projects](https://agjgd.org/projects/).

[![Patreon - Become a Patron](https://camo.githubusercontent.com/24c60c4550632628010d5c53c8cf9abc46d101caea3a76f057bff8884850c3b5/68747470733a2f2f7261737465722e736869656c64732e696f2f62616467652f50617472656f6e2532302d6265636f6d6525323061253230506174726f6e2d4644333334412e706e673f7374796c653d666f722d7468652d6261646765266c6f676f3d70617472656f6e266c6f676f436f6c6f723d464433333441)](https://patreon.com/agjopensource)

Acknowledgements
----------------

[](#acknowledgements)

This project was started by [Andrew G. Johnson (@andrewgjohnson)](https://github.com/andrewgjohnson).

Full list of contributors:

- [Andrew G. Johnson (@andrewgjohnson)](https://github.com/andrewgjohnson)

Our [security policies and procedures](https://github.com/andrewgjohnson/linebreaks4imagettftext/blob/master/.github/SECURITY.md) comes via the [atomist/samples](https://github.com/atomist/samples/blob/master/.github/SECURITY.md) project. Our [issue templates](https://github.com/andrewgjohnson/linebreaks4imagettftext/tree/master/.github/ISSUE_TEMPLATE) comes via the [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) project. Our [pull request template](https://github.com/andrewgjohnson/linebreaks4imagettftext/blob/master/.github/PULL_REQUEST_TEMPLATE.md) comes via the [stevemao/github-issue-templates](https://github.com/stevemao/github-issue-templates) project. The [Jekyll theme](https://github.com/andrewgjohnson/open-source-documentation-jekyll-theme) was released by [Andrew G. Johnson](https://github.com/andrewgjohnson).

Changelog
---------

[](#changelog)

You can find all notable changes in the [changelog](https://github.com/andrewgjohnson/linebreaks4imagettftext/blob/master/CHANGELOG.md).

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance94

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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 ~419 days

Recently: every ~326 days

Total

8

Last Release

13d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.0.0

v1.1.0PHP &gt;=5.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1124501?v=4)[Andrew G. Johnson](/maintainers/andrewgjohnson)[@andrewgjohnson](https://github.com/andrewgjohnson)

---

Top Contributors

[![andrewgjohnson](https://avatars.githubusercontent.com/u/1124501?v=4)](https://github.com/andrewgjohnson "andrewgjohnson (48 commits)")[![ImgBotApp](https://avatars.githubusercontent.com/u/31427850?v=4)](https://github.com/ImgBotApp "ImgBotApp (3 commits)")

---

Tags

composergdgraphicsimageimagesphpimagegdgraphicsimages

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/andrewgjohnson-linebreaks4imagettftext/health.svg)

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

###  Alternatives

[intervention/image

PHP Image Processing

14.3k208.9M2.6k](/packages/intervention-image)[league/glide

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

2.6k53.3M146](/packages/league-glide)[gregwar/image

Image handling

1.0k4.1M50](/packages/gregwar-image)[rosell-dk/webp-convert

Convert JPEG &amp; PNG to WebP with PHP

6049.0M63](/packages/rosell-dk-webp-convert)[sybio/image-workshop

Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)

854945.6k12](/packages/sybio-image-workshop)[andrewgjohnson/imagettftextblur

imagettftextblur is a drop-in replacement for imagettftext with added parameters to add blur, glow and shadow effects to your PHP GD images

28249.2k2](/packages/andrewgjohnson-imagettftextblur)

PHPackages © 2026

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