diff --git a/README.md b/README.md index db91c8b..8ff4358 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1896 TILs and counting..._ +_1897 TILs and counting..._ See some of the other learning resources I work on: @@ -768,6 +768,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Add A Bunch Of CLI Utilities With coreutils](mac/add-a-bunch-of-cli-utilities-with-coreutils.md) - [Capture Screenshot To Clipboard From CLI](mac/capture-screenshot-to-clipboard-from-cli.md) - [Check Network Quality Stats From The Command Line](mac/check-network-quality-stats-from-the-command-line.md) +- [Check Properties Of An Image With `sips`](mac/check-properties-of-an-image-with-sips.md) - [Clean Up Item Layout In Finder Window](mac/clean-up-item-layout-in-finder-window.md) - [Clean Up Old Homebrew Files](mac/clean-up-old-homebrew-files.md) - [Control Which Monitor App Switcher Appears On](mac/control-which-monitor-app-switcher-appears-on.md) diff --git a/mac/check-properties-of-an-image-with-sips.md b/mac/check-properties-of-an-image-with-sips.md new file mode 100644 index 0000000..f02644b --- /dev/null +++ b/mac/check-properties-of-an-image-with-sips.md @@ -0,0 +1,49 @@ +# Check Properties Of An Image With `sips` + +I [used Figma to create a basic design for a t-shirt +screenprinting](https://bsky.app/profile/jbranchaud.bsky.social/post/3mz43v6asns2f). +Before I sent the image asset off to the printer, I needed to verify a couple +properties of the image where right. + +My first thought was that there is probably a way to do this with `ffmpeg`, but +I intentionally asked Claude in a non-leading way how to do this. It surfaced a +Mac-specific utility I'd never heard of -- `sips` (_Scriptable Image Processing +System_). + +Sometimes it is hard to tell if an image exported correctly with transparent +background (alpha channel). Part of how I was able to verify that was to point +`sips` at the PNG file and ask if it has an alpha channel. The `-g` flag (short +for _get property_) is the way to output a property like this. + +```bash +❯ sips -g hasAlpha ~/Downloads/Untitled/orange-shirt-print-front.png +/Users/lastword/Downloads/Untitled/orange-shirt-print-front.png + hasAlpha: yes +``` + +I then wanted to check that the dimensions of the image were right. I had +carefully sized the canvas in Figma to correspond to specs required by the +printer. Similar to above, I can use `-g` to grab the `pixelWidth` and +`pixelHeight` properties of the image. + +Unfortunately the pixel dimensions of the exported PNG were not what I was +expecting. + +```bash +❯ sips -g pixelWidth -g pixelHeight ~/Downloads/Untitled/orange-shirt-print-front.png +/Users/lastword/Downloads/Untitled/orange-shirt-print-front.png + pixelWidth: 1152 + pixelHeight: 1536 +``` + +I then found some additional export settings in Figma and tried again. Nailed +it. + +```bash +❯ sips -g pixelWidth -g pixelHeight ~/Downloads/Marty\ Supreme\ —\ 12\ ×\ 16\ in\ print.png +/Users/lastword/Downloads/Marty Supreme — 12 × 16 in print.png + pixelWidth: 3600 + pixelHeight: 4800 +``` + +See `man sips` for more details.