zimg
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

zimg

Build Status License NPM Version NPM Downloads Dependency Status Code Style

Pre-optimize images for Next.js production or others via sharp

Installation

$ npm install zimg

CLI Usage

Use npx:

$ npx zimg <cwd> [options]

Globally install:

$ npm install zimg -g
$ zimg --help
zimg/0.1.0

Usage:
  $ zimg [cwd]

Commands:
  [cwd]  Optimize images for production via sharp

For more info, run any command with the `--help` flag:
  $ zimg --help

Options:
  -p, --pattern <pattern>  Glob pattern to match files, default to `**/*.{jpg,jpeg,png}`
  -s, --sizes <sizes>      Sizes to generate, default to `[640, 720, 1280, 1600]`
  -q, --quality <quality>  Quality of generated images, default to `75`
  -v, --version            Display version number
  -h, --help               Display this message

API Usage

import { zimg } from 'zimg'
await zimg({
  cwd: process.cwd(),
  pattern: '**/*.{jpg,jpeg,png}',
  sizes: [640, 720, 1280, 1600],
  quality: 75
})
// searching images in cwd, and resize it

API Reference

zimg(options?)

options

cwd
  • Type: string
  • Details: Current working directory
  • Default: process.cwd()
pattern
  • Type: string
  • Details: Glob pattern to match files
  • Default: '**/*.{jpg,jpeg,png}'
filename
  • Type: string
  • Details: Filename of optimized image
  • Default: '[name].[size]'
sizes
  • Type: number[]
  • Details: Sizes to generate
  • Default: [640, 720, 1280, 1600]
quality
  • Type: number
  • Details: Quality of generated images
  • Default: 75
skipOptimized
  • Type: boolean
  • Details: Skip optimized images rather than overwrite
  • Default: true

Related

  • zce/velite - Turns Markdown / MDX, YAML, JSON, or others into app's data layer with Zod schema.
  • zce/caz - A simple yet powerful template-based Scaffolding tools.

Contributing

  1. Fork it on GitHub!
  2. Clone the fork to your own machine.
  3. Checkout your feature branch: git checkout -b my-awesome-feature
  4. Commit your changes to your own branch: git commit -am 'Add some feature'
  5. Push your work back up to your fork: git push -u origin my-awesome-feature
  6. Submit a Pull Request so that we can review your changes.

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

License

MIT © zce

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    29
    • latest

Version History

Package Sidebar

Install

npm i zimg

Weekly Downloads

29

Version

0.1.0

License

MIT

Unpacked Size

9.25 kB

Total Files

7

Last publish

Collaborators

  • zce