-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
39 lines (29 loc) · 957 Bytes
/
test.py
File metadata and controls
39 lines (29 loc) · 957 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
30
31
32
33
34
35
36
37
38
39
import sys, os, PythonMagick, PyPDF2
class magazine(object):
def getNumberOfPages(self, pdfPath):
pdf_im = pyPdf.PdfFileReader(file(pdfPath, "rb"))
return pdf_im.getNumPages()
def saveFrontCoverImage(self, pdfPath):
if (os.path.isfile(pdfPath)):
im = PythonMagick.Image()
im.density('300')
im.read(pdfPath + '[0]')
im.write(pdfPath[:-3] + 'png')
magazine = magazine()
magazine.saveFrontCoverImage('test.pdf')
sys.exit(0)
print('Converting %d pages.' % npage)
for p in range(npage):
im = PythonMagick.Image()
im.density('300')
im.read(pdf + '[' + str(p) +']')
im.write('file_out-' + str(p)+ '.png')
sys.exit(0)
p = PythonMagick.Image()
p.density('300')
#p.read(pdf)
#p.write('doc.jpg')
image = PythonMagick.Image(pdf)
image.write('doc.jpg')
image.transform('300x300')
image.write('doc_small.jpg')