Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Simmons <jim@sugarlabs.simmons>2010-12-09 20:39:32 (GMT)
committer James Simmons <jim@sugarlabs.simmons>2010-12-09 20:39:32 (GMT)
commit0d46d81985c02e326459a44761a91e68a376e8b3 (patch)
tree6528185abbdb7b8743823754c46aa7bfcb5f80b9
parent2030e18fe878a747265b9ffc16c9885aa44cac1d (diff)
Make scripts work in Windows
-rwxr-xr-xmakedjvus.py7
-rwxr-xr-xpgconvert.py4
-rwxr-xr-xproofer.py8
-rwxr-xr-xresizepics.py27
-rwxr-xr-xruntesseract.py5
5 files changed, 39 insertions, 12 deletions
diff --git a/makedjvus.py b/makedjvus.py
index 3e3b980..8b868a0 100755
--- a/makedjvus.py
+++ b/makedjvus.py
@@ -16,11 +16,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import glob
import getopt
import sys
import subprocess
def make_djvus(filename):
+ """This function is called
+ for each image file."""
subprocess.call(["c44", filename])
print 'filename', filename
@@ -29,6 +32,10 @@ def make_djvus(filename):
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "")
+ if len(args) == 1:
+ print 'using glob'
+ args = glob.glob(args[0])
+ args.sort()
i = 0
while i < len(args):
make_djvus(args[i])
diff --git a/pgconvert.py b/pgconvert.py
index f042fcb..9b83509 100755
--- a/pgconvert.py
+++ b/pgconvert.py
@@ -19,8 +19,8 @@
import getopt
import sys
-# This is a script to take the a file in PG format and convert it to a text file that does
-# not have newlines at the end of each line.
+# This is a script to take the a file in PG format and convert it to a text
+# file that does not have newlines at the end of each line.
def convert(file_path, output_path):
diff --git a/proofer.py b/proofer.py
index bfd591e..f84ef3f 100755
--- a/proofer.py
+++ b/proofer.py
@@ -18,6 +18,7 @@
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
+import glob
import sys
import os
import gtk
@@ -102,7 +103,6 @@ class Proofer():
def find_text_file(self, filename):
filename_tuple = filename.split('.')
text_filename = filename_tuple[0] + '.txt'
- text_filename = '../text/' + text_filename
return text_filename
def save_current_file(self, filename):
@@ -137,7 +137,7 @@ class Proofer():
self.window.set_size_request(1200, 600)
self.window.set_border_width(0)
self.scrolled_window = gtk.ScrolledWindow(
- hadjustment=None, \
+ hadjustment=None,
vadjustment=None)
self.scrolled_window.set_policy(gtk.POLICY_NEVER,
gtk.POLICY_AUTOMATIC)
@@ -178,6 +178,10 @@ class Proofer():
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "")
+ if len(args) == 1:
+ print 'using glob'
+ args = glob.glob(args[0])
+ args.sort()
Proofer().main(args)
except getopt.error, msg:
print msg
diff --git a/resizepics.py b/resizepics.py
index aa714b7..9fde9a6 100755
--- a/resizepics.py
+++ b/resizepics.py
@@ -16,42 +16,53 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import glob
import getopt
import sys
import os
import gtk
import pygame
-SCREEN_WIDTH = 900
+SCREEN_WIDTH = 1400
ARBITRARY_LARGE_HEIGHT = 10000
-JPEG_QUALITY = 80
+JPEG_QUALITY = 90
def resize_image(filename):
filename_tuple = filename.split('.')
out_filename = filename_tuple[0] + '.jpg'
- print '%s file size before conversion: %d KB' % (filename, os.stat(filename).st_size / 1024)
+ print '%s file size before conversion: %d KB' % (
+ filename, os.stat(filename).st_size / 1024)
im = pygame.image.load(filename)
image_width, image_height = im.get_size()
- print '%s image size before conversion: %d x %d' % (filename, image_width, image_height)
+ print '%s image size before conversion: %d x %d' % (
+ filename, image_width, image_height)
resize_to_width = SCREEN_WIDTH
if image_width <= SCREEN_WIDTH:
resize_to_width = image_width
try:
- scaled_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(filename, resize_to_width, ARBITRARY_LARGE_HEIGHT)
- scaled_pixbuf.save(out_filename, "jpeg", {"quality":"%d" % JPEG_QUALITY})
+ scaled_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
+ filename, resize_to_width, ARBITRARY_LARGE_HEIGHT)
+ scaled_pixbuf.save(out_filename, "jpeg",
+ {"quality":"%d" % JPEG_QUALITY})
except:
print 'File could not be converted'
- print '%s file size after conversion %d KB' % (out_filename, os.stat(out_filename).st_size /1024)
+ print '%s file size after conversion %d KB' % (
+ out_filename, os.stat(out_filename).st_size /1024)
im = pygame.image.load(out_filename)
image_width, image_height = im.get_size()
- print '%s image size after conversion: %d x %d' % (out_filename, image_width, image_height)
+ print '%s image size after conversion: %d x %d' % (
+ out_filename, image_width, image_height)
print ''
return
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "")
+ if len(args) == 1:
+ print 'using glob'
+ args = glob.glob(args[0])
+ args.sort()
i = 0
while i < len(args):
success = resize_image(args[i])
diff --git a/runtesseract.py b/runtesseract.py
index bdf5dd1..703cbe0 100755
--- a/runtesseract.py
+++ b/runtesseract.py
@@ -16,6 +16,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import glob
import getopt
import sys
import subprocess
@@ -31,6 +32,10 @@ def run_tesseract(filename):
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "")
+ if len(args) == 1:
+ print 'using glob'
+ args = glob.glob(args[0])
+ args.sort()
i = 0
while i < len(args):
run_tesseract(args[i])