Hello.
I am trying to take a specified image (that has fixed dimensions...720480) and crop it to a fixed size (360480). I then would like, if possible, to just send it to the browser. I read the manual, but it didn't really help. At first, I wanted to just spit it back out to the browser, but I got an error stating that headers were already sent, but the line reference it gave was just some html and a php if statement. When I did a
var_dump(headers_sent());
after the plain-text of the image, all I got was "bool(true)". I also tried outputting the pic to a temp file and then echoing an image tag, but it didn't work either...the image was the right dimensions, but it just gave the file not found graphic. Iam using
imagecreate()
because
imagecreatetruecolor()
gave me an error message stating that it was only in GD2, even though I have PHP 4.2.3, which according to the manual, should support GD2 (unless I am misunderstanding it). I enabled the php_gd.dll in php.ini, and
phpinfo()
shows that the GD version is 1.6.2 or higher. I don't know if my problem would be solved by GD2, but I can't figure out where to dl the dll.
Here is my code (I know it is probably not as efficient as possible):
$pic_num = $_POST['pic_num'];
$src_type = $_POST['src_type'];
$pic_num2 = $pic_num;
while (strlen($pic_num2) < '4')
{
$pic_num2 = '0'.$pic_num2;
}
$pic_path = '"images/' . $pic_num2 . '.jpg"';
some code
<p align="center"> <?php if($src_type == "png")
{
include('image.php');
} else {
echo('<img border="0" src="images/'.$pic_num.'.jpg" height="350">');
} ?>
image.php:
<?php
header('Content-type: image/jpeg');
//$picsrc = imagecreatefromjpeg($pic_path);
$picsrc = imagecreatefromjpeg("images/0001.jpg");
$picdst = imagecreate(360,480);
imagecopyresized($picsrc,$picdst,0,0,180,0,360,480,360,480);
ImageJPEG($picdst/*, "temp.jpg"*/);
//var_dump(headers_sent());
?>
If anyone can help me, I would greatly appreciate it.
Thank you for your time,
Kyle