Proyectos
Ver en GitHub
coollabsio/next-image-transformation
Acerca de
Sustituto directo del servicio de optimización de imágenes de Next.js de Vercel. Versión en la nube 👇
Diseño y multimediaCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- -1
- in 15 days
- -1
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalNext.js Image Transformation
An open-source & self-hostable image optimization service, a drop-in replacement for Vercel's Image Optimization.
Cloud with free global CDN
The cloud version, with free global CDN and simple pricing available here: https://images.coollabs.io
Try it out
- Change the
widthquery parameter to see the image resize on the fly. - Add the
heightquery parameter to see the image crop on the fly. - Add the
qualityquery parameter to see the image quality change on the fly.
https://image.coollabs.io/image/https://cdn.coollabs.io/images/image1.jpg?width=500
Includes
- Next Image Transformation API.
- A simple API written in Bun that transforms the incoming request to Imgproxy format and forwards it to the Imgproxy service.
- Imgproxy service.
- A powerful and fast image processing service that can resize, crop, and transform images on the fly.
How to deploy with Coolify
- Login to your Coolify instance or the cloud.
- Create a new service and select the
Next.js Image Transformationtemplate. - Optional: Set the
ALLOWED_REMOTE_DOMAINSenvironment variable to the domain of your images (e.g.example.com,coolify.io). By default, it is set to*which allows any domain. - Set the your
<domain>on theNext Image Transformationservice. - Deploy your service.
How to use in Next.js
- In
next.config.jsadd the following:
module.exports = {
images: {
loader: 'custom',
loaderFile: './loader.js',
},
}
- Create a file called
loader.jsin the root of your project and add the following:
'use client'
export default function myImageLoader({ src, width, quality }) {
const isLocal = !src.startsWith('http');
const query = new URLSearchParams();
const imageOptimizationApi = '<image-optimization-domain>';
// Your NextJS application URL
const baseUrl = '<your-nextjs-app-domain>';
const fullSrc = `${baseUrl}${src}`;
if (width) query.set('width', width);
if (quality) query.set('quality', quality);
if (isLocal && process.env.NODE_ENV === 'development') {
return src;
}
if (isLocal) {
return `${imageOptimizationApi}/image/${fullSrc}?${query.toString()}`;
}
return `${imageOptimizationApi}/image/${src}?${query.toString()}`;
}
- Replace
<image-optimization-domain>with the URL of what you set on theNext Image Transformation API. - Replace
<your-nextjs-app-domain>with the URL of your Nextjs application.
Currently supported transformations
- width
- height
- quality
Explorar proyectos relacionados
Cargando…