def writeTextBlock(self, line): # rqhuang.... bug here. if isRFCPageBreaker(line): self.outputTextBlock() return getattr(self, "writeContent") if re.match(r'^\s+Figure\s.*', line): self.textBlock.write(line) createImage( self.textBlock.getvalue(), "%s/img%d.jpg" % (self.root_dir + "/" + self.images_dir, self.imageCount)) self.output.write('<img src="%s/img%d.jpg" />' % (self.images_dir, self.imageCount)) self.imageCount = self.imageCount + 1 self.textBlock.close() self.textBlock = None self.output.write("<p>\n") return getattr(self, "writeContent") if self.isTextBlockBlockEnd(line): self.outputTextBlock() return self.writeContent(line) self.textBlock.write(line) return getattr(self, "writeTextBlock")
def writeTitle(self, line): if re.match('^\S.*$', line): self.output.write(''' <html> <head> <title>%s</title> <link rel="stylesheet" href="css/rfc.css" type="text/css" /> </head> <body>''' % (self.rfc.upper() + " - " + self.title)) createImage( self.info.getvalue(), '%s/auths.jpg' % (self.root_dir + "/" + self.images_dir)) createCoverFromImage( '%s/auths.jpg' % (self.root_dir + "/" + self.images_dir), '%s/cover.jpg' % (self.root_dir + "/" + self.images_dir)) self.output.write('<img src="%s/auths.jpg"/>' % (self.images_dir)) self.output.write("<h1>%s</h1>" % (self.title)) return self.writeAbstract(line) if line.lstrip().rstrip(): self.title = self.title and ( self.title + ' ' + line.lstrip().rstrip()) or line.lstrip().rstrip() return getattr(self, "writeTitle")
def main(): postType = str( input( "Please enter what type of posts you want (t = top, n = new, h = hot): " )).lower() postTypes = ["t", "n", "h"] while postType not in postTypes: print("Incorrect entry") postType = str( input( "Please enter what type of posts you want (t = top, n = new, h = hot): " )).lower() amount = input( "Please enter the amount (1-10) of posts you want in the video: ") while amount.isnumeric() == False: print("incorrect input, please try again") amount = input( "Please enter the amount (1-10) of posts you want in the video: ") amount = int(amount) while amount > 10: print("Value too high, please try again") amount = input( "Please enter the amount (1-10) of posts you want in the video: ") x = asyncio.run(getRedditPost(postType, amount)) count = 0 for i in x: count += 1 createImage(i) y = textToSpeech(i) combineAudioAndImage(y, count) makeFilm()
def outputTextBlock(self): outputlines = self.textBlock.getvalue().splitlines()[:-1] if isImageOutput(outputlines): createImage(self.textBlock.getvalue(), "%s/img%d.jpg" % (self.root_dir + "/" + self.images_dir, self.imageCount)) self.output.write('<img src="%s/img%d.jpg" />' % (self.images_dir, self.imageCount)) self.imageCount = self.imageCount + 1 else: self.output.write("<blockquote> \n") for i in outputlines: #if re.match(r'^\s+[A-Z].*', i): # self.output.write("<br />") #self.output.write("%s\n" %(re.sub(r"\s", " ", i.lstrip()))) self.output.write("%s\n" %(i)) self.output.write("</blockquote> \n") self.textBlock.close() self.textBlock = None self.output.write("<p>\n")
def outputTextBlock(self): outputlines = self.textBlock.getvalue().splitlines()[:-1] if isImageOutput(outputlines): createImage(self.textBlock.getvalue(), "%s/img%d.jpg" % (self.rfc, self.imageCount)) self.output.write('<img src="img%d.jpg" />' % (self.imageCount)) self.imageCount = self.imageCount + 1 else: self.output.write("<blockquote> \n") for i in outputlines: #if re.match(r'^\s+[A-Z].*', i): # self.output.write("<br />") #self.output.write("%s\n" %(re.sub(r"\s", " ", i.lstrip()))) self.output.write("%s\n" %(i)) self.output.write("</blockquote> \n") self.textBlock.close() self.textBlock = None self.output.write("<p>\n")
def writeTitle(self, line): if re.match('^\S.*$', line): self.output.write(''' <html> <head> <title>%s</title> <link rel="stylesheet" href="css/rfc.css" type="text/css" /> </head> <body>''' % (self.rfc.upper()+" - "+self.title)) createImage(self.info.getvalue(), '%s/auths.jpg' % (self.root_dir + "/" + self.images_dir)) createCoverFromImage('%s/auths.jpg' % (self.root_dir + "/" +self.images_dir), '%s/cover.jpg' % (self.root_dir + "/" +self.images_dir)) self.output.write('<img src="%s/auths.jpg"/>' % (self.images_dir )) self.output.write("<h1>%s</h1>" % (self.title)) return self.writeAbstract(line) if line.lstrip().rstrip(): self.title = self.title and (self.title + ' ' + line.lstrip().rstrip()) or line.lstrip().rstrip() return getattr(self, "writeTitle")
def outputTextBlock(self): outputlines = self.textBlock.getvalue().splitlines()[:-1] if isImageOutput(outputlines): createImage(self.textBlock.getvalue(), "%s/img%d.png" % (self.rfc, self.imageCount)) self.output.write('<img src="img%d.png" />' % (self.imageCount)) self.imageCount = self.imageCount + 1 else: self.output.write("<blockquote> \n") for i in outputlines: i=sanitizeSpecChars(i) # Remove 2+ initial spaces since we're using blockquote i=re.sub(r'^\s\s+','',i) # Reduce 3+ consecutive spaces to 2 spaces; i=re.sub(r'\s\s\s+',' ',i) self.output.write("%s<br/>" %(i)) self.output.write("</blockquote> \n") self.textBlock.close() self.textBlock = None self.output.write("<p>\n")
def writeTextBlock(self, line): # rqhuang.... bug here. if isRFCPageBreaker(line): self.outputTextBlock() return getattr(self, "writeContent") if re.match(r'^\s+Figure\s.*', line): self.textBlock.write(line) createImage(self.textBlock.getvalue(), "%s/img%d.jpg" % (self.root_dir + "/" + self.images_dir, self.imageCount)) self.output.write('<img src="%s/img%d.jpg" />' % (self.images_dir, self.imageCount)) self.imageCount = self.imageCount + 1 self.textBlock.close() self.textBlock = None self.output.write("<p>\n") return getattr(self, "writeContent") if self.isTextBlockBlockEnd(line): self.outputTextBlock() return self.writeContent(line) self.textBlock.write(line) return getattr(self, "writeTextBlock")
def writeTitle(self, line): if re.match('^\S.*$', line): self.output.write(''' <html> <head> <title>%s</title> <link rel="stylesheet" href="../css/rfc.css" type="text/css" /> <meta name="cover" content="%s/cover.png" /> <meta name="Author" content="rfc2kindle" /> </head> <body>''' % (self.rfc.upper()+" - "+self.title, self.rfc)) createImage(self.info.getvalue(), '%s/auths.png' % (self.rfc)) createCoverFromImage('%s/auths.png' % (self.rfc), '%s/cover.png' % (self.rfc)) self.output.write('<img src="auths.png" />') self.output.write("<h1>%s</h1>" % (self.title)) return self.writeAbstract(line) if line.lstrip().rstrip(): self.title = self.title and (self.title + ' ' + line.lstrip().rstrip()) or line.lstrip().rstrip() return getattr(self, "writeTitle")
import json import sys import os.path import image sys.path.append('../') from auth import auth import config if __name__ == '__main__': # 이미지를 바꾸시려면 testImage.jpg 대신 # 사용하실 이미지가 있는 파일 경로를 넣어주세요 imageInfo = json.loads( image.createImage('./testImage.jpg', config.getUrl('/storage/v1/files'), auth.get_headers(config.apiKey, config.apiSecret)).text) print(imageInfo) data = { 'message': { 'to': '수신번호 입력', 'from': '발신번호 입력', 'text': '발송 예제', 'imageId': imageInfo['fileId'] } } res = requests.post(config.getUrl('/messages/v4/send'), headers=auth.get_headers(config.apiKey, config.apiSecret), json=data) print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.animation as animation from image import createImage from colors import randomColorShades from fill import fillImage from fill import fillImageFirstIteration from fill import fillImageMiddleIterations from fill import deleteFromBoundary width = 100 height = 100 imageSize = width * height image = createImage(width, height) dominantColor = None #dominantColor='red' #dominantColor='green' #dominantColor='blue' randomColorShades_list = randomColorShades(imageSize, dominantColor) initialColorShadesLength = len(randomColorShades_list) boundaryPixels_dict = {} fillImage = fillImage(dominantColor, width, height, randomColorShades_list, imageSize, image, initialColorShadesLength, boundaryPixels_dict) imagePlot = plt.imshow(fillImage, origin='lower') plt.show() ''' width=40 height=40 imageSize=width*height
import image libdir = os.path.dirname(__file__) sys.path.append(os.path.split(libdir)[0]) from auth import auth config = configparser.ConfigParser() config.read('config.ini') apiKey = config['AUTH']['ApiKey'] apiSecret = config['AUTH']['ApiSecret'] if __name__ == '__main__': # 이미지를 바꾸시려면 testImage.jpg 대신 # 사용하실 이미지가 있는 파일 경로를 넣어주세요 imageInfo = json.loads( image.createImage('./image/testImage.jpg', config['SERVER']['IMGURI'], auth.get_headers(apiKey, apiSecret)).text) data = { 'message': { 'to': config['VALUE']['to'], 'from': config['VALUE']['from'], 'text': 'test', 'imageId': imageInfo['imageId'] } } res = requests.post(config['SERVER']['URI'] + 'send', headers=auth.get_headers(apiKey, apiSecret), json=data) print(json.dumps(json.loads(res.text), indent=2, ensure_ascii=False))
def createImageByWord(word): targetDir = '/Users/xiaxianlin1/Download/' createImage(word, targetDir)