TechSpider
A searchable, categorised online resourse for finding technical information and solutions to problems
Welcome! You are viewing the web category.
Below are the Apache and mod_fcgid: Problem serving binary content with Apache 2.2.13 - PHP 5.2.9 related pages
Custom Search
You can search the database for more Apache articles using the box below:
Custom Search

Apache Articles:
As an additional note, i found another watermark script which fails with the
same error (it will need the same .htaccess as in my first post - save the
script as modify.php as well or adjust the name in .htaccess accordingly) as
PHP will try to parse the jpg file instead of displaying the image.

Again, switching to cgi-fcgi or mod_php, the image gets displayed
(differences between mod_fcgid and mod_cgi as shown in the httpd.include in
my previous post):

<?php
// -------------------------------------------------------------------------
//
// The code below is free software; you can redistribute it and/or modify
//
// it under the terms of the Creative Commons Attribution license:
//
// http://creativecommons.org/licenses/by/2.5/
//
// The following line must reside in any derivative works:
//
// portions (cc) Doncho Angelov 2005 (http://doncho.net)
//
// -------------------------------------------------------------------------
//

//
// SETUP
//

// the location of the picture, which contains the normal watermark
// (we first try to apply this one)
define(BIG_WATERMARK_FILE, $_SERVER['DOCUMENT_ROOT'] . "/watermark.jpg");
// the location of the picture, which contains the smaller watermark
// (for the images, which are smaller than 5 times the normal watermark)
define(SMALL_WATERMARK_FILE, $_SERVER['DOCUMENT_ROOT'] . "/watermark.jpg");

// SETUP ends

// generate the image with watermark
function watermark($source, $outputType="") {

// determine the type of the source image
$sourceType = getFileType($source);

// output the header of the new image
if (empty($outputType)) $outputType = $sourceType;
// if you hate GIF files, you can switch to PNG
if ($outputType == "gif") $outputType = "png";
header("Content-type:image/$outputType");

// create the source
$createSource = "ImageCreateFrom".strtoupper($sourceType);
$showImage = "Image".strtoupper($outputType);
$output = $createSource($source);

// load the big logo
$logo = loadWatermark(BIG_WATERMARK_FILE);

// check if the watermark is not bigger than the logo
if (ImageSX($output)<(ImageSX($logo)*5) ||
ImageSY($output)<(ImageSY($logo)*5))
// if so, fallback to a smaller logo
$logo = loadWatermark(SMALL_WATERMARK_FILE);

$x = ImageSX($output) - ImageSX($logo);
$y = ImageSY($output) - ImageSY($logo);

ImageAlphaBlending($output, true);

ImageCopy($output, $logo, $x, $y, 0, 0, ImageSX($logo), ImageSY($logo));
$showImage($output);

ImageDestroy($output);
ImageDestroy($logo);
}

function getFileType($string)
{
$type = strtolower(eregi_replace("^(.*\.)","",$string));
if ($type == "jpg") $type = "jpeg";

return $type;
}

function loadWatermark($watermarkFile)
{
$watermarkType = getFileType($watermarkFile);
$createWatermark = "ImageCreateFrom".strtoupper($watermarkType);
return $createWatermark($watermarkFile);
}

//
// main functionality starts here
//

$image = $_SERVER["PATH_TRANSLATED"];

if (empty($image)) die();

if (!file_exists($image))
{
header("404 Not Found");
echo "Requested File Not Found."; die();
}

$outputType = getFileType($image);

watermark($image, $outputType);
?>

I wonder whether i have a special environment which causes this behaviour
only with me. Otherwise i would expect a lot more 'noise' from other people
when switching to mod_fcgid from either mod_php or mod_fastcgi as these
scripts will fail.

Regards,
Marcus






Article list Name Date
Click Here Marcus Merz 2009-09-19 07:48:56
Click Here Jeff Trawick 2009-09-20 01:42:58
Click Here Marcus Merz 2009-09-20 16:30:02
Click Here Jeff Trawick 2009-09-21 15:27:13
Click Here Marcus Merz 2009-09-21 18:24:34
Currently Viewing : This ArticleMarcus Merz2009-09-21 18:40:34
Click Here Jeff Trawick 2009-09-21 21:55:59
Click Here Marcus Merz 2009-09-22 05:21:49
Click Here Marcus Merz 2009-09-22 18:07:12
Click Here Marcus Merz 2009-09-23 18:33:17
Click Here Marcus Merz 2009-10-11 10:16:30
Click Here Jeff Trawick 2009-10-12 20:14:40
Click Here Jeff Trawick 2009-10-12 20:43:56
Click Here Marcus Merz 2010-02-23 21:47:58
Click Here Jeff Trawick 2010-02-23 23:57:30


Copyright Techspider V0.81   |   Techspider Sitemap