The Problem

Copying large images, videos, or PDFs into chat apps, email, or document tools is slow and often hits file-size limits. Clop intercepts clipboard content and file drops on macOS, compresses them in the background, and hands back a smaller version — no manual export step.

What This Does

Clop is a native macOS app (SwiftUI, 34 Swift files) that watches the clipboard and Finder. When you copy an image, it runs pngquant, jpegoptim, gifsicle, or ffmpeg to shrink it. Videos recorded via screen capture get compressed using Apple Silicon's Media Engine when available. PDFs go through ghostscript.

The app also exposes a CLI (ClopCLI/main.swift) for scripted optimization, plus a Finder extension (FinderOptimiser/) that adds a right-click "Optimize" action. Shortcuts integration lives in Clop/ClopShortcuts.swift, with sample .shortcut files under Clop/Shortcuts/.

How It Is Wired

The import graph is flat: 0 internal modules, 0 edges, no cycles. Everything compiles into one target, so there is no module boundary to reason about — but that also means no enforced separation between UI, logic, and I/O.

Execution starts at Clop/ClopApp.swift (the @main entry point). From there, control flows into Clop/ContentView.swift for the UI and Clop/DropZone.swift for drag-and-drop handling. The core optimization pipeline lives in Clop/OptimisationUtils.swift (1,413 lines), which routes to per-format handlers:

  • Clop/Images.swift — PNG/JPEG/GIF/HEIC conversion and resizing
  • Clop/Video.swift — screen recording compression
  • Clop/PDF.swift — PDF optimization via ghostscript
  • Clop/Uploads.swift — upload to Backblaze/SSH/Dropshare

The widest blast radius is OptimisationUtils.swift and Images.swift — nearly every feature path passes through them. Clop/Automation.swift handles hotkeys and the on-demand Ctrl-Shift-C trigger.

The app shells out to external binaries (pngquant, ffmpeg, ghostscript, etc.) rather than linking them. A bundled archive Clop/bin.tar.lrz contains these tools; Makefile handles extraction and build. The app also writes to the filesystem for backup folders (Clop/Migrations.swift manages state).

How To Use It

Setup: Requires Xcode and macOS. Build via the Makefile:

make build

Configuration: No env vars. App settings are in Clop/Settings.swift — conversion formats, backup folder location, hotkeys. The Clop/Info.plist handles system permissions.

Running it: Launch the built app from Xcode or open Clop.app. The CLI, if installed, is invoked as clop <file>.

Real-World Use

A designer copies a 12 MB screenshot into Slack. Clop intercepts it, runs pngquant, and pastes a 1.2 MB version. For a screen recording, Clop/Video.swift compresses it via ffmpeg and presents a floating thumbnail (Clop/FloatingResult.swift) for drag-and-drop. A scripted pipeline could use the CLI to batch-optimize a folder before upload.

Code Health & Issues

Static analysis (41 findings: 14 high, 27 medium) flags three recurring problems:

  • High – Deep nesting (22 instances)Clop/Automation.swift, Clop/CompactResult.swift, Clop/CompareView.swift hit indentation depth 8. Fix with early returns/guard clauses.
  • High – Duplicated code (60 repeated 6-line blocks across 19 files) — notably Clop/ActionButtons.swift and Clop/CompactResult.swift. Extract shared helpers.
  • High – Oversized files (11 instances)Clop/ClopApp.swift, Clop/Images.swift, Clop/OptimisationUtils.swift exceed 1,400 lines. Split by responsibility.
  • Medium – High branching density (7 instances)Clop/DropZone.swift has 197 branch points over 663 lines.

SDLC gaps: no test files, no CI pipeline, no lockfile. The repo has a GPLv3 license and no committed secrets. Any change to OptimisationUtils.swift ships with zero regression signal.

The Bottom Line

Clop is a functional, feature-complete macOS utility with a clean external toolchain strategy. The flat structure and absence of tests make it risky to modify — especially the 1,400-line core files. Use it if you need a working clipboard optimizer and are prepared to add tests and CI before making substantial changes.