Does anyone know how to make a image have rounded corners using a PHP script?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Download easyphpthumbnail.class.php from this link
from this you can resize and convert image into rounded image.
in below example image is converted into transparent circle image.
This script shows how to apply rounded corners to images using PHP and GD Library. It is as simple as drawing four quadrants of a circle over the four corners of the image. The circle itself has to be transparent.
This script, on the other hand, generates rounded corner graphics for HTML or CSS based solutions. It generates the four corners that you can overlay over an image using CSS positioning or HTML tables.
its easy to create some rounded thumbs using php, just use Thumbnailer :)
Instead of modifying the image, why not just wrap it in some HTML that has images at each corner that overlay the original to provide the appearance of rounded corners?
By doing the image editing in your .php script, you're going to put undue load on your web server, and that means your application won't scale well.
You will need the GD library for that. There must be a lot of examples on the web. Here is one :
http://www.assemblysys.com/dataServices/php_roundedCorners.php
How to use it?
Needless to say, PHP and the GD library needs to be installed on your server. You’ll also need a png file of the corner. You can use one of these corner images if you want: [http://assemblysys.com/wp/wp-content/uploads/2013/03/rounded_corners.zip]
Just paste the code above and save it in a .php file. Make the necessary changes to the $images_dir and $corner_source variables (lines 10 and 11). Link the src attribute of your image to that file, using the following URL variables:
Examples
There are a lot of options available, you can find them using Google. The easiest way though is using the Thumbnailer. It's as simple as two lines of code:
Fun it is, isn't it? :) There are a lot of other options available. The corners will be antialiased.