PHP dynamically generates random images of a specified size, _php tutorial

Source: Internet
Author: User

PHP dynamically generates random images of a specified size,


The example in this paper describes how PHP dynamically generates random images of a specified size. Share to everyone for your reference, as follows:

<?php$image_width = +, $image _height = +, $image _str = ", if (Isset ($_get[' W '])) {$image _width = intval ($_get[' W ']) ;} if (Isset ($_get[' h '))) {$image _height = intval ($_get[' h ']);} if (Isset ($_get[' s ')) {$image _str = $_get[' s '];} $img = Imagecreate ($image _width, $image _height); $color = Imagecolorallocate ($img, Mt_rand (157,255), Mt_rand (157,255), Mt_rand (157,255)) Imagefilledrectangle ($img, 0, $image _height, $image _width, 0, $color); $step = Mt_rand ($start) = Mt_rand (0, $step); $color = Imagecolorallocate ($img, Mt_rand (200,255), Mt_rand (200,255), Mt_rand (200,255)); Imagesetthickness ($img, Mt_rand (3)), if ($image _height > $image _width) {for ($i = $start; $i < $image _height * 2; $i  + = $step) {imageline ($img, 0, $i, $i, 0, $color);  }}else{for ($i = $start; $i < $image _width * 2; $i + = $step) {imageline ($img, $i, 0, 0, $i, $color);  }}if ($image _str! = ") {$black = imagecolorallocate ($img, 0, 0, 0); Imagestring ($img, 5, 5, $image _str, $black);} Header (' Content-tyPe:image/png '); Imagepng ($img); Imagedestroy ($img); 

More readers interested in PHP related content can view this site topic: "PHP graphics and picture Operation skills Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP date and Time usage summary", " PHP Primer for object-oriented programming, PHP string Usage Summary, Introduction to PHP+MYSQL database operations, and PHP common database operations Tips Summary

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • PHP generated image verification code-with five kinds of verification code
    • How to generate thumbnails of pictures using PHP
    • Example of PHP generated image verification code
    • How PHP uses Imagick to generate images
    • PHP implementation of the QQ space to get the user name of the current user and generate pictures
    • Create a picture on a Web page with PHP code
    • How to generate thumbnail images in bulk in PHP
    • PHP Generate Image Verification code
    • How PHP generates image thumbnails
    • PHP generated image thumbnail class code sharing based on GD2 graphics library
    • Phplot Generating Picture class usage
    • PHP Generate image Verification code, click to switch instances
    • PHP reads the phone number from the database and generates a picture

http://www.bkjia.com/PHPjc/1113696.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113696.html techarticle PHP dynamically generate a random image of the size of the method, the example of this paper describes the dynamic generation of PHP random image size of the method. Share to everyone for your reference, as follows: Php$ima ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.