repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
imgx.mdMarkdown106 lines6.4 KiBsource raw download

imgx — ImageMagick without the incantations#

One subcommand per thing you actually do to an image: compress, resize, convert, crop, rotate, strip, thumbnail. Everything writes to output/ beside the source, so the original is never touched. Quick card: imgx-cheat. Full magick underneath: imgx raw ….

Compress — the one you reach for#

Every path also runs -strip, so metadata goes with it.

What each knob actually does#

Format Path taken The lever that matters
jpg / jpeg -strip -quality N -q. Lossy, DCT-based; quality is the whole story.
webp -strip -quality N -q. Usually 25–35% under jpeg at matched quality.
png -strip -colors N -depth 8 + max deflate -c. png is lossless, so the only real saving is fewer colours.
anything else -strip -quality N falls back to the quality path

png's compression level is already pinned at maximum (compression-level=9, filter 5, strategy 1) — turning it up further is not a thing. If a png is not shrinking, it has too many colours, not too little deflate.

Which format for which image#

The decision that changes the outcome far more than any flag.

Resize#

Geometry strings pass straight through to ImageMagick, so its full grammar works.

-s value Effect
800x600 fit inside the box, aspect kept
800x600! ! forces exact WxH — aspect broken
50% scale by percent
x600 height only, width follows
800x600^ ^ fills the box, may overflow (pair with -extent to crop to it)
800x600> shrink only, never enlarge — what the default uses

Thumbnail, crop, rotate, strip, convert#

Batch#

imgx batch ./dir compress -c 128 runs a subcommand over every png/jpg/jpeg/webp in a directory. Any subcommand and its flags work:

Results land in dir/output/. Originals are untouched — this is the whole reason batch is safe to run twice.

Output layout#

Omit the destination and imgx builds one:

SRC's-directory/output/NAME-suffix.ext        (output/ created if absent)
Subcommand Suffix
compress -compressed
resize -resized
crop -cropped
rotate -rotated
thumb -thumb
strip -stripped

Give an explicit destination and it is used verbatim, extension and all.

info#

imgx info a.png wraps identify -verbose and greps the lines worth reading: dimensions, format, colorspace, depth, filesize. Falls back to plain identify if the verbose parse finds nothing.

raw — full magick, no training wheels#

imgx raw ARGS… passes everything to magick verbatim. Anything the subcommands do not expose lives here.

Flags worth knowing when you drop to raw#

Flag Does
-gravity center -extent WxH pad or crop to an exact canvas, anchored
-background none keep transparency when extending the canvas
-auto-orient apply EXIF rotation before anything else — do this first or crops land wrong
-sampling-factor 4:2:0 jpeg chroma subsampling; meaningfully smaller files
-interlace Plane progressive jpeg / interlaced png
-unsharp 0x0.75+0.75+0.008 the standard post-downscale sharpen

Why a wrapper and not an alias#

magick is one binary covering several hundred operators whose order is significant — -resize before -crop and after it are different pictures, and -strip after -quality throws away the setting. The subcommands here fix an order that is correct for the common case and pick defaults that are not landmines: never upscale, always strip, always write somewhere new.

An alias could not do the destination-extension routing that makes imgx compress a.png out.webp a single step, and it could not keep originals safe under batch. When the fixed order is wrong for what you want, raw is right there.