Request More Help With XBM Image

Wildman best_lay at
Mon Feb 29 16:51:08 EST 2016

I want to take an image file, convert it to XBM format and
display it.  Thanks to Mr. Otten I can open and display the
XBM image without any problems.  The script first calls an
external program for the image conversion then I can open
and display it.  Of course, I am left with the XBM file that
needs to be deleted.  It seemed to me to be a better approach
to use stdout and pipe thereby eliminating the XBM file
altogether.  Here is code I have so far but I'm not sure
what to do next...

convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-"
p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True)
xbmFile, err = p.communicate()

The variable fileName contains the image file path and name.
The variable convert contains the complete command.  The last
argument in the command tells the convert utility to covert
to an XBM and to direct the output to stdout.  After the above
code runs xbmFile contains the actual image, which is plain
text.  (X BitMap (XBM) is a plain text binary image format.)

My question is how do I take the xbmFile variable and convert
it to an image object that can be displayed?  The technique
for displaying an image from a file does not work or at least
I have not been able to get it to work.

<Wildman> GNU/Linux user #557453
"Be at war with your vices, at peace with your neighbors,
and let every new year find you a better man."
  -Benjamin Franklin

More information about the Python-list mailing list