<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Shell Scripting on Arcanelab Blog</title><link>https://blog.arcanelab.com/tags/shell-scripting/</link><description>Recent content in Shell Scripting on Arcanelab Blog</description><generator>Hugo</generator><language>en-US</language><copyright>Zoltán Majoros</copyright><lastBuildDate>Wed, 08 Feb 2023 14:15:00 +0100</lastBuildDate><atom:link href="https://blog.arcanelab.com/tags/shell-scripting/index.xml" rel="self" type="application/rss+xml"/><item><title>Compressing PDFs on Macs Let’s say you have a pdf file with large embedded images in…</title><link>https://blog.arcanelab.com/2023/02/compressing-pdfs-on-macs-lets-say-you-have-a-pdf-file-with/</link><pubDate>Wed, 08 Feb 2023 14:15:00 +0100</pubDate><guid>https://blog.arcanelab.com/2023/02/compressing-pdfs-on-macs-lets-say-you-have-a-pdf-file-with/</guid><description>&lt;h1&gt;Compressing PDFs on Macs&lt;/h1&gt;
&lt;p&gt;Let&amp;rsquo;s say you have a pdf file with large embedded images in it and you’d like to reduce the filesize a bit, here’s how to do it using the command line.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install ghostscript via Homebrew:&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code&gt;brew install gs&lt;/code&gt;&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Create a shell script, let&amp;rsquo;s call it &lt;code&gt;pdf2smol&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash

if [ -z "$1" ]; then
 echo "Usage: pdf2smol input.pdf [output.pdf] [resolution (default: 150)]"
 exit
fi

if [ -z "$2" ]; then
 output="output.pdf"
else
 output=$2
fi

if [ -z "$3" ]; then
 resolution=150
else
 resolution=$3
fi

set -x

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
-dNOPAUSE -dBATCH -dColorImageResolution=$resolution \
-sOutputFile="$output" "$1"
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>