From 9b53d281d7231a5a2bf6a089a0aacf004d635b25 Mon Sep 17 00:00:00 2001 From: Martin Kraemer Date: Thu, 19 Oct 2000 09:23:47 +0000 Subject: [PATCH] Porting Aid for dealing with the problem that some PHP's have ImageGIF(), others have ImagePNG() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@34111 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/image.xml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/functions/image.xml b/functions/image.xml index 31d3366d0f..b25be6f548 100644 --- a/functions/image.xml +++ b/functions/image.xml @@ -1058,6 +1058,33 @@ function LoadPNG ($imgname) { GD library in version 1.6, this function is not available if you are using that version of the GD library. + + The following code snippet allows you to write more + portable PHP applications by auto-detecting the + type of GD support which is available. Replace + the sequence Header("Content-type: image/gif"); + ImageGif($im); by the more flexible sequence: + + +<?php + if(function_exists("imagegif")) { + Header("Content-type: image/gif"); + ImageGif($im); + } + elseif(function_exists("imageJpeg")) { + Header("Content-type: image/jpeg"); + ImageJpeg($im, "", 0.5); + } + elseif(function_exists("imagePng")) { + Header("Content-type: image/png"); + ImagePng($im); + } + else + die("No image support in this PHP server"); +?> + + +