Giter VIP home page Giter VIP logo

imgsquash's Introduction

SUMMARY

Image compression full stack website code. Contains both api service and frontend written in node, react and next.js framework.

SCREENSHOTS

screen-one screen-two screen-three

โ€ƒ

SETTING UP GOOGLE CLOUD STORAGE

  1. Create a project on google cloud and add a free cloud storage bucket via this quickstart guide:
  2. Authenticate using either gcloud command line tool (download here) or set GOOGLE_APPLICATION_CREDENTIALS env variable with the service account file.

STARTING THE API SERVICE

  1. Create .env file in the root of the folder with the following variables. See dotenv on how to add env variables.
    • API_VERSION : 1 (optional).
    • GC_STORAGE : your-google-cloud-bucket-name
    • DL_BASE_URL : [YOUR-API-URL]/1/dl
  2. Do npm install to install all node modules for api.
  3. Do npm run dev to start the dev server on 3000 port.
  4. Do npm start for production

STARTING THE FRONTEND

  1. Do npm install to install all node modules for frontend.
  2. Do npm run dev will start the webpack server on 3001 port.
  3. Do npm run build and npm start to build and use the code in production.

NOTES

  1. Following programs are used for optimization

    • mozjpeg (lossy jpeg compression)
    • jpegtran (lossless jpeg compression)
    • pngquant (lossy png compression)
    • optipng (lossless png compression)
  2. Current file size upload limit is 10MB.

  3. API Routes. [POST]

    • /image: upload image(s) via file, URL, base64 or Binary.
      • file: file or base64 or binary.
      • lossy: Boolean (default: false)
    • /url: Compression direct image url.
      • url: valid image url.
    • /zip: Accepts list of files object as an array with (id, size and name) and send the zipped result.
      • files: list of files object as an array.

    [GET] - /dl/:id: Generate download url of compressed image. Accept optional query name.

LICENSE

MIT

imgsquash's People

Contributors

dependabot[bot] avatar eashish93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgsquash's Issues

How to install this setup

Can you please tell me how to run this script. Is it possible in github pages or any other hosting plateform. eg - digital ocean.

A bucket name is needed to use Cloud Storage Error

I copied my .env file to the root and /api/ folder to get an error saying:

/Users/surya/Documents/imgsquash/api/node_modules/@google-cloud/storage/build/src/storage.js:132
            throw new Error('A bucket name is needed to use Cloud Storage.');
                  ^
Error: A bucket name is needed to use Cloud Storage.
    at Storage.bucket (/Users/surya/Documents/imgsquash/api/node_modules/@google-cloud/storage/build/src/storage.js:132:19)
    at Object../src/ctrls/image.js (/Users/surya/Documents/imgsquash/api/build/webpack:/src/ctrls/image.js:20:25)
    at __webpack_require__ (/Users/surya/Documents/imgsquash/api/build/webpack:/webpack/bootstrap:19:1)
    at Object../src/ctrls/index.js (/Users/surya/Documents/imgsquash/api/build/webpack:/src/ctrls/index.js:1:29)
    at __webpack_require__ (/Users/surya/Documents/imgsquash/api/build/webpack:/webpack/bootstrap:19:1)
    at Object../src/routes.js (/Users/surya/Documents/imgsquash/api/build/webpack:/src/routes.js:3:27)
    at __webpack_require__ (/Users/surya/Documents/imgsquash/api/build/webpack:/webpack/bootstrap:19:1)
    at Object../src/index.js (/Users/surya/Documents/imgsquash/api/build/webpack:/src/index.js:8:23)
    at __webpack_require__ (/Users/surya/Documents/imgsquash/api/build/webpack:/webpack/bootstrap:19:1)
    at Object.0 (/Users/surya/Documents/imgsquash/api/build/main.js:1083:18)

My env file looks like this:

API_VERSION : 1
GC_STORAGE : data.suryad.com
DL_BASE_URL : data.suryad.com/1/dl

My GCS name is data.suryad.com but am not sure what you mean by API_URL. Not sure if my setup of my env file is wrong, but I cannot do npm run dev and get it running on localhost:3000.

Not running locally on Windows 10

Front end after running is not able to compress images. I didn't check the API part as I don't have GCP account. After uploading status, it throws an error i don't know what's causing this.

image

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.