2

I need to perform batch cropping to approximately 3000 images. Each image is for a different item.

What I need is a crop tool that can define the item from the background and add specific amount of pixels to the top, bottom, right and left of it.

For example, see the image below. Can I use Automator?

  • Due to the sheer complexity, I think this probably falls outside the scope of what's easy with Automator. I'd look into writing a more complete program or utilizing something that already exits. – JMY1000 May 15 '17 at 18:09
  • Yes, that's what i thought but i can not find any software that can do that. – smadgos May 15 '17 at 18:43
  • Python, Java, and most other languages should have libraries available to handle images. It's really up to you. I just think this is probably outside of what Automator can do easily: it might be possible to use shell scripts to do this with added libraries. – JMY1000 May 15 '17 at 18:46
6

You can use Imagemagick, available on Homebrew.

convert /path/to/in.png \
  -trim \
  +repage \
  -bordercolor White \
  -border 100x100 \
  /path/to/out.png
  1. The image is trimmed using -trim operation which removes the border from the image.

    This option removes any edges that are exactly the same color as the corner pixels. Use -fuzz to make -trim remove edges that are nearly the same color as the corner pixels.

    http://www.imagemagick.org/script/command-line-options.php

  2. A +repage is performed on the virtual canvas to ‘flatten’ the crop.

  3. The -border is added, in White.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .