THE WEBLOG OF KEVIN C. MURPHY: CONJURING POLITICAL, CINEMATIC, AND CULTURAL ARCANA SINCE 1999

Head-to-Headers.

| | Comments (10)

As you can see, I've tweaked the design around here for 2005...and there's probably more to come. The rotating title image is a trick I've seen at much better-designed sites such as High Industrial and Donkeymon, so I was pleasantly surprised to see I could basically cut-and-paste my way to coding prowess via this helpful article. All title pics are used without permission and intended as homage...how's that for a useless disclaimer?

10 Comments

Kris said:

Hmm, I can't see the header image. On Safari on the latest version of OS X, I just get text at the top. What am I supposed to be seeing?

Kevin said:

Uh-oh. You should be seeing a randomly selected title image, thanks to a php script.

Do Safari and php scripts not play well together? That might be trouble.

Kevin said:

Ok, I replaced the php script with a newer one...let me know if you see anything in Safari.

Kris said:

Hmm. It's still not working. I had a look at your html and pulled out the image location, and if I put that - http://www.ghostinthemachine.net/titleimages/randompic.php - in my Location bar, it redirects fine to one of your images. So Safari is fine with PHP by itself; just not with the image when included on the page. Hmmm. What's in your randompic.php file? Did you include something like: header("Content-Type: image/gif"); at the top? Just brainstorming here...

Kevin said:

No, to be honest I just downloaded it directly from this site and placed it in a folder. I don't see any Content-Type tag on it at all...here's the code, if that helps:

////////////////////////////////////////////////////////////////////////////////////////*/
$config["systempath"] = "";
$config["webpath"] = "";
$config["type"] = "redirect";

if($config["systempath"] != "")
{
$dircheck = $config["systempath"];
if (is_dir($dircheck)) //check if it is a valid systempath
{
$pathtoread = $config["systempath"];
}
else
{
// If not, it creates an error image and displays it
$img = imagecreate(150, 150);
$red = imagecolorallocate($img, 255, 0, 0);
$yellow = imagecolorallocate($img, 255,255, 0);
imagestring($img, 4, 20, 20, "System", $yellow);
imagestring($img, 4, 20, 40, "path", $yellow);
imagestring($img, 4, 20, 60, "error!", $yellow);
imagepng($img);
imagedestroy($img);
exit();
}
}
else
{
$pathtoread = "."; //Dir where this file is stored
}
if($config["webpath"] != "")
{
$url = $config["webpath"];
}
else
{
$explode = explode("/",$_SERVER["REQUEST_URI"]);
$url = "http://".$_SERVER["SERVER_NAME"]."/";
for($i=0;$i 300))
{
// If not, it creates an error image and displays it
$img = imagecreate(150, 150);
$red = imagecolorallocate($img, 255, 0, 0);
$yellow = imagecolorallocate($img, 255,255, 0);
imagestring($img, 4, 20, 20, "Afmetingen", $yellow);
imagestring($img, 4, 20, 40, "kloppen", $yellow);
imagestring($img, 4, 20, 60, "niet!", $yellow);
imagepng($img);
imagedestroy($img);
exit();
}

if ($ext == ".jpg" || $ext == "jpeg")
{
$bigimage = @imagecreatefromjpeg($img);
}
if ($ext == ".gif")
{
$bigimage = @imagecreatefromgif($img);
}
if ($ext == ".png" || $ext == "jpeg")
{
$bigimage = @imagecreatefrompng($img);
}

//Create an empty image of the given size
$tnimage = imagecreate($tnsize, $tnsize);
$darkblue = imagecolorallocate($tnimage, 0,0, 127);
imagecolortransparent($tnimage,$darkblue);

//Calculate the resizing image factor
$sz = getimagesize($img);
$x = $sz[0];
$y = $sz[1];
if ($x > $y)
{
$dx = 0;
$w = $tnsize;
$h = ($y / $x) * $tnsize;
$dy = ($tnsize - $h) / 2;
}
else
{
$dy = 0;
$h = $tnsize;
$w = ($x / $y) * $tnsize;
$dx = ($tnsize - $w) / 2;
}

// Resizes the image
imagecopyresized($tnimage, $bigimage, $dx, $dy, 0, 0, $w, $h,$x, $y);

// Displays the image
imagepng($tnimage);

// Clears the variables
imagedestroy($tnimage);
imagedestroy($bigimage);
}
else
{
if($config["type"]=="redirect"){
header("Location: ".$url.$img);
}
else if($config["type"]=="readfile"){
readfile($pathtoread."/".$img);
}
else
{
echo "Error: unknown displaytype";
}
}
?>

Kevin said:

Ok, I'm still over my head here, but read up on Content-Type and that sounds like it might indeed have been the problem. So I added that line as you suggested (with image/jpg) and changed the systempath/webpath lines.

Any luck in Safari? :)

Kris said:

Hey, I just realized that the image *is* there, between the two stacks of links. The trouble is that it's about 5 pixels wide by 2 pixels high. I thought it was a bullet or something. If I right-click and open in a new tab, it's full size. So can you maybe put an explicit width and height on that image tag? Are they all the same size?

Kevin said:

They are all the same size, and I've now added explicit height and width tags to my template (but not to the php file.) Perhaps that does the trick?

Thanks for helping me de-bug this, by the way. :)

Kris said:

Beeyoootiful! Works like a charm now. No worries. :)

Kevin said:

Awesome! Thanks. :)

Leave a comment


Type the characters you see in the picture above.

About this Entry

This page contains a single entry by KcM published on December 31, 2004 2:24 AM.

Kid Icarus. was the previous entry in this blog.

Tintin meets the Tenenbaums. is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.31-en