From c6ed95dddad6319e3edf60f3c98d5ee220d990b4 Mon Sep 17 00:00:00 2001 From: borja Date: Thu, 19 Feb 2026 11:14:45 +0100 Subject: [PATCH] nose --- reducepdf.sh | 83 ---------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100755 reducepdf.sh diff --git a/reducepdf.sh b/reducepdf.sh deleted file mode 100755 index b279aa7..0000000 --- a/reducepdf.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -# Function to display usage information and exit -usage() { - echo "Usage: $0 input.pdf output.pdf [-r resolution] [-h]" - echo "" - echo "Options:" - echo "-r Set the image resolution (default is 150ppi)" - echo "-h Display this help message" - exit 1 -} - -# Default settings -RESOLUTION=150 - -# Parse command-line options -while getopts ":r:h" opt; do - case ${opt} in - r) - RESOLUTION=$OPTARG - ;; - h) - usage - ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - exit 1 - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - exit 1 - ;; - esac -done - -shift $((OPTIND - 1)) - -# Check if the correct number of arguments are provided after parsing options -if [ "$#" -ne 2 ]; then - usage -fi - -INPUT_FILE="$1" -OUTPUT_FILE="$2" - -# Check if input file exists -if [ ! -f "$INPUT_FILE" ]; then - echo "Input file '$INPUT_FILE' does not exist." - exit 1 -fi - -# Extract directory and base name from output file path -OUTPUT_DIR=$(dirname "$OUTPUT_FILE") -OUTPUT_BASENAME=$(basename "$OUTPUT_FILE") - -# Create the output directory if it doesn't already exist -mkdir -p "$OUTPUT_DIR" - -# Run Ghostscript command with specified resolution -gs \ - -sDEVICE=pdfwrite \ - -dCompatibilityLevel=1.7 \ - -dPDFSETTINGS=/prepress \ - -dDownsampleMonoImages=false \ - -dDownsampleColorImages=true \ - -dColorImageResolution=$RESOLUTION \ - -dGrayImageResolution=$RESOLUTION \ - -dMonoImageResolution=$RESOLUTION \ - -dPreserveOPIRequests=false \ - -dSubsetFonts=true \ - -dEmbedAllFonts=true \ - -sProcessColorModel=DeviceRGB \ - -dQUIET -dBATCH -dNOPAUSE \ - -sOutputFile="$OUTPUT_FILE" "$INPUT_FILE" - -# Check if Ghostscript command was successful -if [ $? -ne 0 ]; then - echo "Error: Ghostscript failed to process the file '$INPUT_FILE'." - exit 1 -fi - -echo "Successfully converted '$INPUT_FILE' to '$OUTPUT_BASENAME'" -