How to use the pybase64.b64encode function in pybase64

To help you get started, we’ve selected a few pybase64 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NikolasEnt / Lyft-Perception-Challenge / predict.py View on Github external
def encode(array):
    buff = cv2.imencode(".png", array)[1]
    return pybase64.b64encode(buff).decode("utf-8") 
github mayeut / pybase64 / pybase64 / __main__.py View on Github external
def benchmark(args):
    print(__package__ + ' ' + pybase64.get_version())
    data = readall(args.input)
    for altchars in [None, b'-_']:
        for validate in [False, True]:
            print('bench: altchars={0:s}, validate={1:s}'.format(
                  repr(altchars), repr(validate)))
            bench_one(args.duration,
                      data,
                      pybase64.b64encode,
                      pybase64.b64decode,
                      pybase64.encodebytes,
                      altchars,
                      validate)
            bench_one(args.duration,
                      data,
                      base64.b64encode,
                      b64decodeValidate,
                      b64encodebytes,
                      altchars,
                      validate)
github mayeut / pybase64 / pybase64 / __main__.py View on Github external
def encode(args):
    data = readall(args.input)
    data = pybase64.b64encode(data, args.altchars)
    writeall(args.output, data)
github NikolasEnt / Lyft-Perception-Challenge / predict-server.py View on Github external
def encode(array):
    buff = cv2.imencode(".png", array)[1]
    return pybase64.b64encode(buff).decode("utf-8") 
github higlass / higlass-server / fragments / views.py View on Github external
# Encode matrix if required
    if encoding == 'b64':
        for i, matrix in enumerate(matrices):
            id = loci_ids[mat_idx[i]]
            data_types[i] = 'dataUrl'
            if not no_cache and id:
                mat_b64 = None
                try:
                    mat_b64 = rdb.get('im_b64_%s' % id)
                    if mat_b64 is not None:
                        matrices[i] = mat_b64.decode('ascii')
                        continue
                except:
                    pass

            mat_b64 = pybase64.b64encode(np_to_png(matrix)).decode('ascii')

            if not no_cache:
                try:
                    rdb.set('im_b64_%s' % id, mat_b64, 60 * 30)
                except Exception as ex:
                    # error caching a tile
                    # log the error and carry forward, this isn't critical
                    logger.warn(ex)

            matrices[i] = mat_b64

        if max_previews > 0:
            for i, preview in enumerate(previews):
                previews[i] = pybase64.b64encode(
                    np_to_png(preview)
                ).decode('ascii')
github higlass / higlass-server / fragments / views.py View on Github external
mat_b64 = pybase64.b64encode(np_to_png(matrix)).decode('ascii')

            if not no_cache:
                try:
                    rdb.set('im_b64_%s' % id, mat_b64, 60 * 30)
                except Exception as ex:
                    # error caching a tile
                    # log the error and carry forward, this isn't critical
                    logger.warn(ex)

            matrices[i] = mat_b64

        if max_previews > 0:
            for i, preview in enumerate(previews):
                previews[i] = pybase64.b64encode(
                    np_to_png(preview)
                ).decode('ascii')
            for i, preview_2d in enumerate(previews_2d):
                previews_2d[i] = pybase64.b64encode(
                    np_to_png(preview_2d)
                ).decode('ascii')

    # Create results
    results = {
        'fragments': matrices,
        'indices': [int(i) for i in mat_idx],
        'dataTypes': data_types,
    }

    # Return Y aggregates as 1D previews on demand
    if max_previews > 0: