Image::Magick: find the last image read 
Author Message
 Image::Magick: find the last image read
Hi!

Do you know how to find the image latest read into an Image::Magick
object?

I need to read several image and make a montage out of them, but before
edit each image in different way without saving it.

Or maybe it is possible to insert an object of single image into an object
of multiple image?

Thank you.

--
                                   S P Arif Sahari Wibowo
  _____  _____  _____  _____

_____/ /      /    / _____/       http://www.*-*-*.com/



Sun, 18 Jul 2004 22:59:58 GMT  
 Image::Magick: find the last image read
See below.

--
Cheers
Ron Savage

http://savage.net.au/index.html

Quote:
> Hi!

> Do you know how to find the image latest read into an Image::Magick
> object?

The Image::Magick constructor 'new' returns a reference to an array, so you can index into it to process any one image.

You only need to change line 22 [my($dir_name) = '/Scripts/ImageMagick';] to suit your setup.

Tested code:

-----><8-----
#!/usr/bin/perl
#
# Name:
# read-several.pl.
#
# Purpose:
# Use Image::Magick to read in and process several images.
#
# Author:

# http://savage.net.au/index.html

use strict;
use warnings;

use Image::Magick;

# ---------------------------------------------------------

print "Image::Magick V $Image::Magick::VERSION. \n";
print "\n";
my($dir_name) = '/Scripts/ImageMagick';
chdir($dir_name) || die("Can't chdir($dir_name): $!");
opendir(INX, '.') || die("Can't opendir(.): $!");

closedir(INX);
my($file_count) = $#file_name + 1;
my($image) = Image::Magick -> new();

die $result if $result;
my($image_count) = $#{$image} + 1;

print "File count:  $file_count. \n";
print "Image count: $image_count. \n";
print "\n";
print map{"$_. File: $file_name[$_]. \n"} 0 .. $#file_name;
print "\n";

for (0 .. $#{$image})
{
 my($magick, $file_name, $width, $height) = $$image[$_] -> Get('magick', 'base-filename', 'width', 'height');
 print "$_. $magick. Image: $file_name. Size: $width x $height. \n";

Quote:
}

-----><8-----

However, there seems to be a bug in V 5.42 of Image::Magick, in that I get 1 image too many. I will report it now. My output is:

-----><8-----
Image::Magick V 5.42.

File count:  11.
Image count: 12.

0. File: animated-image.gif.
1. File: big-blue-butt.gif.
2. File: big-blue-butt.png.
3. File: bluebutton.png.
4. File: grin.gif.
5. File: model.gif.
6. File: piddle.gif.
7. File: ronsLogo.gif.
8. File: shadow.gif.
9. File: small-blue-butt.png.
10. File: smile.gif.

0. GIF. Image: animated-image.gif. Size: 48 x 48.
1. GIF. Image: animated-image.gif. Size: 48 x 48.
2. GIF. Image: big-blue-butt.gif. Size: 117 x 36.
3. PNG. Image: big-blue-butt.png. Size: 117 x 36.
4. PNG. Image: bluebutton.png. Size: 117 x 36.
5. GIF. Image: grin.gif. Size: 48 x 48.
6. GIF. Image: model.gif. Size: 128 x 192.
7. GIF. Image: piddle.gif. Size: 300 x 300.
8. GIF. Image: ronsLogo.gif. Size: 152 x 84.
9. GIF. Image: shadow.gif. Size: 300 x 100.
10. PNG. Image: small-blue-butt.png. Size: 117 x 18.
11. GIF. Image: smile.gif. Size: 48 x 48.
-----><8-----



Mon, 19 Jul 2004 00:16:43 GMT  
 Image::Magick: find the last image read
On Thu, 31 Jan 2002 10:16:43 +1100,

Quote:
> However, there seems to be a bug in V 5.42 of Image::Magick, in that
> I get 1 image too many. I will report it now. My output is:
> Image::Magick V 5.42.

I can't reproduce that bug for Image::Magick V 5.42 (installed from
5.4.2-3 distribution), Perl 5.6.1 built for i586-linux. If you have an
older 5.4.2 maybe it's already been fixed.

Martien
--
                                |
Martien Verbruggen              | I used to have a Heisenbergmobile.
Trading Post Australia Pty Ltd  | Every time I looked at the
                                | speedometer, I got lost.



Mon, 19 Jul 2004 02:51:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Image::Magick: find the last image read

2. Image Magick finding image size without loading image

3. Converting images without Image::Magick

4. Merging and splitting of images with Image::Magick

5. convert jpg-images to tiff format with image-magick on winnt

6. Image Magick and returning images to a web page

7. AS Perl 629 Image::Magick makes Perl crash when outputting image to file

8. Image::Magick making images from layers

9. ANNOUNCE: Tutorial # 32: Showcasing Image::Magick (part 2): xml-2-image.pl

10. ANNOUNCE: Tutorial # 31: Showcasing Image::Magick (part 1): text-2-image.pl

11. CGI image generation using Image::Magick

12. Displaying Image::Magick image objects in Perl/Tk?

 

 
Powered by phpBB® Forum Software