Created
June 28, 2023 16:00
-
-
Save raphaeltraviss/1d98bec91b50182b2c688f33c5d1f93d to your computer and use it in GitHub Desktop.
macOS command to resize a hi-res image in the pasteboard to a normal size image, for pasting into applications that don't handle HPDI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# copy image to pasteboard via CMD-C | |
# then call pbresize on command line | |
# or call with a custom scale e.g. pbresize 0.7 | |
SCALE_FACTOR=${1:-0.5} | |
pngpaste /tmp/ss.png | |
IMG_WIDTH=$(sips -g pixelWidth /tmp/ss.png | cut -s -d ':' -f 2 | cut -c 2-) | |
SCALED_WIDTH=$(echo "$IMG_WIDTH * $SCALE_FACTOR" | bc) | |
sips -Z $SCALED_WIDTH /tmp/ss.png | |
impbcopy /tmp/ss.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment