전 컴퓨터 코딩에 초보입니다. 우리는 PYTHON을하기 위해 Canopy와 협력하고 우리는 이미지 수정을하고 있습니다. 나는 '모듈'객체에 'draw'오류가 없으며이를 수정하는 방법을 모르겠습니다. 나는 다음 가져온 :'모듈'객체에는 'draw'속성의 속성이 없습니다. 어떻게 수정해야합니까?
import PIL
import os.path
import PIL.ImageDraw
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
내가 실행하려고하고있는 코드이다 : 그것은 당신이 (무승부 찾고있는 방법처럼 보이는 문서), 그리지에서
def round_corners_of_all_images(directory=None):
""" Saves a modfied version of each image in directory.
Uses current directory if no directory is specified.
Places images in subdirectory 'modified', creating it if it does not exist.
New image files are of type PNG and have transparent rounded corners.
"""
if directory == None:
directory = os.getcwd() # Use working directory if unspecified
# Create a new directory 'modified'
new_directory = os.path.join(directory, 'modified')
try:
os.mkdir(new_directory)
except OSError:
pass # if the directory already exists, proceed
#load all the images
image_list, file_list = get_images(directory)
#go through the images and save modified versions
for n in range(len(image_list)):
# Parse the filename
filename, filetype = file_list[n].split('.')
# drawing the text on the picture
draw = ImageDraw.Draw(image_list[n])
font = ImageFont.truetype("Infinite_Stroke",size=24,index=0,encoding="unic")
draw.text((10, 25),(0,0,255),"SAMSUNG", font=font)
# Round the corners with radius = 30% of short side
new_image = round_corners(image_list[n],.30)
#save the altered image, suing PNG to retain transparency
new_image_filename = os.path.join(new_directory, filename + '.jpg')
new_image.save(new_image_filename)
나는 당신이 틀린 대문자가 있다고 생각한다 :'draw = ImageDraw.draw (image_list [n])'->'draw = ImageDraw.Draw (image_list [n])' –
나는 그것을 시도했지만 나는 여전히 같은 메시지를 받고있다. . – evaaaannnnnnnn
_describe_ your error - 전체 추적을 복사하여 붙여 넣으십시오. – DSM