PHP generates an image in two ways: GD
// Default logoprivate function generation_default_img ($ width, $ height, $ img_type, $ output_url) {// check whether the default logo exists if (file_exists ($ output_url) {return ;} else {// create a true color image and return an image Identifier header ('content-Type: image/png '); $ im = imagecreate ($ width, $ height ); // assign color $ bg_color = imagecolorallocate ($ im, 255,255,255); // draw a rectangle and fill it with imagefilledrectangle ($ im, 0, 0, $ width, $ height, $ bg_color); imagepng ($ im, $ output_url); imagedestroy ($ im );}}
Method 2: Imagick
// Default logoprivate function generation_default_img ($ width, $ height, $ img_type, $ output_url) {// Build the canvas $ obj_default = new Imagick (); $ obj_default-> newimage ($ width, $ height, 'white'); $ obj_default-> setimageformat ($ img_type); $ obj_default-> writeimage ($ output_url ); $ obj_default-> clear (); // destroy the object $ obj_default-> destroy ();}