Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function execPdfToCbz {
  4.  
  5. input=${1}
  6. output=${2}
  7.  
  8. quality=90
  9. density=150
  10. height=1280
  11. width=''
  12. sharpen='0x1.0'
  13. background='#FFFFFF'
  14.  
  15. convert \
  16. -verbose \
  17. -density ${density} \
  18. -trim \
  19. "${input}" \
  20. -background "${background}" \
  21. -resize ${width}x${height} \
  22. -quality ${quality} \
  23. -sharpen ${sharpen} \
  24. ${output}
  25. }
  26.  
  27. input=${1}
  28.  
  29. filename=$(basename "${input}")
  30. filename="${filename%.*}"
  31.  
  32. directory='ebook/'
  33. outputFormat='jpg'
  34.  
  35. mkdir \
  36. --verbose \
  37. "${directory}"
  38.  
  39. if [[ -f ${input} ]]; then
  40.  
  41. execPdfToCbz "${input}" "${directory}page-%04d.${outputFormat}"
  42.  
  43. elif [[ -d ${input} ]]; then
  44.  
  45. index=0
  46.  
  47. for inputFile in ${input}*.pdf; do
  48. execPdfToCbz "${inputFile}" "${directory}page-$(printf '%04d' ${index})-%04d.${outputFormat}"
  49. index=$((${index}+1))
  50. done
  51.  
  52. else
  53.  
  54. echo 'Veuillez renseigner un fichier PDF ou un dossier de fichiers PDF'
  55. exit
  56.  
  57. fi
  58.  
  59. zip \
  60. --verbose \
  61. "${filename}.cbz" \
  62. ${directory}page\-*.${outputFormat}
  63.  
  64. rm \
  65. --verbose \
  66. -fr \
  67. "${directory}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement