I have a little problem with my validator code, its saving 0 byte images and I just don't know why, the value variable is an image that actually contains an image, I have tested it several times to see what it contains and its an image but for some reason when it comes to saving it in the database it saves an empty image, please assist me where I could be going wrong. Regards
from gluon import * import pytesseract from PIL import Image class IS_RECEIPT_OR_INVOICE(object): def __init__(self, error_message="The uploaded file is not a receipt or invoice!"): self.error_message = error_message def __call__(self, value): error = None try: image = Image.open(value.file) text = pytesseract.image_to_string(image) if "receipt" not in text.lower() and "invoice" not in text.lower() and "RECEIPT" not in text and "INVOICE" not in text: error = self.error_message except: error = self.error_message return (value, error) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/36a83aca-5eba-4f2f-88ab-e624012468fen%40googlegroups.com.