Last active
January 9, 2024 04:52
-
-
Save isurfer21/a514cb933c969d9254ec0521fac3c705 to your computer and use it in GitHub Desktop.
PNG to PDF converter CLI wrapper made using Imagemagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script takes two arguments: input filename and output filename | |
# It uses imagemagick to convert the input file to a pdf file with specified options | |
# Check if the number of arguments is correct | |
if [ $# -ne 2 ]; then | |
app_name=${0##*/} | |
echo "Syntax: $app_name <input> <output>" | |
echo "Usage: " | |
echo " $app_name input.png output.pdf" | |
echo " $app_name '*.png' output.pdf" | |
exit 1 | |
fi | |
# Assign the arguments to variables | |
input_file=$1 | |
output_file=$2 | |
# Run the imagemagick command with the input and output files | |
magick convert "$input_file" -quality 100 -units PixelsPerInch -density 72x72 "$output_file" | |
# Check if the conversion was successful | |
if [ $? -eq 0 ]; then | |
echo "Conversion successful!" | |
else | |
echo "Conversion failed!" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment