zeppeliner Posted March 5, 2021 Share Posted March 5, 2021 Script that converts jp2 files to png files, then deletes all jp2 files. It requires to work properly imagemagick package. #!/bin/bash haveExtension () # this function returns the position of the first period it encounters (counting backwards), if it fails to find such a character, it prints -1 { for (( i=$((${#1}-1)); i>-1; i--)) # od rozmiaru tekstu do -1 wykonuj do if [ "${1:$i:1}" = '.' ] # if a dot character is searched for at the given position, then then echo $i; # view its location return; # and the end of the function will be fi done echo -1; # and if not, return -1 } getFileName () # this function returns the file name (without the extension) { filename=$(basename "$1"); extPos=$(haveExtension "$filename"); echo ${filename:0:$extPos}; } for i in *.jp2; do echo "Processing file: $i" convert "$i" -quality 100 "$(getFileName "$i").png" done for i in *.jp2; do echo "Deleting file: $i" rm -f "$i" done 1 Link to comment
ssilver79 Posted April 9, 2021 Share Posted April 9, 2021 KDE Dolphin service menu desktop file. ${HOME}/.local/share/kservices5/ServiceMenus/jp2png.desktop [Desktop Entry] Type=Service ServiceTypes=KonqPopupMenu/Plugin MimeType=image/jp2; Icon=autocorrection X-KDE-Priority=TopLevel X-KDE-StartupNotify=false X-KDE-Submenu=Convert Actions=Convert; [Desktop Action Convert] Name=Convert to PNG Icon=image-png Exec=filename=%f; ffmpeg -i "${filename}" "${filename%.*}.png" It requires to work properly ffmpeg package. 2 Link to comment
Recommended Posts