working on Publications
70
public/publications/_first_page_image.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- Configuration ---
|
||||
# DPI for the output image. Higher DPI means higher resolution and larger file size.
|
||||
# Common values: 72, 96, 150, 300
|
||||
OUTPUT_DPI=150
|
||||
|
||||
# PNG quality (0-100). 90 is a good balance.
|
||||
PNG_QUALITY=90
|
||||
|
||||
# --- Script Logic ---
|
||||
|
||||
# Check if magick command is available
|
||||
if ! command -v magick &> /dev/null
|
||||
then
|
||||
echo "Error: 'magick' command not found. Please install ImageMagick."
|
||||
echo "On Arch Linux, you can install it with: sudo pacman -S imagemagick"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if any PDF files were provided as arguments
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "Usage: $0 <pdf_file1.pdf> [<pdf_file2.pdf> ...]"
|
||||
echo "Converts the first page of each PDF to a PNG image using ImageMagick's 'magick' command."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Starting PDF to PNG conversion using 'magick'..."
|
||||
echo "Output DPI: $OUTPUT_DPI, PNG Quality: $PNG_QUALITY"
|
||||
|
||||
# Loop through all PDF files provided as arguments
|
||||
for pdf_file in "$@"; do
|
||||
# Basic validation
|
||||
if [ ! -f "$pdf_file" ]; then
|
||||
echo "Error: File not found: $pdf_file. Skipping."
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$pdf_file" != *.pdf ]]; then
|
||||
echo "Warning: '$pdf_file' does not appear to be a PDF file. Skipping."
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $pdf_file"
|
||||
|
||||
# Get the base filename without the extension
|
||||
base_name=$(basename "$pdf_file" .pdf)
|
||||
|
||||
# Define the output PNG file name
|
||||
output_png="${base_name}.png"
|
||||
|
||||
# Use magick to convert the first page ([0]) of the PDF to PNG
|
||||
# -density: Sets the resolution (DPI)
|
||||
# -quality: Sets the compression quality for PNG
|
||||
# "$pdf_file[0]": Specifies the input PDF file and the first page (index 0)
|
||||
# "$output_png": The desired output PNG file name
|
||||
magick -density "$OUTPUT_DPI" -quality "$PNG_QUALITY" "$pdf_file[0]" "$output_png"
|
||||
|
||||
# Check the exit status of the magick command
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " -> Created: $output_png"
|
||||
else
|
||||
echo " -> Error: Failed to create PNG for $pdf_file."
|
||||
# You could add more specific error handling here if needed,
|
||||
# e.g., trying to use a different density or quality.
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Conversion finished."
|
||||
exit 0
|
||||
BIN
public/publications/altmann2024emergence.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
public/publications/feld2018trajectory.png
Normal file
|
After Width: | Height: | Size: 188 KiB |
BIN
public/publications/illium2020surgical.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
public/publications/illium2021visual.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
public/publications/illium2022constructing.png
Normal file
|
After Width: | Height: | Size: 132 KiB |
BIN
public/publications/illium2022empirical.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
public/publications/illium2022voronoipatches.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
public/publications/koelle23primate.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
public/publications/kolle2023compression.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
public/publications/kolle2024aquarium.png
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
public/publications/muller2020acoustic.png
Normal file
|
After Width: | Height: | Size: 214 KiB |
BIN
public/publications/muller2020analysis.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
public/publications/muller2020soccer.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
public/publications/muller2021acoustic.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
BIN
public/publications/nusslein2022case.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
public/publications/sedlmeier2020policy.png
Normal file
|
After Width: | Height: | Size: 93 KiB |