Skip to content

Commit

Permalink
bash-atproto: fix compressImageForBluesky failing to recompress jpegs
Browse files Browse the repository at this point in the history
It now compresses as close to Bluesky limits as possible, at the cost of speed
  • Loading branch information
Engielolz committed Nov 6, 2024
1 parent 163854c commit 1a6b993
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bash-atproto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function resizeImageForBluesky () {

function compressImageForBluesky () {
$bapecho "image is too big, trying to compress"
convert /tmp/bash-atproto/$workfile /tmp/bash-atproto/new-${workfile%.*}.jpg
convert /tmp/bash-atproto/$workfile -define jpeg:extent=1000kb /tmp/bash-atproto/new-${workfile%.*}.jpg
if [[ $(stat -c %s /tmp/bash-atproto/new-${workfile%.*}.jpg) -gt 1000000 ]]; then baperr "image too big to fit in skeet"; rm /tmp/bash-atproto/$workfile /tmp/bash-atproto/new-${workfile%.*}.jpg; return 1; fi
rm /tmp/bash-atproto/$workfile
mv -f /tmp/bash-atproto/new-${workfile%.*}.jpg /tmp/bash-atproto/${workfile%.*}.jpg
Expand Down

0 comments on commit 1a6b993

Please sign in to comment.