Integrate curio with pillow library

时间:2018-03-09 19:07:43

标签: python python-3.x async-await pillow curio

curio library provides async aopen() function, while pillow has it's own Image.open. I want to create thumbnail and suggest pillow is smart enough not to load all image into memory while creating thumbnail. It looks like this:

self.image = Image.open(path)
self.image.thumbnail((300, 300))

How this can be integrated with the curio library? For me it looks like I have two options:

  • Call aopen(), load data into memory, then create Image object from in-memory data and call Image.thumbnail()
  • Make Image.open() async wrapping with async_thread decorator, but it requires fire all thread machinery.

Is there some better approach for integrating curio and pillow for this task?

0 个答案:

没有答案