O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Php image functions.pptx

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
OOP in PHP.pptx
OOP in PHP.pptx
Carregando em…3
×

Confira estes a seguir

1 de 17 Anúncio

Mais Conteúdo rRelacionado

Mais recentes (20)

Anúncio

Php image functions.pptx

  1. 1. IMAGE FUNCTION • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow imagepng($im,"image.png"); imagedestroy($im); } ?>
  2. 2. line • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $red = imagecolorallocate($im, 255, 0, 0); // red $blue = imagecolorallocate($im, 0, 0, 255); // blue imageline ($im, 5, 5, 195, 5, $red); imageline ($im, 5, 5, 195, 195, $blue); imagepng($im,"image.png"); imagedestroy($im); } ?>
  3. 3. Rectangle • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $red = imagecolorallocate($im, 255, 0, 0); // red $blue = imagecolorallocate($im, 0, 0, 255); // blue imagerectangle ($im, 5, 10, 195, 50, $red); imagefilledrectangle ($im, 5, 100, 195, 140, $blue); imagepng($im,"image.png"); imagedestroy($im); } ?>
  4. 4. Circle • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $red = imagecolorallocate($im, 255, 0, 0); // red $blue = imagecolorallocate($im, 0, 0, 255); // blue imageellipse($im, 50, 50, 40, 60, $red); imagefilledellipse($im, 150, 150, 60, 40, $blue); imagepng($im,"image.png"); imagedestroy($im); } ?>
  5. 5. Arc • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $red = imagecolorallocate($im, 255, 0, 0); // red $blue = imagecolorallocate($im, 0, 0, 255); // blue imagearc($im, 20, 50, 40, 60, 0, 90, $red); imagearc($im, 70, 50, 40, 60, 0, 180, $red); imagearc($im, 120, 50, 40, 60, 0, 270, $red); imagearc($im, 170, 50, 40, 60, 0, 360, $red); imagefilledarc($im, 20, 150, 40, 60, 0, 90, $blue, IMG_ARC_PIE); imagefilledarc($im, 70, 150, 40, 60, 0, 180, $blue, IMG_ARC_PIE); imagefilledarc($im, 120, 150, 40, 60, 0, 270, $blue, IMG_ARC_PIE); imagefilledarc($im, 170, 150, 40, 60, 0, 360, $blue, IMG_ARC_PIE); imagepng($im,"image.png"); imagedestroy($im); } ?>
  6. 6. Text • <?php create_image(); print "<img src=image.png?".date("U").">"; function create_image(){ $im = @imagecreate(200, 200)or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $red = imagecolorallocate($im, 255, 0, 0); // red imagestring($im, 1,file:///C:/apache2triad/htdocs/0image/tutorial1.html 5, 10, "Hello !", $red); imagestring($im, 2, 5, 50, "Hello !", $red); imagestring($im, 3, 5, 90, "Hello !", $red); imagestring($im, 4, 5, 130, "Hello !", $red); imagestring($im, 5, 5, 170, "Hello !", $red); imagestringup($im, 5, 140, 150, "Hello !", $red); imagepng($im,"image.png"); imagedestroy($im); } ?>
  7. 7. Image Rotate Example • <?php $im = imagecreatefrompng("image.png"); $yellow = imagecolorallocate($im, 255, 255, 0); $rotate = imagerotate($im, 90,$yellow); imagepng($rotate,"image_rotated.png"); imagedestroy($im); print "<img src=image.png> - <img src=image_rotated.png>"; ?>
  8. 8. Image Create From • imagecreatefromgif -- Create a new image from file or URL • imagecreatefromjpeg -- Create a new image from file or URL • imagecreatefrompeg -- Create a new image from file or URL • imagecreatefromwbmp -- Create a new image from file or URL • imagecreatefromxbm -- Create a new image from file or URL • imagecreatefromxpm -- Create a new image from file or URL
  9. 9. Resize Image • <?php $original_image = imagecreatefrompng("image.png"); // obtain data from selected image $image_info = getimagesize("image.png"); // data contained in array $image_info may be displayed in next line // print_r($image_info) $width = $image_info[0]; // width of the image $height = $image_info[1]; // height of the image // we will reduce image size to 70%, so new dimensions must be calculate $new_width = round ($width*0.7); $new_height = round ($height*0.7); $new_image = imagecreate($new_width, $new_height); imagecopyresized($new_image, $original_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagepng($new_image,"resized_image.png"); imagedestroy($new_image); print "<img src=image.png> <br>Resized image<BR> <img src=resized_image.png>"; ?>
  10. 10. Get A Portion of Image • <?php // get the original image $original_image = imagecreatefrompng("image.png"); // create new image $new_image = imagecreate(200, 200); // define red color (it will be the background of the new image) $red = imagecolorallocate($new_image, 255, 0, 0); imagecopyresized($new_image, $original_image, 75, 75, 0, 0, 100, 100, 100, 100); imagepng($new_image,"new_image.png"); imagedestroy($new_image); print "<img src=image.png> <br>New image<BR> <img src=new_image.png>"; ?>
  11. 11. Modified an Image • <?php // get the original image $im = imagecreatefrompng("image.png"); // new color $blue = imagecolorallocate($im, 0, 0, 255); // blue $red = imagecolorallocate($im, 255, 0, 0); // red imagefilledrectangle ($im, 80, 5, 195, 60, $blue); imagestring($im, 5, 80, 5, "Modified!", $red); imagepng($im,"modified_image.png"); imagedestroy($im); print "<img src=image.png> <br>Modified image<BR> <img src=modified_image.png>"; ?>
  12. 12. Image Created but not Saved • <?php header("Content-type: image/png"); $im = @imagecreate(200, 200) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 255, 255, 0); // yellow $blue = imagecolorallocate($im, 0, 0, 255); // blue imagestring($im, 3, 5, 5, "My Text String", $blue); imagepng($im); imagedestroy($im); ?>

×