def testRun(name,surname,tc,printnum,x0,y0,z0,r0): name = name.replace('"','') x1 = ast.literal_eval(x0) y1 = ast.literal_eval(y0) z1 = ast.literal_eval(z0) r1 = ast.literal_eval(r0) lImagePath = lastImage.find() #lImagePath = "getPicture.jpg" if (os.path.isfile(lImagePath)): print "loading... " + lImagePath i_base = Image.open(lImagePath) i_base = rotate.rotateImage(resizeZ(i_base, z1),270 - int(r1)) i_base = cropImage(i_base, transform(i_base ,imgSize, x1, y1 -200) ) i_base = cropImage(resizeImage(i_base), icaoSize) i_out = multiplexImage( Image.new("RGB", finalPaperSize , "white") , i_base) out = drawInfo.draw(i_out, name, surname, tc, misc.timeString()) print "saving... to out\\" #i_out.save("out\\" + os.path.basename(lImagePath)) i_out.save("out\\" + tc + ".jpg") print "printing..." for x in range(0,int(printnum)): print "Printed %d" % (x) jpgprinter.printImage(printerNm,i_out, "DS360 - OUT") return "Print Request Done" else: return "File find error... aborted"
def run(name,surname,tc,printnum,x0,y0,z0): name = name.replace('"','') x1 = ast.literal_eval(x0) y1 = ast.literal_eval(y0) z1 = ast.literal_eval(z0) print "find last image..." lImagePath = lastImage.find() lImagePath = "test.jpg" print lImagePath if (os.path.isfile(lImagePath)): print "loading... " + lImagePath i_out = Image.new("RGB", size, "white") i_base = Image.open(lImagePath) print "adım0" image_resize_z = resizeZ(i_base, z1) image_resize_z.save("0.jpg") print "adım1" trans = transform(lastSize, x1, y1) print "adım2" image_crop = cropImage(image_resize_z, trans) image_crop.save("1.jpg") print "adım3" image_resize = resizeImage(rotate.rotateImage(image_crop,270)) image_resize.save("2.jpg") print "adım4" image_zoom = resizePercent(image_resize, 130) image_zoom.save("3.jpg") print "adım5" imagezac = cropImage(image_zoom, lastSize) imagezac.save("4.jpg") i_out = multiplexImage(i_out, imagezac) out = drawInfo.draw(i_out, name, surname, tc, misc.timeString()) print "saving... to out\\" i_out.save("5.jpg") #i_out.save("out\\" + os.path.basename(lImagePath)) print "printing..." for x in range(0,int(printnum)): print "Printed %d" % (x) #jpgprinter.printImage(printerNm,i_out, "DS360 - OUT") return "Print Request Done" else: return "File find error... aborted"
def run(c_id, name, surname, tc, printnum, x0, y0, z0, r0, brightness, color, archive): c_id = c_id.replace('"','') misc.log_("Selected Country",c_id) misc.log_("Name",name) misc.log_("Surname",surname) misc.log_("TC",tc) photo_id = get_pid(c_id) name = name.replace('"','') x1 = ast.literal_eval(x0) y1 = ast.literal_eval(y0) z1 = ast.literal_eval(z0) r1 = ast.literal_eval(r0) brightness = ast.literal_eval(brightness) color = ast.literal_eval(color) x1 = -x1 y1 = -y1 misc.log_t("Archive - REQUEST",archive); if (misc.is_test_mode): lImagePath = "cl\\test-stan.jpg" else: if (archive == "false"): lImagePath = lastImage.find() else: lImagePath = lastImage.g_base() + tc + ".jpg" # needs testing misc.log_t("Target File",lImagePath); if (os.path.isfile(lImagePath)): time = misc.get_time() misc.log_("IMG_","Loading : " + lImagePath) img_base = Image.open( lImagePath) # Load target image # resize image to fit head if(photo_id == 1): img_base = resizeZScale( img_base, 1 + z_offset_vs) # Resize based on app img_base = rotateImage( img_base , 270) # Rotate to fix camera rotation else: if(photo_id == 5): img_base = resizeZScale( img_base, z1 + z_offset_china) # Resize based on app img_base = rotateImage( img_base , 270 - int(r1)) # Rotate to fix camera rotation else: if(photo_id == 4): img_base = resizeZScale( img_base, (z1) + z_offset_USA) # Resize based on app img_base = rotateImage( img_base , 270 - int(r1)) # Rotate to fix camera rotation else: img_base = resizeZScale( img_base, z1 + z_offset) # Resize based on app img_base = rotateImage( img_base , 270 - int(r1)) # Rotate to fix camera rotation img_base = cropImage( img_base, transform( photo_id ,img_base , imgSize, x1, y1) ) img_base = cropImage( resizeToSmallSize(img_base) , s_icao) # don't touch breaks the rest # apply effects if(not brightness == 1): misc.log_t("Enhancer","Brightness " + str(brightness)) enhancer = ImageEnhance.Brightness(img_base) img_base = enhancer.enhance(brightness) if(not color == 1): misc.log_t("Enhancer","Color " + str(color)) enhancer = ImageEnhance.Color(img_base) img_base = enhancer.enhance(color) # 4x4 + draw text i_out = multiplexImage_WQR( Image.new("RGB", paper_size , "white") , img_base , (qr_base_url + tc + ".jpg")) i_out = drawInfo.draw( i_out, name, surname, tc, misc.timeString(time) , owner_name) if(photo_id == 3): cutlines = cl_schengen i_out.paste(cutlines, (0, 0), cutlines) else: if(photo_id == 4): cutlines = cl_usa # cl_usa i_out.paste(cutlines, (0, 0), cutlines) else: if(photo_id == 5): cutlines = cl_china # cl_china.png i_out.paste(cutlines, (0, 0), cutlines) else: if(photo_id == 6): cutlines = cl_icao_schengen i_out.paste(cutlines, (0, 0), cutlines) else: cutlines = cl i_out.paste(cutlines, (0, 0), cutlines) i_small = cropImage(i_out, small_img_size ) i_small.save(os.pardir + "\\output\\small\\" + tc + "-sm.jpg") file_name = os.pardir + "\\output\\" + tc + ".jpg" # + misc.timeStringShort(time) misc.log_("FILE", "TO '" + file_name + "'") i_out.save(file_name) print_image_x( i_out, int(printnum)) return "Print Request Done" else: return "File find error... Aborted."