Exemple #1
0
def explicit(public_id, **options):
    params = {
        "timestamp":
        utils.now(),
        "type":
        options.get("type"),
        "public_id":
        public_id,
        "callback":
        options.get("callback"),
        "headers":
        utils.build_custom_headers(options.get("headers")),
        "eager":
        utils.build_eager(options.get("eager")),
        "eager_notification_url":
        options.get("eager_notification_url"),
        "eager_async":
        options.get("eager_async"),
        "tags":
        options.get("tags") and ",".join(utils.build_array(options["tags"])),
        "face_coordinates":
        utils.encode_double_array(options.get("face_coordinates")),
        "custom_coordinates":
        utils.encode_double_array(options.get("custom_coordinates")),
        "invalidate":
        options.get("invalidate"),
        "context":
        utils.encode_dict(options.get("context")),
        "responsive_breakpoints":
        utils.generate_responsive_breakpoints_string(
            options.get("responsive_breakpoints"))
    }
    return call_api("explicit", params, **options)
Exemple #2
0
def update(public_id, **options):
    resource_type = options.pop("resource_type", "image")
    type = options.pop("type", "upload")
    uri = ["resources", resource_type, type, public_id]
    upload_options = only(options, "moderation_status", "raw_convert", "ocr", "categorization", "detection", "similarity_search")
    if "tags" in options: upload_options["tags"] = ",".join(utils.build_array(options["tags"]))
    if "face_coordinates" in options: upload_options["face_coordinates"] = utils.encode_double_array(options.get("face_coordinates")) 
    if "context" in options: upload_options["context"] = utils.encode_dict(options.get("context")) 
    if "auto_tagging" in options: upload_options["auto_tagging"] = float(options.get("auto_tagging"))
    return call_api("post", uri, upload_options, **options)
def explicit(public_id, **options):
     params = {
        "timestamp": utils.now(),
        "type": options.get("type"),
        "public_id": public_id,
        "callback": options.get("callback"),
        "headers": utils.build_custom_headers(options.get("headers")),
        "eager": utils.build_eager(options.get("eager")),
        "eager_notification_url": options.get("eager_notification_url"),
        "eager_async": options.get("eager_async"),
        "tags": options.get("tags") and ",".join(utils.build_array(options["tags"])),
        "face_coordinates": utils.encode_double_array(options.get("face_coordinates")),
        "custom_coordinates": utils.encode_double_array(options.get("custom_coordinates")),
        "invalidate": options.get("invalidate"),
        "context": utils.encode_dict(options.get("context"))}
     return call_api("explicit", params, **options)
Exemple #4
0
def build_upload_params(**options):
    params = {"timestamp": utils.now(),
              "transformation": utils.generate_transformation_string(**options)[0],
              "public_id": options.get("public_id"),
              "callback": options.get("callback"),
              "format": options.get("format"),
              "type": options.get("type"),
              "backup": options.get("backup"),
              "faces": options.get("faces"),
              "image_metadata": options.get("image_metadata"),
              "exif": options.get("exif"),
              "colors": options.get("colors"),
              "headers": build_custom_headers(options.get("headers")),
              "eager": build_eager(options.get("eager")),
              "use_filename": options.get("use_filename"),
              "unique_filename": options.get("unique_filename"),
              "discard_original_filename": options.get("discard_original_filename"),
              "invalidate": options.get("invalidate"),
              "notification_url": options.get("notification_url"),
              "eager_notification_url": options.get("eager_notification_url"),
              "eager_async": options.get("eager_async"),
              "proxy": options.get("proxy"),
              "folder": options.get("folder"),
              "overwrite": options.get("overwrite"),
              "tags": options.get("tags") and ",".join(utils.build_array(options["tags"])),
              "allowed_formats": options.get("allowed_formats") and ",".join(utils.build_array(options["allowed_formats"])),
              "face_coordinates": utils.encode_double_array(options.get("face_coordinates")),
              "context": utils.encode_dict(options.get("context")),
              "moderation": options.get("moderation"),
              "raw_convert": options.get("raw_convert"),
              "ocr": options.get("ocr"),
              "categorization": options.get("categorization"),
              "detection": options.get("detection"),
              "similarity_search": options.get("similarity_search"),
              "auto_tagging": options.get("auto_tagging") and float(options.get("auto_tagging"))}
    params = dict( [ (k, __safe_value(v)) for (k,v) in params.items()] )
    return params
Exemple #5
0
def build_upload_params(**options):
    params = {
        "timestamp":
        utils.now(),
        "transformation":
        utils.generate_transformation_string(**options)[0],
        "public_id":
        options.get("public_id"),
        "callback":
        options.get("callback"),
        "format":
        options.get("format"),
        "type":
        options.get("type"),
        "backup":
        options.get("backup"),
        "faces":
        options.get("faces"),
        "image_metadata":
        options.get("image_metadata"),
        "exif":
        options.get("exif"),
        "colors":
        options.get("colors"),
        "headers":
        build_custom_headers(options.get("headers")),
        "eager":
        build_eager(options.get("eager")),
        "use_filename":
        options.get("use_filename"),
        "unique_filename":
        options.get("unique_filename"),
        "discard_original_filename":
        options.get("discard_original_filename"),
        "invalidate":
        options.get("invalidate"),
        "notification_url":
        options.get("notification_url"),
        "eager_notification_url":
        options.get("eager_notification_url"),
        "eager_async":
        options.get("eager_async"),
        "proxy":
        options.get("proxy"),
        "folder":
        options.get("folder"),
        "overwrite":
        options.get("overwrite"),
        "tags":
        options.get("tags") and ",".join(utils.build_array(options["tags"])),
        "allowed_formats":
        options.get("allowed_formats")
        and ",".join(utils.build_array(options["allowed_formats"])),
        "face_coordinates":
        utils.encode_double_array(options.get("face_coordinates")),
        "context":
        utils.encode_dict(options.get("context")),
        "moderation":
        options.get("moderation"),
        "raw_convert":
        options.get("raw_convert"),
        "ocr":
        options.get("ocr"),
        "categorization":
        options.get("categorization"),
        "detection":
        options.get("detection"),
        "similarity_search":
        options.get("similarity_search"),
        "auto_tagging":
        options.get("auto_tagging") and float(options.get("auto_tagging"))
    }
    params = dict([(k, __safe_value(v)) for (k, v) in params.items()])
    return params