Precise cropping with ImageCrop

I just realized that BorderDimensions accepts second argument as tolerance. So, what I need is

ImagePad[img, -BorderDimensions[img, 0]]

A workaround allowing ImageCrop to crop images having alpha channel is to temporarily set ColorSpace -> Automatic:

Image[ImageCrop[Image[img, ColorSpace -> Automatic]], ColorSpace -> "RGB"]

Also published here: http://community.wolfram.com/groups/-/m/t/1215584


Strongly related:

  • Blur, GaussianFilter and ImageConvolve doesn't work on some images