I'm looking at using IM4Java to perform some image transformations. The way I'm building this is as a servlet which can then be called from a number of our applications over http. What I'm not sure about is how this will handle concurrency given that IM4Java uses the command line to call Graphics / Image Magick. Specifically
1. Can IM4Java handle multiple concurrent calls to ImageMagick?
2. If so, are there any in built ways of limiting the number of concurrent actions?
In other words, suppose I have an image resize task - I might want to limit this to a maximum of 4 concurrent resize ops to stop it monopolising server resources, with any additional operations queueing up to process. If this can be done using code built into IM4Java, so much the better.
Other than that, fantastic tool. I looked at JMagick and then quickly ran away….yours is clean, simple and easy to use. Well done.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-08-19
I had read through the concurrency section, but that covers a single consumer running multiple asynchronous threads i.e. one application converting multiple images in the background.
In my application, the conversion has to be synchronous (consumers are going to be requesting image resizing and need to get the image back), however, since this is running from a servlet there is the possibility of serving multiple requests at one time. I'm therefore interested in what will happen if I have 10 servlet requests at one time all requesting synchronous image resize operations, and whether there is a way to limit that.
I'm fairly certain that's a different kettle of fish to using a ProcessExecutor but happy to be corrected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are right, I misunderstood your problem. There is no problem using synchronous calls from multiple servlet-threads (at least in theory, since there aren't any shared resources except the global search path), as long as every servlet-thread uses it's own ImageCommand and Operation.
The downside is, you have to implement your own resource-management using some global counter, maybe based on java.util.concurrent.BlockingQueue. But you really have to make sure that all of your conversion processes end.
Bernhard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there,
I'm looking at using IM4Java to perform some image transformations. The way I'm building this is as a servlet which can then be called from a number of our applications over http. What I'm not sure about is how this will handle concurrency given that IM4Java uses the command line to call Graphics / Image Magick. Specifically
1. Can IM4Java handle multiple concurrent calls to ImageMagick?
2. If so, are there any in built ways of limiting the number of concurrent actions?
In other words, suppose I have an image resize task - I might want to limit this to a maximum of 4 concurrent resize ops to stop it monopolising server resources, with any additional operations queueing up to process. If this can be done using code built into IM4Java, so much the better.
Other than that, fantastic tool. I looked at JMagick and then quickly ran away….yours is clean, simple and easy to use. Well done.
Hi,
im4java has no problems with concurrency. You should read the Developer's Guide http://im4java.sourceforge.net/docs/dev-guide.html#parallelProcessing and the following sections on how to do it. It's all there.
Bernhard
I had read through the concurrency section, but that covers a single consumer running multiple asynchronous threads i.e. one application converting multiple images in the background.
In my application, the conversion has to be synchronous (consumers are going to be requesting image resizing and need to get the image back), however, since this is running from a servlet there is the possibility of serving multiple requests at one time. I'm therefore interested in what will happen if I have 10 servlet requests at one time all requesting synchronous image resize operations, and whether there is a way to limit that.
I'm fairly certain that's a different kettle of fish to using a ProcessExecutor but happy to be corrected.
You are right, I misunderstood your problem. There is no problem using synchronous calls from multiple servlet-threads (at least in theory, since there aren't any shared resources except the global search path), as long as every servlet-thread uses it's own ImageCommand and Operation.
The downside is, you have to implement your own resource-management using some global counter, maybe based on java.util.concurrent.BlockingQueue. But you really have to make sure that all of your conversion processes end.
Bernhard