def getPhotos(urls): urls = pan.getPhotos(urls) if (len(urls)<4): print('Could not find sufficient amonut of photos.') else: im = Image.new('RGB', (512,512)) im1 = pan.openphoto(urls[0]) imsquare = make_square(im1) im1 = imsquare.resize((256,256)) im2 = pan.openphoto(urls[2]) imsquare = make_square(im2) im2 = imsquare.resize((256,256)) im3 = pan.openphoto(urls[3]) imsquare = make_square(im3) im3 = imsquare.resize((256,256)) im4 = pan.openphoto(urls[4]) imsquare = make_square(im4) im4 = imsquare.resize((256,256)) im.paste(im1, (0,0)) im.paste(im2, (0, 256)) im.paste(im3, (256, 0)) im.paste(im4, (256,256)) im.show()
def wallpaper(urls): #pastes four images together into 512x512 image if len(urls) >= 4: image1 = pan.openphoto(urls[0]) im1 = image1.resize( (256,256) ) image2 = pan.openphoto(urls[1]) im2 = image2.resize( (256,256) ) image3 = pan.openphoto(urls[2]) im3 = image3.resize( (256,256) ) image4 = pan.openphoto(urls[3]) im4 = image4.resize( (256,256) ) im = Image.new('RGB', (512,512), 'white') im.paste(im1, (0,0)) im.paste(im2, (257,0)) im.paste(im3, (0,257)) im.paste(im4, (257,257)) im.save('wallpaper.jpg') im.show() else: print "Not enough images at location"
from PIL import Image ##must import Image first to be able to use it import check2_helper import panoramio as pan address = input("Enter an address ==> ") urls = pan.getPhotos(address,4) if len(urls)>=4: final_im = Image.new("RGB", (512,512), "white") # use mode 'RGB', color 'white' im_1 = pan.openphoto(urls[0]) im_2 = pan.openphoto(urls[1]) im_3 = pan.openphoto(urls[2]) im_4 = pan.openphoto(urls[3]) im_1 = check2_helper.make_square(im_1) im_2 = check2_helper.make_square(im_2) im_3 = check2_helper.make_square(im_3) im_4 = check2_helper.make_square(im_4) im_1 = im_1.resize((256,256)) im_2 = im_2.resize((256,256)) im_3 = im_3.resize((256,256)) im_4 = im_4.resize((256,256)) final_im.paste(im_1,(0,0)) final_im.paste(im_2,(256,0)) final_im.paste(im_3,(0,256)) final_im.paste(im_4,(256,256)) final_im.show() else:
from PIL import Image import panoramio as pan from check2_helper import make_square address = raw_input('Type an address ==> ') urls = pan.getPhotos(address,4) if len(urls) >= 4: background = Image.new('RGB', (512,512), 'white') im1 = pan.openphoto(urls[0]) im1 = make_square(im1) im1 = im1.resize((256,256)) background.paste(im1,(0,0)) im2 = pan.openphoto(urls[1]) im2 = make_square(im2) im2 = im2.resize((256,256)) background.paste(im2,(256,0)) im3 = pan.openphoto(urls[2]) im3 = make_square(im3) im3 = im3.resize((256,256)) background.paste(im3,(0,256)) im4 = pan.openphoto(urls[3]) im4 = make_square(im4) im4 = im4.resize((256,256)) background.paste(im4,(256,256))
import panoramio as pan urls = pan.getPhotos('Eiffel Paris France', 5) # Return 5 pictures of Eiffel Tower im = pan.openphoto(urls[0]) # Open the first image URL im.show() im2 = pan.openphoto(urls[2]) # Open the first image URL im2.show()