Terminal Crop Guide
Install ImageMagick, save a reusable one-word crop command, and turn any image into a centered square PNG on your Desktop without opening a design app.
A one-word crop command for macOS
This walkthrough uses Terminal, Homebrew, and ImageMagick to create a reusable shortcut named crop. Once it is installed, you can copy an image pathname from Finder, run one command, and get a centered square PNG on the Desktop.
The original image remains unchanged. The output file is created separately with -square.png added to the filename.
- TerminalThe text-based control interface for macOS.
- HomebrewA package manager that installs command-line software.
- ImageMagickAn image toolkit that crops, resizes, converts, and manipulates files.
Open Terminal
Terminal is the text-based control interface for macOS and allows you to run commands directly on the computer.
- Press
Command + Space. - Type
Terminal. - Press
Return.
A black or white terminal window will open.
Install Homebrew
Homebrew is a package manager, or download assistant for command-line software, that makes it easy to install professional tools and utilities on macOS.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Press Return. The Mac may ask for the computer password. When typing the password, nothing appears on screen, no dots or cursor movement. This is normal.
The installer will begin downloading and configuring software automatically. Sometimes Terminal scrolls rapidly with text, and other times it may appear frozen for 5-20 seconds while downloading or compiling files. Both behaviors are normal.
Install time is usually 5-20 minutes. Do not close the Terminal window during installation.
MacBook-Pro:~ username$
When the prompt returns, the computer is waiting for the next command.
Install ImageMagick
ImageMagick is a command-line image editing toolkit that can crop, resize, convert, and manipulate images using text commands.
brew install imagemagick
Notice how easy Homebrew syntax is to read. Even without technical knowledge, you can usually understand the intent of the command.
Homebrew downloads ImageMagick and any supporting components automatically. Terminal may pause for 10-30 seconds at times while files download or install. This is normal.
Install time is usually 2-10 minutes. Wait until the normal terminal prompt appears again.
Create the custom crop command
In this step, you are storing a reusable shortcut command so image cropping becomes a simple one-word command later.
cat >> ~/.zshrc <<'EOF'
crop() {
INPUT="$1"
FILENAME=$(basename "$INPUT")
NAME="${FILENAME%.*}"
OUTPUT="$HOME/Desktop/${NAME}-square.png"
magick "$INPUT" -gravity center -crop 1:1 +repage "$OUTPUT"
echo "Created:"
echo "$OUTPUT"
}
EOF
Press Return. Notice how you can pretty much understand what the script is doing even if you could not write it yourself: input image, Desktop output location, and the crop operation itself.
This step usually completes almost instantly.
Activate the new command
You have created the shortcut script, but right now it is only stored as text. This step tells the computer to load and use it immediately.
source ~/.zshrc
Press Return. This normally finishes immediately.
Use the new crop command
You can now crop images into centered squares with a single command.
- Navigate to the image you want to crop in macOS Finder.
- Hold down
Option. - Right-click the image.
- Click
Copy [filename] as Pathname.
Now open Terminal and type crop. After the space, paste the pathname you copied from Finder.
crop /Users/yourname/Downloads/photo.jpg
The image is opened, cropped into a centered square, and a new PNG file is automatically created on the Desktop: photo-square.png.
The original image remains unchanged.
Make file paths easier to learn
- In Finder, click
View -> Show Path Bar. - Or press
Option + Command + P. - Use the Path Bar to see the full folder path at the bottom of Finder windows.
- Right-click folders or filenames in the Path Bar to copy paths directly.
EJ recommends using this feature because it makes learning file paths and Terminal commands much easier.
Once this works, the next step is learning how to activate the crop script directly from the macOS right-click menu after clicking on an image.

