Image::Magick JPEG=>TIF Conversion 
Author Message
 Image::Magick JPEG=>TIF Conversion

Hello
Among other things, at one stage I want to convert a JPEG picture into TIF
using Image::Magick. Some problems arise which seems like bugs to me. Here
is some example code:

#!perl
use strict;
use Image::Magick;
my $file="P4130004.JPG";        #1600x1200 jpeg
my $res;
my $p = new Image::Magick;

$res=$p->Read($file);   warn "$res" if "$res";
my $width=$p->Get('width');
my $height=$p->Get('height');
my $dim="${width}x$height";
print "$dim\n";

$res=$p->Write(filename=>"out1.tif"); warn "$res" if "$res";

$p->Set('magick'=>'RGB');
$res=$p->Write(filename=>"out2.tif"); warn "$res" if "$res";

my $p2=$p->Montage(geometry=>$dim);
$res=$p2->Write(filename=>"out3.tif"); warn "$res" if "$res";

$p2->Crop($dim);
$res=$p2->Write(filename=>"out4.tif"); warn "$res" if "$res";

According to me all four tif:s should be identical. However out1.tif and
out2.tif are impossible to open with my picture viewer and the files are
very much to small (476 kb). Both out3.tif and out4.tif are valid picture
files (5635 kb and 5645 kb) but out3.tif is 1600x1202 pixels (showing two
white lines in the bottom) and only out4.tif seems to be correct.

So why doesn't it work?

I also get some warnings which I don't understand:

Warning 330: no magic configuration file found (magic.mgk) [No such file or
directory] at cplm.pl line 7.
Warning 315: no delegates configuration file found (delegates.mgk) [No such
file or directory] at cplm.pl line 13.
Warning 315: no delegates configuration file found (delegates.mgk) [No such
file or directory] at cplm.pl line 16.
1600x1200

I'm using PPM:s Image-Magick [5.26] An objected-oriented Perl interface to
ImageMagick for Windows 2000.

Also another thing. Is there any good reference or tutorial for
Image::Magick. The homepage http://www.*-*-*.com/ is incomplete and
functions are not very well specified.

/jN



Sun, 03 Apr 2005 15:35:41 GMT  
 Image::Magick JPEG=>TIF Conversion

| Among other things, at one stage I want to convert a JPEG picture into TIF
| using Image::Magick. Some problems arise which seems like bugs to me. Here
| is some example code:
|
| #!perl
| use strict;
| use Image::Magick;
| my $file="P4130004.JPG";        #1600x1200 jpeg
| my $res;
| my $p = new Image::Magick;
|
| $res=$p->Read($file);   warn "$res" if "$res";
| my $width=$p->Get('width');
| my $height=$p->Get('height');
| my $dim="${width}x$height";
| print "$dim\n";
|
| $res=$p->Write(filename=>"out1.tif"); warn "$res" if "$res";
|
| $p->Set('magick'=>'RGB');
| $res=$p->Write(filename=>"out2.tif"); warn "$res" if "$res";
|
| my $p2=$p->Montage(geometry=>$dim);
| $res=$p2->Write(filename=>"out3.tif"); warn "$res" if "$res";
|
| $p2->Crop($dim);
| $res=$p2->Write(filename=>"out4.tif"); warn "$res" if "$res";
|
| According to me all four tif:s should be identical. However out1.tif and
| out2.tif are impossible to open with my picture viewer and the files are
| very much to small (476 kb).

out1.tif is still JPEG compressed, like the original image was.  The
viewer you're using just doesn't support JPEG compression within
TIFFs.

Add

    $p->Set( compression => 'None' );

to get out1.tif in the format you expect.

out2.tif is identical to out1.tif.

| Both out3.tif and out4.tif are valid picture
| files (5635 kb and 5645 kb) but out3.tif is 1600x1202 pixels (showing two
| white lines in the bottom) and only out4.tif seems to be correct.

out3.tif is created from scratch.  It carries no preconception about
what its compression method should be, so defaults to 'None'.  Why
Montage() adds a border, I can't guess.  Just don't do that.



Mon, 04 Apr 2005 08:04:40 GMT  
 Image::Magick JPEG=>TIF Conversion
On Wed, 16 Oct 2002 09:35:41 +0200,

Quote:
> Also another thing. Is there any good reference or tutorial for
> Image::Magick. The homepage http://www.imagemagick.org is incomplete and
> functions are not very well specified.

In addition to my other post: There is a mailing list for ImageMagick,
which is quite valuable, and contains lots of information. Details on
the mailig list, and a link to its archive are available from
www.imagemagick.org.

Martien
--
                        |
Martien Verbruggen      | That's funny, that plane's dustin' crops
                        | where there ain't no crops.
                        |



Mon, 04 Apr 2005 08:58:30 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Image::Magick JPEG=>TIF Conversion

2. Image Magick complaining about JPEG library

3. Image Magick finding image size without loading image

4. Image::Magick->Write() doesn't want to write

5. Need help with Perl::Magick (Image::Magick)

6. Can't load Magick.so for module Image::Magick

7. Converting images without Image::Magick

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

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

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

11. Image Magick and returning images to a web page

 

 
Powered by phpBB® Forum Software