Hardware Reference
In-Depth Information
def capture_photo(self):
""" Capture a photo and download it from the camera """
filename = join(out, '%s.jpg' % str(uuid4()))
cfg = ['--set-config=%s=%s' % (k, v) for k, v in gphoto_con
fig.items()]
subprocess.call('gphoto2 ' +
'--capture-image-and-download ' +
'--filename="%s" ' % filename,
shell=True)
return filename
def process_image(self, filename):
print "Processing %s..." % filename
print "Applying watermark..."
image = self.watermark(filename)
print "Uploading to remote server..."
url = self.upload(image)
print "Generating QRCode..."
qrcode = self.qrencode(url)
print "Shortening URL..."
tiny = self.shorten(url)
print "Generating HTML..."
html = self.html_output(url, qrcode, tiny)
subprocess.call('xdg-open "%s"' % html, shell=True)
print "Done!"
If you choose not to watermark, you'll want to delete this section:
def watermark(self, image):
""" Apply a watermark to an image """
mark = Image.open(watermark_img)
im = Image.open(image)
if im.mode != 'RGBA':
im = im.convert('RGBA')
layer = Image.new('RGBA', im.size, (0,0,0,0))
position = (im.size[0] - mark.size[0], im.size[1] - mark.size[1])
layer.paste(mark, position)
outfile = join(out, basename(image))
Image.composite(layer, im, layer).save(outfile)
return outfile
The script continues by uploading the image, creating the QR code and the web page,
and offering a shortened URL:
Search WWH ::




Custom Search