problem with enlarge an image using Sample
problem with enlarge an image using Sample
Original image size is 4.3M, 2588X1731.
after this perl code: $image->Sample(width=>5800, height=>5800);
The file turns to 22M, 5800X3879.
Is there a problem with an image being smaller than what sample/scale
sets it to?
Problem exists only when the image size has to be increased.
after this perl code: $image->Sample(width=>5800, height=>5800);
The file turns to 22M, 5800X3879.
Is there a problem with an image being smaller than what sample/scale
sets it to?
Problem exists only when the image size has to be increased.
Your image is PDF and JPEG compressed. We got reasonable results with ImageMagick 6.3.1-0 with this script:
Code: Select all
use Image::Magick;
$image=Image::Magick->new(density=>144);
$image->Read('27_009_01.pdf');
$image->Write(filename=>'image.pdf',compression=>'jpeg',quality=>'90');
My problem is in enlarging the image size.
What I did was to convert PDF to TIFF with Group 4 compression with scaling 'Fit in frame', max width of 5800 px, max height of 5800 px and a distort aspect of 1.
Here are the functions I used: It works well by shrinking images who are bigger than 5800x5800; but when i tried with images smaller than the 5800x5800 frame, it not enlarges the image but also increases the file size unreasonably.
What I did was to convert PDF to TIFF with Group 4 compression with scaling 'Fit in frame', max width of 5800 px, max height of 5800 px and a distort aspect of 1.
Here are the functions I used:
Code: Select all
my ($width, $height) = (5800, 5800);
my $image = Image::Magick->new;
$image->Read($infile); # takes a long time
my ($w, $h) = $image->Get('width', 'height');
my ($newW, $newH);
if ($w / $width >= $h / $height) {
$newW = $width;
$newH = $h * $width / $w;
} else {
$newH = $height;
$newW = $w * $height / $h;
}
$image->Sample(width=>$newW, height=>$newH);
$image->Quantize( colors=>2, colorspace=>'gray' );
$image->Set(compression=>'Group4');
$image->Write($outfile);
We use this script: and it returns a file that is 613078 bytes long which seems reasonable for a 5800x4350image. We're using ImageMagick 6.3.1-1. Here is the description of the resulting image:
Code: Select all
use Image::Magick;
$image=Image::Magick->new();
$x = $image->Read('logo:');
warn "$x" if "$x";
$x = $image->Sample('5800x5000');
warn "$x" if "$x";
$x = $image->Quantize(colors=>2, colorspace=>'gray');
warn "$x" if "$x";
$x = $image->Write(filename=>'logo.tif',compression=>'Group4');
warn "$x" if "$x";
- tiffinfo logo.tif
TIFF Directory at offset 0x959b0 (612784)
Image Width: 5800 Image Length: 4350
Resolution: 72, 72 (unitless)
Bits/Sample: 1
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white
FillOrder: msb-to-lsb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 1
Rows/Strip: 4350
Planar Configuration: single image plane
DocumentName: logo.tif
Software: ImageMagick 6.3.1 12/11/06 Q16 http://www.imagemagick.org
magick wrote: We use this script:and it returns a file that is 613078 bytes long which seems reasonable for a 5800x4350image. We're using ImageMagick 6.3.1-1. Here is the description of the resulting image:Code: Select all
use Image::Magick; $image=Image::Magick->new(); $x = $image->Read('logo:'); warn "$x" if "$x"; $x = $image->Sample('5800x5000'); warn "$x" if "$x"; $x = $image->Quantize(colors=>2, colorspace=>'gray'); warn "$x" if "$x"; $x = $image->Write(filename=>'logo.tif',compression=>'Group4'); warn "$x" if "$x";
- tiffinfo logo.tif
TIFF Directory at offset 0x959b0 (612784)
Image Width: 5800 Image Length: 4350
Resolution: 72, 72 (unitless)
Bits/Sample: 1
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white
FillOrder: msb-to-lsb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 1
Rows/Strip: 4350
Planar Configuration: single image plane
DocumentName: logo.tif
Software: ImageMagick 6.3.1 12/11/06 Q16 http://www.imagemagick.org
OK. I ran the above program on my machine and got the resulting image of 50888330 bytes. So the problem is in my version of ImageMagic?
tiffinfo logo.tif
TIFF Directory at offset 0x301f568 (50460008)
Image Width: 5800 Image Length: 4350
Resolution: 72, 72 (unitless)
Bits/Sample: 16
Compression Scheme: None
Photometric Interpretation: palette color (RGB from colormap)
FillOrder: msb-to-lsb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 1
Rows/Strip: 1
Planar Configuration: single image plane
Color Map: (present)
DocumentName: logo.tif
Software: ImageMagick 6.2.6 03/27/06 Q16 http://www.imagemagick.org
Sample() function seems not working properly for logo file, the output file logo.tif is a black screen no matter what size it is changed to.
I just cannot upgrade to the latest version thinking it will work. There could be may be new issues. Is ImageMagick 6.2.6 reported as having a problem with enlarging image using sample?
For the newest release, is there a binary RPM that will run under CentOS?
Thank you.
I just cannot upgrade to the latest version thinking it will work. There could be may be new issues. Is ImageMagick 6.2.6 reported as having a problem with enlarging image using sample?
For the newest release, is there a binary RPM that will run under CentOS?
Thank you.
I have another version of ImageMagick: 6.1.9 08/25/06 Q8 http://www.imagemagick.org.
This one works fine by enlarging logo file but it still does work for enlarging PDF files.
What can I do??
This one works fine by enlarging logo file but it still does work for enlarging PDF files.
What can I do??