I've written a small image viewer which basically mirrors html's "map",
i.e. each image has a set of areas which link to other images. I'm using
it to view pages from a street atlas which I've scanned (you click on
the arrows that indicate on which page the map continues) and also
photo's I've taken from street corners in a city (you click on the left
or right side of the image to virtually turn left or right, click on the
top of the image to advance to the next corner, click on the bottom of
the image to turn 180�).
Since the images themselves are quite big, I'm using a scrolled canvas,
but I'd also like to scale images to (arbitrary) sizes. I just scale the
areas' coordinates by my rescale factor (e.g. 0.33) which works quite
fine, but I use Image::Copy(-shrink, -subsample => 1/$scale) which does
not work as desired as it wants to subsample using integral values, so
if my rescale factor is 0.33, the areas and the rescaled image do not match.
How would I rescale an image using arbitrary, non-integral scaling factors?
Thanks,
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef M�llers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
External graphics libraries are the best bet for image manipulation.
Use Image::Magick scale or mogrify resize. There is also an
Image::Resize which uses GD.
> External graphics libraries are the best bet for image manipulation. Use
> Image::Magick scale or mogrify resize. There is also an Image::Resize
> which uses GD.
I've heard from others that the API of ImageMagick changes often.
In my experience ImageMagick is sometimes eating up a lot of memory and it
seems show more bugs than other image manipulation packages.
For me Imager is working quite well.
Oliver
Thanks for the hints. I have used Image::Magick already elsewhere (e.g.
using Annotate to create title slides for slide-shows), but they all
seem to be alien to Tk!
I would have to load an image, rescale it, then store it back into a
file and the reload it using Tk::Photo. Any idea how I could load the
image, rescale and then hand over to Tk::Photo? I know that I can use an
in-core image if that's encoded, so I would do that (use encode_base64()
from MIME::Base64), I'd like to avoid the store and reload.
Thanks,
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
> I would have to load an image, rescale it, then store it back into a
> file and the reload it using Tk::Photo. Any idea how I could load the
> image, rescale and then hand over to Tk::Photo? I know that I can use an
> in-core image if that's encoded, so I would do that (use encode_base64()
> from MIME::Base64), I'd like to avoid the store and reload.
I'm using the method you describe (using encode_base64()). Something
along the lines
$img = Imager->new;
$img->read(file => "foo");
$newimg = $img->scale();
$newimg->write(data => \$inmemory);
$mainwindow->Photo("photo", data => encode_base64($inmemory));
Works well, although to me it feels a bit clumsy.
Until now I haven't found a better alternative.
Oliver
Thanks in a million. That did the trick.
Not sure if handling a 7 Megapixel image in memory is The Right Thing,
but ... it does what I want it to do.