Ciao Daniele, grazie per la risposta. Ho modificato lo script così:
Codice PHP:
<?php
//watermark program
//Show that a jpeg image is going to be returned
//echo $QUERY_STRING;
//exit;
//File names
$jpegQuality = 90;
$wmark='watermark.png';
$wmarks='watermark_s.png';
$noimg='noimg.png';
$mimage=$QUERY_STRING;
// mod to display default image instead of 404
if (file_exists($QUERY_STRING)) {
// echo "The file $QUERY_STRING exists";
header("Content-type: image/jpeg");
//Loading
$watermark_img = imagecreatefrompng($wmark);
$watermarks_img = imagecreatefrompng($wmarks);
$wmrk_size = getimagesize($wmark);
$wmrks_size = getimagesize($wmarks);
$main_img = imagecreatefromjpeg($mimage);
//ImageAlphaBlending($main_image, true);
//Merge the 2 buffers
//The figure "300" can be changed to any figure suitable for your situation.
if ((ImageSX($main_img) > 500) && (ImageSY($main_img) > 300)) {
$posx = (0);
$posy = (ImageSY($main_img) - ImageSY($watermark_img));
imagecopy($main_img, $watermark_img, $posx, $posy, 0, 0, $wmrk_size[0], $wmrk_size[1]);
}else{
$posxs = (0);
$posys = (ImageSY($main_img) - ImageSY($watermarks_img));
imagecopy($main_img, $watermarks_img, $posxs, $posys, 0, 0, $wmrks_size[0], $wmrks_size[1]);
}
//Output file to browser
imagejpeg($main_img, '', $jpegQuality);
imagedestroy($watermark_img);
imagedestroy($watermarks_img);
imagedestroy($main_img);
} else {
//echo "The file $QUERY_STRING does not exist";
/*
//Loading
$noimg_show = imagecreatefrompng($noimg);
//Output file to browser
imagejpeg($noimg_show, '', $jpegQuality);
imagedestroy($noimg_show);
*/
header("HTTP/1.0 404 Not Found");
echo "<HTML>
<HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD>
<BODY>
<H1>Not Found</H1>
The requested document was not found on this server.
<P>
<HR>
<ADDRESS>
Web Server at gambacicli.com
</ADDRESS>
</BODY>
</HTML>
<!--
- Unfortunately, Microsoft has added a clever new
- \"feature\" to Internet Explorer. If the text of
- an error's message is \"too small\", specifically
- less than 512 bytes, Internet Explorer returns
- its own error message. You can turn that off,
- but it's pretty tricky to find switch called
- \"smart error messages\". That means, of course,
- that short error messages are censored by default.
- IIS always returns error messages that are long
- enough to make Internet Explorer happy. The
- workaround is pretty simple: pad the error
- message with a big comment like this to push it
- over the five hundred and twelve bytes minimum.
- Of course, that's exactly what you're reading
- right now.
-->
"; die();
}
?>
E pare funzionare bene (l'header che ho messo va bene?)... Volevo però sapere se c'è un modo più elegante per visualizzare la pagina di errore di default... con questa soluzione in caso modifichi la suddetta pagina devo aggiornare anche lo script...
Segnalibri