I was planning to upload images via http://pypi.python.org/pypi/Flask-Uploads then I wanted to resize them for display by the application. I suppose I would upload the raw image and then have some kind of background task run in the background to resize the images. What is a simple way to achieve this? I wondered about having a background script which polls for new images, i.e. using Cron? Is there a way within flask to fork off an image processing task, not related to the initiating web request. Perhaps I'm making this too complex. Also ideally I want it to work on Windows as well as Linux. Any thoughts? Thanks, Jim.
http://docs.python.org/library/multiprocessing.html http://code.google.com/p/workerpool/ For image processing as you describe I would use multiprocessing. If multiprocessing isn't available on Windows you might try conditional use of workerpool on Windows and multiprocessing on Linux. Den Nov 20, 2010 kl. 10:16 AM skrev JimG: I was planning to upload images via http://pypi.python.org/pypi/Flask-Uploads then I wanted to resize them for display by the application. I suppose I would upload the raw image and then have some kind of background task run in the background to resize the images. What is a simple way to achieve this? I wondered about having a background script which polls for new images, i.e. using Cron? Is there a way within flask to fork off an image processing task, not related to the initiating web request. Perhaps I'm making this too complex. Also ideally I want it to work on Windows as well as Linux. Any thoughts? Thanks, Jim.
I use Gearman as a background task job. http://gearman.org/ Benefit of using Gearman is that the client submitting a task and a worker performing it can be totally disjoint and in different languages, separate hosts .. etc. On Wed, Nov 24, 2010 at 8:48 AM, Rob Mela <rob@thinkingscreen.com> wrote: > http://docs.python.org/library/multiprocessing.html > http://code.google.com/p/workerpool/ > > For image processing as you describe I would use multiprocessing. If > multiprocessing isn't available on Windows you might try conditional use of > workerpool on Windows and multiprocessing on Linux. > > Den Nov 20, 2010 kl. 10:16 AM skrev JimG: > > I was planning to upload images via > http://pypi.python.org/pypi/Flask-Uploads then I wanted to resize them for > display by the application. > > I suppose I would upload the raw image and then have some kind of > background task run in the background to resize the images. > > What is a simple way to achieve this? I wondered about having a background > script which polls for new images, i.e. using Cron? > > Is there a way within flask to fork off an image processing task, not > related to the initiating web request. > > Perhaps I'm making this too complex. Also ideally I want it to work on > Windows as well as Linux. > > Any thoughts? Thanks, Jim. > > >
For users of uwsgi there's the uwsgi spooler.. Perhaps less flexible than gearman, but that might not matter in this use case. http://projects.unbit.it/uwsgi/wiki/Spooler <http://projects.unbit.it/uwsgi/wiki/Spooler> Den Nov 24, 2010 kl. 9:26 AM skrev Arek Bochinski: I use Gearman as a background task job. http://gearman.org/ Benefit of using Gearman is that the client submitting a task and a worker performing it can be totally disjoint and in different languages, separate hosts .. etc. On Wed, Nov 24, 2010 at 8:48 AM, Rob Mela <rob@thinkingscreen.com<mailto:rob@thinkingscreen.com>> wrote: http://docs.python.org/library/multiprocessing.html http://code.google.com/p/workerpool/ For image processing as you describe I would use multiprocessing. If multiprocessing isn't available on Windows you might try conditional use of workerpool on Windows and multiprocessing on Linux. Den Nov 20, 2010 kl. 10:16 AM skrev JimG: I was planning to upload images via http://pypi.python.org/pypi/Flask-Uploads then I wanted to resize them for display by the application. I suppose I would upload the raw image and then have some kind of background task run in the background to resize the images. What is a simple way to achieve this? I wondered about having a background script which polls for new images, i.e. using Cron? Is there a way within flask to fork off an image processing task, not related to the initiating web request. Perhaps I'm making this too complex. Also ideally I want it to work on Windows as well as Linux. Any thoughts? Thanks, Jim.
depending on your access, "inotify" would perhaps trigger the resizing. On Wed, Nov 24, 2010 at 1:48 PM, Rob Mela <rob@thinkingscreen.com> wrote: > http://docs.python.org/library/multiprocessing.html > http://code.google.com/p/workerpool/ > > For image processing as you describe I would use multiprocessing. If > multiprocessing isn't available on Windows you might try conditional use of > workerpool on Windows and multiprocessing on Linux. > > Den Nov 20, 2010 kl. 10:16 AM skrev JimG: > > I was planning to upload images via > http://pypi.python.org/pypi/Flask-Uploads then I wanted to resize them for > display by the application. > > I suppose I would upload the raw image and then have some kind of > background task run in the background to resize the images. > > What is a simple way to achieve this? I wondered about having a background > script which polls for new images, i.e. using Cron? > > Is there a way within flask to fork off an image processing task, not > related to the initiating web request. > > Perhaps I'm making this too complex. Also ideally I want it to work on > Windows as well as Linux. > > Any thoughts? Thanks, Jim. > > >
Does resizing an uploaded image take too long to make it while processing the request? If you can safely answer that with "Yes" and not just because that is what you think the answer is, you need a task queue, which is something you probably want to use celery[1] for as this is very difficult to implement, especially if you want to make sure nothing gets lost etc. [1]: http://celeryproject.org
Hi, I think you can use PIL (http://www.pythonware.com/products/pil/) to do that. As an example, you can watch the django-imagekit code ( http://bitbucket.org/jdriscoll/django-imagekit) that demonstrate some possibilites offered by PIL. Jérôme.