CemilF
CemilF

Reputation: 125

Content-Aware Image Cropping with C#

I am working on a CMS like project which users can upload images with contents. I have to create thumbnails for the uploaded images on the fly. Lets say the thumbnail size as 125x75

I can resize images without problem but when it comes to crop operation several problems occur. My resize and crop procedure works like this:

  1. Load the original image.
  2. Resize the image to desired size preventing the original aspect ratio depending on the given maximum width or height
  3. If the result image has a different aspect ration than the output aspect ratio than a centered crop operation is applied.

But what I want to achive is a content-aware cropping as described in Jue Wang's article Opticrop: Content-aware Cropping with PHP and ImageMagick

Is there any way to do it with C# or is there a library that can do this operation.

Note: I do not want content-aware resizing. Content-aware resizing (seam craving) can be done with ImageResizing.net SeamCarving plugin

Upvotes: 4

Views: 1398

Answers (1)

Yannick Blondeau
Yannick Blondeau

Reputation: 9651

If you are using the ImageResizing.net framework, the WhitespaceTrimmer plugin may be a good starting point I think.

If you want to write the code yourself, this Gist shows a good solution using entropy but is written in Ruby.

Upvotes: 1

Related Questions