링크에서 이미지를 가져올 스크립트를 작성 중입니다. 그런 다음 이미지는 PIL
모듈을 사용하여 크기가 조정되고 pyimgur
을 사용하여 Imgur에 업로드됩니다. 디스크에 이미지를 저장하고 대신 이미지를 메모리에 저장 한 다음 메모리에서 Imgur로 업로드하려고합니다. 스크립트에게 :이 스크립트를 실행하면크기 조정 후 이미지를 Imgur에 업로드 PIL
from pyimgur import Imgur
import cStringIO
import requests
from PIL import Image
LINK = "http://pngimg.com/upload/cat_PNG106.png"
CLIENT_ID = '29619ae5d125ae6'
im = Imgur(CLIENT_ID)
def _upload_image(img, title):
uploaded_image = im.upload_image(img, title=title)
return uploaded_image.link
def _resize_image(width, height, link):
#Retrieve our source image from a URL
fp = requests.get(link)
#Load the URL data into an image
img = cStringIO.StringIO(fp.content)
im = Image.open(img)
#Resize the image
im2 = im.resize((width, height), Image.NEAREST)
#saving the image into a cStringIO object to avoid writing to disk
out_im2 = cStringIO.StringIO()
im2.save(out_im2, 'png')
return out_im2.getvalue()
나는이 오류가 발생합니다 : TypeError: file() argument 1 must be encoded string without NULL bytes, not str
누구나 마음에 솔루션을?
GData API를 사용하여 Google App Engine에서 Picasa로 사진을 업로드하려고 할 때 [TypeError]가 중복 될 수 있습니다. (http://stackoverflow.com/questions/1715574/typeerror-when-trying-to-upload-pictures-from -google-app-engine-to-picasa-with-t) –