-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpdf_from_pngs.py
More file actions
29 lines (23 loc) · 924 Bytes
/
pdf_from_pngs.py
File metadata and controls
29 lines (23 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
def pdf_from_pngs(imdir,pdfname):
"""
% (C) Nick Holschuh - Amherst College -- 2024 ([email protected])
%
% This function calls the imagemagick command "convert" to make a pdf from pngs in a directory
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The inputs are:
%
% imdir -- You must provide this with a directory containing pngs
% pdfname -- The name of the file to write
%
%%%%%%%%%%%%%%%
% The outputs are:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
frames = '%s/*.png' % (imdir)
os.system("convert -adjoin "+frames+" -gravity center -scale '90<x770<' "+pdfname)
if os.path.isfile(pdfname) == 0:
frames = '%s/*.jpg' % (imdir)
os.system("convert -adjoin "+frames+" -gravity center -scale '90<x770<' "+pdfname)