Create images with embedded text using advanced typography

Overview

Image with Text

This class makes it super easy to render images with multiple, independently styled text blocks. You can control each text block's alignment, color, font, line height, and size. You may also position each text block with specific X and Y coordinates relative to the source image.

Installation

Install this library with Composer. Add this to your composer.json file:

{
    "require": {
        "nmcteam/image-with-text": "~2.0"
    }
}

Then run composer install.

Usage

Here's a quick demonstration. You can find this full working demo in the example/ directory.

<?php
require '../vendor/autoload.php';

// Create image
$image = new \NMC\ImageWithText\Image(dirname(__FILE__) . '/source.jpg');

// Add styled text to image
$text1 = new \NMC\ImageWithText\Text('Thanks for using our image text PHP library!', 3, 25);
$text1->align = 'left';
$text1->color = 'FFFFFF';
$text1->font = dirname(__FILE__) . '/Ubuntu-Medium.ttf';
$text1->lineHeight = 36;
$text1->size = 24;
$text1->startX = 40;
$text1->startY = 40;
$image->addText($text1);

// Add another styled text to image
$text2 = new \NMC\ImageWithText\Text('No, really, thanks!', 1, 30);
$text2->align = 'left';
$text2->color = '000000';
$text2->font = dirname(__FILE__) . '/Ubuntu-Medium.ttf';
$text2->lineHeight = 20;
$text2->size = 14;
$text2->startX = 40;
$text2->startY = 140;
$image->addText($text2);

// Render image
$image->render(dirname(__FILE__) . '/destination.jpg');

How to Contribute

  • Fork the repo on GitHub and send a pull request
  • Find a list of TODOs on the GitHub issue tracker

We have not written any unit tests just yet, but we hope to do that soon.

Author

Josh Lockhart

Copyright

(c) 2013 New Media Campaigns

License

MIT

You might also like...
Simple, fast and secure archive for images
Simple, fast and secure archive for images

Slim Image Archive Simple*, fast and secure archive for images: Create multiple categories with multiple albums with multiple images! Manage multiple

The image server plugin allows you to add responsive images via config without extra elements

Grav image server plugin adds picture tag with loading, responsive, high density images

Contao extension to provide the possibility of defining alternative images to be used on different output devices.
Contao extension to provide the possibility of defining alternative images to be used on different output devices.

Contao Image Alternatives This extensions expands the capabilities of using responsive images with art direction in Contao. You will have the possibil

⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.
⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.

⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.

A simple page view counter that store data as text and shows data as a PNG image

Image Counter A simple page view counter that store data as text and shows the counter as a PNG image.

Create material deisgn avatars for users just like Google Messager. It may not be unique but looks better than Identicon or Gravatar.
Create material deisgn avatars for users just like Google Messager. It may not be unique but looks better than Identicon or Gravatar.

Material-Design-Avatars Create material deisgn avatars for users just like Google Messager. It may not be unique but looks better than Identicon or Gr

Laravel Favicon - Create dynamic favicons based on your environment settings.
Laravel Favicon - Create dynamic favicons based on your environment settings.

Laravel Favicon Create dynamic favicons based on your environment settings. Laravel Package Development If you want to learn how to create reusable PH

Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image

Laravel ImageUp The qcod/laravel-imageup is a trait which gives you auto upload, resize and crop for image feature with tons of customization. Install

PHP Exif Library - library for reading and writing Exif headers in JPEG and TIFF files using PHP.

PEL: PHP Exif Library README file for PEL: PHP Exif Library. A library with support for reading and writing Exif headers in JPEG and TIFF images using

Comments
  • Updated Text.php

    Updated Text.php

    Update text.php so that text lines can support text sentences like.

    "Really love NMCTeam Image-with-text \n - John Ballinger" where - John Ballinger will be rendered on a new line.

    opened by sponno 0
  • Allow for multiple backends

    Allow for multiple backends

    Currently this is tied directly to the Intervention image library, which depends on GD2. We should abstract this so that it does not depend on any particular image library.

    opened by nmcteam 0
Releases(2.2.0)
Owner
New Media Campaigns
New Media Campaigns
ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library

================================ ImageWorkshop class ================================ Summary and features Really flexible and easy-to-use PHP class t

Clément Guillemain 853 Dec 27, 2022
GifCreator is a PHP class that creates animated GIF from multiple images

================================ GifCreator ================================ GifCreator is a PHP class to create animated GIF from multiple images For

Clément Guillemain 320 Dec 15, 2022
Easily convert images with Glide

Easily convert images with Glide This package provides an easy to use class to manipulate images. Under the hood it leverages Glide to perform the man

Spatie 374 Dec 30, 2022
A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API.

A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API. This enables you to build cool little tricks, like showing your latest followers or sponsors, latest content creted, a qrcode to something, a progress bar for some goal, and whathever you can think of.

Erika Heidi 172 Jan 5, 2023
Optimize your images on the fly with Glide for Laravel.

Glide for Laravel Optimize your images on the fly with Glide for Laravel. Support us Like our work? You can support us by purchasing one of our produc

Flowframe 53 Oct 17, 2022
Upload SVG images in Magento 2.x

Upload SVG images in Magento 2.x This extension for Magento 2 allows uploading SVG images in the following sections: wysiwyg editor in static blocks a

Magegadgets 6 Dec 23, 2022
PHP library to resize, scale and crop images.

PHP library to resize, scale and crop images.

Gumlet 1.1k Jan 3, 2023
Inline Images Protocol implementation for PHP.

Imgecho Echo the image on iTerm App using Inline Images Protocol. Installation Use Composer to install. composer require mileschou/imgecho Usage Use

MilesChou 4 May 30, 2022
The Tinify API allows you to compress and optimize WebP, JPEG and PNG images.

The Tinify API allows you to compress and optimize WebP, JPEG and PNG images. It is designed as a REST service. The client libraries in various languages make it very easy to interact with the Tinify API.

Devscast 10 May 13, 2022
The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API

Gregwar's Image class The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API. Installation With compos

Grégoire Passault 958 Dec 29, 2022