Converting .png to .xpm with transparency and RGB colorspace

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
peter_p
Posts: 2
Joined: 2013-04-07T23:30:04-07:00
Authentication code: 6789

Converting .png to .xpm with transparency and RGB colorspace

Post by peter_p »

Hi,

I need to convert a .png image to .xpm containing a RGB colorspace and keeping the transparency information of the .png image. The problem is the resulting .xpm file always contains only a blackwhite colorspace. But I need a RGB colorspace in the resulting .xpm file.

I am using ImageMagick 6.7.7-10 (ubuntu 12.10). The code I use to convert the image is:

convert -background none Contours.png Contours.xpm

I also tried to force the number of colors (-colors 256) and the colorspace (-colorspace RGB) without success.

I hope someone can help me with this problem,

Thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting .png to .xpm with transparency and RGB colors

Post by snibgo »

First, I sugget you upgrade to a more recent version of IM. That one is ancient.

Second, I know nothing about XPM format. But converting a PNG with transparency to XPM and back to PNG works fine with no options at all, and no visible colour change. However, the alpha becomes binary, ie on or off, and loses any graduation.

Code: Select all

convert a.png x.xpm
convert x.xpm aa.png
snibgo's IM pages: im.snibgo.com
peter_p
Posts: 2
Joined: 2013-04-07T23:30:04-07:00
Authentication code: 6789

Re: Converting .png to .xpm with transparency and RGB colors

Post by peter_p »

Your answer clarified the behavior of convert.

As you pointed out the xpm format only supports binary transparency. In my special case the image data only consist of black pixels and an appropriate alpha value. So converting this png image with 8bit transparency to xpm must result in a monochrome image.

Thanks for your help.
Post Reply