def pgmagick_image(source, **options): """ Try to open the source file using pgmagick, ignoring any errors. """ # Use a StringIO wrapper because if the source is an incomplete file like # object, PIL may have problems with it. For example, some image types # require tell and seek methods that are not present on all storage # File objects. # import ipdb; ipdb.set_trace() if not source: return source.open() # If tried by a previous source_generator, will be closed source = StringIO(source.read()) try: blob = Blob(source.read()) image = Image(blob) except Exception: logger.exception("unable to read image to create thumbnail") return if not image.isValid(): return return convertGMtoPIL(image)
def pgmagick_image(source, **options): """ Try to open the source file using pgmagick, ignoring any errors. """ # Use a StringIO wrapper because if the source is an incomplete file like # object, PIL may have problems with it. For example, some image types # require tell and seek methods that are not present on all storage # File objects. # import ipdb; ipdb.set_trace() if not source: return source.open() # If tried by a previous source_generator, will be closed source = StringIO(source.read()) try: blob = Blob(source.read()) image = Image(blob) except Exception: logger.exception("unable to read image to create thumbnail") return if not image.isValid(): return return convertGMtoPIL(image)
def is_valid_image(self, raw_data): blob = Blob() blob.update(raw_data) im = Image(blob) return im.isValid()
def is_valid_image(self, raw_data): blob = Blob() blob.update(raw_data) im = Image(blob) return im.isValid()