Reply to How do you zoom in on an image using PHP?

Your name:

Reply:


Posted by comp.lang.php on 05/05/06 01:16

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):

[PHP]
<?
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&auml;lsignalandet" value="val">
</form>
</body>
</html>
<? } ?>
[/PHP]

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация