Exception issue with PerlMagick **RESOLVED**
Posted: 2008-12-01T09:18:29-07:00
I think I'm lost... or I don't understand what I'm doing...
Problem 1... I'm getting file/directory not found during the ReadImage if I don't specify the path for the file, yet some of the files I want generated are generating...
Problem 2... If I specify the path, I get exceptions when doing any transformations.
Here is the entire code:
Here is the exception output if I specify the path:
Can anyone help? I'm afraid I'm misunderstanding something somewhere...
Problem 1... I'm getting file/directory not found during the ReadImage if I don't specify the path for the file, yet some of the files I want generated are generating...
Problem 2... If I specify the path, I get exceptions when doing any transformations.
Here is the entire code:
Code: Select all
$backgroundfile = "d:\Perltesting\agentphoto\agentwebsitebg.png";
$workingfile = "d:\Perltesting\agentphoto\test.tif";
$filenoext = substr($workingfile, 0, -4);
$workingfilejpg = $filenoext . ".jpg";
$workingfiletif = $filenoext . ".tif";
$workingfilejpgbw = $filenoext . "bw.jpg";
$workingfiletifbw = $filenoext . "bw.tif";
$workingfilejpgmod = $filenoext . "mod.jpg";
$workingfilegifagentws = $filenoext . "agentws.png";
$workingfilegifagentws2 = $filenoext . "agentws2.png";
$wf2 = $filenoext . "agentws2.png";
#$backgroundfile = "agentwebsitebg.png";
#$workingfile = "test.tif";
#$filenoext = substr($workingfile, 0, -4);
#$workingfilejpg = $filenoext . ".jpg";
#$workingfiletif = $filenoext . ".tif";
#$workingfilejpgbw = $filenoext . "bw.jpg";
#$workingfiletifbw = $filenoext . "bw.tif";
#$workingfilejpgmod = $filenoext . "mod.jpg";
#$workingfilegifagentws = $filenoext . "agentws.png";
#$workingfilegifagentws2 = $filenoext . "agentws2.png";
#$wf2 = $filenoext . "agentws2.png";
print "$wf2\n";
$diroutput = `dir`;
print "$diroutput\n";
print "Read...\n";
$agent1=Image::Magick->new();
$x1=$agent1->ReadImage($workingfile) or print "$workingfile - Read 1 Failed $!\n";
$agent2=Image::Magick->new();
$x2=$agent2->ReadImage($workingfile) or print "$workingfile - Read 2 Failed $!\n";
$agent3=Image::Magick->new();
$x3=$agent3->ReadImage($workingfile) or print "$workingfile - Read 3 Failed $!\n";
$agent4=Image::Magick->new();
$x4=$agent4->ReadImage($workingfile) or print "$workingfile - Read 4 Failed $!\n";
$agent5=Image::Magick->new() or print "New Failed $!\n";
$x5=$agent5->ReadImage($backgroundfile) or print "$backgroundfile - Read 5 Failed $!\n";
$x4 = $agent4->Set(debug=>'exception');
$x5 = $agent5->Set(debug=>'exception');
print "Transform Image to Grayscale... \n";
$x2 = $agent2->Quantize(colorspace=>'gray');
$x3 = $agent3->Quantize(colorspace=>'gray');
print "First Write Image... \n";
$x1=$agent1->WriteImage($workingfilejpg);
$x2=$agent2->WriteImage($workingfilejpgbw);
$x3=$agent3->WriteImage($workingfiletifbw);
print "Transform Image to Passport Needs... \n";
$x1 = $agent1->Set(density=>'72x72');
$x1 = $agent1->Frame(geometry=>'1x1', fill=>"Black");
$x1 = $agent1->Scale(geometry=>'94x116');
print "Second Write Image... \n";
$x1=$agent1->WriteImage($workingfilejpgmod);
print "Transform Image for Agent Website Needs ... \n";
print "Set Density\n";
$x4 = $agent4->Resample(density=>'300x300');
print "Set Units\n";
$x4 = $agent4->Set(units=>'pixelsperinch');
print "Set Rotation\n";
$x4 = $agent4->Rotate(degrees=>'-5', background=>'none');
print "Set Scale\n";
$x4 = $agent4->Scale(geometry=>'194x233');
#$x5 = $agent5->Composite(image=>'$x4', compose=>'over', geometry=>'225x256+15+11') or print "Compsite Failed $!";
print "Set Composite\n";
$x5 = $agent5->Composite(image=>'$x4', compose=>'over', mask=>'$x5', geometry=>'225x256+15+11') or print "Compsite Failed $!";
print "Third Write Image... \n";
$x4=$agent4->WriteImage($workingfilegifagentws);
$x5=$agent5->WriteImage($wf2) or print "Write Failed $!\n";
$agent5->WriteImage($wf2);
print "Script Complete";
Here is the exception output if I specify the path:
Code: Select all
Read...
Transform Image to Grayscale...
2008-12-01T10:12:30-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Quantize'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Quantize'
First Write Image...
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
Transform Image to Passport Needs...
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Frame'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Scale'
Second Write Image...
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
Transform Image for Agent Website Needs ...
Set Density
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Resample'
Set Units
Set Rotation
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Rotate'
Set Scale
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Scale'
Set Composite
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/6456/Exception
no images defined `Composite'
Third Write Image...
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
2008-12-01T10:12:31-06:00 0:01 0.000u 6.4.1 Exception PerlMagick[3072]: Magick.xs/unknown/12348/Exception
no images defined `Image::Magick'
Script Complete
Can anyone help? I'm afraid I'm misunderstanding something somewhere...