From c45b7944cbbe3c5b902040f353df2bdd1fefd400 Mon Sep 17 00:00:00 2001 From: Wei-ju Wu Date: Tue, 20 Sep 2016 08:38:40 -0700 Subject: [PATCH] png2image and wav2ami migrated to python3 --- utils/png2image.py | 8 ++++---- utils/wav2ami.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/utils/png2image.py b/utils/png2image.py index 082bbb8..7abb07d 100755 --- a/utils/png2image.py +++ b/utils/png2image.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ For license, see gpl-3.0.txt @@ -23,10 +23,10 @@ def color_to_plane_bits(color, depth): def write_amiga_image(image, outfile): imdata = im.getdata() width, height = im.size - colors = [i for i in chunks(map(ord, im.palette.tobytes()), 3)] + colors = [i for i in chunks([b for b in im.palette.tobytes()], 3)] depth = int(math.log(len(colors), 2)) - map_words_per_row = width / 16 + map_words_per_row = int(width / 16) if width % 16 > 0: map_words_per_row += 1 @@ -42,7 +42,7 @@ def write_amiga_image(image, outfile): planebits = color_to_plane_bits(color, depth) # now we need to "or" the bits into the words in their respective planes wordidx = (x + i) / 16 # word number in current row - pos = y * map_words_per_row + wordidx # list index in the plane + pos = int(y * map_words_per_row + wordidx) # list index in the plane for planeidx in range(depth): if planebits[planeidx]: planes[planeidx][pos] |= (1 << (15 - (x + i) % 16)) # 1 << ((x + i) % 16) diff --git a/utils/wav2ami.py b/utils/wav2ami.py index b330e85..f065717 100755 --- a/utils/wav2ami.py +++ b/utils/wav2ami.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import argparse import wave import struct @@ -13,12 +13,12 @@ if __name__ == '__main__': parser.add_argument('wavfile') args = parser.parse_args() - print args.wavfile + print(args.wavfile) infile = wave.open(args.wavfile) - print "# channels: ", infile.getnchannels() - print "sample width: ", infile.getsampwidth() - print "frame rate: ", infile.getframerate() - print "# frames: ", infile.getnframes() + print("# channels: ", infile.getnchannels()) + print("sample width: ", infile.getsampwidth()) + print("frame rate: ", infile.getframerate()) + print("# frames: ", infile.getnframes()) num_frames = infile.getnframes() data = [conv_amplitude(infile.readframes(1)) for _ in range(num_frames)] #print data