4

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

2
  • 1
    You actually ask for this function function opticrop($image, $w, $h, $out, $format) ported on asp.net, or with other words, a function to determines the center-of-edginess, and crop the image around there. Commented Aug 30, 2012 at 7:17
  • Yes. That is what I am exactly looking for. I have to find the the center-of-edginess as you have mentioned but how? I think I have to port it myself. Commented Sep 5, 2012 at 7:59

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, actually I can't figure out how WhitespaceTrimmer plugin will help me to find the center-of-edginess as Aristos commented on my post. I do not have any problem with white space.
The WhitespaceTrimmer plugin uses edge detection to find parts of the image that has to be removed. As it is open-source, I thought you could have a look there and use that as a starting point...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.