Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function execPdfToCbz {
- input=${1}
- output=${2}
- quality=90
- density=150
- height=1280
- width=''
- sharpen='0x1.0'
- background='#FFFFFF'
- convert \
- -verbose \
- -density ${density} \
- -trim \
- "${input}" \
- -background "${background}" \
- -resize ${width}x${height} \
- -quality ${quality} \
- -sharpen ${sharpen} \
- ${output}
- }
- input=${1}
- filename=$(basename "${input}")
- filename="${filename%.*}"
- directory='ebook/'
- outputFormat='jpg'
- mkdir \
- --verbose \
- "${directory}"
- if [[ -f ${input} ]]; then
- execPdfToCbz "${input}" "${directory}page-%04d.${outputFormat}"
- elif [[ -d ${input} ]]; then
- index=0
- for inputFile in ${input}*.pdf; do
- execPdfToCbz "${inputFile}" "${directory}page-$(printf '%04d' ${index})-%04d.${outputFormat}"
- index=$((${index}+1))
- done
- else
- echo 'Veuillez renseigner un fichier PDF ou un dossier de fichiers PDF'
- exit
- fi
- zip \
- --verbose \
- "${filename}.cbz" \
- ${directory}page\-*.${outputFormat}
- rm \
- --verbose \
- -fr \
- "${directory}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement