Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Zoom-in, Zoom-out, and Pan script !

Posted on 1999-06-28
3
Medium Priority
?
815 Views
Last Modified: 2012-05-04
I need to zomm-in out and pan images from a web page. I don't want to use Java but CGI.
Does anybody knows how or where to find such scripts.

Thanks
0
Comment
Question by:No1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:jhurst
ID: 1213567
would be fairly easy to write if you use ImageMagick since it will allow you to select parts of an image and create a new image.  So a zoom would just select a part of it.  The standard image would take the whole image but have ImageMagick re-size it down to the size you want, etc.

0
 

Author Comment

by:No1
ID: 1213568
Can you invoke it from a web page. The zoom-in and out should be done on the fly. If yes where to find ImageMagick please.
Thanks
0
 
LVL 1

Accepted Solution

by:
mjpieters earned 800 total points
ID: 1213569
There are two options using modules. Which one you'll use will depend on what will work on your platform, and what type of images you are displaying. Both modules are available from CPAN (http://www.cpan.org/).

Option 1 is GD, from Lincoln D. Stein (http://www.cpan.org/authors/id/LDS/GD-1.19.tar.gz). It is based on Thomas Boutell's gd library, which is included in the package. It can only manipulate GIF images. Usage is simple:

use GD;

# read gif image
open SRC, "path/to/image.gif";
my ($oSrcImg) = GD::Image::newFromGif(SRC);
close SRC;

# create target image, same size as src
my ($iW, iH) = $oSrcImg->getBounds();
my ($oTargetImg) = new GD::Image($iW, $iH);

# resize (zoom in on top left quarter);
$oTargetImg->copyResized($oSrcImage, 0, 0, 0, 0, $iW, $IH, int($iW / 2), int($iH / 2));

# return data to browser
print "Content-Type: image/gif\n\n";
binmode STDOUT; # May be necessary on some systems.
print $oTargetImg->gif();

Option 2 is Image::Magick (http://www.cpan.org/authors/id/JCRISTY/PerlMagick-4.26.tar.gz) by John Cristy. It requires the ImageMagick library. The install files coming with the perl package tell you where to get it, and how to install it. It can manipulate a wide range of image types, in many different ways. It is more versatile than GD, but you may have difficulties getting it compiled.

Example code:
use Image::Magick

my ($sRet); # Return value from methods. Use this to
            # detect errors.
my ($oImg) = new Image::Magick();
$sRet = $oImg->Read('path/to/image.jpg');

# get width and height
my ($iW) = $oImg->Get('width');
my ($iH) = $oImg->Get('height');

# Zoom to twice the size
$oImg->Zoom(width=>(2 * $iW), height=>(2 * $iH));
# And Crop to top left corner
$oImg->Crop(x=>0, y=>0, width=>$iW, height=>$iH);

# return to browser
print "Content-Type: image/jpg\n\n";
binmode STDOUT; # May be necessary on some systems.
$oImg->Write('-');

You can find the full documentation of the Image::Magick module at http://www.wizards.dupont.com/cristy/www/perl.html

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question