Hands-on tutorial

Remove a photo background in PhotoCraft: a tested coffee-cup mask

Remove a real photo’s red background with PhotoCraft’s CLI. See an automatic selection miss a shadow, repair the cup mask, and export a transparent PNG.

What you will make

Remove the red table and shadow from a real coffee photo, keep an editable mask and export a transparent PNG.

Method
Command line · CLI
Version
PhotoCraft 0.18.0
Platform
Windows x64
Tested

This exercise uses terminal commands, not desktop menu steps. Results apply to the sample and version shown.

Need PhotoCraft? Choose an official download ↗
Finished coffee cutout on a light background
Result from the tested mask, shown on cream. Download the PNG for transparency. View full size ↗

A photo with a useful problem

This cup has a clear outline, but its shadow is dark red. PhotoCraft’s automatic Remove Background kept that shadow in our test. We will show that result, then replace it with a selection drawn around the cup and handle.

The instructions use the PhotoCraft 0.18.0 CLI on Windows x64. The selection coordinates fit this 960 × 540 photograph. This method is useful for a simple, rigid shape; it does not demonstrate hair selection, translucent objects or automatic removal on arbitrary photos.

White coffee cup and handle on a red table, with a dark red shadow to the right
Practice photo: Coffee cup seen from above, credited to www.Pixel.la Free Stock Photos on Wikimedia Commons; CC0. We use its 960-pixel thumbnail. View full size ↗

Sources: Photo, author and CC0 record · CC0 public-domain dedication

1. Try the automatic command on a copy

Download coffee-source.jpg into the folder containing photocraft-cli.exe, then open PowerShell 7 there. Run these two commands. The first saves a masked PSD; the second exports its appearance.

Look to the right of the cup in the image below. A large red area remains. The command finished successfully, but this is not a usable transparent cutout. We kept the failed result here so you can recognize the same problem in your own work.

Automatic background removal keeping the cup and a large unwanted red shadow
Actual automatic output. The red shadow is still opaque; at x=700, y=270 its alpha is 255. View full size ↗
powershell
.\photocraft-cli.exe run .\coffee-source.jpg --cmd layer.removeBackground --out .\coffee-auto.psd
.\photocraft-cli.exe convert .\coffee-auto.psd .\coffee-auto.png

2. Select the cup and handle explicitly

Start again from the original JPEG. The command below makes its Background into a normal layer, draws an ellipse around the bowl, then adds a six-point outline around the handle. It gives the combined edge a 0.5 px feather and a small inward shift before saving it as a layer mask.

The ellipse starts at x=351, y=147 and measures 254 × 255 px. The handle points follow the outside of the handle. These numbers are measurements for the supplied photo, so use the original dimensions. Resizing or cropping the input invalidates them.

Coffee cup and handle with the red table and shadow removed
The saved mask removes the table and shadow. A slight red cast remains along parts of the photographed rim; the mask does not recolour the cup. View full size ↗
powershell
.\photocraft-cli.exe run .\coffee-source.jpg --cmd layer.new.layerFromBackground --cmd select.rect --params '{"x":351,"y":147,"width":254,"height":255,"ellipse":true,"antiAlias":true}' --cmd select.lasso --params '{"points":[[244,253],[354,253],[355,298],[245,292],[241,282],[241,265]],"mode":"add","antiAlias":true}' --cmd select.refineEdge --params '{"feather":0.5,"shiftEdge":-5,"output":"layerMask"}' --cmd select.deselect --out .\coffee-cutout.psd

3. Reopen the mask and export the PNG

Read the saved PSD with info. The image layer should report hasMask: true. Then convert it to PNG. The warning about flattening refers to the PNG; the PSD retains its mask.

Our exported PNG is 960 × 540. The corner and the old shadow position are transparent, while the coffee remains opaque. Those checks catch the large failure in step 1; inspecting a few pixels does not certify every point on the edge.

powershell
.\photocraft-cli.exe info .\coffee-cutout.psd
.\photocraft-cli.exe convert .\coffee-cutout.psd .\coffee-cutout.png

Scroll to view all columns on a small screen.

Pixel (x, y)What it checksObserved alpha
50, 50Red table removed0 — transparent
480, 270Coffee retained255 — opaque
700, 270Unwanted shadow removed0 — transparent

4. Check the edge on light and dark backgrounds

A cutout can look acceptable on one background and reveal a fringe on another. These previews were made in PhotoCraft by adding a solid layer below the same saved cup layer. Inspect the rim and the end of the handle at actual size.

The geometric selection slightly simplifies the handle corners. This is a practical cutout for the sample, not a pixel-perfect product retouch. If your deliverable needs an exact contour, adjust the mask around those corners and compare it with the untouched photograph.

Coffee cutout placed on a pale cream background
The same saved mask over a light background. The cream preview background is a separate layer in our test. View full size ↗

The same edge on a dark background

The dark preview makes pale or coloured edge pixels easier to see. Notice the faint warm edge on the handle: some of that colour is in the photograph itself. Contracting the mask further would hide more of it, but would also remove more of the cup.

Coffee cutout placed on a dark charcoal background
The same mask over charcoal. Check this view before using the transparent PNG on a dark page. View full size ↗

5. Prove that the hidden photo is still there

Disable the layer mask in another PSD and export it. In our test, the red table and shadow returned. This is why we kept a mask rather than deleting background pixels. Keep the original JPEG as well.

powershell
.\photocraft-cli.exe run .\coffee-cutout.psd --cmd layer.layerMask.enabled --params '{"enabled":false}' --out .\coffee-restored.psd
.\photocraft-cli.exe convert .\coffee-restored.psd .\coffee-restored.png

Test scope and source

We ran the commands, reopened the PSD, checked its mask and inspected the actual PNG outputs on 4 November 2026. A separate reproduction of the commands confirmed the mask and the three alpha values. We did not test desktop menu steps or a Photoshop round trip for this photo.

The source photo is listed under CC0 on Wikimedia Commons, with the contributor recorded as www.Pixel.la Free Stock Photos. The page includes a review of that license. Our downloadable source is the 960 × 540 version; the cutout and background previews are derived from it.

Sources: Original photo and license record · PhotoCraft version used for this exercise