def save(self, sender):
     if self.pixel_editor.has_image():
         image = self.pixel_editor.get_image()
         option = console.alert('Save Image', '', 'Camera Roll', 'New File', 'Copy image')
         if option == 1:
             photos.save_image(self.superview['preview'].image)
             console.hud_alert('Saved to cameraroll')
         elif option == 2:
             # Saves image to disk
             imageName = console.input_alert('Save Image')
             if imageName[-4:] == ".png":
                 imageName = imageName[:-4]
             fileName = ('images/' + imageName + '.png')
             if isfile(fileName):
                 console.hud_alert('File exist!','error')
                 return False
             self.pixel_editor.imageName = imageName
             #name = 'images/image_{}.png'
             #get_num = lambda x=1: get_num(x+1) if isfile(name.format(x)) else x
             #file_name = name.format(get_num())
             pixels_to_png(self.superview['editor'].background_color, self.pixel_editor.pixels, self.pixel_editor.row*2, self.pixel_editor.column, fileName)
             console.hud_alert('Image saved as "{}"'.format(fileName))
         elif option == 3:
             clipboard.set_image(image, format='png')
             console.hud_alert('Copied')
     else:
         self.show_error()
def main():
    img = clipboard.get_image()
    if not img:
        print('No input image')
        return
    if not img.mode.startswith('RGB'):
        img = img.convert('RGB')
    gray_img = ImageOps.grayscale(img)
    clipboard.set_image(gray_img)
Example #3
0
def pic_save(image, image_mode, width, height, quality, resize):
    print('\nPicture save is in process ...')
    if resize:
        image = image.resize((width, height), Image.ANTIALIAS)
    background = Image.new(image_mode, (width,height), 'white')
    background.paste(image, (0, 0))
    clipboard.set_image((background), format='jpeg', jpeg_quality=quality)
    photos.save_image(clipboard.get_image())
    fmt = 'Completed!\nResolution = {} x {}, quality = {:.0f}%, mode = {}'
    print(fmt.format(width, height, quality * 100, image_mode))
Example #4
0
def pic_save(image, image_mode, width, height, quality, resize):
    print('\nPicture save is in process ...')
    if resize:
        image = image.resize((width, height), Image.ANTIALIAS)
    background = Image.new(image_mode, (width,height), 'white')
    background.paste(image, (0, 0))
    clipboard.set_image((background), format='jpeg', jpeg_quality=quality)
    photos.save_image(clipboard.get_image())
    fmt = 'Completed!\nResolution = {} x {}, quality = {:.0f}%, mode = {}'
    print(fmt.format(width, height, quality * 100, image_mode))
Example #5
0
def pic_save(image, m, x, y, q, r, filename):
	print
	print 'File: ' + filename + ' is in process ...'
	if r == True:
		image = image.resize((x, y), Image.ANTIALIAS)	
	background = Image.new(m, (x, y), 'white')
	background.paste(image,(0,0))
	clipboard.set_image((background), format='jpeg', jpeg_quality=q)
	image2 = clipboard.get_image()
	image2.save(filename, 'JPEG')
Example #6
0
def main():
    if not appex.is_running_extension():
        print('This script is intended to be run from the sharing extension.')
        return
    img = appex.get_image()
    if not img:
        print('No input image')
        return
    if not img.mode.startswith('RGB'):
        img = img.convert('RGB')
    gray_img = ImageOps.grayscale(img)
    clipboard.set_image(gray_img)
Example #7
0
def pic_save(image, width, height, text, font, fontsize, color, x, y, scale):
    background = Image.new('RGBA', (width,height), 'white')
    background.paste(image, (0, 0))
    draw = ImageDraw.Draw(background)
    y = height - (y * scale)
    x = x * scale
    f = ImageFont.truetype(font, int(fontsize * scale))
    textsize = draw.textsize(text, font=f)
    x -= textsize[0]/2
    y -= ((textsize[1]/1.15)/2) # remove offset / add div factor 1.15 (difference between pixel size and font size)
    draw.text((x, y), text, font=f, fill=color)
    clipboard.set_image(background, format='jpeg', jpeg_quality=0.98)
    photos.save_image(clipboard.get_image())
Example #8
0
def pic_save(image, width, height, text, font, fontsize, color, x, y, scale):
    background = Image.new('RGBA', (width,height), 'white')
    background.paste(image, (0, 0))
    draw = ImageDraw.Draw(background)
    offset = fontsize / 3.2  # offset is relative to the fontsize
    fontsize *= scale
    y = height - y
    f = ImageFont.truetype(font, int(fontsize))
    textsize = draw.textsize(text, font=f)
    x -= textsize[0]/2
    y -= (textsize[1]/2) + offset
    draw.text((x, y), text, font=f, fill=color)
    clipboard.set_image(background, format='jpeg', jpeg_quality=0.98)
    photos.save_image(clipboard.get_image())
Example #9
0
def main():
		console.clear()
		print "Generating image..."
		console.show_activity()

		_1 = im1.resize((366,650),Image.ANTIALIAS)
		_2 = im2.resize((366,650),Image.ANTIALIAS)
		background.paste(_1,(0,0))
		background.paste(_2,(380,0))
		background.show()
		console.hide_activity()

		clipboard.set_image(background, format='jpeg', jpeg_quality=0.80)
		print "\n\n Image set to clipboard"
	def save(self, sender):
		if self.pixel_editor.has_image():
			image = self.pixel_editor.get_image()
			option = console.alert('Save Image', '', 'Camera Roll', 'New File', 'Copy image')
			if option == 1:
				photos.save_image(image)
				console.hud_alert('Saved to cameraroll')
			elif option == 2:
				name = 'image_{}.png'
				get_num = lambda x=1: get_num(x+1) if os.path.isfile(name.format(x)) else x
				file_name = name.format(get_num())
				with open(file_name, 'w') as f:
					ui_to_pil(image).save(f, 'png')
				console.hud_alert('Image saved as "{}"'.format(file_name))
			elif option == 3:
				clipboard.set_image(image, format='png')
				console.hud_alert('Copied')
		else: 
			self.show_error()
 def googlemap(self):
     url = 'http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=roadmap'
     url = url + '&format=png&size=800x600&scale=1'
     group = ''
     newpoints = []
     colorpath = {
         'walking': '0x00d55a',
         'running': '0x660f4',
         'transport': '0x848484',
         'cycling': '0x00cdec',
         '': ''
     }
     run_in_moves = False
     for point in self.points:
         if point['group'] == 'running':
             run_in_moves = True
         if point['group'] == group:
             newpoints.append((point['lat'], point['lon']))
         else:
             try:
                 path = polyline.encode(newpoints)
                 print path
             except:
                 path = ''
             url = url + '&path=color:' + colorpath[
                 group] + '%7Cweight:5%7Cenc:' + path
             newpoints = [(point['lat'], point['lon'])]
             group = point['group']
     # do not forget final segment
     url = url + '&path=color:' + colorpath[
         group] + '%7Cweight:5%7Cenc:' + polyline.encode(newpoints)
     # add strava runs if run not recorded in Moves data
     if not run_in_moves:
         for run in self.stravarunpaths:
             url = url + '&path=color:' + colorpath[
                 'running'] + '%7Cweight:5%7Cenc:' + run
     url = url + '&markers=color:blue%7Csize:normal' + self.coordstostring(
         self.places)
     #print url
     img = Image.open(BytesIO(urllib.urlopen(url).read()))
     clipboard.set_image(img)
 def save(self, sender):
     if self.pixel_editor.has_image():
         image = self.pixel_editor.get_image()
         option = console.alert('Save Image', '', 'Camera Roll', 'New File',
                                'Copy image')
         if option == 1:
             photos.save_image(image)
             console.hud_alert('Saved to cameraroll')
         elif option == 2:
             name = 'image_{}.png'
             get_num = lambda x=1: get_num(x + 1) if os.path.isfile(
                 name.format(x)) else x
             file_name = name.format(get_num())
             with open(file_name, 'w') as f:
                 ui_to_pil(image).save(f, 'png')
             console.hud_alert('Image saved as "{}"'.format(file_name))
         elif option == 3:
             clipboard.set_image(image, format='png')
             console.hud_alert('Copied')
     else:
         self.show_error()
# This is a Pythonista script that will download an image, given its URL, and place that
# into the clipboard.
#
# So: from Image URL in clipboard to actual Image in clipboard.
#
# (c) 2014 Dexter Ang. MIT License.
#

import clipboard
import urllib2
import webbrowser
from cStringIO import StringIO
from PIL import Image

img_download = urllib2.urlopen(clipboard.get())
img_string = StringIO(img_download.read())
img = Image.open(img_string)
clipboard.set_image(img)
Example #14
0
	def run(self, input):
		clipboard.set_image(input.value)
		self.status = 'complete'
 def screenshot_action(self, sender):
     print("Saving a screenshot to the clipboard.")
     clipboard.set_image(self.get_shapshot())
Example #16
0
if stacktype == 'h':
	newdims = (sum([x[0] for x in imdim])+(padding+2*border), max([x[1] for x in imdim])+(2*border))
else:
	newdims = (max([x[0] for x in imdim])+int(2*border), sum([x[1] for x in imdim])+(padding+2*border))

newimage = Image.new('RGBA', newdims, bkgcolor+transparency)

# Add the two original images to the joined one
newimage.paste(imlist[0],(border,border))
if stacktype == 'h':
	newimage.paste(imlist[1],(imdim[0][0]+border+padding,border))
else:
	newimage.paste(imlist[1],(border,imdim[0][1]+border+padding))


if platform == 'darwin':
	# Save image to a tmp file
	filename = '/var/tmp/image.jpg'
	fh = open(filename,'w')
	newimage.save(fh, 'JPEG', quality=90)
	fh.close()
	# View the file using default image viewer
	proc = sp.Popen(['/bin/sh','-'], stdin=sp.PIPE, stdout=sp.PIPE)
	stdout = proc.communicate('open '+ filename)
else:
	# Save image to clipboard
	clipboard.set_image(newimage)
	# View the file
	newimage.show()

Example #17
0
def copy_action(sender):
    img = create_image()
    clipboard.set_image(img)
Example #18
0
# https://forum.omz-software.com/topic/4504/image-processing-using-objc

from PIL import Image, ImageOps, ImageFilter, ImageChops
import photos, clipboard, webbrowser

imo = clipboard.get_image(idx=0)

if not imo.mode == 'RGB':
    img = imo.convert('RGB')

    im1 = img.filter(ImageFilter.MaxFilter(size=9))

    im2 = ImageChops.subtract(im1, img)

    im3 = ImageOps.invert(im2)

    im4 = im3.filter(ImageFilter.SHARPEN)

    im5 = ImageOps.autocontrast(im4, cutoff=1)

clipboard.set_image(im5, jpeg_quality=1.0)
webbrowser.open('workflow://')
Example #19
0
		if set_im == "x":

				print "Exited"

		else:

    			print "\n\n"

		if set_im == "1":
	
			if __name__ == '__main__':
				main()

		elif set_im == "2":
			console.clear()
			print "Generating image..."
			console.show_activity()
	
			_1 = im1.resize((366,650),Image.ANTIALIAS)
			_2 = im2.resize((366,650),Image.ANTIALIAS)

			background.paste(_1,(380,0))
			background.paste(_2,(0,0))
			background.show()
			console.hide_activity()
		
			clipboard.set_image((background), format='jpeg', jpeg_quality=0.80)
			
			print "\n\n Image set to clipboard"
Example #20
0
def setImageClip():
	shutil.move(fileName, "img)
	img = Image.open("img/"+fileName)
	img.show()
	clipboard.set_image(img)
Example #21
0
 def screenshot_action(self, sender):
     print('Saving a screenshot to the clipboard.')
     clipboard.set_image(self.get_shapshot())
# Imports two screenshots (iPhone 5) from the iOS clipboard and creates a single image
# Based on: http://www.macstories.net/tutorials/a-better-way-to-combine-iphone-screenshots-with-keyboard-maestro/
# Images are pasted in order of Photos.app


import clipboard
import Image

im1 = clipboard.get_image(idx=0)
im2 = clipboard.get_image(idx=1)
_1 = im1.resize((366,650),Image.ANTIALIAS)
_2 = im2.resize((366,650),Image.ANTIALIAS)
background = Image.new('RGBA', (746,650), (255, 255, 255, 255))
background.paste(_1,(0,0))
background.paste(_2,(380,0))
background.show()

clipboard.set_image(background)
Example #23
0
if stacktype == 'h':
    newdims = (sum([x[0] for x in imdim]) + (padding + 2 * border),
               max([x[1] for x in imdim]) + (2 * border))
else:
    newdims = (max([x[0] for x in imdim]) + int(2 * border),
               sum([x[1] for x in imdim]) + (padding + 2 * border))

newimage = Image.new('RGBA', newdims, bkgcolor + transparency)

# Add the two original images to the joined one
newimage.paste(imlist[0], (border, border))
if stacktype == 'h':
    newimage.paste(imlist[1], (imdim[0][0] + border + padding, border))
else:
    newimage.paste(imlist[1], (border, imdim[0][1] + border + padding))

if platform == 'darwin':
    # Save image to a tmp file
    filename = '/var/tmp/image.jpg'
    fh = open(filename, 'w')
    newimage.save(fh, 'JPEG', quality=90)
    fh.close()
    # View the file using default image viewer
    proc = sp.Popen(['/bin/sh', '-'], stdin=sp.PIPE, stdout=sp.PIPE)
    stdout = proc.communicate('open ' + filename)
else:
    # Save image to clipboard
    clipboard.set_image(newimage)
    # View the file
    newimage.show()
Example #24
0
 def copy(self):
     clipboard.set_image(self.imgmono)
# Based on: http://www.macstories.net/tutorials/a-better-way-to-combine-iphone-screenshots-with-keyboard-maestro/
# Uses two screenshots saved in Pythonista's image manager

import Image
import clipboard
im1 = Image.open('_1').convert("RGB")
im2 = Image.open('_3').convert("RGB")
background = Image.new('RGBA', (746, 650), (255, 255, 255, 255))
background.paste(im1, (0, 0))
background.paste(im2, (380, 0))
background.show()

clipboard.set_image(background)
while 1:
       data=conn.recv(102400)  
       if(len(data)!=0):
       	     #print('0')
             conn.sendall('0'.encode())  
             data_all+=data
             # print(data.decode())
       else:
             #print('OVER') 
             conn.sendall(''.encode())  
             break
if data_all[0:1]=='0'.encode():
	wh=0
	hi=0
	for i in range(15):
		if(data_all[i:i+1]=='|'.encode()):
			wh=i
		if(data_all[i:i+1]=='&'.encode()):
			hi=i
	widge=int(data_all[0:wh].decode())
	height=int(data_all[wh+1:hi].decode())
	img_get=Image.new('RGBA',(widge,height))
	img_get=Image.open(io.BytesIO(data_all[hi+1:]))
	img_get.show()
	clipboard.set_image(img_get)
else:
	print(data_all[1:].decode())
	clipboard.set(data_all[1:].decode())
conn.close()