GithubHelp home page GithubHelp logo

matheus2212 / php-render-image Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 783 KB

Script that will render the image using the given dimmensions and image file.

License: MIT License

PHP 88.58% HTML 11.42%
image-resizer image-resizing php-image-resizer php-image

php-render-image's Introduction

PHP Render Image

This script will render the image on the server side.

Just use the HTML and PHP $_GET sintax to render the image you want.

The script sets the header depending on the type of file (jpeg -> header(image/jpeg));

This scrips allows you to:

  • Fit image on specified dimmensions
  • Cut image
  • Enlarge image
  • Keep original dimmensions

If the image doesn't match any of the specified dimmensions, the script will automatically render it with the most suitable dimmensions.

All renders keeps image aspect ratio "as is".


For example:

<img src="render_image.php?image=../path/to/image.jpeg&mode=profile_name" />

It can also be set using URL (the script have a domain validation).

<img src="render_image.php?image=../path/to/image.jpeg&profile=profile_name&mode=cut&width=1080&height=720" />
<img src="render_image.php?image=../path/to/image.jpeg&profile=profile_name&mode=fit&width=1080&height=720" />
<img src="render_image.php?image=../path/to/image.jpeg&profile=profile_name&mode=scale&width=1080&height=720" />
<img src="render_image.php?image=../path/to/image.jpeg&profile=profile_name&mode=original" />

Example of render profile:

$setup = array(
    /*"profile_name" => array( // é o nome da configuração - evite repetir
        "width" => 300, // width in pixels
        "height" => 300, // height in pixels
        "mode" => 'cut', // render mode (cut, fit, scale, original)
        "background_color" => "#000000" // transparent for .png images
    ),*/
    "screenshot" => array(
        "width" => 1200,
        "height" => 900,
        "mode" => 'cut',
    ),
);

Enjoy!

php-render-image's People

Contributors

matheus2212 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.