PHP/Graphics Image/imagejpeg

Материал из Web эксперт

Перейти к: навигация, поиск

Basic image script

 
<?php
    $image = imagecreate(400,300);
    // do stuff to the image
    imagejpeg($image, "", 75);
    imagedestroy($image);
?>



Loading an Existing Image

 
<?
    $animage = imagecreatefromjpeg ("images/tiger.jpg")){
    imagejpeg ($animage);
    header ("Content-type: image/jpeg");
    imagedestroy ($animage);
?>



Working with JPGs

 
<?php
    $animage = imagecreate (200, 200);
    $red = imagecolorallocate ($animage, 255, 0, 0);
    imagerectangle ($animage, 0, 0, 200, 200, $red);
    imagejpeg ($animage);
    header ("Content-type: image/jpeg");
    imagedestroy ($animage);
?>