Jim Vickroy wrote: > The attachment is a simple script that creates a 2D array of unsigned, > 8-bit integers and uses matplotlib to save it as a PNG file. > > Unfortunately, the PNG file is much larger than expected -- apparently > because it is True-Color; on my MS Windows machine, bit depth, for the > file, is listed as 32 rather than the expected 8.
> Can matplotlib be used to accomplish this? If so, could someone direct > me to where this is discussed? I don't think so directly. MPL uses a 32 bit image buffer internally, and that's what gets saved out in the PNG. You can post-process the image with something like ImageMagick. Another alternative is to use PIL -- you can grab the matplotlib buffer, make a PIL image out of it, and use PIL to convert to an 8-bit palleted image. For that matter, you could probably bypass MPL, and use numpy to create the 8-bit image you want, and PIL to save it as a PNG. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users