Git Product home page Git Product logo

cocotweaks---img-api's Introduction

API URL

https://ai.cocotweaks.net/img/api/

Function

Currently, it will only resize image best to fit. Maybe add more function in the future.

Parameter

All of the paramter is required, otherwise server will return error message.

ImageUrl

The url of image. Accept png, jpg and gif, and the file which not larger than 500MB.

Width

The width of resized image. Must be integer.

Height

The height of resized image. Must be integer.

Usage

You can call the API to resize image with post method. Currently it only accept remote image.

Get cropped image by GET method:

You can just use the this url to crop the image. This method will return an cropped image directly, not JSON result.

https://ai.cocotweaks.net/img/api/?imageUrl={image_url}&width={image_width}&height={image_height}

Get cropped image by POST method:

fetch('https://apiserver.com', {
  body:JSON.stringify({
    width: 500,
    height: 300,
    imageUrl: 'http://example.com/image.png',
  }),
  headers: {
    'content-type': 'application/json',
  },
  method: 'POST',
})
.then(response => response.json())
.then((result) =>{
  console.log(result);
});

If everything is OK, it will return a JSON which contain status and cropped image data (Data url of resized image):

{ status: 'Success',
  cropped_image_data:
   '/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2OTApLCBxdWFsaXR5ID0gODUK/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxERExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8IAEQgBLAHWAwEiAAIRAQMRAf/EABwAAAEFAQEBAAAAAAAAAAAAAAIAAQQFBgMHCP/EABkBAQEBAQEBAAAAAAAAAAAAAAABAgMEB...' }

The API will not keep your image.

Otherwise it will return a json which contain error message. For example:

{ status: 'Failed',
  error_message": 'Please provide the url of image.'}

cocotweaks---img-api's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.