473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do you zoom in on an image using PHP?

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

May 4 '06 #1
1 5309

comp.lang.php wrote:
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)));


[snip]

UPDATE:

I think this is the culprit, because if I click on the upper left hand
corner of the image, I get something LIKE a zoomed-in image but
terribly offset, otherwise, nuthin' but black:

[PHP]
$factor=3.75;
$posx = floor($_POST['val_x'] * $factor - (int)($image_width / 2));
$posy = floor($_POST['val_y'] * $factor - (int)($image_height / 2));
[/PHP]

I suspect the calculations for $posx and $posy are causing it to
happen.. but I don't have any idea how to fix that.

Phil

May 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: stef | last post by:
Hello: I am trying to design a web page whose graphics content would change according to the "text Zoom" settings of the user. (Basically the goal is to use mathematical symbols that...
2
by: ACaunter | last post by:
Hi there, I have a bunch of images on my ASP.Net website, and i wanted to have a zoom feature as well..., I can do it with panels and just keep doing the image.width = image.width * 2... but i...
2
by: Mo Ade via .NET 247 | last post by:
How do I write code to include a zoom feature in my project so that when my Vb Form loads an image I can click in my main menu zoom in or zoom out? -------------------------------- From: Mo Ade ...
6
by: Rich | last post by:
Hello, I am putting together a simple picture viewing program to view jpg. bmp pictures. I have the picturebox sizemode set to autosize. I have the picturebox in a pannel set to autoscroll, so...
1
by: Ricardo Furtado | last post by:
I've been with a problem for about two months and i've bought books and search the internet for an explanation, and haven't found one. I'm developing a cephalometric software, that needs to capture...
3
by: Keith G Hicks | last post by:
In MS Access image controls there's a property setting for "Size Mode" --> Clip, Zoom or Stretch. I don't see any similar property in an asp image control. When I have an image on a page, it seems...
4
by: Yoshitha | last post by:
I'm developing windows application using c#.net (vs 2003), i've placed several images (picture boxes) in panel control and i want to zoom the panel control so that the images and text which...
4
by: wasishincar | last post by:
I'm trying to read a bitmap and zoom in/out it on screen. I wrote some code but it did not perform as I expect. The bitmap shift 1 pixel to the upper-left coner when zooming in/out button was...
0
by: murry19830507 | last post by:
i want creat an web application(c#.net),which contains an image and one radiobutton list with 3 radiobuttons(zoom in ,zoom out ,zoom window) when user checked on zoom in imge has to be zoom inthe...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.