[ocrfeeder] Removed unused code



commit d8d4924b8f09eae44e4b5d755343fadbb937cb56
Author: Joaquim Rocha <jrocha igalia com>
Date:   Fri Jan 22 17:12:17 2010 +0100

    Removed unused code

 feeder/documentGeneration.py |   24 -----------
 util/graphics.py             |   95 ------------------------------------------
 2 files changed, 0 insertions(+), 119 deletions(-)
---
diff --git a/feeder/documentGeneration.py b/feeder/documentGeneration.py
index 33fc652..66a9cdd 100644
--- a/feeder/documentGeneration.py
+++ b/feeder/documentGeneration.py
@@ -80,30 +80,6 @@ class DocumentGenerator:
         elif align == ALIGN_FILL:
             return 'justified'
 
-class PdfGenerator(DocumentGenerator):
-    
-    def __init__(self, name, image_path):
-        width, height = getImagePrintSize(image_path)
-        self.document = canvas.Canvas(name, pagesize = (width * inch, height * inch))
-    
-    def addText(self, data_box):
-        text = data_box.getText()
-        text_object = self.document.beginText()
-        text_object.setTextOrigin(data_box.x, data_box.y)
-        text_object.setFont('Times-Roman', data_box.text_data.size)
-        text_object.moveCursor(0, data_box.text_data.size)
-        text_object.textLines(text)
-        self.document.drawText(text_object)
-    
-    def addImage(self, data_box):
-        pass
-    
-    def save(self):
-        self.document.save()
-    
-    def newPage(self):
-        self.document.showPage()
-
 class HtmlGenerator(DocumentGenerator):
     
     def __init__(self, name):
diff --git a/util/graphics.py b/util/graphics.py
index 09ae0c7..4af41dc 100644
--- a/util/graphics.py
+++ b/util/graphics.py
@@ -90,101 +90,6 @@ def getImagePrintSize(image_object):
     x_resolution, y_resolution = resolution
     width, height = image_object.size
     return ( float(width) / float(x_resolution), float(height) / float(y_resolution) )
-    
-
-def OLDgetTextSizeFromImage(image):
-    width, height = image.size
-    text_sizes = [0]
-    line_spaces = [0]
-    remove_last_space = True
-    for i in range(getTextBeginHeight(image), height, 1):
-        current_line = image.crop((0, i - 1, width, i))
-        current_line.convert('L')
-        blank_line = True
-        colors = current_line.getcolors()
-        background_color = 255
-        if colors:
-            background_color = (list(colors[0][1])).pop()
-        if colors:
-            for color in colors:
-                if colorsContrast(list(color[1]).pop(), background_color):
-                    blank_line = False
-                    break
-            if blank_line:
-                remove_last_space = True
-                if len(text_sizes) > 1 or text_sizes[0] != 0:
-                    line_spaces[-1] += 1
-                if text_sizes[-1]:
-                    text_sizes.append(0)
-            else:
-                remove_last_space = False
-                text_sizes[-1] += 1
-                if line_spaces:
-                    if line_spaces[-1]:
-                        line_spaces.append(0)
-    if remove_last_space:
-        if line_spaces:
-            del line_spaces[-1]
-    text_sizes.sort()
-    text_sizes = [i for i in text_sizes if i != 0]
-    line_spaces.sort()
-    line_spaces = [i for i in line_spaces if i != 0]
-    
-    text_size = 0
-    if text_sizes:
-        text_sizes_avg = sum(text_sizes) / len(text_sizes)
-        for i in text_sizes:
-            if i > text_sizes_avg:
-                text_size = math.floor(i)
-                break
-        text_size = max(text_sizes)
-    line_space = 0
-    if line_spaces:
-        line_spaces_avg = sum(line_spaces) / len(line_spaces)
-        for i in line_spaces:
-            if i > line_spaces_avg:
-                line_space = math.floor(i)
-                break
-        line_space = max(line_spaces)
-    return text_size, 0
-count = 0
-def OLDgetTextSizeFromImage(image):
-    width, height = image.size
-    global count
-    debug('Image #%s' % count)
-    image.save('/tmp/img%s.png' % count , 'PNG')
-    count += 1
-    text_sizes = [0]
-    for i in xrange(getTextBeginHeight(image), height):
-        current_line = image.crop((0, i - 1, width, i))
-        current_line.convert('L')
-        blank_line = True
-        colors = current_line.getcolors()
-        background_color = 255
-        if colors:
-            colors.sort()
-            background_color = (list(colors[-1][1])).pop()
-            for color in colors:
-                if colorsContrast(list(color[1]).pop(), background_color):
-                    blank_line = False
-                    break
-            if blank_line:
-                if text_sizes[-1]:
-                    text_sizes.append(0)
-            else:
-                text_sizes[-1] += 1
-    text_sizes.sort()
-    text_sizes = [i for i in text_sizes if i != 0]
-    text_size = 0
-    if text_sizes:
-        text_sizes_avg = sum(text_sizes) / len(text_sizes)
-        for i in text_sizes:
-            if i > text_sizes_avg:
-                text_size = math.floor(i)
-                break
-        text_size = max(text_sizes)
-    debug('Text Size: ', text_size)
-    return text_size
 
 def getTextSizeFromImage(image):
     width, height = image.size



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]