]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/tools/img2img.py
3ce1e9f7ff2e6c163f1b8921a649fe6c57e2a3d3
2 Common routines for the image converter utilities.
4 import sys
, os
, glob
, getopt
, string
5 from wxPython
.wx
import *
7 if wxPlatform
== "__WXGTK__":
8 # some bitmap related things need to have a wxApp initialized...
11 wxInitAllImageHandlers()
13 def convert(file, maskClr
, outputDir
, outputName
, outType
, outExt
):
14 if string
.lower(os
.path
.splitext(file)[1]) == ".ico":
15 icon
= wxIcon(file, wxBITMAP_TYPE_ICO
)
16 img
= wxBitmapFromIcon(icon
)
18 img
= wxBitmap(file, wxBITMAP_TYPE_ANY
)
21 return 0, file + " failed to load!"
25 mask
= wxMaskColour(img
, maskClr
)
32 newname
= os
.path
.join(outputDir
,
33 os
.path
.basename(os
.path
.splitext(file)[0]) + outExt
)
34 if img
.SaveFile(newname
, outType
):
35 return 1, file + " converted to " + newname
37 img
= wxImageFromBitmap(img
)
38 if img
.SaveFile(newname
, outType
):
41 return 0, file + " failed to save!"
46 def main(args
, outType
, outExt
, doc
):
47 if not args
or ("-h" in args
):
56 opts
, fileArgs
= getopt
.getopt(args
, "m:n:o:")
57 except getopt
.GetoptError
:
74 for file in glob
.glob(arg
):
75 if not os
.path
.isfile(file):
77 ok
, msg
= convert(file, maskClr
, outputDir
, outputName
,