Creating an Empty File
Posted: 2009-07-20T19:06:32-07:00
I have Ubuntu 9.04. I had ImageMagick 7:6.4.5.4.dfsg1-1ubuntu3.1 installed from the repositories, as well as PerlMagick of the same version. I noticed that when I tried to use SetPixel, it always made the blue component maxed up (as in 1 or 255). I have heard that it's best to have the most recent version of PerlMagick when trying to use SetPixel, so I uninstalled what I had from the repositories and built a new install from this site, version 6.5.4-3 2009-07-20 Q16 OpenMP. The building and installing went fine, and the checks here worked OK.
Now it's developed a different problem. My perl scripts that worked at least half well, though a little blue, with the older version of PerlMagick are now just making empty files. The .png files I'm trying to write come out with 0 bytes. I have below an example script that results in this lack of substance in the resulting file. It runs through just fine with no errors or dieing, all the way to the checkpoint at the end. Might anyone know what's going on?
Now it's developed a different problem. My perl scripts that worked at least half well, though a little blue, with the older version of PerlMagick are now just making empty files. The .png files I'm trying to write come out with 0 bytes. I have below an example script that results in this lack of substance in the resulting file. It runs through just fine with no errors or dieing, all the way to the checkpoint at the end. Might anyone know what's going on?
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use strict 'refs';
use Image::Magick;
my $image=Image::Magick->new(size=>'10x10');
$image->ReadImage('xc:white');
my @pixel;
$pixel[0]=.7;
$pixel[1]=.5;
$pixel[2]=0;
$image->SetPixel(channel=>"All",x=>0,y=>0,color=>\@pixel);
my @pixels;
@pixels = $image->GetPixel(x=>0,y=>0);
print "Pixel gotted: ($pixels[0],$pixels[1],$pixels[2])\n";
my $filename = "pixelTest.png";
open(IMAGE, ">$filename") || die "Can't open $filename: $!";
$image->Write(file=>\*IMAGE, filename=>$filename) || die "Couldn't write image using path of :$filename";
close(IMAGE);
print "Check point\n";
exit;
Code: Select all
$ ./pixelTest.pl
Pixel gotted: (0.699992370489052,0.500007629510948,0)
Check point