Convert PNG to BMP

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
Zeokat

Convert PNG to BMP

Post by Zeokat »

How can i write a BMP output with a PNG as source and the output have to be a BMP 24.

Code: Select all

my $image_magick = Image::Magick->new();
my $x = $image_magick->Read('file.png');
$image_magick->Write(filename=>'test.bmp');
Perhaps someone can help me.

Infos obtained with identify (over output file):

Code: Select all

Image: char_rot_0.bmp
  Format: BMP (Microsoft Windows bitmap image)
  Class: DirectClass
  Geometry: 16x27+0+0
  Resolution: 28.34x28.34
  Print size: 0.564573x0.952717
  Units: PixelsPerCentimeter
  Type: GrayscaleMatte
  Endianess: Undefined
  Colorspace: Gray
  Depth: 8-bit
  Channel depth:
    gray: 8-bit
    alpha: 1-bit
  Channel statistics:
    gray:
      min: 22 (0.0862745)
      max: 255 (1)
      mean: 241.833 (0.948366)
      standard deviation: 40.9867 (0.160732)
    alpha:
      min: 0 (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
  Histogram:
       363: (255,255,255,255) #FFFFFF white
         3: (229,229,229,255) #E5E5E5 grey90
         3: (250,250,250,255) #FAFAFA grey98
         2: (158,158,158,255) #9E9E9E grey62
         2: (206,206,206,255) #CECECE rgba(206,206,206,0)
         2: (231,231,231,255) #E7E7E7 rgba(231,231,231,0)
         2: (248,248,248,255) #F8F8F8 rgba(248,248,248,0)
         2: (252,252,252,255) #FCFCFC grey99
         2: (254,254,254,255) #FEFEFE rgba(254,254,254,0)
         1: ( 22, 22, 22,255) #161616 rgba(22,22,22,0)
         1: ( 29, 29, 29,255) #1D1D1D rgba(29,29,29,0)
         1: ( 45, 45, 45,255) #2D2D2D rgba(45,45,45,0)
         1: ( 52, 52, 52,255) #343434 rgba(52,52,52,0)
         1: ( 53, 53, 53,255) #353535 rgba(53,53,53,0)
         1: ( 58, 58, 58,255) #3A3A3A rgba(58,58,58,0)
         1: ( 62, 62, 62,255) #3E3E3E rgba(62,62,62,0)
         1: ( 66, 66, 66,255) #424242 grey26
         1: ( 77, 77, 77,255) #4D4D4D grey30
         1: ( 82, 82, 82,255) #525252 grey32
         1: ( 83, 83, 83,255) #535353 rgba(83,83,83,0)
         1: ( 84, 84, 84,255) #545454 grey33
         1: ( 98, 98, 98,255) #626262 rgba(98,98,98,0)
         1: ( 99, 99, 99,255) #636363 grey39
         1: (102,102,102,255) #666666 grey40
         1: (104,104,104,255) #686868 rgba(104,104,104,0)
         1: (105,105,105,255) #696969 DimGray
         1: (111,111,111,255) #6F6F6F rgba(111,111,111,0)
         1: (117,117,117,255) #757575 grey46
         1: (129,129,129,255) #818181 rgba(129,129,129,0)
         1: (130,130,130,255) #828282 grey51
         1: (135,135,135,255) #878787 grey53
         1: (144,144,144,255) #909090 rgba(144,144,144,0)
         1: (146,146,146,255) #929292 rgba(146,146,146,0)
         1: (149,149,149,255) #959595 rgba(149,149,149,0)
         1: (153,153,153,255) #999999 grey60
         1: (164,164,164,255) #A4A4A4 rgba(164,164,164,0)
         1: (166,166,166,255) #A6A6A6 grey65
         1: (175,175,175,255) #AFAFAF rgba(175,175,175,0)
         1: (176,176,176,255) #B0B0B0 grey69
         1: (182,182,182,255) #B6B6B6 rgba(182,182,182,0)
         1: (183,183,183,255) #B7B7B7 rgba(183,183,183,0)
         1: (185,185,185,255) #B9B9B9 rgba(185,185,185,0)
         1: (202,202,202,255) #CACACA rgba(202,202,202,0)
         1: (210,210,210,255) #D2D2D2 rgba(210,210,210,0)
         1: (211,211,211,255) #D3D3D3 LightGray
         1: (213,213,213,255) #D5D5D5 rgba(213,213,213,0)
         1: (219,219,219,255) #DBDBDB grey86
         1: (220,220,220,255) #DCDCDC gainsboro
         1: (224,224,224,255) #E0E0E0 grey88
         1: (225,225,225,255) #E1E1E1 rgba(225,225,225,0)
         1: (227,227,227,255) #E3E3E3 grey89
         1: (228,228,228,255) #E4E4E4 rgba(228,228,228,0)
         1: (233,233,233,255) #E9E9E9 rgba(233,233,233,0)
         1: (234,234,234,255) #EAEAEA rgba(234,234,234,0)
         1: (235,235,235,255) #EBEBEB grey92
         1: (236,236,236,255) #ECECEC rgba(236,236,236,0)
         1: (241,241,241,255) #F1F1F1 rgba(241,241,241,0)
         1: (244,244,244,255) #F4F4F4 rgba(244,244,244,0)
         1: (251,251,251,255) #FBFBFB rgba(251,251,251,0)
         1: (253,253,253,255) #FDFDFD rgba(253,253,253,0)
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgba(223,223,223,0)
  Matte color: grey74
  Transparent color: none
  Page geometry: 16x27+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    create-date: 2008-08-09T16:44:26+02:00
    modify-date: 2008-08-09T16:41:51+02:00
    signature: 22029d3f9b95e7848a1fee225764f1744edd0d90b47494c4d20fab6703a565c8
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 1.81kb
  Number pixels: 4.3e+002b
  Version: ImageMagick 6.4.2 08/01/08 Q16 http://www.imagemagick.org
And i need that the output is :
Type: Grayscale --> and not Grayscale matte
alpha: 1-bit --> this have to be removed
The alpha infos should be removed too
alpha:
min: 0 (0)
max: 0 (0)
mean: 0 (0)
standard deviation: 0 (0)
Transparent color: black (and not none)

Thanks in advance.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert PNG to BMP

Post by magick »

Use this code:

Code: Select all

$image_magick->Write(filename=>'bmp3:test.bmp');
If that does not give you what you want, try bmp2: instead.
Zeokat

Re: Convert PNG to BMP

Post by Zeokat »

Thanks for the reply... i fixed it with next:

Code: Select all

$image_magick->Write(filename=>"char_rot_$i.bmp",type=>'Grayscale',alpha=>'Deactivate'); 
Post Reply