/static-image

Easy and powerful way to speed up loading of images on your website. Developed using node with typescript.

Primary LanguageTypeScriptMIT LicenseMIT

Logo Static

S T A T I C

Easy and powerful way to speed up loading of images on your website.
Developed using node with typescript.

Instagram - static.dedeard.my.id - dedeard.my.id - Linkedin



buymeacoffee


Getting Started

Using Node.js

Requirements

Run the app

  1. Clone this repo
  2. yarn install to install all required dependencies
  3. yarn dev to run development server and vscode debugging
  4. yarn test to run unit testing
  5. yarn build to compile the typescript code
  6. yarn start to run production server

Using Docker

Requirements

Run the app

  1. Clone this repo
  2. npm run docker:dev up to run development server and vscode debugging
  3. npm run docker:test up to run unit testing
  4. npm run docker up to run production server



Api

Image Service

URL format:

  • https://cdn.dedeard.my.id/image/:image-url
  • https://cdn.dedeard.my.id/image/:options/:image-url

Note: all requests must use GET or HEAD method, otherwise it will be rejected.

For example: https://cdn.dedeard.my.id/image/w=400,h=300/static.dedeard.my.id/kai.jpg

Martial Peak - Yang kai

Supported Input Image Types:

  • JPEG
  • PNG
  • WebP
  • AVIF
  • GIF
  • SVG
  • TIFF

Options:

format=:string OR f=:string

Convert image format.

Value: webp - jpeg - jpg - png

For example: /image/format=webp/static.dedeard.my.id/kai.jpg


quality=:percentage OR q=:percentage

Set new image quality in percentage.

Value: 10 - 100

Default: 80

For example: /image/quality=80/static.dedeard.my.id/kai.jpg


width=:pixel OR w=:pixel

Set new image width in pixel.

Value: val > 0

For example: /image/width=600/static.dedeard.my.id/kai.jpg


height=:pixel OR h=:pixel

Set new image height in pixel.

Value: val > 0

For example: /image/height=600/static.dedeard.my.id/kai.jpg


Avatar Service

URL format:

  • https://cdn.dedeard.my.id/avatar/:nickname.:format?:options

Note: all requests must use GET or HEAD method, otherwise it will be rejected.

For example: https://cdn.dedeard.my.id/avatar/dede ard.jpg?size=320

Avatar Example

Options:

format=:string OR f=:string

Set avatar format.

Value: webp - jpeg - jpg - png - svg

Default: webp

For example: /avatar/dede ard.png


size=:pixel OR s=:pixel

Set avatar size in pixel.

Value: val > 0

Default: 60

For example: /avatar/dede ard?size=120


maxlength=:pixel OR m=:pixel

Set avatar maximum character length.

Value: 1 - 3

Default: 2

For example: /avatar/dede ard?maxlength=3


color=:hex OR c=:hex

Set avatar text color.

Default: 111827

For example: /avatar/dede ard?color=000000


bgcolor=:hex OR b=:hex

Set avatar background color.

Default: f3f4f6

For example: /avatar/dede ard?color=ffffff


OG Image Service

URL format:

  • https://cdn.dedeard.my.id/og/:text.:format?:options

Note: all requests must use GET or HEAD method, otherwise it will be rejected.

For example: https://cdn.dedeard.my.id/og/Hello World.jpg?sign=static.dedeard.my.id/og-image

OG Image Example

Options:

format=:string OR f=:string

Set image format.

Value: webp - jpeg - jpg - png - svg

Default: webp

For example: /og/Hello World.jpg


sign=:string OR s=:string

Set image sign.

For example: /og/Hello World?sign=example.com/path


color=:hex OR c=:hex

Set image text color.

Default 111827

For example: /og/Hello World?color=000000


bgcolor=:hex OR b=:hex

Set image background color.

Default f3f4f6

For example: /og/Hello World?color=ffffff


Placeholder Service

URL format:

  • https://cdn.dedeard.my.id/placeholder/:options

Note: all requests must use GET or HEAD method, otherwise it will be rejected.

For example: https://cdn.dedeard.my.id/placeholder/width=400,height=300.webp

Placeholder Example

Options:

format=:string OR f=:string

Set image format.

Value: webp - jpeg - jpg - png - svg

Default: svg

For example: /placeholder/_.jpg


width=:pixel OR w=:pixel

Set new image width in pixel.

Value: val > 0

Default: 640

For example: /placeholder/width=600


height=:pixel OR h=:pixel

Set new image height in pixel.

Value: val > 0

Default: 480

For example: /placeholder/height=600


color=:hex OR c=:hex

Set image text color.

Default 111827

For example: /placeholder/color=000000


bgcolor=:hex OR b=:hex

Set image background color.

Default f3f4f6

For example: /placeholder/bgcolor=ffffff