Every line of 'python convert png to jpg' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
12 def png2rgb(b64png): 13 b = base64.b64decode(b64png) 14 i = io.BytesIO(b) 15 img = mpimg.imread(i, format='PNG') 16 # # Pretty slow 17 # img = Image.open(i) 18 # i = np.array(img.getdata(), np.uint8).reshape(img.size[1], img.size[0], 3) 19 return img
32 def png2x(fig): 33 """render figure to 2x PNG via HTML""" 34 import matplotlib 35 if not fig.axes and not fig.lines: 36 return 37 # double DPI 38 dpi = 2 * matplotlib.rcParams['savefig.dpi'] 39 pngbytes = print_figure(fig, fmt='png', dpi=dpi) 40 x,y = pngxy(pngbytes) 41 x2x = x // 2 42 y2x = y // 2 43 png64 = encodestring(pngbytes).decode('ascii') 44 return u"" % (png64, x2x, y2x)
41 def frameToJPeg( frame ): 42 jpeg = cv2.imencode('.jpg', frame)[1].tostring() 43 jpegFramesCache[bytes(jpeg)] = frame 44 return jpeg