Link to home
Start Free TrialLog in
Avatar of madhero
madhero

asked on

php and image manipulation

[info]
I have a high resolution (300+ dpi), most probably a tiff. The image is a picture of a city with buidings etc...

[concept]
I want to be able to click on the image, capture the cursor x/y coordinates (having the image as a form element) and center-zoom a certain amount. I would like to do that to a certain level where the image finally loses too much quality.

[other]
i also want to convert the image to jpg since it will be viewed through a browser and change the image's resolution to a more web friendly one. All of this based always on the original tiff image that does not get changed in anyway. I guess this is more of a copy the original image and do the processing than spitting out a temp image than doing any work on the original image.

I know ImageMagik will do most of this, if not everything, but I'm not sure if I'll be able to use 3rd party software.

Thx / paul
Avatar of euclidian
euclidian

PHP does not handle TIFF files, but many other image formats (jpeg, gif, xpm, png). So I would recommend to first convert this large image into one of these supported formats.

Next, you need some php code to load the image and display the 'right' piece of it. This would look something like this:

filename: image.png

<?
# ... insert validation for $x0, $y0, $width and $height and $outwidth, $outheight

#
#
# send the right header
header("Content-Type: image/png");
# load the image
$im = @imagecreatefrompng ($imgname);
# get the right piece of the image and resize it.
imagecopyresized($im2,$im,0,0,$x0,$y0,$outwidth, $outheight, $width,$height);

# output the image
imagepng($im2);
?>

in your html file, you will just inlcude something like:

<input type="image" name="image" src="image.png?x0.... >

this will return the coordinate the user clicks on as $image_x and $image_y. You can use this to calculate x0,y0...
euclidian>

for PHP installations that don't use buffering, you should only put your header() function on the first line.
ASKER CERTIFIED SOLUTION
Avatar of euclidian
euclidian

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation in the Cleanup topic area:

Answered by euclidian

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

snoyes_jw
EE Cleanup Volunteer