I want to use the quick action: Remove Background, which is available in the Finder of MacOS Ventura (right click -> quick actions -> Remove Background)

Does someone know how to do it with a Terminal command-line / shell script?

I tried to record the action in Automator, but without any luck. It ends up with a Watch Me Do action which I can't do anything with. But maybe i'm doing something wrong and there is another way. With the action I don't want the Finder to come up front. So on a way that the app with the shell function keeps upfront. I'm using Max from cycling'74 for the shell commands.

Thanks in advance!

  • 1
    There is a shortcuts command and an automator command that you can use to trigger Shortcuts and Automator workflows.
    – benwiggy
    Commented Apr 6, 2023 at 13:37
  • Thanks a lot! I never used Shortcuts, but i made a shortcut which removes the background and with shortcut command-line it's perfect.
    – Aart
    Commented Apr 6, 2023 at 22:50
  • @Aart could you share your Shortcut? can you batch remove backgrounds? shortcuts run "Remove Background" -i /path/to/folder/*.jpg [?]
    – Mazzy
    Commented Jun 30, 2023 at 3:55
  • You can start by using screencapture -iW ~/Desktop/screenshot.png. This will capture a screenshot without the background. You can then use open -a "Preview" ~/Desktop/screenshot.png to open the image in Preview.
    – Thinkr
    Commented Jun 30, 2023 at 8:37
  • Of course, you could make this a shell script, make it executable with chmod +x remove_background.sh and run it with ./remove_background.sh. (remove_background is just a sample name for the script)
    – Thinkr
    Commented Jun 30, 2023 at 8:40

1 Answer 1


I use GraphicsMagick (FOSS) to run a one-liner to remove the background from images. Below is the command I use to make the background transparent.

gm convert infile.png -fuzz 5% -transparent "#ffffff" outfile.png

What this is doing is taking the infile.png file and with the convert command, making transparent the color defined in hex; in this case white (#ffffff)

You may have to adjust the “fuzz” factor depending on how precise you need it. -fuzz gives you some wiggle room by allowing close to the color you specified to be selected.

You must log in to answer this question.

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