Code Monkey home page Code Monkey logo

php_image_resize's Introduction

PHP - easy and smart image resize function

resizing a image with 1 simple function

How to use : (code snippet)

//indicate which file to resize (can be any type jpg/png/gif/etc...)
$file = 'your_path_to_file/file.png';

//indicate the path and name for the new resized file
$resizedFile = 'your_path_to_file/resizedFile.png';

//call the function
smart_resize_image($file , null, SET_YOUR_WIDTH , SET_YOUR_HIGHT , false , $resizedFile , false , false ,100 );
smart_resize_image(null , file_get_contents($file), SET_YOUR_WIDTH , SET_YOUR_HIGHT , false , $resizedFile , false , false ,100 );

//done!

Funcion call (with doc)

 /**
 * easy image resize function
 * @param $file - file name to resize
 * @param  $string - The image data as a string
 * @param $width - new image width
 * @param $height - new image height
 * @param $proportional - keep image proportional, default is no
 * @param $output - name of the new file (include path if needed)
 * @param $delete_original - if true the original image will be deleted
 * @param $use_linux_commands - if set to true will use "rm" to delete the image, if false will use PHP unlink
 * @param $quality - enter 1-100 (100 is best quality) default is 100
 * @return boolean|resource
 */
function smart_resize_image($file,
                            $string = null,
                            $width = 0,
                            $height = 0,
                            $proportional = false,
                            $output = 'file',
                            $delete_original = true,
                            $use_linux_commands = false,
 $quality = 100
 ) {code code code...

Enjoy!

php_image_resize's People

Contributors

nimrod007 avatar maxim avatar gedrox avatar bobrobh avatar xjsv avatar henridv avatar nunorafaelrocha avatar tchalvak avatar yuzurus 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.