PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation

Related tags

Imagery PHPThumb
Overview

Build Status

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 are incorrect as they haven't been updated for the new version. Your 1.0 code is not compatible with 2.0! Please review the updated examples for how to use the new version.

PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation. It features the ability to resize by width, height, and percentage, create custom crops, or square crops from the center, and rotate the image. You can also easily add custom functionality to the library through plugins. It also features the ability to perform multiple manipulations per instance (also known as chaining), without the need to save and re-initialize the class with every manipulation.

More information and documentation is available at the project's wiki: https://github.com/masterexploder/PHPThumb/wiki

Documentation / Help

I've tried to thoroughly document things as best I can, but here's a list of places to find documentation / help:

  • Documentation - Your best friend, the library docs
  • Forums - Got questions, comments, or feedback? This is the place to visit
  • Developer Docs - Auto-generated docs for developers… these cover the code itself

License

PHP Thumb is released under MIT license.

Comments
  • Merge 2.0 branch into master

    Merge 2.0 branch into master

    I would suggest creating a tag at the current state of master and then merge in version 2.0.

    I understand version 2.0 works a lot different then the current version. When the merge is performed, the repository can be submitted to Packagist and Travis-CI, and people can also update the documentation.

    Thoughts @masterexploder and @Blackshawk?

    opened by mikealmond 13
  • new plugin

    new plugin

    Hi! I made a new little plugin. Maybe it could be useful for somebody. It makes the rotation of jpeg images depends on the EXIF headers in their source. Now the image saves in only one, horisontal, orientation. And thats why some images became rotated the wrong way.

    Cheers Nick.

    opened by nik-kor 11
  • write plugin greyscale (images black and white)

    write plugin greyscale (images black and white)

    Hello I want to make a plugin for images in black and white. I read the documentation but I do not understand how? Would you advice or example to make my plugin ? Best regards

    opened by gtraxx 8
  • PHPThumb Error

    PHPThumb Error

    Hi there,

    Warning: opendir(/home6/johngrae/public_html/graeterartgallery/phpthumb/thumb_plugins) [function.opendir]: failed to open dir: No such file or directory in /home6/johngrae/public_html/graeterartgallery/phpthumb/PhpThumb.inc.php on line 213

    Where line 213 is this if statement: if ($handle = opendir($pluginPath)) In the function: public function loadPlugins ($pluginPath)

    This is the error I am getting. PHPThumb seems to be still working, however, this error is showing and I am not sure why as all files are present. Please let me know how to get rid of this error!

    Thanks in advance!!!

    Lindsay

    opened by LMcGhee-zz 8
  • Reorganization, namespaces, unit tests

    Reorganization, namespaces, unit tests

    I started a reorganization of this project a few days ago and I had a few goals in mind.

    • PHP 5.3 namespaces (PSR-0 compliant)
    • Project be autoload-able
    • Refactor class structure
    • Refactor plugin system
    • Add unit testing
    • Add project to Packagist for quick installation and autoloading

    The library is now fully compatible with existing frameworks like ZF, Symfony2, and others that sport standard autoloaders. All classes are namespaced, the plugin system has been refactored (and is, I believe, much more effective and existing plugins can be easily ported).

    PHPUnit tests have been included and as of the latest commit code coverage is at about 15% (up from 0% - there were no automated tests when I started). These tests cover most of the "operational" work rather than image processing. Such tests will probably need to be added by smarter people than me.

    opened by Blackshawk 7
  • new Adaptive resize that goes from top (not from center)

    new Adaptive resize that goes from top (not from center)

    I'm loving the ease of this library.

    However, I'm racking my brains to get images to resize then crop from the top.

    It's for a womens clothing catalog. We want uniform sizes... but not cropped drastically like vanilla cropping does. Adaptive resize is almost perfect, except that whenever I use adaptive resize (croping from center) it cuts parts of the models head off.

    What do you think??? Thanks in advance!!

    opened by chuckienorton 7
  • Fatal error: Allowed memory in GdThumb.inc.php

    Fatal error: Allowed memory in GdThumb.inc.php

    Hi guys,

    I have a bit of an issue I have users that upload images to my site, they are resized to 480x360 which are obviously quite small.

    The problem is some of my users are uploading photos straight off their digital camera which are around 2mb. (Silly, i know) but it kinda seems rude to tell them to go resize them and come back. The majority of people will give up and not bother coming back.

    I seem to get their initial image onto my server no problems. It hits a problem when it comes to the resize and watermark creation:

    $thumb = PhpThumbFactory::create($inputs); $thumb->resize(480,360)->createWatermark('../carcru-watermark.png')->save($input);

    I have tried adding unset($thumb); as well as suggested to free memory.

    I have also increased the memory limit using ini_set("memory_limit","256M"); in the GdThumb.inc.php. (Thinking perhaps my host is the issue?)

    This makes no difference It still throws the error below:

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 17152 bytes) in /home/carcru/public_html/GdThumb.inc.php on line 113

    Is there any other option or can anyone shed more light on this? Obviously I could check their original upload size and tell them the photo is too big but I'd like to keep it graceful for the user.

    opened by shwebdev 7
  • file size of jpgs

    file size of jpgs

    Hello, i have a problem when uploading an image. For example if i upload a 18k jpg 200x303 and do:

    $thumb->Resize(300, 450)->save('image.jpg');

    i end up with a 30k jpg file, why is that? the image should be untouched, what am i doing wrong? gifs and pngs are working fine.

    opened by nicmo 5
  • Plugins not working

    Plugins not working

    Plugins, including the offcial one, are not working. Probably has something to do with overloading!

    Warning: Parameter 6 to GdReflectionLib::createReflection() expected to be a reference, value given in C:\xampp\htdocs\new\includes\phpthumb\ThumbBase.inc.php on line 212

    Fatal error: Uncaught exception 'RuntimeException' with message 'Cannot show image, headers have already been sent' in C:\xampp\htdocs\new\includes\phpthumb\GdThumb.inc.php:569 Stack trace: #0 C:\xampp\htdocs\new\includes\phpthumb\proov.php(6): GdThumb->show() #1 {main} thrown in C:\xampp\htdocs\new\includes\phpthumb\GdThumb.inc.php on line 569

    opened by keevitaja 4
  • Fix for php 7.2

    Fix for php 7.2

    Version 7.2 throws an warning when setOptions method is called Warning: sizeof(): Parameter must be an array or an object that implements Countable in /path/to/project/vendor/masterexploder/phpthumb/src/PHPThumb/GD.php on line

    Since $options variable is just declared and not defined code throws warning.

    Best, Andrej

    opened by Andrej- 3
  • Not working when image size greater than 1.5 MB

    Not working when image size greater than 1.5 MB

    I don't know if that's suppose to happen... It works with jpg until 1.5 MB, with image ex. 1.8 MB it just stops, lefting the page incomplete. Am I missing something? screen

    opened by ApofisXII 3
  • Fixing return typo annotation in rotateImage method

    Fixing return typo annotation in rotateImage method

    Hi,

    With PHP 7.2 and Symfony 3.4 we can't extract translation due to a small typo in the docblock of the rotateImage method. I fix it, hopes it helps others :)

    PHP: PHP 7.2.34-30+0~20220614.72+debian11 Symfony: v3.4.49 Command: php bin/console translation:extract fr de en es ja --dir=./src/ --dir=./app/Resources/TwigBundle/views --dir=./app/Resources/views/ --output-dir=./app/Resources/translations --domain=mail

    [Doctrine\Common\Annotations\AnnotationException]
    [Semantical Error] The annotation "@retunrn" in method PHPThumb\GD::rotateImage() was never imported. Did you ma
    ybe forget to add a "use" statement for this annotation?

    @retunrn error

    opened by slig36 0
  • A false start. Please clean up the mess!

    A false start. Please clean up the mess!

    Link to documentation (https://wiki.github.com/iselby/PHPThumb/) is DEAD!

    Link to forums (http://phpthumb.gxdlabs.com/forums) is DEAD!

    Link to developer docs (http://phpthumb.gxdlabs.com/apidocs) is DEAD!

    Example on the 'Configuration Wiki page' is incorrect. File "ThumbLib.inc.php" DOES NOT EXIST

    Maybe time to clean up the mess?

    opened by R-W-C 6
  • [PHP 7.2] sizeof(): Parameter must be an array or an object that implements Countable

    [PHP 7.2] sizeof(): Parameter must be an array or an object that implements Countable

    I know that this project seems abandoned... But here's the issue with sizeof:

                                                                                                                 
      [PHPUnit_Framework_Exception] sizeof(): Parameter must be an array or an object that implements Countable  
                                                                                                                 
    #1  Codeception\Subscriber\ErrorHandler->errorHandler
    #2  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/GD.php:972
    #3  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/PHPThumb.php:64
    #4  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/GD.php:89
    #5  /home/travis/build/Maslosoft/Mangan/src/Model/Image.php:101
    #6  /home/travis/build/Maslosoft/Mangan/src/Model/File.php:145
    #7  /home/travis/build/Maslosoft/Mangan/vendor/maslosoft/mangantest/tests/unit/GridFS/ImageTest.php:34
    #8  GridFS\ImageTest->testIfWillResizeSavedImage
    

    The problem is that options are defined without value:

        protected $options;
    

    So in fact are initialized with null, not empty array.

    Then there is check for array size with sizeof (alias for count).

    Workaround

    Create class:

    class ImageThumb extends GD
    {
    	protected $options = [];
    }
    

    And use this new class instead of GD.

    opened by pmaselkowski 4
  • Command Injection Vulnerability?

    Command Injection Vulnerability?

    When googling for "PHPThumb", one of the suggested searches is "PHPThumb exploit". One of the results links to this:

    http://www.securityfocus.com/bid/39605/exploit

    Attackers can exploit this issue via a browser. Reports indicate that this issue is being exploited in the wild.

    The following example URIs are available:

    http://www.example.com/phpThumb_1.7.9/phpThumb.php?src=Z:/home/example.com/www/kartinka.jpg&fltr[]=blur|5 -quality 75 -interlace line "Z:/home/example.com/www/kartinka.jpg" jpeg:"Z:/home/example.com

    http://www.example.com/phpThumb_1.7.9/phpThumb.php?src=/home/example.com/public_html/kartinka.jpg&fltr[]=blur|5 -quality 75 -interlace line "/home/example.com/public_html/kartinka.jpg" jpeg:"/home/example.com/public_html/kartinka.jpg" ; ls -la ;&phpThumbDebug=9

    Is this is an actual issue?

    opened by dliebner 2
  • Compress image

    Compress image

    Hi there! First of all, I want to thank you for the great documentation you've provided on the Wiki. It really helped me!

    I see it's possible to resize images and set the jpegQuality, but is it also possible to set the PNG quality? Many thanks!

    opened by TheLeonKing 0
Releases(2.1)
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
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
PHP Image Manipulation

Intervention Image Intervention Image is a PHP image handling and manipulation library providing an easier and expressive way to create, edit, and com

null 13k Jan 3, 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
phpThumb() - The PHP thumbnail generator

phpThumb phpThumb() - The PHP thumbnail generator phpThumb() uses the GD library and/or ImageMagick to create thumbnails from images (GIF, PNG or JPEG

James Heinrich 292 Dec 17, 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
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
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
PHPExif is a library which gives you easy access to the EXIF meta-data of an image

PHPExif v0.6.4 PHPExif is a library which gives you easy access to the EXIF meta-data of an image. PHPExif serves as a wrapper around some native or C

null 135 Dec 4, 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
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
: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