diff --git a/main.py b/main.py index 9fd911a..b138446 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,9 @@ -import sys, os +import sys +import os from package import app -os.environ["GOOGLE_APPLICATION_CREDENTIALS"]=os.path.join(sys.path[0], 'package', 'key', 'photo_tagging_service.json') +os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.path.join( + sys.path[0], 'package', 'key', 'photo_tagging_service.json') if __name__ == "__main__": - sys.exit(app.run()) \ No newline at end of file + sys.exit(app.run()) diff --git a/package/app.py b/package/app.py index 4df864f..df30670 100644 --- a/package/app.py +++ b/package/app.py @@ -51,7 +51,7 @@ def run(): # Alert the user that there are duplicates in the directory and ask whether or not to continue if len(identicals) > 0: - print('Identical files were found in the directory, continue?') + print('Identical files were the directory, continue?') print(',\n\t'.join(identicals)) xmps = [possible for possible in files diff --git a/package/process.py b/package/process.py index 65ac4b9..1a68683 100644 --- a/package/process.py +++ b/package/process.py @@ -28,22 +28,22 @@ class FileProcessor(object): def rawOptimize(self): rgb = rawpy.imread(os.path.join(INPUT_PATH, self.file_name)) - imageio.imsave(temp_file_path, rgb.postprocess()) + imageio.imsave(self.temp_file_path, rgb.postprocess()) rgb.close() # Information on file sizes - print("Raw Size: {} {}".format(*_size(os.path.join(INPUT_PATH, self.file_name))), end=' | ') - print("Resave Size: {} {}".format(*_size(temp_file_path)), end=' | ') - pre = os.path.getsize(temp_file_path) - self._optimize(temp_file_path) - post = os.path.getsize(temp_file_path) - print("Optimized Size: {} {} ({}% savings)".format(*_size(temp_file_path), round((1.0 - (post / pre)) * 100), 2) ) + print("Raw Size: {} {}".format(*self._size(os.path.join(INPUT_PATH, self.file_name))), end=' | ') + print("Resave Size: {} {}".format(*self._size(self.temp_file_path)), end=' | ') + pre = os.path.getsize(self.temp_file_path) + self._optimize(self.temp_file_path) + post = os.path.getsize(self.temp_file_path) + print("Optimized Size: {} {} ({}% savings)".format(*self._size(self.temp_file_path), round((1.0 - (post / pre)) * 100), 2) ) def basicOptimize(self): pre = os.path.getsize(os.path.join(INPUT_PATH, self.file_name)) - self._optimize(os.path.join(INPUT_PATH, self.file_name), copy=temp_file_path) - post = os.path.getsize(temp_file_path) - print("Optimized Size: {} {} ({}% savings)".format(*_size(temp_file_path), round((1.0 - (post / pre)) * 100), 2) ) + self._optimize(os.path.join(INPUT_PATH, self.file_name), copy=self.temp_file_path) + post = os.path.getsize(self.temp_file_path) + print("Optimized Size: {} {} ({}% savings)".format(*self._size(self.temp_file_path), round((1.0 - (post / pre)) * 100), 2) ) def run(self, client): @@ -55,7 +55,7 @@ class FileProcessor(object): self.basicOptimize() # Open the image, read as bytes, convert to types Image - image = Image.open(temp_file_path) + image = Image.open(self.temp_file_path) bytesIO = io.BytesIO() image.save(bytesIO, format='jpeg') image.close()