Ejemplo n.º 1
0
def get_pdiff_bbox(idx):
    idx = int(idx)
    d = DIFF[idx]
    try:
        _, pdiff_image = util.generate_pdiff_image(d.a_path, d.b_path)
        bbox = util.get_pdiff_bbox(pdiff_image)
    except util.ImageMagickNotAvailableError:
        return 'ImageMagick is not available', 501
    except util.ImageMagickError as e:
        return 'ImageMagick error %s' % e, 501
    return jsonify(bbox)
Ejemplo n.º 2
0
def get_pdiff(idx):
    idx = int(idx)
    d = DIFF[idx]
    try:
        _, pdiff_image = util.generate_pdiff_image(d.a_path, d.b_path)
        dilated_image = util.generate_dilated_pdiff_image(pdiff_image)
    except util.ImageMagickNotAvailableError:
        return 'ImageMagick is not available', 501
    except util.ImageMagickError as e:
        return 'ImageMagick error %s' % e, 501
    return send_file(dilated_image)
Ejemplo n.º 3
0
def get_pdiff_bbox(idx):
    idx = int(idx)
    d = DIFF[idx]
    try:
        _, pdiff_image = util.generate_pdiff_image(d.a_path, d.b_path)
        bbox = util.get_pdiff_bbox(pdiff_image)
    except util.ImageMagickNotAvailableError:
        return 'ImageMagick is not available', 501
    except util.ImageMagickError as e:
        return 'ImageMagick error %s' % e, 501
    return jsonify(bbox)
Ejemplo n.º 4
0
def get_pdiff(idx):
    idx = int(idx)
    d = DIFF[idx]
    try:
        _, pdiff_image = util.generate_pdiff_image(d.a_path, d.b_path)
        dilated_image = util.generate_dilated_pdiff_image(pdiff_image)
    except util.ImageMagickNotAvailableError:
        return 'ImageMagick is not available', 501
    except util.ImageMagickError as e:
        return 'ImageMagick error %s' % e, 501
    return send_file(dilated_image)
Ejemplo n.º 5
0
def get_thick_dict(diff):
    """Similar to thin_dict, but includes potentially expensive fields."""
    d = get_thin_dict(diff)
    d.update({"is_image_diff": is_image_diff(diff), "no_changes": no_changes(diff)})
    if d["is_image_diff"]:
        if d["a"]:
            d["image_a"] = util.image_metadata(diff.a_path)
        if d["b"]:
            d["image_b"] = util.image_metadata(diff.b_path)
        if d["a"] and d["b"]:
            try:
                d["are_same_pixels"], _ = util.generate_pdiff_image(diff.a_path, diff.b_path)
            except util.ImageMagickError:
                d["are_same_pixels"] = False
            except util.ImageMagickNotAvailableError:
                pass
    return d
Ejemplo n.º 6
0
Archivo: diff.py Proyecto: xuv/webdiff
def get_thick_dict(diff):
    '''Similar to thin_dict, but includes potentially expensive fields.'''
    d = get_thin_dict(diff)
    d.update({
        'is_image_diff': is_image_diff(diff),
        'no_changes': no_changes(diff)
    })
    if d['is_image_diff']:
        if d['a']: d['image_a'] = util.image_metadata(diff.a_path)
        if d['b']: d['image_b'] = util.image_metadata(diff.b_path)
        if d['a'] and d['b']:
            try:
                d['are_same_pixels'], _ = util.generate_pdiff_image(
                        diff.a_path, diff.b_path)
            except util.ImageMagickError:
                d['are_same_pixels'] = False
            except util.ImageMagickNotAvailableError:
                pass
    return d