re: http://www.phpbuilder.com/columns/pablo19990729.php3
I tried recreating his code (with some modernity considering he's using PHP 3 and I'm using PHP 4.3.2 - PHP 5.0.4):
<?
if ($_POST['blah']) {
list($image_width, $image_height) = @getimagesize('http://valsignalandet.com/images/stave.jpg');
$zoomImgObj = @imagecreatefromjpeg('http://valsignalandet.com/images/stave.jpg');
$imageObj = @imagecreatetruecolor($image_width, $image_height);
$factor=3.75;
$posx = floor($_POST['val_x'] * $factor - floor((int)($image_width / 2)));
$posy = floor($_POST['val_y'] * $factor - floor((int)($image_height / 2)));
$copia = @imagecopyresized($zoomImgObj, $imageObj, 0, 0, $posx, $posy, $image_width, $image_height, $image_width, $image_height);
@imagejpeg($imageObj, '/tmp/val.jpg');
@imagedestroy($imageObj);
@imagedestroy($zoomImgObj);
$contents = @file_get_contents('/tmp/val.jpg');
require_once('/var/www/html/tools/tools_globals/client_globals.inc.php');
require_once('/var/www/html/tools/ivc/ivc_globals/project_globals.inc.php');
require_once('/var/www/html/tools/ivc/include/classes.inc.php');
require_once('/var/www/html/tools/ivc/include/db_action.inc.php');
DownloadGenerator::generateForceDownloadHeaders('/tmp/val.jpg', $contents);
} else {
?>
<html>
<head>
<title>asdf</title>
</head>
<body>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<input type="hidden" id="blah" name="blah" value="foo">
<input type="image" id="val" name="val" src="http://valsignalandet.com/images/stave.jpg" alt="Välsignalandet" value="val">
</form>
</body>
</html>
<? } ?>
However, each time I run this script, the resulting downloaded "image" is a black graphic, same width and height as the original image.
What I want is the ability to zoom in on an image based upon the place where the user clicks (thus capturing the positions via $_POST)
Any suggestions?
Thanx
Phil