Last active
February 6, 2018 13:17
-
-
Save przemoc/1039310 to your computer and use it in GitHub Desktop.
Converting EPS w/ crop marks to PDF w/ TrimBox+CropBox and final JPEG
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/sh | |
# SPDX-License-Identifier: MIT | |
## Copyright (C) 2011 Przemyslaw Pawelczyk <przemoc@gmail.com> | |
## | |
## This script is licensed under the terms of the MIT license. | |
## https://opensource.org/licenses/MIT | |
# | |
# Converting EPS w/ crop marks to PDF w/ TrimBox+CropBox and final JPEG | |
# Simple script with brief explanation | |
# 2+3D 40th anniversary issue (10 years) cover contest | |
# http://2plus3d.pl/artykuly/konkurs-na-okladke-40-numeru-2plus3d | |
# EPS in: http://dl.dropbox.com/u/1691461/2plus3d/szablon.zip | |
# EPS file name w/o extension | |
EPS=szablon | |
# Sanitize EPS | |
eps2eps $EPS.eps $EPS-eps2eps.eps | |
# Convert it to PDF | |
epstopdf --hires $EPS-eps2eps.eps | |
# Prepare LaTeX file using previously obtained PDF, and define there some PDF | |
# boxes as in the comments from original EPS | |
## (BTW you can create your cover now in LaTeX, have fun!) | |
cat >$EPS-withcrop.tex <<_EOF | |
\documentclass{article} | |
\usepackage[paperwidth=665.1495bp,paperheight=865.7012bp]{geometry} | |
\usepackage{pdfpages} | |
\begin{document} | |
\pagestyle{empty} | |
\pdfpageattr{% | |
% Below MediaBox is commented, because pdflatex outputs its own according to | |
% page size, which has a bit lesser but still acceptable accuracy. | |
%% 234.65mm x 305.40mm | |
%/MediaBox[0 0 665.1495 865.7012] | |
%% 209.25mm x 280.00mm | |
/TrimBox[36.0000 36.0000 629.1495 829.7012] | |
/CropBox[36.0000 36.0000 629.1495 829.7012] | |
} | |
\includepdf[noautoscale=true]{$EPS-eps2eps} | |
\end{document} | |
_EOF | |
# Generate final PDF | |
pdflatex $EPS-withcrop.tex | |
# Convert it to high-quality trimmed JPEG | |
convert -verbose -density 437x435.4 -define pdf:use-trimbox=true $EPS-withcrop.pdf \ | |
-resize 33.333% -quality 100 $EPS-trimmed.jpg |
Author
przemoc
commented
Feb 6, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment