![]() ![]() * Note : You can add more supported image formats adding more parameters to the switch statement. * Resize image given a height and width and return raw image data. The main use of this function is to view an image in the browser, convert any other image type to PNG and applying filters to the image. It supports the png, jpg and gif formats, you can extend the supported methods modifying the switch statement in the function. To save the image to a file, you can use any of these: imagejpeg(), imagepng(), or imagegif(), depending on your desired output format. The imagepng () function is an inbuilt function in PHP which is used to display image to browser or file. To resize an image from a file, use the following method. In this case, we are going to show you a way to resize your images and decrease the quality using plain PHP without use the Imagick library. In that case, DON'T use 'createimagefrompng' and 'imagepng' to output the image. If you care about speed, you probably already cache your generated images to a file. ![]() There are many ways to resize and decrease the quality of an image, and probably it would be better if you create your own function as it may fit better to your needs. PHP internally works with a temporary file when sending the image to the browser, so you'll gain nothing by calling imagepng () twice. How this script works: What this script does, it resizes any PNG, JPG or GIF image to the given width and height and stores the image to a specified location.If the width is set to 0 it will automatically calculate the width by using the height given by keeping the aspect ratio the same is. You may want to resize the uploaded files of the user to save space on your server. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |