BMBM
BMBM

Reputation: 16033

imagemagick in asp.net via command line

I use Imagemagick in my ASP.NET webproject to generate thumbs via the commandline interface of imagemagick using a System.Diagnostics.Process

When a user visists a site, 20 media items are fetched from the database, and for each an thumb image gets generated, like this:

var thumb = media.GetThumb(100, 100);

which starts a Process that uses the "convert" command from imagemagick

However, the performance could be better.

I know, caching the thumbs is a good option, and that is exactly what I am going to do.

However, I suspect, that starting a new Process for each image that is not cached is quite expensive. Any better like "reusing" a process or keeping imagemagick in memory and access this instance or what not?

Upvotes: 1

Views: 926

Answers (2)

BMBM
BMBM

Reputation: 16033

As the time it takes for a thumbnail to be generated is not too long, I am right now using just the caching solution. Furthermore, I dont want to add to much complexity to the project - keeping it as simple as possible.

But for future projects I am trying to evaluate if I can start a background thread at the Application_Start Event, which queries the database for 10 images, generates their thumbs and goes on with the next 10 etc. until no more images without thumbnail exist. This seems like a doable approach, although I havent used it in production yet.

Upvotes: 0

gimel
gimel

Reputation: 86492

Try ImageMagick.NET,

A .NET wrapper of perhaps the greatest image manipulation API there is, ImageMagick

Though still in alpha, it (or the earlier version) might provide the functionality you need. A very brief look into the source reveals very little functionality, but it might be a start.

Upvotes: 1

Related Questions