No description
  • TypeScript 80.4%
  • Dockerfile 10.6%
  • Makefile 9%
Find a file
nzambello 232cb42b82
All checks were successful
Docker CI / release (push) Successful in 10m15s
feat: add heic support + convert API
2025-12-11 12:17:57 +01:00
.gitea/workflows ci: remove git server and image tag 2024-05-21 22:21:21 +03:00
.dockerignore ci: sharp compatibility with bun 2024-03-25 15:24:31 +02:00
.editorConfig first commit 2024-03-25 11:17:19 +02:00
.gitignore first commit 2024-03-25 11:17:19 +02:00
bun.lockb feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
docker-compose.yml first commit 2024-03-25 11:17:19 +02:00
Dockerfile feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
index.test.ts feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
index.ts feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
Makefile feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
package.json feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
README.md feat: add heic support + convert API 2025-12-11 12:17:57 +01:00
tsconfig.json feat: add heic support + convert API 2025-12-11 12:17:57 +01:00

resize-img-api

Image resizing and format conversion API built with Hono and Sharp.

API Endpoints

Resize API

/api/imgresize/:width/:height/:url

Resize images to specified dimensions.

  • :width and :height can be numbers in pixels or auto
  • :url should be URL encoded (use encodeURIComponent() in JS)

Query parameters:

  • ?format= - Output format: avif, gif, heif, jpeg, jpg, jp2, pdf, png, svg, tiff, webp (default: jpeg)
  • ?fit= - Resize fit mode: cover, contain, fill, inside, outside (default: inside)

Example:

/api/imgresize/200/200/https%3A%2F%2Fmemori.ai%2Flogo.png?format=png

Convert API

/api/convert/:format/:url

Convert images between different formats (e.g., HEIC to PNG/JPEG).

  • :format - Target format: avif, gif, heif, jpeg, jpg, jp2, pdf, png, svg, tiff, webp
  • :url should be URL encoded

Example:

/api/convert/png/https%3A%2F%2Fexample.com%2Fimage.heic

Docker

Build and run using Make:

make build          # Build Docker image
make run            # Start container
make test           # Run tests (requires container running)
make run-test       # Build, run container, and run tests
make stop           # Stop container
make clean          # Stop container and remove image

Or manually:

docker build -t resize-img-api .
docker run -p 8787:8787 resize-img-api

Development

Install dependencies:

bun install

Run locally:

bun start        # Production mode
bun dev          # Development mode with hot reloading

Run tests:

bun test         # Run tests (requires server running on localhost:8787)
make run-test    # Start container and run tests

Notes

  • The API supports HEIC/HEIF format conversion (requires libvips built with HEIC support)
  • Images are cached with Cache-Control: s-maxage=31536000, stale-while-revalidate
  • URL encoding is required for image URLs (use encodeURIComponent() in JavaScript)

This project was created using bun init in bun v1.0.26. Bun is a fast all-in-one JavaScript runtime.