Search code examples
shellbitmapghostscriptbmp

Converting a BMP to another file image type using GhostSCript


I have a .bmp image file, and always returns the error when i convert from a bitmap:

gs -sDEVICE=png256 -o ./teste.png ./teste.bmp

Returns:

GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in BM~
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   2025   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:970/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Current file position is 5
GPL Ghostscript 9.26: Unrecoverable error, exit code 1

The error Error: /undefined in BM~ returns with all output attempts


Solution

  • Ghostscript doesn't process .bmp files, it accepts PDF or PostScript. You could write a PostScript program to place a .bmp image (see for example viewgif.ps) but that's not the same thing at all.

    You need an image processing application such as ImageMagick, as suggested by Mark Setchell above.