Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Win32 converting 32bit bmp images to 24bit

by JaWi (Hermit)
on Oct 31, 2002 at 08:56 UTC ( #209370=note: print w/replies, xml ) Need Help??

in reply to Win32 converting 32bit bmp images to 24bit

ImageMagick has fairly detailed online documentation for the Perl bindings to their libraries. If you go here, you can see all available options and sample scripts to reach certain effects.

Untested, and out of the blue I could think of the following script:

#!/usr/bin/perl -w use strict; use Image::Magick; my($image); $image = new Image::Magick; $image->Read('my_original.bmp'); $image->Quantize(treedepth => 24); open(IMAGE, ">my_output.bmp"); $image->Write(file=>\*IMAGE, filename=>"my_output.bmp"); close(IMAGE);
Did I already say it isn't tested? :-)


-- JaWi

"A chicken is an egg's way of producing more eggs."

Replies are listed 'Best First'.
Re: Re: Win32 converting 32bit bmp images to 24bit
by rochlin (Acolyte) on Oct 31, 2002 at 18:39 UTC
    That didn't appear to do it. I get an empty file as the output. Just to be clear, I don't think there would be a problem if I had a 24 bit bmp to start with (which is what most applications seem to expect - including image::magick from my tests).

    I do get a warning message on executing any imagemagick method "no magic configuration file found (magic.mgk)-No such file or directory- at line" for example. But that doesn't seem to interfere with Image::Magick operation (I ran a couple of the scripts from the documentation and they gave the warning but worked fine).

    Probably more to the point is an error I get when reading in the 32 bit bmp in quesetion: "Warning 325: Not a BMP image file (J:/temp/screencaps/newcap.bmp) at line 7". This image opens fine in Photoshop and in Mozilla 1.1 - so it is a valid BMP. Just (as I said in the original post) a 32bit BMP. Chesirecat said some not so obvious code was needed to get it to 24bit (which then ought to be a valid bmp as far as ImageMagick is concerned). Which brings me back to the original question, which would seem to require some code outside of Image::Magick calls ...

    Test Code: (for ref: line warn after the Read($name))

    use strict; use Image::Magick; my $image = Image::Magick->new; my $name = q(J:/temp/screencaps/newcap.bmp); my $x = $image->Read($name); warn "$x" if "$x"; $x = $image->Write(filename=>'J:/temp/screencaps/new.bmp'); warn "$x" if "$x";

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://209370]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2022-08-13 10:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found