I've got what appears to me to be some strange behaving code, although I'm sure someone will look at it and inform me....no, here's your issue. I hope
this chunck is part of a 'parent' page and is the page that displays the images' in binary format:
Code: Select all
$imgPath = "/home/somesite/public_html/somedir/photos/".$photo;
$fp = fopen($imgPath, "r");
$imageFile = fread ($fp, 300000);
fclose($fp);
$tmpfname = tempnam ("../imagesTMP", "IMG");
$fp = fopen($tmpfname, "w");
fwrite($fp, $imageFile);
fclose($fp);
$photoInfo=GetImageSize($imgPath);
if ($photoInfo[2]=="1") {
$im_old = imageCreateFromGif($tmpfname);
} elseif ($photoInfo[2]=="2") {
$im_old = imageCreateFromJpeg($tmpfname);
} elseif ($photoInfo[2]=="3") {
$im_old = imageCreateFromPng($tmpfname);
}
//**** Delete Temporary File ****
unlink($tmpfname);
$th_max_width = 1.5 * $photoInfo[0];
$th_max_height = 1.5 * $photoInfo[1];
$ratio = ($width > $height) ? $th_max_width/$photoInfo[0] :
$th_max_height/$photoInfo[1];
$th_width = $photoInfo[0] * $ratio;
$th_height = $photoInfo[1] * $ratio;
$im_new = imagecreatetruecolor($th_width,$th_height);
imageAntiAlias($im_new,true);
$th_file_name = $photoDir;
imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height,
$photoInfo[0], $photoInfo[1]);
if ($photoInfo[2]=="1") {
imageGif($im_new,$th_file_name,100);
} elseif ($photoInfo[2]=="2") {
imageJpeg($im_new,$th_file_name,100);
} elseif ($photoInfo[2]=="3") {
imagePng($im_new,$th_file_name);
}
//then the image is displayed here with a link
echo "<a href=\"../photos/$photo\" onClick=\"return enlarge('../photos/$photo',event)\"><img name=\"tnImage\" src=\"../photos/$photo\" border=\"0\" alt=\"ENLARGE THIS PHOTO\"></a>";Code: Select all
echo "<a href=\"http://somesite.com/somedir/enlargeTEST.html?photo=$photo\" target=\"enlarge\" onmouseover=\"window.status='ENLARGE THIS PHOTO';return true;\" onmouseout=\"window.status=' ';return true;\" onClick=\"window.open('enlargeTEST.html?photo=$photo', 'enlagre', 'status=yes,menubar=no,scrollbars=yes,height=275,width=300,resizable=no'); return false\"><img src=\"..//../photos/$photo\" border=\"0\" alt=\"ENLARGE THIS PHOTO\"></a>";
//This code works excellent.I want to be able to use the first code because I want to utilize the JS stuff that happens there and not open a new, second window. I know the JS works fine if I cut out the PHP image code stuff. So the JS isn't the issue.
Why would the PHP image code spit out the image in binary in the first example, but work perfectly in the second example (same code, just in a new child window)??
Thanks