package io.prime.web.thumbnailator.filter;

import net.coobird.thumbnailator.Thumbnails.Builder;
import net.coobird.thumbnailator.geometry.Coordinate;

public class CropFilter implements ThumbnailatorFilter
{
	private int width;
	private int height;

	public <T> void filter(Builder<T> builder) 
	{
		builder.crop(new Coordinate(this.width, this.height));
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

}

@@ -39,16 +39,59 @@
 ter;%0D%0A%0D%0A
+import org.springframework.util.Assert;%0D%0A%0D%0A
 import n
@@ -178,26 +178,78 @@
 eometry.
-Coordinate
+Position;%0D%0Aimport net.coobird.thumbnailator.geometry.Positions
 ;%0D%0A%0D%0Apub
@@ -346,16 +346,45 @@
 height;%0D
+%0A%09private Position position;%0D
 %0A%0D%0A%09publ
@@ -434,60 +434,372 @@
 %0D%0A%09%09
-builder.crop(new Coordinate(this.width, this.height)
+Assert.isTrue(this.width %3E 0 %7C%7C this.height %3E 0);%0D%0A%09%09if (this.width %3E 0 && this.height %3E 0) %7B%0D%0A%09%09%09builder.size(width, height);%0D%0A%09%09%7D else %7B%0D%0A%09%09%09if ( this.width %3E 0 ) %7B%0D%0A%09%09%09%09builder.width(this.width);%0D%0A%09%09%09%7D else %7B%0D%0A%09%09%09%09builder.height(this.height);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09if (null == this.position) %7B%0D%0A%09%09%09this.position = Positions.CENTER;%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09builder.crop(position
 );%0D%0A

fix CropFilter