PHP Image Manipulation

Overview

Intervention Image

Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and compose images. The package includes ServiceProviders and Facades for easy Laravel integration.

Latest Version Build Status Monthly Downloads

Requirements

  • PHP >=5.4
  • Fileinfo Extension

Supported Image Libraries

  • GD Library (>=2.0)
  • Imagick PHP extension (>=6.5.7)

Getting started

Code Examples

// open an image file
$img = Image::make('public/foo.jpg');

// resize image instance
$img->resize(320, 240);

// insert a watermark
$img->insert('public/watermark.png');

// save image in desired format
$img->save('public/bar.jpg');

Refer to the official documentation to learn more about Intervention Image.

Contributing

Contributions to the Intervention Image library are welcome. Please note the following guidelines before submitting your pull request.

  • Follow PSR-2 coding standards.
  • Write tests for new functions and added features
  • API calls should work consistently with both GD and Imagick drivers

License

Intervention Image is licensed under the MIT License.

Copyright 2017 Oliver Vogel

Comments
  • Call to undefined method Intervention\Image\Facades\Image::make()

    Call to undefined method Intervention\Image\Facades\Image::make()

    I am unable to make images. I get the following message:

    Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Intervention\Image\Facades\Image::make() open: /Users/Sites/gcfs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php

    I am running Intervention\Image 1.6.2

    opened by nickdelja 39
  • Can't install successfully

    Can't install successfully

    Can't install successfully "require": { "laravel/framework": "4.1.*", "intervention/image": "dev-master", }

    $ composer update Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Installation request for intervention/image dev-master -> satisfiable by i ntervention/image[dev-master]. - intervention/image dev-master requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.

    opened by raselkhancse 34
  • Error reading certain JPG's:

    Error reading certain JPG's: "NotReadableException: Image source not readable"

    I have the latest version installed in my Laravel 4 app, it works 80% of time time but for some reason certain JPG's cause it to throw a 500 error that says "Image source not readable". Any JPG from my Canon 7D DSLR causes that error. If I import the image to Photoshop and re-save it then it'll work just fine. But I've also found the same issue with quite a few images from the web. If I pick 10 images at random about 20% of them will fail consistently.

    Seems like a bug.

    opened by nathanfirth 29
  • Unable to init from given url

    Unable to init from given url

    http://cdn.dota2.com/apps/570/icons/econ/leagues/subscriptions_ren_ren_yi_che_joy_league_first_season_large.1cf72b430b0f4bac6fd480b4f79e82448d8eefde.p

    Why error was thrown in this url using remote url?

    opened by ronjunevaldoz 27
  • Empty content

    Empty content

    Hey there, I am using your package along with the new version of Laravel (5.2) and I am getting and empty content (blank image) using the example that you got posted on your web site.

    Example:

    // create a new image resource $img = Image::canvas(800, 600, '#ff0000');

    // send HTTP header and output image data header('Content-Type: image/png'); echo $img->encode('png');

    I do not know why it happens because I have the same controller doing the duty with the before Laravel version and it works fine.

    any guide will be great.

    thanks!

    opened by gocanto 22
  • Blank image

    Blank image

    This package does not work on Laravel 5.2 all of a sudden. It used to work fine before, but now it does not generate images. The following code:

        Route::get('test', function() {
            $img = \Image::make(public_path().'/images/image-square.png')->resize(300, 200);
    
            return $img->response('jpg');
        });
    

    Used to work just fine, but now it fails resulting in this:

    image

    Whats wrong?

    opened by simplenotezy 21
  • Transparent watermarks? (using insert())

    Transparent watermarks? (using insert())

    Hi,

    I've tried inserting a transparent watermark using a png but the transparent section of the watermark is rendered as white. I've attached a copy of the image it generates along with the watermark I am using.

    516f8cfdddad8_large

    watermark

    Do you know if transparent watermark overlays are possible with the current script, or if I am doing this wrong? The code I used was using the example provided in the docs.

    Thanks

    bug 
    opened by dinglidingli 18
  • Intervention/image with Flysystem

    Intervention/image with Flysystem

    Hello,

    I just discovered Flysystem and learn that it will be integrated into Laravel 5.0. Is it possible to use Flysystem with Intervention/image right now in Larravel 4.2 and how, or do you plan to support it?

    Thanks.

    opened by mikeshow 17
  • PNG w/ transparency to JPEG conversion creates black background

    PNG w/ transparency to JPEG conversion creates black background

    Not sure if there is a workaround when inputting a transparent PNG but generating a JPEG with your package. Let me know if you'd like to see an example or if this is a common problem. Thanks.

    opened by egekhter 16
  • Unable to read exif data unless loaded from path

    Unable to read exif data unless loaded from path

    At the momement it's only possible to read exif data from images loaded from a path.

    exif_read_data supports the ability to load from base64 encoded data-urls. This means it is possible, in theory, to read exif data from images that are loaded through any of the init methods and not just those from file paths.

    Would there be any support from the maintainers of this library to add exif reading capabilities to images loaded through means other than files?


    related: https://github.com/Intervention/image/issues/336

    opened by dhensby 14
  • imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

    imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

    I am using this package with laravel and for some files that I am trying to resize it happens randomly I get this error:

    imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file"

    Stack Frame

    /Applications/MAMP/htdocs/laravelweb/vendor/intervention/image/src/Intervention/Image/Image.php
    
           case IMG_PNG:
           case 3:
           $this->resource = imagecreatefrompng($path);
           break;
    
           case IMG_JPG:
           case 2:
           $this->resource = imagecreatefromjpeg($path);
           break;
    
    opened by altrim 13
  • Write text on the picture. The height of single text is the same

    Write text on the picture. The height of single text is the same

        $text = "上饶市";
        $image = Image::canvas(count(mb_str_split($text))*60, 58);
        $image->text($text, count(mb_str_split($text))*30, 58, function ($font) {
            $font->file(base_path("/fonts/hanzi.ttf"));
            $font->size(58);
            $font->color('#FF3F30');
            $font->align('center');
            
        });
        return $image->response("png");
    
    opened by wanghousheng 0
  • Allow EXIF data to be read from streams.  Fixes: #1190

    Allow EXIF data to be read from streams. Fixes: #1190

    Intervention can create images from filenames and streams (and others).

    PHP:exif_read_data() can read EXIF data from both filenames and streams (since PHP 7.2).

    But when intervention creates an Image from a stream, it reads the data (excluding the EXIF data), and then creates a new stream from just the image data. Thus the EXIF data is lost.

    We lose the original stream (and the EXIF data) here: src/Intervention/Image/AbstractDecoder.php#L125

    We create a new stream from this (EXIF-less) data here: src/Intervention/Image/Commands/StreamCommand.php#L20

    When we create an image from a file, we store the basename/dirname in the Image object. (Actually, in the parent File object). This original data is used to read EXIF data.

    This PR uses a similar approach for images created from a stream. We keep a copy of the original stream and use it when we need the EXIF data.

    I created a test case for this, using a rotated image. This test passes. There are a number of pre-existing test failures, which I haven't investigated.

    opened by fisharebest 1
  • Orientation EXIF tag lost with Imagick and gd drivers

    Orientation EXIF tag lost with Imagick and gd drivers

    The Intervention Image library, when initiating from a stream, loses all EXIF data with the gd driver, while it resets the Orientation EXIF tag to 0 with the Imagick driver.

    The following code, used on this test image:

    <?php
    use Intervention\Image\ImageManager;
    
    $driver = ['driver' => 'Imagick'];
    $image_manager = new ImageManager($driver);
    
    $image = $image_manager->make('./Landscape_3.jpg');
    echo "Instantiated from file path, Imagick:\n";
    echo var_export($image->exif(), TRUE);
    echo "\n";
    
    $stream = fopen('./Landscape_3.jpg', 'r');
    $image = $image_manager->make($stream);
    echo "Instantiated from stream, Imagick:\n";
    echo var_export($image->exif(), TRUE);
    echo "\n";
    
    $driver = ['driver' => 'gd'];
    $image_manager = new ImageManager($driver);
    
    $image = $image_manager->make('./Landscape_3.jpg');
    echo "Instantiated from file path, gd:\n";
    echo var_export($image->exif(), TRUE);
    echo "\n";
    
    $stream = fopen('./Landscape_3.jpg', 'r');
    $image = $image_manager->make($stream);
    echo "Instantiated from stream, gd:\n";
    echo var_export($image->exif(), TRUE);
    echo "\n";
    ?>
    

    Generates the following output:

    Instantiated from file path, Imagick:
    array (
      'FileName' => 'Landscape_3.jpg',
      'FileDateTime' => 1667820935,
      'FileSize' => 348796,
      'FileType' => 2,
      'MimeType' => 'image/jpeg',
      'SectionsFound' => 'ANY_TAG, IFD0',
      'COMPUTED' =>
      array (
        'html' => 'width="1800" height="1200"',
        'Height' => 1200,
        'Width' => 1800,
        'IsColor' => 1,
        'ByteOrderMotorola' => 1,
      ),
      'Orientation' => 3,
      'XResolution' => '72/1',
      'YResolution' => '72/1',
      'ResolutionUnit' => 2,
      'YCbCrPositioning' => 1,
    )
    Instantiated from stream, Imagick:
    array (
      'FileDateTime' => 0,
      'FileSize' => 440610,
      'FileType' => 2,
      'MimeType' => 'image/jpeg',
      'SectionsFound' => 'ANY_TAG, IFD0',
      'COMPUTED' =>
      array (
        'html' => 'width="1800" height="1200"',
        'Height' => 1200,
        'Width' => 1800,
        'IsColor' => 1,
        'ByteOrderMotorola' => 1,
      ),
      'Orientation' => 0,
      'XResolution' => '72/1',
      'YResolution' => '72/1',
      'ResolutionUnit' => 2,
      'YCbCrPositioning' => 1,
    )
    Instantiated from file path, gd:
    array (
      'FileName' => 'Landscape_3.jpg',
      'FileDateTime' => 1667820935,
      'FileSize' => 348796,
      'FileType' => 2,
      'MimeType' => 'image/jpeg',
      'SectionsFound' => 'ANY_TAG, IFD0',
      'COMPUTED' =>
      array (
        'html' => 'width="1800" height="1200"',
        'Height' => 1200,
        'Width' => 1800,
        'IsColor' => 1,
        'ByteOrderMotorola' => 1,
      ),
      'Orientation' => 3,
      'XResolution' => '72/1',
      'YResolution' => '72/1',
      'ResolutionUnit' => 2,
      'YCbCrPositioning' => 1,
    )
    Instantiated from stream, gd:
    array (
      'FileDateTime' => 0,
      'FileSize' => 593747,
      'FileType' => 2,
      'MimeType' => 'image/jpeg',
      'SectionsFound' => 'COMMENT',
      'COMPUTED' =>
      array (
        'html' => 'width="1800" height="1200"',
        'Height' => 1200,
        'Width' => 1800,
        'IsColor' => 1,
      ),
      'COMMENT' =>
      array (
        0 => 'CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 90
    ',
      ),
    )
    

    Notice how, when using a stream, the gd driver loses all EXIF data, while the Imagick driver has the Orientation wrongly set to 0.

    Therefore issue 745 is still open. As the API clearly states that "Image object must be instantiated from file path to read the EXIF data correctly", this is not a bug, but it is in my opinion an important missing feature of the library.

    opened by gmarcon 1
  • Fix: cannot read EXIF data from files with 'falsy' folder name

    Fix: cannot read EXIF data from files with 'falsy' folder name

    If an image is created from a file with a 'falsy' folder name (e.g. 0/image.jpeg), then the code falls into the wrong branch, and fails to read the EXIF data.

    opened by fisharebest 0
PHP 5.3 Object Oriented image manipulation library

Imagine Tweet about it using the #php_imagine hashtag. Image manipulation library for PHP 5.3 inspired by Python's PIL and other image libraries. Requ

Bulat Shakirzyanov 4.3k Jan 6, 2023
This is an image manipulation REST API written in PHP Laravel Framework

Laravel Image Manipulation REST API Demo Here is fully working Demo: https://www.lobiimages.com/ You have to register first in order to generate acces

TheCodeholic 42 Dec 15, 2022
PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation

PHP Thumb NOTICE - This project was recently updated to 2.0 and is PSR-0 compliant and supports Composer integration. Some parts of the documentation

Ian Selby 985 Dec 4, 2022
Wonderfully easy on-demand image manipulation library with an HTTP based API.

Glide Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud i

The League of Extraordinary Packages 2.4k Dec 19, 2022
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

QCode.in 708 Dec 22, 2022
A Laravel Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Gravatar for Laravel 5.x, 6, 7 and 8 Installation First, pull in the package through Composer via the command line: composer require creativeorange/gr

Creativeorange 477 Dec 1, 2022
This plugin adds a new image style for the Core Image block.

This plugin adds a new image style for the Core Image block. Introduction How to use? Go to Gutenberg Editor and add a image block. e.g. Add new image

Mahesh Waghmare 3 Feb 17, 2022
Symfony Bundle to assist in imagine manipulation using the imagine library

LiipImagineBundle PHPUnit PHP-CS-Fixer Coverage Downloads Release This bundle provides an image manipulation abstraction toolkit for Symfony-based pro

Liip 1.6k Dec 30, 2022
🌄 Perceptual image hashing for PHP

ImageHash A perceptual hash is a fingerprint of a multimedia file derived from various features from its content. Unlike cryptographic hash functions

Jens Segers 1.9k Dec 28, 2022
php-gd based image templates

gdaisy A highly experimental image templating system based on PHP-GD to dynamically generate image banners and covers. Installation 1. Require erikahe

Erika Heidi 67 Nov 22, 2022
Grabs the dominant color or a representative color palette from an image. Uses PHP and GD, Imagick or Gmagick.

Color Thief PHP A PHP class for grabbing the color palette from an image. Uses PHP and GD or Imagick libraries to make it happen. It's a PHP port of t

Kevin Subileau 610 Dec 28, 2022
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
image sharing site made in PHP just for fun and freetime

2bart image sharing site made in PHP just for fun and freetime To-do list: upload system [DONE] ✔️ views system [DONE] ✔️ image list system [DONE] ✔️

goom 1 Oct 22, 2021
Image manager extension for the Yii PHP framework.

yii-imagemanager Image manager extension for the Yii PHP framework. Introduction I started this project to reduce the need for boilerplate code when w

Christoffer Niska 23 Aug 28, 2020
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

Image Optimizer This library is handy and very easy to use optimizer for image files. It uses optipng, pngquant, jpegoptim, svgo and few more librarie

Piotr Śliwa 879 Dec 30, 2022
:racehorse: find the size of an image without downloading the whole file. Supports batch requests.

FasterImage FasterImage finds the dimensions or filetype of a remote image file given its uri by fetching as little as needed, based on the excellent

Will Washburn 58 Nov 30, 2022
Extract colors from an image like a human would do.

ColorExtractor Extract colors from an image like a human would do. Install Via Composer $ composer require league/color-extractor:0.3.* Usage require

The League of Extraordinary Packages 1.2k Jan 1, 2023
An open source image hosting service powered by Laravel

Limg An open source image hosting service powered by Laravel Features Upload your image via file, url or ShareX ! Manage your image (custom title, pub

Thomas 56 Dec 16, 2022
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.

Victor Ribeiro 10 Apr 19, 2022