开发者

Using pngcrush with git export filter

I’d like to optimize png files when I export them (using git archive) from the repository, using a smudge filter. However, if I understand it correctly, these filters work only via STDIN and STDOUT开发者_StackOverflow社区, while pngcrush needs a “real” file.

Is there any workaround?


Use temporary files. eg:

IN=$(mktemp)
OUT=$(mktemp)

# save stdin to temp file
cat > "$IN"

# Crush the image and ignore regular output.
# Die if pngcrush fails.
pngcrush "$IN" "$OUT" > /dev/null || exit $?

# write temp file to stdout
cat "$OUT"

# clean up
rm "$IN" "$OUT" &
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜