示例#1
0
def upload_review_image():
    verify_required_condition(condition='image' in request.files,
                              error_msg=assets.ExceptionMessages.MISSING_PARAM.format(param='file[image]'),
                              error_code=httplib.BAD_REQUEST)
    image_url = save_image(request.files['image'], None, base_image_url_factory, current_app.testing)
    return jsonify({
        'image_url': image_url,
        'resized_image_url': resize(image_url, '600x400')
    })
示例#2
0
def test_resize_with_hashing():
    resize_url = 'http://test.dev/'
    resize_root, images, filenames = create_tmp_images()
    fn0, fn1 = filenames
    app = create_resizeapp(RESIZE_URL=resize_url, RESIZE_ROOT=resize_root)

    with app.test_request_context():
        image_url = flask.url_for("static", filename=fn0)
        expected_path = fr._construct_relative_cache_path(fn0, 'jpeg', 60, 200, 300, '', 'no-fill', 'upscale', '')
        expected_url = op.join(resize_url, expected_path)
        generated_url = fr.resize(image_url, '200x300', format='jpg', quality=60)
        assert expected_url == generated_url
示例#3
0
def upload_review_image():
    if 'image' in request.files:
        filename = review_images.save(request.files['image'])
        return jsonify({
            'image_url':
            g.config.get('OPINEW_API_SERVER') +
            url_for('media.get_review_image', filename=filename),
            'resized_image_url':
            resize(
                g.config.get('OPINEW_API_SERVER') +
                url_for('media.get_review_image', filename=filename),
                '600x400')
        })
    return '', 400
示例#4
0
def test_resize_noop():
    app = create_resizeapp(RESIZE_NOOP=True)
    with app.test_request_context():
        generated_image_path = resize('xyz.png', 'WxH')
    assert generated_image_path == 'xyz.png'