PHP/Graphics Image/imagecreatefromjpeg

Материал из Web эксперт
Перейти к: навигация, поиск

Creating an Image from an Existing Image

   <source lang="html4strict">

Loading an Existing Image <?php

   $animage = imagecreatefromjpeg ("myImage.jpg"); 
   imagejpeg ($animage); 
   header ("Content-type: image/jpeg"); 
   imagedestroy ($animage); 

?>

 </source>
   
  


Saving and Outputting the Modified Image

   <source lang="html4strict">

<?php $animage = imagecreatefromjpeg ("myImage.jpg"); $black = imagecolorallocate ($animage, 0, 0, 0); $topleftx = 10; $toplefty = 40; $bottomrightx = 700; $bottomrighty = 90; $strlen = (strlen ($_GET["whattosay"]) * imagefontwidth (5)); $xcoord = (((($bottomrightx - $topleftx) - $strlen) / 2) + $topleftx); imagestring($animage, 5, $xcoord, 50, $_GET["whattosay"], $black); imagejpeg ($animage); header ("Content-type: image/jpeg"); imagejpeg ($animage,"savedimages/" . time() . ".jpg"); imagedestroy ($animage); ?>

 </source>