Skip to content
Snippets Groups Projects
Commit e244ef93 authored by Jan Hendriks's avatar Jan Hendriks
Browse files

New release with many improvements, see CHANGELOG.md for details


Signed-off-by: default avatarJan Hendriks <jan.hendriks@telekom.de>
parent 58af6f9f
No related branches found
No related tags found
No related merge requests found
Pipeline #11111 passed with stages
in 8 seconds
# Changelog
Changes:
* v1.6:
- Fixed generating into single pdf by switching from sh to bash for this script and fixing passing of selected files
- Fixed check for img2pdf
* v1.5:
- Switched from ImageMagick to img2pdf due to better performance and less user interaction required (no need to adjust policies)
- When converting multiple images a PDF name proposal of longest common name is generated
......
install(FILES image2pdf.desktop DESTINATION ${KDE_INSTALL_APPDIR})
\ No newline at end of file
HowToInstall.gif

2.4 MiB

HowToUse_SeparatePDF.gif

398 KiB

HowToUse_SinglePDF.gif

852 KiB

= image2pdf
File manager addon, that converts images to pdfs with one click (using https://github.com/josch/img2pdf[img2pdf]).
File manager addon, that converts images to pdfs with one click (using https://github.com/josch/img2pdf[img2pdf]):
.Single PDF generation
image::HowToUse_SinglePDF.gif[]
.Separate PDF generation
image::HowToUse_SeparatePDF.gif[]
It is supported by any File manager compliant with https://specifications.freedesktop.org/desktop-entry-spec/latest/[freedesktop.org's Desktop Entry Specification], like:
......@@ -20,30 +27,12 @@ For more info, see https://store.kde.org/p/998424
=== Installation for KDE5/Plasma
Use Dolphin > Settings > Context menus > Download > Search for image2pdf
==== Alternative: Manual installation methods
===== System-wide installation
- place the .desktop file in `/usr/share/kservices5/ServiceMenus/`:
[source,shell]
----
sudo cp image2pdf.desktop /usr/share/kservices5/ServiceMenus/
----
===== User installation
- place the .desktop file in `~/.local/share/kservices5/ServiceMenus/`:
Use Dolphin > Settings > Context menus > Download > Search for "image2pdf":
[source,shell]
----
cp image2pdf.desktop ~/.local/share/kservices5/ServiceMenus/
----
.Showcased installation
image::HowToInstall.gif[]
For KDE5, running `kbuildsycoca5` should then make the ServiceMenu immediately available.
If upgrading from an older version, deleting the `.desktop` file and running former command to remove the plugin from Dolphin cache, then copying the file again and running the command again should do the trick.
For alternative, manual installation methods please see INSTALLATION.adoc
== Feedback
......
......@@ -3,11 +3,14 @@ Type=Service
Actions=image2pdf;images2singlepdf
Icon=application-pdf
Encoding=UTF-8
TryExec=convert
TryExec=img2pdf
Version=1.5
ServiceTypes=KonqPopupMenu/Plugin
MimeType=image/*
#Debug option: Terminal=true
#Debug option: TerminalOptions=\s--noclose
[Desktop Action image2pdf]
Exec=if ! command -v img2pdf 1>/dev/null; then kdialog --title "image2pdf" --msgbox "img2pdf could not be found, please install from https://github.com/josch/img2pdf#installation"; exit 1;fi;count=0;errorCount=0;errorMessage="";for f in %F; do result=$(img2pdf "$f" -o "${f%.*}.pdf" 2>&1); if [ $? -eq 0 ]; then count=$((count+1)); else errorCount=$((errorCount+1)); errorMessage=${result}; fi;done;if [ $errorCount -eq 0 ]; then kdialog --title "image2pdf" --passivepopup "Converted $count image(s) into PDF files!" 5;else kdialog --title "image2pdf error" --error "The conversion failed with $errorCount error(s): $errorMessage";fi;
Icon=application-pdf
......@@ -21,7 +24,7 @@ Name[ru]=Конвертировать в отдельные PDF
Name[zh_CN]=转换图像至多次PDF文件
[Desktop Action images2singlepdf]
Exec=if ! command -v img2pdf 1>/dev/null; then kdialog --title "image2pdf" --msgbox "img2pdf could not be found, please install from https://github.com/josch/img2pdf#installation"; exit 1;fi;longest_common="";for f in %F; do fdir=$(dirname "$f"); count=$((count+1)); basefilename=$(basename "$f"); if [ "$count" -eq 1 ]; then longest_common="$basefilename"; else length=$((${#basefilename} < ${#longest_common} ? ${#basefilename} : ${#longest_common})); common=""; for ((i=0; i<length; i++)); do if [ "${basefilename:i:1}" != "${longest_common:i:1}" ]; then break; fi; common="${common}${basefilename:i:1}"; done; longest_common="$common"; fi;done;cd "$fdir" || exit;targetFileName=$(kdialog --getsavefilename "${fdir}/${longest_common}.pdf" "application/pdf");if [ $? -eq 0 ]; then targetFileName="${targetFileName%.*}.pdf"; result=$(img2pdf %F -o "$targetFileName" 2>&1); if [ $? -eq 0 ]; then kdialog --title "image2pdf" --passivepopup "Converted $count image(s) into '$targetFileName'!" 5; else kdialog --title "image2pdf error" --error "The conversion failed with error: $result"; fi;else echo "Aborted";fi;
Exec=bash -c 'if ! command -v img2pdf 1>/dev/null; then kdialog --title "image2pdf" --msgbox "img2pdf could not be found, please install from https://github.com/josch/img2pdf#installation"; exit 1;fi;longest_common="";count=0;fileArray=();for f in "$@"; do fileArray+=( "$f" ); fdir=$(dirname "$f"); count=$((count+1)); basefilename=$(basename "$f"); if [ "$count" -eq 1 ]; then longest_common="$basefilename"; else length=$((${#basefilename} < ${#longest_common} ? ${#basefilename} : ${#longest_common})); common=""; i=0; while [ "$i" -lt "$length" ]; do if [ "${basefilename:i:1}" != "${longest_common:i:1}" ]; then break; fi; common="${common}${basefilename:i:1}"; i=$(($i + 1)); done; longest_common="$common"; fi;done;cd "$fdir" || exit;targetFileName=$(kdialog --getsavefilename "${fdir}/${longest_common}.pdf" "application/pdf");if [ $? -eq 0 ]; then targetFileName="${targetFileName%.*}.pdf"; result=$(img2pdf "${fileArray[@]}" -o "$targetFileName" 2>&1); if [ $? -eq 0 ]; then kdialog --title "image2pdf" --passivepopup "Converted $count image(s) into $targetFileName!" 5; else kdialog --title "image2pdf error" --error "The conversion failed with error: $result"; fi;else echo "Aborted";fi;' sh %F
Icon=application-pdf
Name=Convert image(s) into single PDF
Name[de]=Konvertiere Bild(er) in einzelnes PDF
......
#!/usr/bin/env sh
set -euo pipefail
set -euo
out="out"
scripts="scripts"
rm -rf "${out}"
......
......@@ -3,11 +3,14 @@ Type=Service
Actions=image2pdf;images2singlepdf
Icon=application-pdf
Encoding=UTF-8
TryExec=convert
TryExec=img2pdf
Version=1.5
ServiceTypes=KonqPopupMenu/Plugin
MimeType=image/*
#Debug option: Terminal=true
#Debug option: TerminalOptions=\s--noclose
[Desktop Action image2pdf]
Exec=${MULTIPDF}
Icon=application-pdf
......@@ -21,7 +24,7 @@ Name[ru]=Конвертировать в отдельные PDF
Name[zh_CN]=转换图像至多次PDF文件
[Desktop Action images2singlepdf]
Exec=${SINGLEPDF}
Exec=bash -c '${SINGLEPDF}' sh %F
Icon=application-pdf
Name=Convert image(s) into single PDF
Name[de]=Konvertiere Bild(er) in einzelnes PDF
......
#!/usr/bin/env sh
#!/bin/bash
if ! command -v img2pdf 1>/dev/null; then
kdialog --title "image2pdf" --msgbox "img2pdf could not be found, please install from https://github.com/josch/img2pdf#installation";
exit 1;
fi;
longest_common="";
for f in %F; do
count=0;
fileArray=();
for f in "$@"; do
fileArray+=( "$f" );
fdir=$(dirname "$f");
count=$((count+1));
basefilename=$(basename "$f");
......@@ -13,11 +16,13 @@ for f in %F; do
else
length=$((${#basefilename} < ${#longest_common} ? ${#basefilename} : ${#longest_common}));
common="";
for ((i=0; i<length; i++)); do
i=0;
while [ "$i" -lt "$length" ]; do
if [ "${basefilename:i:1}" != "${longest_common:i:1}" ]; then
break;
fi;
common="${common}${basefilename:i:1}";
i=$(($i + 1));
done;
longest_common="$common";
fi;
......@@ -26,12 +31,12 @@ cd "$fdir" || exit;
targetFileName=$(kdialog --getsavefilename "${fdir}/${longest_common}.pdf" "application/pdf");
if [ $? -eq 0 ]; then
targetFileName="${targetFileName%.*}.pdf";
result=$(img2pdf %F -o "$targetFileName" 2>&1);
result=$(img2pdf "${fileArray[@]}" -o "$targetFileName" 2>&1);
if [ $? -eq 0 ]; then
kdialog --title "image2pdf" --passivepopup "Converted $count image(s) into '$targetFileName'!" 5;
kdialog --title "image2pdf" --passivepopup "Converted $count image(s) into $targetFileName!" 5;
else
kdialog --title "image2pdf error" --error "The conversion failed with error: $result";
fi;
else
echo "Aborted";
fi;
fi;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment