
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
@ecopages/image-processor
Advanced tools
A powerful and flexible image processing library designed to optimize and manage responsive images in ecopages applications.
ecopages:imagesnpm install @ecopages/image-processor
import path from 'node:path';
import { ConfigBuilder } from '@ecopages/core';
import { ImageProcessorPlugin } from '@ecopages/image-processor';
const imageProcessor = new ImageProcessorPlugin({
name: 'ecopages-image-processor',
type: 'image',
options: {
sourceDir: path.resolve(import.meta.dir, 'src/images'),
outputDir: path.resolve(import.meta.dir, '.eco/images'),
publicPath: '/images',
acceptedFormats: ['jpg', 'jpeg', 'png', 'webp'],
quality: 80,
format: 'webp',
sizes: [
{ width: 320, label: 'sm' },
{ width: 768, label: 'md' },
{ width: 1024, label: 'lg' },
{ width: 1920, label: 'xl' },
],
},
});
export default await new ConfigBuilder()
.setRootDir(import.meta.dir)
.setBaseUrl(import.meta.env.ECOPAGES_BASE_URL)
.setProcessors([imageProcessor])
.build();
| Option | Type | Default | Description |
|---|---|---|---|
sourceDir | string | '/src/public/assets/images' | Source directory for images |
outputDir | string | '/dist/assets/optimized' | Output directory for processed images |
publicPath | string | '/assets/optimized' | Public URL path for images |
sizes | Array<{width: number, label: string}> | [] | Image variants configuration |
quality | number | 80 | Output image quality (0-100) |
format | 'webp' | 'jpeg' | 'png' | 'avif' | 'webp' | Output image format |
acceptedFormats | string[] | ['jpg','jpeg','png','webp'] | Accepted input formats |
The ecopages:images virtual module provides a unified, type-safe way to handle images across your project:
// All images from your source directory are available as named exports
import { heroImage, profilePicture, blogThumbnail } from 'ecopages:images';
// Names are automatically converted to camelCase
// example:
// src/images/hero-image.jpg -> heroImage
// src/images/profile_picture.png -> profilePicture
No manual dependencies.modules declaration is required for ecopages:images; imports are automatically detected and included in the client bundle.
Images are available through the virtual module ecopages:images:
import { myImage } from 'ecopages:images';
// myImage contains:
// {
// attributes: {
// src: string,
// width: number, // original image width
// height: number, // original image height
// sizes: string,
// srcset: string
// },
// variants: Array<{ width, height, src, label }>
// }
import { EcoImage } from '@ecopages/image-processor/component/html';
// Basic usage
EcoImage({
...myImage,
width: 800,
height: 600,
alt: 'My image',
});
// Advanced usage
EcoImage({
...myImage,
alt: 'My image',
layout: 'constrained',
priority: true,
aspectRatio: '16/9',
staticVariant: 'xl',
});
import { EcoImage } from "@ecopages/image-processor/component/react";
// Basic usage
<EcoImage
{...myImage}
alt="My image"
/>
// Advanced usage
<EcoImage
{...myImage}
alt="My image"
layout="constrained"
priority
aspectRatio="16/9"
staticVariant="xl"
/>
The component accepts all standard HTML/React image attributes (src, alt, data-*, crossOrigin, etc.) in addition to the following specific props:
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | From image metadata | Original width, can be overridden if needed |
height | number | From image metadata | Original height, can be overridden if needed |
priority | boolean | false | Prioritize loading |
layout | 'fixed' | 'constrained' | 'full-width' | 'constrained' | Layout behavior |
staticVariant | string | - | Force specific size variant |
aspectRatio | string | From width/height | Override the natural aspect ratio |
unstyled | boolean | false | Disable default styling |
Note: Images imported through ecopages:images automatically include their width and height metadata, preventing layout shifts by default. These values can be overridden when needed, for example when using a different aspect ratio or specific layout requirements.
EcoImage({
...myImage,
layout: 'fixed',
width: 400,
height: 300,
alt: 'Fixed image',
});
EcoImage({
...myImage,
layout: 'constrained',
width: 800,
alt: 'Constrained image',
});
EcoImage({
...myImage,
layout: 'full-width',
alt: 'Full-width image',
});
alt text for accessibilitypriority for above-the-fold imageswidth and height to prevent layout shiftsaspectRatio only when you need to force a different aspect ratio than width/heightlayout modes based on your needsFAQs
Image processor, transform and optimize images for web
We found that @ecopages/image-processor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.