Exemplo n.º 1
0
def render(meshes, fileName, wireFrame=False):
  global initialized, SIZE
  assert initialized

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  for mesh in meshes:
    glPolygonMode(GL_FRONT_AND_BACK, (GL_LINE if wireFrame else GL_FILL))
    glPushMatrix()

    # apply transformations
    glColor3f(*mesh.getColor())
    glTranslatef(*mesh.getTranslation())
    glScalef(*mesh.getScale())
    glRotatef(mesh.getRotation()[2], 0, 0, 1)
    glRotatef(mesh.getRotation()[1], 0, 1, 0)
    glRotatef(mesh.getRotation()[0], 1, 0, 0)

    # send triangles
    glBegin(GL_TRIANGLES)
    for triangle in mesh.getTriangles():
      for vertex in triangle:
        glVertex3f(vertex[0], vertex[1], vertex[2])
    glEnd()

    glPopMatrix()

  glFlush()
  glutSwapBuffers()

  # save the framebuffer to disk
  data = glReadPixels(0, 0, SIZE[0], SIZE[1], GL_RGB, GL_BYTE)
  img = Image.frombuffer('RGB', SIZE, data, 'raw', 'RGB')
  flipped = ImageOps.mirror(ImageOps.flip(img))
  flipped.save(fileName)
 def __second_half(self, image, x_range):
     height = image.size[1]
     width = abs(x_range[1] - x_range[0])
     i2 = ImageOps.mirror(image.crop((x_range[0], 0, x_range[1], height)))
     vec = numpy.zeros(image.size[0]*image.size[1])
     vec[0:i2.size[0]*i2.size[1]] = i2.getdata()
     return vec
 def __second_half(self, image, x_range):
     height = image.size[1]
     width = abs(x_range[1] - x_range[0])
     i2 = ImageOps.mirror(image.crop((x_range[0], 0, x_range[1], height)))
     vec = numpy.zeros(image.size[0] * image.size[1])
     vec[0:i2.size[0] * i2.size[1]] = i2.getdata()
     return vec
Exemplo n.º 4
0
def main(argv):
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('--mirror-x', action='store_true')
    parser.add_argument('--mirror-y', action='store_true')
    parser.add_argument('--no-display', action='store_false', dest='display')
    parser.add_argument('--no-click', action='store_false', dest='clicks')
    args = parser.parse_args(argv[1:])

    am = AutoMeta()

    print "Getting images..."
    pos, im1, im2 = get_images(am)
    if args.mirror_x:
        im2 = ImageOps.mirror(im2)
    if args.mirror_y:
        im2 = ImageOps.flip(im2)
    print "got"

    print "Aligning..."
    pix = get_difference_image(im1, im2)
    print "done"

    print "Finding differences...",
    diffs = get_difference_spots(pix)
    print "done"

    if args.clicks:
        # TODO: if two diffs are very close, only click one
        for diff in diffs:
            am.move_mouse(pos[0] + diff[1], pos[1] + diff[0])
            time.sleep(.1)
            am.left_click()

    if args.display:
        Image.fromarray(pix).show()
Exemplo n.º 5
0
def main(argv):
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('--mirror-x', action='store_true')
    parser.add_argument('--mirror-y', action='store_true')
    parser.add_argument('--no-display', action='store_false', dest='display')
    parser.add_argument('--no-click', action='store_false', dest='clicks')
    args = parser.parse_args(argv[1:])

    am = AutoMeta()

    print "Getting images..."
    pos, im1, im2 = get_images(am)
    if args.mirror_x:
        im2 = ImageOps.mirror(im2)
    if args.mirror_y:
        im2 = ImageOps.flip(im2)
    print "got"

    print "Aligning..."
    pix = get_difference_image(im1, im2)
    print "done"

    print "Finding differences...",
    diffs = get_difference_spots(pix)
    print "done"

    if args.clicks:
        # TODO: if two diffs are very close, only click one
        for diff in diffs:
            am.move_mouse(pos[0] + diff[1], pos[1] + diff[0])
            time.sleep(.1)
            am.left_click()

    if args.display:
        Image.fromarray(pix).show()
Exemplo n.º 6
0
	def sharpen( self ):
		g = rightclick.Graphic
		data = list( g.DIB.value )
		data.reverse()
		data = ''.join( data )
		format = 'RGB'
		H = g.SizePixel.Height
		W = (len( data ) / 3) / H		# SizePixel.Width can be off by one for some reason (OOo bug)
		import Image
		image = Image.frombuffer( format, (W, H), data, 'raw', format, 0, 1 )
		import ImageOps
		image = ImageOps.mirror( image )
		import ImageFilter
		image = image.filter( ImageFilter.SHARPEN )
		import tempfile
		f = tempfile.NamedTemporaryFile( suffix = '.png', delete = False )		# requires Python 2.6 -- delete is new
		image.save( f, format='png' )
		f.close()
		import util.draw
		g = util.draw.embed( self.getcomponent(), f.name )
		import os
		os.unlink( f.name )
		page = self.getcontroller().CurrentPage
		page.add( g )
		g.Position = rightclick.Position
		g.Size = rightclick.Size
#		page.remove( rightclick )		# crashes OOo
		self.getcontroller().select( g )
Exemplo n.º 7
0
    def _mirror_pic(pic_path):
        pic_name = os.path.split(pic_path)[1]
        video_name = os.path.split(pic_path)[0].split('/')[-1]
        mirror_pic_name = 'conv-mirror-{0}'.format(pic_name)
        mirror_pic_path = os.path.join(FRAME_DB_PATH, 'conv-mirror-{0}'.format(video_name))
        command = ['mkdir', '-m', '775', mirror_pic_path]
        p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        p.communicate()

        img = Image.open(pic_path)
        img_mirror = ImageOps.mirror(img)
        img_mirror.save(os.path.join(mirror_pic_path, mirror_pic_name))
Exemplo n.º 8
0
	def specchiatadx(self, boxdx, boxdxcrop, boxdxmirror, lineaditaglio):
		imagecrop = self.imagedx.crop(boxdx)
		imagemirror = ImageOps.mirror(imagecrop)
		nuovaimmaginedx = Image.new("RGB", ((self.dimensioni[0]-lineaditaglio)*2,self.dimensioni[1]))
		nuovaimmaginedx.paste(imagemirror, boxdxmirror)
		nuovaimmaginedx.paste(imagecrop, boxdxcrop)
		nuovaimmaginedx.save("partedx.jpg")
		global nuovaimmaginedx
		
		self.photo3 = ImageTk.PhotoImage(nuovaimmaginedx)
		self.canvas3.create_image(0,0, anchor="nw", image=self.photo3)
		self.canvas3.config(width=self.photo3.width(),height=self.photo3.height())
		self.canvas3.pack(side="left")
Exemplo n.º 9
0
	def specchiatasx(self, boxsx, boxsxtraslato, lineaditaglio):
		imagecrop = self.imagesx.crop(boxsx)
		imagemirror = ImageOps.mirror(imagecrop)
		nuovaimmaginesx = Image.new("RGB",(lineaditaglio*2,self.dimensioni[1]))
		nuovaimmaginesx.paste(imagecrop, boxsx)	
		nuovaimmaginesx.paste(imagemirror, boxsxtraslato)
		nuovaimmaginesx.save("partesx.jpg")
		global nuovaimmaginesx
		
		self.photo2 = ImageTk.PhotoImage(nuovaimmaginesx)
		self.canvas2.create_image(0,0, anchor="nw", image=self.photo2)
		self.canvas2.config(width=self.photo2.width(),height=self.photo2.height())
		self.canvas2.pack(side="left")
Exemplo n.º 10
0
 def snap(self):
     imgfile = tempfile.NamedTemporaryFile(suffix=".jpg",delete=False)
     pic = self.cam.getImage()
     pic = ImageOps.mirror(pic)
     pic = pic.resize((320,240))
     pic.save(imgfile,"JPEG")
     template = open(self.templateFile)
     rtffile = tempfile.NamedTemporaryFile(suffix=".rtf",delete=False)
     rtf = template.read()
     for param in self.params:
         rtf = rtf.replace("%" + param[0] + "%", param[2].get())
     #TODO - make this more resilient to changes in the picture path
     rtf = rtf.replace(self.replacePicture,imgfile.name.replace("\\",'\\\\\\\\'))
     rtffile.write(rtf)
     rtffile.close()
     win32api.ShellExecute (0,"print", rtffile.name, None, ".", 0)
Exemplo n.º 11
0
 def MapCB(self, data):
     wx.Yield()       
     self.parent.mp.btn_rf.Enable(False)
     self.parent.mp.btn_rf.SetLabel("Updating Map...")  
            
     array_length = len(data.data)
     self.image_width = int(np.sqrt(array_length))
     self.resolution = self.Truncate(data.info.resolution, 5)
     self.origin_pos = data.info.origin.position
     self.origin_orient = data.info.origin.orientation        
     
     color_data = self.TranslateToRGB(data.data)    
     img=Image.new('RGB', (self.image_width,self.image_width))
     img.putdata(color_data)  
     # Rotate and flip image (otherwise it won't match the real map)
     img = img.rotate(180)
     img_mirror = ImageOps.mirror(img)
     
     if not self.refresh:
         try:
             os.remove(self.filename)
         except OSError:
             pass        
         img_mirror.save(self.filename)
         if self.mframe.modes['verbose']:         
             print "Map file created. (%s)" % self.filename
         self.refresh = True
     
     # Creates the wx.Image to be passed to the ZoomPanel
     self.image = self.PilImageToWxImage(img_mirror)
     self.image_data = data.data
     wx.CallAfter(self.mframe.SetMapMetadata, self.image_width,
                  self.resolution,self.origin_pos)
     if self.mframe.current_map == self.GetDefaultFilename():
         print "set image"
         wx.CallAfter(self.mframe.SetImage, self.image)  
         
     self.parent.mp.btn_rf.SetLabel("View Live Map")       
     self.parent.mp.btn_rf.Enable(True)
Exemplo n.º 12
0
    def run(self):
        while True:

            # for each document waiting on our input port
            for doc in self.receive_all('in'):
                try:
                    # grab the serialized image
                    raw_image = doc.get('image_data')

                    # grab the meta-data we need
                    size = doc.get_meta('size', 'image_data')
                    mode = doc.get_meta('mode', 'image_data')

                    # deserialize the image content
                    image = Image.fromstring(mode, size, raw_image)

                    # perform the mirroring
                    mirrored_image = ImageOps.mirror(image)

                    # update the meta-data for the image
                    doc.set_meta('size', mirrored_image.size, 'image_data')
                    doc.set_meta('mode', mirrored_image.mode, 'image_data')

                    # update the image_data with the new serialized payload
                    doc.set('image_data', mirrored_image.tostring())

                except Exception as e:
                    log.error('Component Failed: %s' % self.__class__.__name__)
                    log.error('Reason: %s' % str(e))
                    log.debug(traceback.print_exc())

                # send the document to the next component
                self.send('out', doc)

            # yield the CPU, allowing another component to run
            self.yield_ctrl()
Exemplo n.º 13
0
# The fonts from http://hangeul.naver.com
# I used it via ttf-nanum package of Ubuntu linux
fontPath = r'/usr/share/fonts/truetype/nanum/NanumMyeongjo.ttf'

# To find proper fontsize fited-in given dimention
fontSize = 0
for i in range(32, 2000):
    font = ImageFont.truetype(fontPath, i, encoding="unic")
    text = "한".decode('utf-8')
    textSize = font.getsize(text)
    if textSize[0] > 236 or textSize[1] > 236:
        print textSize, i
        fontSize = i - 10
        break

font = ImageFont.truetype(fontPath, fontSize, encoding="unic")

for y in range(5):
    for x in range(5):
        panelChar = panelChars[x+(y*5)]
        charSize = font.getsize(panelChar)
        xMargin = (236 - charSize[0])/2
        yMargin = (236 - charSize[1])/2
        #print panelChar.encode('utf-8'), charSize, xMargin, yMargin
        draw.text((x*236+xMargin, y*236+yMargin), panelChar, font=font)

image = ImageOps.mirror(image)
image.save('panel_%s.png'%os.path.basename(fontPath), dpi=(DPI, DPI))

# vim: et sw=4 fenc=utf-8:
Exemplo n.º 14
0
def createCert(name, marks):
    """ creates and saves individual certificates in folder """
    print '\t -creating certificate for "%s" with %s' % (name, marks)
    # open certificate border
    img = Image.open("award_template.png")

    addText(img, "Certificate of Completion", "OLDENGL.TTF", 80, (0, -400))

    # add name and award
    award_font = "Cast Iron.ttf"
    addText(img, "Python", award_font, 140, (0, -240))
    addText(img, "Programming", award_font, 110, (0, -80))

    addText(img, "presented to", "georgiai.ttf", 36, (0, 30))
    if len(name) > 14:
        addText(img, name, "BRUSHSCI.TTF", 100, (0, 140))
    else:
        addText(img, name, "BRUSHSCI.TTF", 120, (0, 140))
    addText(img, "for attending", "georgiaz.ttf", 32, (0, 230))
    addText(img, award_event, "georgiab.ttf", 64, (0, 310))
    addText(img, "%s" % award_date, "georgiai.ttf", 44, (0, 410))

    # add signature lines
    addText(img, "Instructor", "georgiai.ttf", 32, (450, 444))
    addLine(img, (450, 424), 420)
    addText(img, "Instructor", "georgiai.ttf", 32, (-440, 444))
    addLine(img, (-440, 424), 420)

    LEFT = 0
    RIGHT = 1

    logo = {LEFT: {"xy": (210, 640), "resize": 1.1}, RIGHT: {"xy": (1200, 640), "resize": 1.1}}

    seal = {LEFT: {"xy": (230, 630), "resize": 0.8}, RIGHT: {"xy": (1200, 630), "resize": 0.8}}

    foot = {LEFT: {"xy": (180, 690), "resize": 0.7}, RIGHT: {"xy": (1050, 690), "resize": 0.7}}

    graph = {LEFT: {"xy": (210, 650), "resize": 1.0}, RIGHT: {"xy": (1180, 650), "resize": 1.0}}

    settings = {"logo": logo, "seal": seal, "foot": foot, "graph": graph}
    # print settings

    for side, mark in enumerate(marks):
        if mark:
            mark_img = Image.open(mark + ".png")
            xy = settings[mark][side]["xy"]
            resize = settings[mark][side]["resize"]
            mark_img = mark_img.resize((int(mark_img.size[LEFT] * resize), int(mark_img.size[RIGHT] * resize)))
            if mark == "foot" and side == LEFT:
                mark_img = ImageOps.mirror(mark_img)
            img.paste(mark_img, xy, mark_img)

    # add seal or logo
    if False:  # add seal
        seal = Image.open("seal.png")
        seal = seal.resize((int(seal.size[0] * 0.8), int(seal.size[1] * 0.8)))
        img.paste(seal, (230, 630), seal)
    if False:  # add logo
        seal = Image.open("Emag_logo.png")
        seal = seal.resize((int(seal.size[0] * 1.1), int(seal.size[1] * 1.1)))
        img.paste(seal, (230, 630), seal)

    # add Montey Python foot
    if False:
        foot = Image.open("foot.png")
        foot = foot.resize((int(foot.size[0] * 0.7), int(foot.size[1] * 0.7)))
        img.paste(foot, (1050, 700), foot)
    if False:
        graph = Image.open("graph.png")
        graph = graph.resize((int(graph.size[0] * 1), int(graph.size[1] * 1)))
        img.paste(graph, (1200, 650), graph)

    # save to 'certificate' folder
    img.save("certificates/%s.png" % name, "PNG")
Exemplo n.º 15
0
 def mirror(self):
     self.img = ImageOps.mirror(self.img)
     self.update()
Exemplo n.º 16
0
 def mirror(self):
     self.img = ImageOps.mirror(self.img)
     self.update()
Exemplo n.º 17
0
def get_sv_pano(panoid, zoom):
   print "Fetching panorama " + str(panoid) + " from Google Stret View."
   img = ImageOps.mirror(get_panorama_image(panoid, zoom))
   #img.save("/home/erik/Code/streetview_demo/test_sv.jpg")
   return img
Exemplo n.º 18
0
 def updateImage(self):
     pic=ImageOps.mirror(self.cam.getImage())
     self.tkpi=ImageTk.PhotoImage(pic)
     self.label_image.configure(image=self.tkpi)
     self.parent.after(self.updateAfter,self.updateImage)
Exemplo n.º 19
0
# To find proper fontsize fited-in given dimention
fontSize = 0
for i in range(12, 2000):
    font = ImageFont.truetype(fontPath, i, encoding="unic")
    text = "한".decode('utf-8')
    textSize = font.getsize(text)
    if textSize[0] > cPix or textSize[1] > cPix:
        print "Font size", textSize, i
        fontSize = i - 10
        break

font = ImageFont.truetype(fontPath, fontSize, encoding="unic")

print "cPix =", cPix
for y in range(5):
    for x in range(5):
        panelChar = panelChars[x+(y*5)]
        charSize = font.getsize(panelChar)
        xMargin = (cPix - charSize[0])/2
        yMargin = (cPix - charSize[1])/2
        #print panelChar.encode('utf-8'), charSize, xMargin, yMargin
        draw.text((x*cPix+xMargin+panelMarginX, y*cPix+yMargin+panelMarginY),
                  panelChar, font=font)

# mirror it to toner transfer
image = ImageOps.mirror(image)
image.save('panel_%s.png'%os.path.basename(fontPath), dpi=(DPI, DPI))

# vim: et sw=4 fenc=utf-8:
Exemplo n.º 20
0
import Image
import ImageOps
import os
import matplotlib.image as mpimg


path = os.path.dirname(os.path.abspath(__file__)) + '/image/Arrows/redArrow'
spritelist = [f for f in os.listdir(path)]
for spritename in spritelist:
    if spritename[-4:] != '.png':
        continue
    name = spritename[:-4]
    print name
    img = Image.open("image/Arrows/redArrow/" + spritename)
    img = ImageOps.mirror(img)
    img.save("image/Arrows/redArrowNew/" + name + '_flip.png')
Exemplo n.º 21
0
def vertical_symmetry(digit, features, prefix=''):
    width,height = digit.image.size
    first_half = numpy.array(digit.image.crop((0, 0, width/2, height)).getdata())
    second_half = numpy.array(ImageOps.mirror(digit.image.crop((width/2, 0, width, height)).getdata()))
    second_half = second_half[:len(first_half)]
    features[prefix+'vertical_symmetry'] = numpy.linalg.norm(first_half-second_half)
Exemplo n.º 22
0
for f in faces:
    for i in f : 
        uvIds.append(int(i))
uvCounts = om.MIntArray()    
for c in range(0,len(faces),1):
    uvCounts.append(int(len(f)))
meshnode.assignUVs(uvCounts,uvIds)
print("TIME ",time.time() -t1)
listecolor = numpy.array(listecolor)
for l in range(100):
    colour = (0, 0, 255 * l / 100)
    imdraw.line((0, l, 100, l), fill=colour)#line are xy->xy
del imdraw
import ImageOps
im=Image.open("/Users/ludo/uv.png")
imo=ImageOps.mirror(im)
im=ImageOps.flip(imo)
im.save("/Users/ludo/uv.png")
#53
#56
#75
#C4D
#    tag.SetSlow(i, c4d.Vector((x+2)/sizex,(y+2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+s-2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+2)/sizey,0))
x=0
y=0
s=20
u = om.MFloatArray(len(vertices))
v = om.MFloatArray(len(vertices))
Exemplo n.º 23
0
def mirror(img_list):
    for img in img_list:
        tmp_img = ImageOps.mirror(img)
        yield tmp_img
Exemplo n.º 24
0
def render(imageToRender,xOffset,yOffset,w=128,h=64,nocrop=False, overlayBottom=False):

	global imageTop, imageBottom, screenHeight, screenWidth, panels, matrix, image, renderImage, tileSize, rows, cols, transWiring

	#w = screenWidth
	#h = screenHeight

	segmentImage = []

	# the rendered image is the screen size
	#renderImage = Image.new("RGBA", (screenWidth , 32))

	if(nocrop == True) :
		for n in range(0,rows) :
			segmentWidth = tileSize[1] * cols
			segmentHeight = 32
			xPos = n * segmentWidth - xOffset
			yPos = n * 32 #- yOffset
			segment =  imageToRender.crop((0, yPos, segmentWidth, segmentHeight + yPos))
			renderImage.paste(segment, (xPos,0,segmentWidth + xPos,segmentHeight))

	elif (nocrop == False) :
		segmentWidth = tileSize[1] * cols
		segmentHeight = 32

		#yOffset = 10
		#xOffset = 100
		# Must crop exactly the overlap and position of the to-be-rendered image with each segment
		#           ________________
		#           |               |
		#           |               |
		#           |    |||||||||  |
		#           -----|||||||||---
		#           |    |||||||||  |
		#           |    |||||||||  |

		
		cropP1 = [0,0]
		cropP2 = [0,0]

		for n in range(0,rows) :

			# Crop PLACEMENTS\
			a = max(0, xOffset) + segmentWidth * n
			b = max(0, yOffset - segmentHeight * n)
			c = min(segmentWidth, xOffset + w) + segmentWidth * n
			d = min(segmentHeight, yOffset + h - segmentHeight * n)

			# Cropping
			cropP2 = [  cropP1[0] + c - xOffset, 
						cropP1[1] + min(32, d - yOffset + n * segmentHeight)]

			cropP1 = [max(0 , 0 - xOffset),     max(0, n * segmentHeight - yOffset)]
			cropP2 = [min(w , segmentWidth - xOffset),   min(h, n * segmentHeight + 32 - yOffset)]

			pCrop  = cropP1 + cropP2

			if ((n==0 or n == 2 or n == 4) and (transWiring == False) ) : pCrop[1] = 0
			segmentImage.append(imageToRender.crop(pCrop))

			#print(a,b,c,d,cropP1,cropP2)


			# Depending on the cabling, either copy segment laterally - which I think
			# is faster, or transform the segment each time to flip and mirror because
			# the panels are upside down wrt the ones below them
			# Wiring from BACK  **** = ribbon jumper cables
			#           ________________
			#           |               |
			#           |        <--  * |
			#           |           | * |
			#           --------------*--
			#           |             * |
			#           |        ^    * |
			#           |        |-->   |
			#           ________________

			#           ________________
			#           |        ^      |
			#           | *      |-->   |
			#           |    *          |
			#           --------*--------
			#           |          *    |
			#           |        ^    * |
			#           |        |-->   |
			#           ________________


			# Only render if needs be
			if(pCrop[3] - pCrop[1] > 0 ) : 
				if ( pCrop[2] - pCrop[0] > 0) :
					segImg = segmentImage[n]
					if ((n==0 or n == 2 or n == 4) and (transWiring == False) ) : 
						# This flips, reveses and places the segment when the row is "upside down" wrt
						# the previous row of panels - this is when transWiring == False - i.e no long transverse cable
						segImg = ImageOps.flip(segImg)
						segImg = ImageOps.mirror(segImg)

						an = segmentWidth - xOffset - w
						if(an < 0) : an = 0

						bn = segmentHeight - yOffset - h
						if(bn < 0) : bn = 0

						renderImage.paste( segImg, (an, bn, an + pCrop[2] - pCrop[0], bn + pCrop[3] - pCrop[1]))
					else:
						renderImage.paste( segImg, (a, b, a + pCrop[2] - pCrop[0], b + pCrop[3] - pCrop[1]))

	 
			cropP1[1] = cropP2[1]


	if(overlayBottom) :
		renderImage = Image.new("RGBA", (w , h))
		renderImage.paste(imageToRender, (0,0))
		iid = renderImage.im.id
		idtemp = image.im.id
		matrix.SetImage(iid, xOffset + screenWidth, 0)
	else :
		iid = renderImage.im.id
		idtemp = image.im.id
		matrix.SetImage(iid, 0, 0)
Exemplo n.º 25
0
def createCert(name, marks):
    ''' creates and saves individual certificates in folder '''
    print '\t -creating certificate for "%s" with %s' % (name, marks)
    # open certificate border
    img = Image.open('award_template.png')

    addText(img, 'Certificate of Completion', 'OLDENGL.TTF', 80, (0, -400))

    # add name and award
    award_font = 'Cast Iron.ttf'
    addText(img, 'Python', award_font, 140, (0, -240))
    addText(img, 'Programming', award_font, 110, (0, -80))

    addText(img, 'presented to', 'georgiai.ttf', 36, (0, 30))
    if len(name) > 14:
        addText(img, name, 'BRUSHSCI.TTF', 100, (0, 140))
    else:
        addText(img, name, 'BRUSHSCI.TTF', 120, (0, 140))
    addText(img, 'for attending', 'georgiaz.ttf', 32, (0, 230))
    addText(img, award_event, 'georgiab.ttf', 64, (0, 310))
    addText(img, '%s' % award_date, 'georgiai.ttf', 44, (0, 410))

    # add signature lines
    addText(img, 'Instructor', 'georgiai.ttf', 32, (450, 444))
    addLine(img, (450, 424), 420)
    addText(img, 'Instructor', 'georgiai.ttf', 32, (-440, 444))
    addLine(img, (-440, 424), 420)

    LEFT = 0
    RIGHT = 1

    logo = {
        LEFT: {
            'xy': (210, 640),
            'resize': 1.1
        },
        RIGHT: {
            'xy': (1200, 640),
            'resize': 1.1
        }
    }

    seal = {
        LEFT: {
            'xy': (230, 630),
            'resize': 0.8
        },
        RIGHT: {
            'xy': (1200, 630),
            'resize': 0.8
        }
    }

    foot = {
        LEFT: {
            'xy': (180, 690),
            'resize': 0.7
        },
        RIGHT: {
            'xy': (1050, 690),
            'resize': 0.7
        }
    }

    graph = {
        LEFT: {
            'xy': (210, 650),
            'resize': 1.0
        },
        RIGHT: {
            'xy': (1180, 650),
            'resize': 1.0
        }
    }

    settings = {'logo': logo, 'seal': seal, 'foot': foot, 'graph': graph}
    #print settings

    for side, mark in enumerate(marks):
        if mark:
            mark_img = Image.open(mark + '.png')
            xy = settings[mark][side]['xy']
            resize = settings[mark][side]['resize']
            mark_img = mark_img.resize((int(mark_img.size[LEFT] * resize),
                                        int(mark_img.size[RIGHT] * resize)))
            if mark == 'foot' and side == LEFT:
                mark_img = ImageOps.mirror(mark_img)
            img.paste(mark_img, xy, mark_img)

    # add seal or logo
    if False:  # add seal
        seal = Image.open('seal.png')
        seal = seal.resize((int(seal.size[0] * 0.8), int(seal.size[1] * 0.8)))
        img.paste(seal, (230, 630), seal)
    if False:  # add logo
        seal = Image.open('Emag_logo.png')
        seal = seal.resize((int(seal.size[0] * 1.1), int(seal.size[1] * 1.1)))
        img.paste(seal, (230, 630), seal)

    # add Montey Python foot
    if False:
        foot = Image.open('foot.png')
        foot = foot.resize((int(foot.size[0] * 0.7), int(foot.size[1] * 0.7)))
        img.paste(foot, (1050, 700), foot)
    if False:
        graph = Image.open('graph.png')
        graph = graph.resize((int(graph.size[0] * 1), int(graph.size[1] * 1)))
        img.paste(graph, (1200, 650), graph)

    # save to 'certificate' folder
    img.save('certificates/%s.png' % name, 'PNG')
Exemplo n.º 26
0
tri2 = [(100,140), (470,140), (800,10)]
transformblit(tri1, tri2, blank, part1)
tri2 = [(344,218), (365,0), (800,670)]
transformblit(tri1, tri2, blank, part1)
# final trim
part1 = part1.crop((213, 141, 469, 419))

contrast = ImageEnhance.Contrast(part1)
part1 = contrast.enhance(1.5)

#Start: Part 2 of the QR code
part2 = qr.crop((2031, 1584, 2287, 1742))
contrast = ImageEnhance.Contrast(part2)
part2 = contrast.enhance(2.7)

part2 = ImageOps.mirror(part2)


part2 = part2.rotate(0+20-4, resample=Image.BICUBIC, expand=True)

width, height = part2.size
m = -0.49
xshift = abs(m) * width
new_width = width + int(round(xshift))
part2 = part2.transform((new_width, height), Image.AFFINE,
        (1.1, m, -xshift if m > 0 else 0, 0, 1.605, 0), Image.BILINEAR)
part2 = part2.resize((800, 700), Image.ANTIALIAS)
contrast = ImageEnhance.Contrast(part2)
part2 = contrast.enhance(1.2)

part2 = part2.crop((245, 80, 393, 301))
Exemplo n.º 27
0
def main():
    
    bin = []
    
    im = Image.open("merged-172x72-rotate.png")
    
    panel = panel.Panel(172,72,"L",2,"v","msb")
    
    #print im.format, im.size, im.mode
    # Save it as a temp BMP file
    # and invoke system default image viewer to show it 
    #im.show()

    (x,y) = im.size
    ratio2 = float(x)/float(y)
    ratio3 = float(y)/float(x)
    #print ratio2
    #print ratio3

    
    dither =im.convert(mode='P', dither=Image.FLOYDSTEINBERG)
    #dither.show()
    
    di = dither.convert('L')
    bw = ImageOps.mirror(di)
    #bw.show()
    (b,p) = bw.getextrema()
    print "B&W image ranges : %02X - %02X"%(b,p)
    
    bw.point(lambda i: (0xFF-i)&0xC0).show()
    
    #enh = ImageEnhance.Contrast(bpp2)
    #enh.enhance(2).show()
    
    (x,y)=bw.size
    ol =  list(bw.getdata())
    #print "x=%d,y=%d,len=%d"%(x,y,len(ol))
    
    print ">> co-ordinate"
    for i in range(y):
        for j in range(x):
            print "%02X%02x"%(i,j),
        print ""
     
    print ">> value"
    for i in range(y):
        for k in range(x):
            print "%02X"%(ol[k+i*72]),
        print ""
    '''    
    '''
    print ">> array"
    for i in range(len(ol)):
        #print "%02X"%(ol[i]>>5),
        print "%02X"%(ol[i]),
    
    for i in range(len(ol)/4):
        val0= ol[i*4]&0xC0
        val1= (ol[i*4+1]&0xC0)>>2
        val2= (ol[i*4+2]&0xC0)>>4
        val3= (ol[i*4+3]&0xC0)>>6
        val = val0+val1+val2+val3
        #print "%02X=%02X:%02X:%02X:%02X(%02X:%02X:%02X:%02X)"%(val,val0,val1,val2,val3,ol[i],ol[i+1],ol[i+2],ol[i+3])
        bin.append(val)
        
    #print "len=%d"%(len(bin))
    
    '''
    for i in range(len(bin)):
        print "%02X"%(bin[i]),
    '''
    
    #for i in range(len(bin)):
    for i in range(172):
        for j in range(18):
            #print "0x%02X:(%02X,%02X,%02X),"%(bin[j+i*18],i,j,j+i*18),
            print "0x%02X,"%(bin[j+i*18]),
        print
Exemplo n.º 28
0
 def operation(self, img):
     return ImageOps.mirror(img)
Exemplo n.º 29
0
            else:
                img_buf[i, j] = 255
            j += 1
        i += 1
        if i >= 96:
            i = 0
            k += 8
    return out


def get_hex(input_list):
    i = 0
    header_file = open('image.h', 'ab')
    header_file.write('static const unsigned char BAW[] = {\n')
    for b in input_list:
        if i > 10:
            header_file.write('\n')
            i = 0
        header_file.write(hex(b) + ', ')
        i += 1
    header_file.write('};\n\n\n')


out = Image.open('LLb3NGi.png')
ll = encode(ImageOps.mirror(out.convert("L")))
jj = decode(ll)
jj.show()
print ll
get_hex(ll)
print str(len(ll))
Exemplo n.º 30
0
                img_buf[i,j] =0
            else:
                img_buf[i,j] =255
            j+=1
        i+=1
        if i>=96:
            i=0
            k+=8
    return out

def get_hex(input_list):
    i=0
    header_file = open('image.h','ab')
    header_file.write('static const unsigned char BAW[] = {\n')
    for b in input_list:
        if i > 10:
            header_file.write('\n')
            i=0
        header_file.write(hex(b)+', ')
        i+=1
    header_file.write('};\n\n\n')

out=Image.open('LLb3NGi.png')
ll =encode(ImageOps.mirror(out.convert("L")))
jj=decode(ll)
jj.show()
print ll
get_hex(ll)
print str(len(ll))

Exemplo n.º 31
0
def mirror(filename, newSide):
    img = Image.open(filename)
    mirror_img = ImageOps.mirror(img)
    mirror_img.save(newSide + '_' + filename)
Exemplo n.º 32
0
def mymirror(filename, outname):
    img = Image.open(filename)
    mirror_img = ImageOps.mirror(img)
    mir_img = np.array(mirror_img)
    m_img = Image.fromarray(mir_img, mode='RGB')
    m_img.save(outname)
Exemplo n.º 33
0
for f in faces:
    for i in f : 
        uvIds.append(int(i))
uvCounts = om.MIntArray()    
for c in range(0,len(faces),1):
    uvCounts.append(int(len(f)))
meshnode.assignUVs(uvCounts,uvIds)
print("TIME ",time.time() -t1)
listecolor = numpy.array(listecolor)
for l in range(100):
    colour = (0, 0, 255 * l / 100)
    imdraw.line((0, l, 100, l), fill=colour)#line are xy->xy
del imdraw
import ImageOps
im=Image.open("/Users/ludo/uv.png")
imo=ImageOps.mirror(im)
im=ImageOps.flip(imo)
im.save("/Users/ludo/uv.png")
#53
#56
#75
#C4D
#    tag.SetSlow(i, c4d.Vector((x+2)/sizex,(y+2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+s-2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+2)/sizey,0), 
#                c4d.Vector((x+s-2)/sizex,(y+2)/sizey,0))
x=0
y=0
s=20
u = om.MFloatArray(len(vertices))
v = om.MFloatArray(len(vertices))
Exemplo n.º 34
0
def mirror(filename, newSide):
	img = Image.open(filename)
	mirror_img = ImageOps.mirror(img)
	mirror_img.save(newSide + '_' + filename)
Exemplo n.º 35
0
def mirror(img_list):
    for img in img_list:
        tmp_img = ImageOps.mirror(img)
        yield tmp_img
Exemplo n.º 36
0
 def operation(self, img):
     return ImageOps.mirror(img)