Anda di halaman 1dari 4

Image processing dengan php

1. imagecreate

http://127.0.0.1/aauji3/bikgbr01.php
bikin gambar01

<?php
header("Content-Type: image/png");
$im = @imagecreate(210, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 220, 220, 250);
$tulisan = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 8, 10, 15, "A Simple Text String", $tulisan);
imagepng($im);
imagedestroy($im);
?>


2. imagecreatefromjpeg & rotate

http://127.0.0.1/aauji3/bikjpgrot.php
bikin (image dari) jpg dan rotate

<?
header ( "Content-type: image/jpeg" );

$filename = 'Alisia_Rininta.jpg';
$source = imagecreatefromjpeg($filename);
$degrees = 70;

$bg = imagecolorallocate($source, 0, 128, 128);

$rotate = imagerotate($source, $degrees, 0);
imagefill($rotate, 0, 0, $bg);

imagejpeg($rotate);
?>


3. image dan poligon

Image & poligon

<?
$filename = 'Alisia_Rininta.jpg';
$source = imagecreatefromjpeg($filename);

// Allocate a color for the polygon
$col_poly = imagecolorallocate($source, 0, 155, 155);

// Draw the polygon
imagepolygon($source, array(
50, 0, 100, 250,
300, 250, 350, 0
),
4,
$col_poly);

// Output the picture to the browser
header('Content-type: image/png');

imagepng($source);
imagedestroy($source);
?>


4. image and ellipse

<?
$filename = 'Alisia_Rininta.jpg';
$source = imagecreatefromjpeg($filename);

// Choose a color for the ellipse.
$col_ellipse = imagecolorallocate($source, 255, 0, 0);

// Draw the ellipse.
imageellipse($source, 200, 150, 300, 200, $col_ellipse);

// Output the picture to the browser
header('Content-type: image/png');

imagepng($source);
imagedestroy($source);
?>



Untuk memahaminya, lakukan analisis.






Analisis 1. Bahan dari file http://127.0.0.1/aauji3/bikgbr01.php


<?php
header("Content-Type: image/png");
$im = @imagecreate(210, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 220, 220, 250);


imagepng($im); // image ditampilkan ke screen
imagedestroy($im);
?>


Tampilkan image berukuran 210 piksel x 50 piksel sebagai dasar gambar.


$im = @imagecreate(210, 50)
returns an image identifier representing a blank image of specified size.


$background_color = imagecolorallocate($im, 220, 220, 250);
Warna dasar (background) abu-abu : RGB = 220, 220, 250

Anda mungkin juga menyukai