Click to See Complete Forum and Search --> : Problem using image functions
loureiro
03-03-2004, 11:21 AM
hi,
i just installed winLAMP on my computer and i have some scripts that do some image manipulation...however they do not run properly on my machine... i know you're suppose to have the gd library and a few other things however when i was about to try to install the gd library i read the read me file and it said that gd was already installed...if it is already installed then how come the image manipulation doesnt work? any help with getting my computer up to speed would be very helpful! thanks!
tekky
03-03-2004, 11:38 AM
without knowing a few things...
a) your setup
b) some code for whats not working...
c) what you've tried
nobody really has a clue what you are doing/working with....
loureiro
03-03-2004, 11:42 AM
i am running:
php 4.3.4
Apache/1.3.29 (Win32) PHP/4.3.4
and here is the code im trying to run: yet nothing shows up...
<?php
header("Content-type: image/jpeg");
require("functions.php");
//load image
$imageLocation = "LondonDigitalOne_MikeLoiselle.jpg";
$path = "./test/test.jpg";
$im = @imagecreatefromjpeg($imageLocation);
//set background color
$bgColor = imagecolorallocate($im, 255, 255, 255);
//set all other attributes
$fontSize = 25;
$angle = 0;
$font = "ARIALBD.TTF";
$text = "Mike Loiselle";
//cover old text
imagefilledrectangle ($im, 210, 30, 480, 60, $bgColor);
//calculate text size for output
$fontAtt = imagettfbbox($fontSize, $angle, $font, $text);
$fixedFontAtt = fontAttributes($fontAtt);
$imageAtt = getimagesize($imageLocation);
$locationX = (($imageAtt[0]/2)-($fixedFontAtt[0]/2));
$locationY = (($imageAtt[1]/2)+($fixedFontAtt[1]/2));
//set text color and write text
$color = imagecolorallocate($im, 0, 0, 113);
imagettftext($im, $fontSize, $angle, round($locationX), round($locationY)-35, $color, $font, $text);
imagejpeg($im,$path);
imagejpeg($im);
imagedestroy($im);
?>
now i know that i need to install the true type library...which im not 100% sure on how to do but the image should still show up yet its not...it gives me the broken link to an image picture. please help!
tekky
03-03-2004, 11:49 AM
have you tried commenting out the TTF stuff, just to ensure the font stuff isnt breaking the image?
loureiro
03-03-2004, 11:55 AM
yes i commented out all the ttf stuff and its still not working...any ideas?
tekky
03-03-2004, 12:14 PM
place some debug echos in the script at various points to find out if you are executing at all, if so, at what point output halts... then go from there...
loureiro
03-03-2004, 12:26 PM
$im = @imagecreatefromjpeg($imageLocation);
this is where it gets stuck...it cant perform this...any suggestion on why?
tekky
03-03-2004, 01:53 PM
per a suggestion on php.net...
if (!$im) { /* See if it failed */ }
checking if $im is false (!$im) will tell if the imagecreate failed...
sounds like thats happening...
and also..
did you found that sometimes it hang the php when imagecreatefromjpeg() run on bad JPEG. I found that this is cause by the JPEG file U used dont have EOI (end of image)
the FF D9 at the end of your JPEG
JPEG image should start with 0xFFD8 and end with 0xFFD9
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.