From b08b2fac78bac6c0eb504be163c6cbc440d792de Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Sun, 5 Apr 2020 11:09:36 +0300 Subject: [PATCH] switch to python3 for image_list --- files/image_list.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/files/image_list.py b/files/image_list.py index 825c565..197c108 100755 --- a/files/image_list.py +++ b/files/image_list.py @@ -1,5 +1,5 @@ -#!/usr/bin/env python -from __future__ import print_function +#!/usr/bin/env python3 +# ~ from __future__ import print_function import sys import os import re @@ -408,7 +408,7 @@ def get_dims(filename): idargs=['identify','-format','%wx%h',filename+'[0]'] p=subprocess.Popen(idargs,stdout=subprocess.PIPE) out, err = p.communicate() - return (out.strip().split('x')) + return (out.decode('utf8').strip().split('x')) def call_viewer(opts, files): """ Runs the viewer program, contains defaults """ @@ -545,8 +545,8 @@ def get_colors(filename): '-format','"%[fx:mean.r],%[fx:mean.g],%[fx:mean.b]"','info:-'] p=subprocess.Popen(mean_args,stdout=subprocess.PIPE,stdin=subprocess.PIPE) border, err = p.communicate(input=img) - mean=[float(i) for i in mean.strip().strip('"').split(',')] - border=[float(i) for i in border.strip().strip('"').split(',')] + mean=[float(i) for i in mean.decode('utf8').strip().strip('"').split(',')] + border=[float(i) for i in border.decode('utf8').strip().strip('"').split(',')] return (mean,border) def get_color_diff(c1,c2): @@ -581,12 +581,13 @@ def append_fingerprints(opt): conn.commit() def get_fingerprint(filename): - small_args=['convert','-define','jpeg:size=256x256',filename+'[0]','-resize','160x160!', + print(filename) + small_args=['convert','-define','jpeg:size=256x256',filename+'[0]','-resize','160x160!', '-alpha', 'off', '-colorspace','Gray','-blur','2x2','-normalize','-equalize','-resize','16x16','-depth','1','TXT:-'] p=subprocess.Popen(small_args,stdout=subprocess.PIPE) img, err = p.communicate() values='' - for row in img.split('\n'): + for row in img.decode('utf8').split('\n'): if row.find("gray(0)") > 0: values += '0' continue