Giter Site home page Giter Site logo

thumb's Introduction

Thumb

A simple, local image only, thumbnail generation script written in PHP with a file based cache and optional browser based cache.

Example Usage

Firstly, make sure your cache directory is writable, then access the script like so:

<img src='thumb.php?src=./images/photo.jpg&size=400x300' />

Query Parameters

Key Example Value Default Description
src ./images/photo.jpg Absolute path, relative path, or local URL to the source image. Remote URLs are not allowed
size 100, 100x200, 100x, x100, <500 100 Width and/or height must be between 8 and 1500
crop 0 - 1 1 0 = Displays the entire image within the canvas
1 = Crop the image so that the entire canvas is used
trim 0 - 1 0 0 = Displays white space for unused canvas
1 = Removes any white space
zoom 0 - 1 0 For when the size of the canvas is larger than the original image size
0 = Will not enlarge image
1 = Enlarges image beyond the original image size
align c, t, r, b, l, tl, tr, br, bl c Alignment of image when cropped
sharpen 0 - 100 0 Percentage strength of the image sharpness, based on the percentage midpoint of 12 (strong) and 28 (weak)
gray 0 - 1 0 0 = Displays resized image as normal
1 = Converts image to grayscale
ignore 0 - 1 0 0 = Displays resized image as normal
1 = Displays original image file with the animation present

Size Parameter

Value Description
250 Creates a square image 250px in width and 250px in height
250x400 Creates an image 250px in width and 400px in height
250x Creates an image with a width of 250px and the height will be automatically calculated to maintain the aspect ration of the original image
x250 Createse an image with a height of 250px and the width will be automatically calculated to maintain the aspect ration of the original image
<800 Creates an image where the width or height does not exceed 800px. For landscape images the width will be 800px and the height will be automatically calculated, and for portrait images the height will be 800px and the width will be automatically calculated.

Automatic Orientation Correction

If you're dealing with images straight from a camera, some may contain EXIF data which specifies the original orientation the image should be viewed at.

To enable this feature, change the constant ADJUST_ORIENTATION to true.

More information, and an in depth analysis of EXIF Orientation can be found in this article written by @daveperrett

License

Thumb.php is licensed under the MIT license, see LICENSE.md for details.

thumb's People

Contributors

jamiebicknell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thumb's Issues

White square

White square

cache browser - clear
cache folder - clear
error log - 0
Locally - works

screenshot_1

Decrepated in PHP 8

PHP Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

Line 193: $trim_w = ($trim) ? 1 : ($w == '') ? 1 : 0;

Set image quality

Sometimes the thumbsnail generated with this library have a bigger file size then the original files, even when they have a bigger resolution. The problem is, that the generated images (jpg) have always 100% image quality. It would be great to set the file quality in the parameter or the library should use the quality of the original image.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.