diff --git a/NTFT.py b/NTFT.py index 6d3d6a9..e1530a7 100644 --- a/NTFT.py +++ b/NTFT.py @@ -120,11 +120,11 @@ class NTFT: #the actual stored data is a image with the sizes padded to the nearest power of 2 psize = [] - for i in size: + for i in (w, h): p = 1 while 1<

[ [ ]]" print "" @@ -243,31 +242,53 @@ if __name__ == "__main__": sys.exit() input = sys.argv[1] - Encode = True#if false it'll decode - if input[-4:].lower == "ntft" or len(sys.argv) >= 5: + if input[-4:].lower() == "ntft" or len(sys.argv) >= 5: + print "Mode: NTFT -> image" Encode = False + else: + print "Mode: image -> NTFT" + Encode = True#if false it'll decode if len(sys.argv) >= 3: output = sys.argv[2] + width, height = None, None if len(sys.argv) >= 5: if (not sys.argv[3].isdigit()) or (not sys.argv[4].isdigit()): - print "Invalid sizes" + print "Invalid size input!" sys.exit() width = int(sys.argv[3]) height = int(sys.argv[4]) - else: - width, height = None, None + + if not (width and height): + print "Image size not provided!" + sys.exit() + else: output = ".".join(input.split(".")[:-1]) + (".ntft" if Encode else ".png") print "Converting..." if Encode: + try: + image = ReadImage(input) + except IOError as err: + print err + sys.exit() + i = NTFT() i.Loaded = True - i.Image = ReadImage(input) + i.Image = image i.WriteFile(output) else: - WriteImage(NTFT().ReadFile(input, (width, height)).Image, output) + try: + ntft = NTFT().ReadFile(input, (width, height)) + except IOError as err: + print err + sys.exit() + + if not ntft:#eeror message already printed + sys.exit() + + WriteImage(ntft.Image, output) print "Done!" \ No newline at end of file diff --git a/ReadMe.txt b/ReadMe.txt index 091b5e0..f6f3c67 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -5,7 +5,7 @@ --VERSIONS-- PPM.py: v1.05 UGO.py: v0.92 -NTFT.py: v0.71 +NTFT.py: v0.73 --DESCRIPTION-- PPM.py can read the metadata, thumbnail, frames and the sound of Flipnote Studio files: .ppm