]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/tools/img2img.py
2 Common routines for the image converter utilities.
4 import sys
, os
, glob
, getopt
, string
5 from wxPython
.wx
import *
7 wxInitAllImageHandlers()
9 def convert(file, maskClr
, outputDir
, outputName
, outType
, outExt
):
10 if string
.lower(os
.path
.splitext(file)[1]) == ".ico":
11 icon
= wxIcon(file, wxBITMAP_TYPE_ICO
)
12 img
= wxBitmapFromIcon(icon
)
14 img
= wxBitmap(file, wxBITMAP_TYPE_ANY
)
17 return 0, file + " failed to load!"
21 mask
= wxMaskColour(img
, maskClr
)
28 newname
= os
.path
.join(outputDir
,
29 os
.path
.basename(os
.path
.splitext(file)[0]) + outExt
)
30 if img
.SaveFile(newname
, outType
):
31 return 1, file + " converted to " + newname
33 img
= wxImageFromBitmap(img
)
34 if img
.SaveFile(newname
, outType
):
37 return 0, file + " failed to save!"
42 def main(args
, outType
, outExt
, doc
):
43 if not args
or ("-h" in args
):
52 opts
, fileArgs
= getopt
.getopt(args
, "m:n:o:")
53 except getopt
.GetoptError
:
70 for file in glob
.glob(arg
):
71 if not os
.path
.isfile(file):
73 ok
, msg
= convert(file, maskClr
, outputDir
, outputName
,