Images für Synology SPK Packages erstellen

Status
Für weitere Antworten geschlossen.

DI4bI0

Benutzer
Mitglied seit
08. Mrz 2011
Beiträge
264
Punkte für Reaktionen
14
Punkte
24
Nabend zusammen,

hier mal ein kleines shell script, um alle benötigten images für ein SPK Packege zu erstellen:
PHP:
#!/bin/sh

# made by DI4bI0
# http://www.diablos-netzwerk.de

# Create all Images for a Synology SPK Package

# App name = image name
appname="${1}"

# Source Image file must be placed in the input folder
inputFileName="${2}"

# create base64
base64="${3}"

# input folder for the source image
inputFolder="$(dirname $0)/input"

# Load the image file
inputFile="${inputFolder}/${inputFileName}"

# output directory for the created images
outputFolder="$(dirname $0)/output"

# Package Icon Resolutions
PackageiconResolutions="256 120 72"

# App Icon Resolutions
appiconResolutions="72 64 48 32 24 16"

[ ! -d $inputFolder ] && mkdir $inputFolder || :
[ ! -d $outputFolder ] && mkdir $outputFolder || :

if [[ "${appname}" == "" ]] || [[ ! -f "${inputFile}" ]] || [[ "${base64}" != "base64" && "${base64}" != "base64oneline" ]]; then
    echo "Usage ${0} 'APPNAME' 'INPUTFILE' '(base64|base64oneline)'"
    echo "Usage example: ${0} ts3server image.png base64oneline"
    echo "Importent: The 'INPUTFILE' must be placed in the ${inputFolder} folder!"
    exit 1
fi

# Create Package Icons
for PackageiconResolution in $(echo ${PackageiconResolutions}); do
    convert -geometry ${PackageiconResolution}x${PackageiconResolution} -quality 95 $inputFile ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.png > /dev/null 2>&1
    RETURNVALUE=$?
    if [ $RETURNVALUE != 0 ]; then
        echo "Error creating PACKAGE_ICON_${PackageiconResolution}.png ERRORCODE: '${RETURNVALUE}'"
    else
        echo "Image PACKAGE_ICON_${PackageiconResolution}.png created successful"
    fi
done

# Create App Icons
for appiconResolution in $(echo ${appiconResolutions}); do
    convert -geometry ${appiconResolution}x${appiconResolution} -quality 95 $inputFile ${outputFolder}/${appname}_${appiconResolution}.png > /dev/null 2>&1
    RETURNVALUE=$?
    if [ $RETURNVALUE != 0 ]; then
        echo "Error creating ${appname}_${appiconResolution}.png ERRORCODE: '${RETURNVALUE}'"
    else
        echo "Image ${appname}_${appiconResolution}.png created successful"
    fi
done

# Create base64 Package Icons
if [ "${3}" == "base64" ]; then
    for PackageiconResolution in $(echo ${PackageiconResolutions}); do
        openssl base64 -in ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.png -out ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.b64 > /dev/null 2>&1
        RETURNVALUE=$?
        if [ $RETURNVALUE != 0 ]; then
            echo "Error creating PACKAGE_ICON_${PackageiconResolution}.b64 ERRORCODE: '${RETURNVALUE}'"
        else
            echo "Base64 PACKAGE_ICON_${PackageiconResolution}.b64 created successful"
        fi
    done
fi

# Create base64 Package Icons oneline
if [ "${3}" == "base64oneline" ]; then
    for PackageiconResolution in $(echo ${PackageiconResolutions}); do
        openssl base64 -in ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.png -out ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.b64 > /dev/null 2>&1
        RETURNVALUEIMAGE=$?
        cat ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.b64 | tr -d '\n' > ${outputFolder}/PACKAGE_ICON_${PackageiconResolution}.oneline.b64 > /dev/null 2>&1
        RETURNVALUEBASE64=$?
        if [[ $RETURNVALUEIMAGE != 0 ]] || [[ $RETURNVALUEBASE64 != 0 ]]; then
            echo "Error creating PACKAGE_ICON_${PackageiconResolution}.oneline.b64 ERRORCODE: '${RETURNVALUE}'"
        else
            echo "Base64 oneline PACKAGE_ICON_${PackageiconResolution}.oneline.b64 created successful"
        fi
    done
fi

# Fix some image names
mv ${outputFolder}/PACKAGE_ICON_72.png ${outputFolder}/PACKAGE_ICON.png > /dev/null 2>&1
[[ "${3}" == "base64" ]] || [[ "${3}" == "base64oneline" ]] && mv ${outputFolder}/PACKAGE_ICON_72.b64 ${outputFolder}/PACKAGE_ICON.b64 > /dev/null 2>&1
[ "${3}" == "base64oneline" ] && mv ${outputFolder}/PACKAGE_ICON_72.oneline.b64 ${outputFolder}/PACKAGE_ICON.oneline.b64 > /dev/null 2>&1

exit 0

Vielleicht kann es ja einer gebrauchen :)


mfg Diablo
 

Blackknova

Benutzer
Mitglied seit
06. Jul 2015
Beiträge
7
Punkte für Reaktionen
0
Punkte
0
Ja das inspiriert mich schon etwas ehrlich gesagt :)
 

DI4bI0

Benutzer
Mitglied seit
08. Mrz 2011
Beiträge
264
Punkte für Reaktionen
14
Punkte
24
Freut mich :)
 
Status
Für weitere Antworten geschlossen.
 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat