Paint on a jpg image file in PHP

Description

The following code shows how to paint on a jpg image file.

Example


<?php/*from  w  w w.  ja  va 2 s .  co m*/
$mainImage = imagecreatefromjpeg('jpgFile.jpg');   
$mainWidth = imagesx($mainImage);
$mainHeight = imagesy($mainImage);
$thumbWidth = intval($mainWidth / 4);
$thumbHeight = intval($mainHeight / 4);
$myThumbnail = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($myThumbnail, $mainImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
header("Content-type: image/jpeg");
imagejpeg($myThumbnail);
imagedestroy($myThumbnail);
imagedestroy($mainImage);

?>




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text