Автостарт на основе текста scritp, которые работают постоянно в фоновом режиме

Попробуйте выполнить следующий сценарий bash:

#!/bin/bash

max_width=0
max_height=0
border=10

# Trim all files to remove the white borders
for i in *.png; do
    convert $i -trim "${i%.*}"__trimmed.png
done

# Find the max width and height
for i in *__trimmed.png; do
    w="$(identify -format "%w" $i)"
    h="$(identify -format "%h" $i)"
    if (( $w > $max_width )); then max_width=$w; fi;
    if (( $h > $max_height )); then max_height=$h; fi; 
done

# Add a small border (optional)
max_width=$(($max_width+$border))
max_height=$(($max_height+$border))

# Add borders to all pictures so that they all have the same size
# "-gravity center" will center them
# -background None will avoid the default white background as your sample image
# was a png with a transparent backgroud
for i in *__trimmed.png; do
    convert $i -background None -gravity center -extent "${max_width}x${max_height}" "${i%__trimmed.*}".png
done

rm -f *__trimmed.png
0
задан 3 December 2017 в 01:15

0 ответов

Другие вопросы по тегам:

Похожие вопросы: