Br'er Rabbit has asked for the wisdom of the Perl Monks concerning the following question:
How about this one?
Is there a simple way to "use Image::Magic;" (aka PerlMagick, the Perl API to ImageMagick) to create a new "dummy" PNG image out of the ether; that is, no reading in an existing PNG file?
I've been trying for over a week and no matter what I've tried, the "magick" of files I create (which I take to be the file format: like 'PNG') come back as 'MIFF'.
I don't want to pollute the thread with my scattershot stuff that hasn't worked; if you've got a short example, please share.
I will say that my goal is to manipulate the file and Write it after it's created. I don't want to worry about how to "save as a PNG" after doing all the work, and instead, am hoping to create the write type of file before any work is started.
I hit "create" to stumbit and then this works, creating a 10x10 pixel PNG file, which is recognized as a PNG when written and read back in (I'm kinda like a novice monk who sits at the outermost gate talking to hisself):
#!/usr/bin/perl use Image::Magick; my $image=Image::Magick->new(format=>'PNG',size='10x10'); # critical t +o solution was this "format" key my $err=$image->Read("canvas:orange"); warn "$err" if $err; # these are good ideas because PerlMagick sometim +es fails silently $err=$image->Write("CANVAS_ORANGE.png"); warn "$err" if $err; my $other=Image::Magick->new; my $err=$other->Read("CANVAS_ORANGE.png"); warn "$err" if $err; my $format=$other->Get('format'); my $magick=$other->Get('magick'); print "Format:$format Magick:$magick\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [SOLVED] PerlMagick (ImageMagick API): create a new "dummy" PNG file from the ether
by roboticus (Chancellor) on Sep 26, 2019 at 13:33 UTC |