[ocrfeeder/introspection] Fix using newer versions of Unpaper
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder/introspection] Fix using newer versions of Unpaper
- Date: Mon, 7 Jul 2014 21:13:59 +0000 (UTC)
commit 51972aa019d25eaaacb598f654a7e481b7196b06
Author: Joaquim Rocha <me joaquimrocha com>
Date: Mon Jul 7 22:16:24 2014 +0200
Fix using newer versions of Unpaper
Unpaper has been forked and newer versions do not seem to work when
the output image's name is the same one as the input's so the command
had to be updated.
gb#705610
src/ocrfeeder/util/lib.py | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/ocrfeeder/util/lib.py b/src/ocrfeeder/util/lib.py
index 5fff20a..1e7914e 100644
--- a/src/ocrfeeder/util/lib.py
+++ b/src/ocrfeeder/util/lib.py
@@ -135,19 +135,23 @@ def getUnpaperCommand(configuration_manager):
def unpaperImage(configuration_manager, image_path):
tmp_dir = configuration_manager.TEMPORARY_FOLDER
prefix = os.path.splitext(image_path)[0]
- unpapered_name = os.path.join(tmp_dir, os.path.basename(prefix) + '.ppm')
- if os.path.exists(unpapered_name):
- unpapered_name = getNonExistingFileName(unpapered_name)
+ basename = os.path.basename(prefix)
+ unpapered_in = getNonExistingFileName(os.path.join(tmp_dir,
+ basename + '_orig.pnm'))
+ unpapered_name = getNonExistingFileName(os.path.join(tmp_dir,
+ basename + '.pnm'))
image_path = Image.open(image_path)
- image_path.save(unpapered_name, format = 'PPM')
+ image_path.save(unpapered_in, format = 'PPM')
command = getUnpaperCommand(configuration_manager)
- command += ' %s %s' % (unpapered_name, unpapered_name)
+ command += ' %s %s' % (unpapered_in, unpapered_name)
print command
try:
os.system(command)
except Exception, exception:
debug(exception)
return None
+ finally:
+ os.unlink(unpapered_in)
return unpapered_name
def obtainScanners():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]