Move image data creation from middleware to task.