]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/tools/img2img.py
   1 #---------------------------------------------------------------------- 
   2 # Name:        wxPython.tools.img2img 
   3 # Purpose:     Common routines for the image converter utilities. 
   8 # Copyright:   (c) 2002 by Total Control Software 
   9 # Licence:     wxWindows license 
  10 #---------------------------------------------------------------------- 
  11 # 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net) 
  13 # o V2.5 compatability update  
  23 def convert(file, maskClr
, outputDir
, outputName
, outType
, outExt
): 
  24     if os
.path
.splitext(file)[1].lower() == ".ico": 
  25         icon 
= wx
.Icon(file, wx
.BITMAP_TYPE_ICO
) 
  26         img 
= wx
.BitmapFromIcon(icon
) 
  28         img 
= wx
.Bitmap(file, wx
.BITMAP_TYPE_ANY
) 
  31         return 0, file + " failed to load!" 
  35             mask 
= wx
.MaskColour(img
, maskClr
) 
  42             newname 
= os
.path
.join(outputDir
, 
  43                                    os
.path
.basename(os
.path
.splitext(file)[0]) + outExt
) 
  44         if img
.SaveFile(newname
, outType
): 
  45             return 1, file + " converted to " + newname
 
  47             img 
= wx
.ImageFromBitmap(img
) 
  48             if img
.SaveFile(newname
, outType
): 
  51                 return 0, file + " failed to save!" 
  56 def main(args
, outType
, outExt
, doc
): 
  57     if not args 
or ("-h" in args
): 
  66         opts
, fileArgs 
= getopt
.getopt(args
, "m:n:o:") 
  67     except getopt
.GetoptError
: 
  84         for file in glob
.glob(arg
): 
  85             if not os
.path
.isfile(file): 
  87             ok
, msg 
= convert(file, maskClr
, outputDir
, outputName
,