X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ee01d50d05b7d72dd372e8f3a0c78b9da6c23b38..82b3920c64a77f00e2b38d8f0e1601cd74e427e4:/scripts/crop.py diff --git a/scripts/crop.py b/scripts/crop.py old mode 100644 new mode 100755 index 3266e090..764e8e5c --- a/scripts/crop.py +++ b/scripts/crop.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # import sys import os @@ -20,13 +20,12 @@ def crop(image, top=0, right=0, bottom=0, left=0): bottom = int(height * bottom) if left < 1: left = int(width * left) - + bounds = (int(left), int(top), int(width - right), int(height - bottom)) image = image.crop(bounds) image.load() return image - output_dir = realpath(os.getcwd()) + '/output' bounds = [float(i) for i in sys.argv[1].split(':')] @@ -37,6 +36,6 @@ for file_name in sys.argv[2:]: except IOError, e: sys.stderr.write('\nerror:%s:%s\n' % (file_name, e.message)) continue - + image = crop(image, *bounds) - image.save(output_dir + '/' + basename(file_name)) \ No newline at end of file + image.save(output_dir + '/' + basename(file_name))