[Ubuntu] pdf 압축하기

서해빈·2021년 5월 27일
0

Ubuntu

목록 보기
2/2

Ghostscript - ubuntu에서 pdf 압축하기

Notion에 PDF를 업로드하는 과정에서 10MB이상의 파일은 유료 요금제부터 가능하다는 것을 알았다.

윈도우였다면 NesPDF를 사용해 resize했겠지만, 현재 사용하는 환경은 우분투여서 어떻게 해결할지 검색하본 결과 linux 배포판에 기본적으로 설치되어 있는 ghostscript를 사용한 방법을 알게되었다.

요약하자면 다음의 명령어를 사용해 pdf를 압축할 수 있다.

# 설치 확인
$ sudo apt install ghostscript
# 압축
$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress \
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf

이 때, -dPDFSETTINGS 옵션으로 압축할 해상도를 설정할 수 있다.

-dPDFSETTINGS=/screen   (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook    (low quality, 150 dpi images)
-dPDFSETTINGS=/printer  (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default  (almost identical to /screen)

최대한 용량을 줄이고 싶으니 ebook으로 설정!

압축 결과 11.4MB였던 원본이 457.9KB로 압축되었다...!
99.6%의 압축률... ㄷㄷㄷ 압축본을 열어봤는데 원본에 비해 화질이 떨어진다는 느낌도 받지 못했다. 👍👍

참고 및 출처

  • Ghostscript PDF Reference & Tip - 바로가기
  • 리눅스Linux에서 PDF를 압축하는 방법 [GUI 및 터미널] - 바로가기

0개의 댓글