Giter VIP home page Giter VIP logo

global19 / svg-autocrop-serverless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cncf/svg-autocrop-serverless

0.0 2.0 0.0 712 KB

πŸš—πŸŒ½πŸ”³πŸ’β€β™€οΈπŸ™…β€β™€οΈπŸ’β€β™‚οΈπŸ™…β€β™‚οΈServerless infrastructure for SVG Autocrop

Home Page: https://autocrop.cncf.io

License: MIT License

Shell 4.14% JavaScript 37.80% HTML 58.07%

svg-autocrop-serverless's Introduction

What is this: A repo for a serverless (gcloud functions) api of svg-autocrop.

Install: npm install, at this moment a nodejs v10 is used

Debug locally: functions-framework --target=autocrop1

where autocrop1 is a function name from an index.js

Deploy: gcloud functions deploy --runtime=nodejs10 --region=us-central1 --trigger-http autocrop1

Example API Usage:

        const baseUrl = 'https://us-central1-cncf-svg-autocrop.cloudfunctions.net/autocrop';
        const rp = require('request-promise');
        const input = require('fs').readFileSync(`node_modules/svg-autocrop/fixtures/f5.input.svg`, 'utf-8');
        const response = await rp({
            method: 'POST',
            body: {"svg": input, title: "new title"},
            uri: baseUrl,
            json: true
        }); 
        console.info(response);

output: { success : true, result: '<svg ...', stats: { originalSize: 1000, transformedSize: 500 }} OR { success : false, error: '...' }

Price

We assume that an average request time is 10 seconds, we use the best virtual machine to get the result fast enough thus it is 2GB RAM and 2.8GHz CPU, and an average SVG file is 100kB (usually it is even less) thus a bandwidth for a request is 0.3Mb

$32 per 100,000 requests per month:

photo

100,000 invocations divided by ($31.74 x 100 cents) is 32, so we can do 32 logo autocrops per penny.

svg-autocrop-serverless's People

Contributors

andreykozlov1984 avatar dankohn avatar ribice avatar

Watchers

James Cloos avatar  avatar

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.