Spaces:
Sleeping
Sleeping
Update pixelconversion.py
Browse files- pixelconversion.py +3 -9
pixelconversion.py
CHANGED
|
@@ -61,15 +61,9 @@ def openDrawPDF(path):
|
|
| 61 |
|
| 62 |
|
| 63 |
if page.rotation !=0:
|
| 64 |
-
|
| 65 |
else:
|
| 66 |
-
|
| 67 |
-
annot = page.add_rect_annot( rect=rect ) # 'rectangle'
|
| 68 |
-
annot.set_colors( fill=(75/255,0,130/255) ,stroke=(75/255,0,130/255) )
|
| 69 |
-
annot.set_opacity(0.9)
|
| 70 |
-
annot.set_border(border=None, width=0)
|
| 71 |
-
annot.update()
|
| 72 |
-
|
| 73 |
text = """Scale Document"""
|
| 74 |
annot1=page.add_freetext_annot(rectText, text, fontsize=45, fontname='helv', border_color=(1,1,1), text_color=(1,1,1), rotate=rotate, align=1)
|
| 75 |
annot1.update()
|
|
@@ -113,7 +107,7 @@ def getAreaPerimeter(pdfpath, plan):
|
|
| 113 |
data = res.content
|
| 114 |
doc=fitz.open("pdf", data)
|
| 115 |
for page in doc:
|
| 116 |
-
pix = page.get_pixmap(dpi=
|
| 117 |
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 118 |
img=np.array(pl)
|
| 119 |
print(img.shape)
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
if page.rotation !=0:
|
| 64 |
+
page.draw_rect([shape[3][0]-10,shape[3][1]-10,shape[1][0]+10,shape[1][1]+10], color = (75/255,0,130/255), width = 1,fill=(75/255,0,130/255),fill_opacity=0.9 )
|
| 65 |
else:
|
| 66 |
+
page.draw_rect([shape[0][0]-10,shape[0][1]-10,shape[2][0]+10,shape[2][1]+10], color = (75/255,0,130/255), width = 1,fill=(75/255,0,130/255),fill_opacity=0.9 )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
text = """Scale Document"""
|
| 68 |
annot1=page.add_freetext_annot(rectText, text, fontsize=45, fontname='helv', border_color=(1,1,1), text_color=(1,1,1), rotate=rotate, align=1)
|
| 69 |
annot1.update()
|
|
|
|
| 107 |
data = res.content
|
| 108 |
doc=fitz.open("pdf", data)
|
| 109 |
for page in doc:
|
| 110 |
+
pix = page.get_pixmap(dpi=300) # render page to an image
|
| 111 |
pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
|
| 112 |
img=np.array(pl)
|
| 113 |
print(img.shape)
|