vanderlay Posted November 29, 2006 Share Posted November 29, 2006 FIXED - need to ensure all paths a relative if using STYLE tags to call image via higher dir.... :-\UPDATED - I got the file below to work if i called it as an image not as a filecallimage.html[code]<img src="image.php">[/code]however now the image will only show if the script calling the image is in the same DIR as the image script, ieworks - displays imagewww/callimage.htmlwww/image.phpdoes not display image (the script is called but no image displays)www/callimage.htmlwww/images/image.phpis there a way to put the image into a $var or similar so the image can be called from another directory?thanksArtHello,I am trying to get an image to resize using GD. The code works if the page sits aloneimage.php[code]if(!extension_loaded('gd')){ if(strtoupper(substr(PHP_OS,0,3)) == 'WIN'){ dl('php_gd2.dll'); }else{ dl('gd.so'); }}/* Set the width (in pixels) for the smaller version - we will calculate the smaller version height based on the dimensions of the source image */$smallwidth = 100;/* Create an image resource from the source graphic*/$im = ImageCreateFromGif('001.gif');/* Get the source image dimensions: */$srcwidth = ImagesX($im);$srcheight = ImagesY($im);/* By dividing our smaller version width by the source image width, we will have the correct proportion for the smaller version height: */$proportion = $smallwidth / $srcwidth;$smallheight = round($srcheight * $proportion);/* Now we can create a new image resource for the smaller version: */$small = ImageCreateTrueColor($smallwidth, $smallheight);/* Finally, we can copy the contents of $im into $small and resize it at the same time: */ImageCopyResized($small, $im, 0, 0, 0, 0, $smallwidth, $smallheight, $srcwidth, $srcheight);/* Output to browser: */header ("content-type: image/gif");ImageGif($small);/* Destroy the image resources */ImageDestroy($im);ImageDestroy($small);[/code]however if a place any echo or html before the [code]header ("content-type: image/gif");ImageGif($small);[/code] it generates an error or shows the image code(garbage?)any code after the ImageGif($small); will not show at all. Any advice on how i actually use this function as part of an .inc file would be great,thanksArt Link to comment https://forums.phpfreaks.com/topic/28833-solved-gd-wont-show-image-if-called-from-higher-dir/ Share on other sites More sharing options...
JasonLewis Posted November 29, 2006 Share Posted November 29, 2006 well headers and GD arnt my area but this is what i am thinking:the reason it isnt showing AFTER the ImageGif($small); is because the content-type is set to image, so therfor it cannot and will not display text because of this. and i think this may be the same before the header when it shows garbage.not sure, just what i think... Link to comment https://forums.phpfreaks.com/topic/28833-solved-gd-wont-show-image-if-called-from-higher-dir/#findComment-132008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.