Search code examples
image-processingcommand-linescaling

How can I scale an xpm image, retaining symbolic colour names


I'm trying to batch scale a load of xpm images to double pixel size. I can do this using ImageMagick like this:

convert infile.xpm -sample 200% outfile.xpm

However, the symbolic colour names are lost.

In the original input, the colour entries are as follows:

".  c #007EBF s active_hilight_1",
"+  c #0A5E89 s active_color_1",
"@  c #143D52 s active_shadow_1",

In the up-scaled version:

"  c #143D52",
". c #0A5E89",
"X c #007EBF",

The colour names changed, which is fine, but as you can see the s <symbolic-name> suffixes are stripped.

Does anyone know a quick way to do this using ImageMagick or a similar (open-source) utility?

Thanks

EDIT: Seems ImageMagick can't due this due to a bug, but does anyone know any other tool which may be able to do this?


Solution

  • mogrify -sample 200% *.xpm
    

    ^ This works as long as you have a new (post 2019-09-02) version of ImageMagick with the xpm output bug fixed, as described here: https://github.com/ImageMagick/ImageMagick/issues/1684

    Today's master branch, for example, passes symbolic colour names through properly.