Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 19c19
- < import Image, ImageChops
- ---
- > import Image
- 32d31
- <
- 57c56
- < thumbnailimage = Image.new ( "RGB", (boardObj.width, boardObj.height), (0,255,0) )
- ---
- > # thumbnailimage = Image.new ( "RGB", (boardObj.width, boardObj.height), (0,255,0) )
- 65,85c64,66
- < # Generate a Temporary HTML file
- < tempFilePath = self.GetTextTempFilename(board.id, boardObj.zindex)
- < tempHTML = self.TempTextGenerator(boardObj.text, 6);
- < f = open(tempFilePath, 'w')
- < f.write(tempHTML)
- < f.close()
- <
- < # Call the ImageMagick
- < tempCommand = self.MakeImageMagickCommand(tempFilePath, (tempFilePath + '.png'), '-trim -fuzz 12% -transparent white')
- < result = os.popen(tempCommand)
- <
- < # Image Processing
- < textThumb = Image.open (tempFilePath + '.png')
- <
- < # Generate Transparent mask
- < mask = textThumb.convert("L")
- < mask = ImageChops.invert(mask)
- < thumbimage.paste(textThumb,(boardObj.posx, boardObj.posy),mask)
- <
- < del mask
- < del textThumb
- ---
- > textboximage = Image.new ( "RGB", (boardObj.width, boardObj.height), (255,0,0) )
- > thumbimage.paste(textboximage,(boardObj.posx, boardObj.posy))
- > del textboximage
- 97c78
- < thumbimage.save (thumbimageFile,"PNG")
- ---
- > thumbimage.save (thumbimageFile,"JPEG")
- 99c80
- < thumbimage.save (iconimageFile,"PNG")
- ---
- > thumbimage.save (iconimageFile,"JPEG")
- 120,133d100
- <
- < # Kit Addition
- < def GetTextTempFilename (self, boardid, zindex ):
- < tempHTMLFile= boardid + str(zindex) + "_texttemp.html"
- < return os.path.join ( self.absDir, "uploadfile", tempHTMLFile )
- <
- < def MakeImageMagickCommand (self, srcFile, dstFile, parameter):
- < return 'convert html:' + srcFile + ' ' + parameter + ' ' + dstFile
- <
- < def TempTextGenerator (self, textFromBoard, size):
- < header = "<html><head><title>1</title></head><body>"
- < footer = "</body></html>"
- < return header + '<font size="' + str(size) + '">' + textFromBoard + '</font>' + footer
- <
Add Comment
Please, Sign In to add comment