import
cv2 as cv
import
openpyxl
template_path
=
'template12.png'
details_path
=
'gsocOrgsList.xlsx'
output_path
=
'/home/nikhil/Desktop/gfg'
font_size
=
3
font_color
=
(
0
,
0
,
0
)
coordinate_y_adjustment
=
15
coordinate_x_adjustment
=
7
obj
=
openpyxl.load_workbook(details_path)
sheet
=
obj.active
for
i
in
range
(
1
,
11
):
get_name
=
sheet.cell(row
=
i ,column
=
1
)
certi_name
=
get_name.value
img
=
cv.imread(template_path)
font
=
cv.FONT_HERSHEY_PLAIN
text_size
=
cv.getTextSize(certi_name, font, font_size,
10
)[
0
]
text_x
=
(img.shape[
1
]
-
text_size[
0
])
/
2
+
coordinate_x_adjustment
text_y
=
(img.shape[
0
]
+
text_size[
1
])
/
2
-
coordinate_y_adjustment
text_x
=
int
(text_x)
text_y
=
int
(text_y)
cv.putText(img, certi_name,
(text_x ,text_y ),
font,
font_size,
font_color,
10
)
certi_path
=
output_path
+
'/certi'
+
'.png'
cv.imwrite(certi_path,img)