npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@uni/image

v1.1.3

Published

[![npm](https://img.shields.io/npm/v/@uni/image.svg)](https://www.npmjs.com/package/@uni/image)

Readme

@uni/image

npm

Install

$ npm install @uni/image --save

or

$ npm install @uni/apis --save

chooseImage

Selects an image from the local album or takes a photo with the camera.

Supported

Usage

import { chooseImage } from '@uni/image';

chooseImage({
  count: 1,
  sourceType: ['album', 'camera'],
  success (res) {
    const tempFilePaths = res.tempFilePaths
  }
});

// promise
chooseImage({
  count: 1,
  sourceType: ['album', 'camera']
}).then(res => {
  const tempFilePaths = res.tempFilePaths
});

You can also import from the big package:

import { image } from '@uni/apis';

image.chooseImage({
  count: 1,
  sourceType: ['album', 'camera'],
  success (res) {
    const tempFilePaths = res.tempFilePaths
  }
});

// promise
image.chooseImage({
  count: 1,
  sourceType: ['album', 'camera']
}).then(res => {
  const tempFilePaths = res.tempFilePaths
});

Methods

chooseImage(options)

Arguments

| Property | Type | Description | required | Default | | --- | --- | --- | --- | --- | | options | object  | | ✘ | - | | options.count | number | The maximum number of images allowed | ✘ | 1 | | options.sourceType | Array<string>  | The source of the image | ✘ | ['album', 'camera'] | | options.success | Function  | The callback function for a successful API call | ✘ | - | | options.fail | Function  | The callback function for a failed API call | ✘ | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |

Special Arguments

| Property | Type | Description | required | Default | Supported | | --- | --- | --- | --- | --- | -- | | options.sizeType | Array.<string>  | The size of the select image | ✘ | ['original', 'compressed'] | |

Return

| Property | Type | Description | | --- | --- | --- | | tempFilePaths | Array<string>  | The list of local temporary file paths to images | | tempFiles | Array<Object> | The local temporary file list for images |

res.tempFiles

| Property | Type | Description | | --- | --- | --- | | path | string  | The path to the local temporary file | | size | number  | The size of a local temporary file, in bytes |

compressImage

Compresses images. Multiple types of compression quality are available.

Supported

Usage

import { compressImage } from '@uni/image';

compressImage({
  src: 'http://img.icon.com/a.png',
  quality: 1,
  success: (res) => {
    console.log('success', res);
  },
  fail: (res) => {
    console.log('fail', res);
  },
  complete: (res) => {
    console.log('complete', res);
  }
});

// promise
compressImage({
  src: 'http://img.icon.com/a.png',
  quality: 1
}).then(response => {})
  .catch(error => {})
  .finally(res => {});

You can also import from the big package:

import { image } from '@uni/apis';

image.compressImage({
  src: 'http://img.icon.com/a.png',
  quality: 1,
  success: (res) => {
    console.log('success', res);
  },
  fail: (res) => {
    console.log('fail', res);
  },
  complete: (res) => {
    console.log('complete', res);
  }
});

// promise
image.compressImage({
  src: 'http://img.icon.com/a.png',
  quality: 1
}).then(response => {})
  .catch(error => {})
  .finally(res => {});

Methods

compressImage(options)

Arguments

| Property | Type | Description | required | Default | | --- | --- | --- | --- | --- | | options | object  | | ✔️ | - | | options.src | string  | The path to the image. It can be a relative path, a temporary file path, or a file compress-image path | ✔️ | - | | options.quality | number  | Compression quality. The value range is 0-3. | ✘ | - | | options.success | Function  | The callback function for a successful API call | ✘ | - | | options.fail | Function  | The callback function for a failed API call | ✘ | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |

Return

| Property | Type | Description | | --- | --- | --- | | tempFilePath | string | The temporary file path to the compressed image |

getImageInfo

Obtains image information. For network images, it only takes effect when the download domain name is configured.

Supported

Usage

import { getImageInfo } from '@uni/image';

getImageInfo({
  src: 'http://img.icon.com/a.png',
  success: (res) => {
    console.log('success', res);
  },
  fail: (res) => {
    console.log('fail', res);
  },
  complete: (res) => {
    console.log('complete', res);
  }
});

// promise
getImageInfo({
  src: 'http://img.icon.com/a.png'
}).then(response => {})
  .catch(error => {})
  .finally(res => {});

You can also import from the big package:

import { image } from '@uni/apis';

image.getImageInfo({
  src: 'http://img.icon.com/a.png',
  success: (res) => {
    console.log('success', res);
  },
  fail: (res) => {
    console.log('fail', res);
  },
  complete: (res) => {
    console.log('complete', res);
  }
});

// promise
image.getImageInfo({
  src: 'http://img.icon.com/a.png'
}).then(response => {})
  .catch(error => {})
  .finally(res => {});

Methods

getImageInfo(options)

Arguments

| Property | Type | Description | required | Default | | --- | --- | --- | --- | --- | | options | object  | | ✔️ | - | | options.src | string  | The path to the image. It can be a relative path or a path to a network image. | ✔️ | - | | options.success | Function  | The callback function for a successful API call | ✘ | - | | options.fail | Function  | The callback function for a failed API call | ✘ | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |

Return

| Property | Type | Description | | --- | --- | --- | | width | number  | The original width of the image (in px). | | height | number  | The original height of the image (in px). | | path | number  | The local path to the image |

Special Return

| Property | Type | Description | Supported | | --- | --- | --- | --- | | orientation | string  | Device orientation when taking photos | | | type | string  | Image format | no Dingding |

orientation

| Value | Description | | --- | --- | | up | Default orientation (landscape) | | up-mirrored | Mirrored orientation of up | | down | Rotates the device 180 degrees | | down-mirrored | Mirrored orientation of down | | left-mirrored | Mirrored orientation of left | | right | Rotates the device 90 degrees clockwise | | right-mirrored | Mirrored orientation of right | | left | Rotates the device 90 degrees counterclockwise |

previewImage

Previews the image in full screen on a new page. You can save or send it to others while preview.

Supported

Usage

import { previewImage } from '@uni/image';

previewImage({
  urls: ['url1', 'url2'],
  current: 1,
});

You can also import from the big package:

import { image } from '@uni/apis';

image.previewImage({
  urls: ['url1', 'url2'],
  current: 1,
});

Methods

previewImage(options)

Arguments

| Property | Type | Description | required | Default | | --- | --- | --- | --- | --- | | options | object  | | ✘ | - | | options.urls | Array<string> | The URLs of images to preview | ✘ | | | options.current | number  | The index of the current image in urls list | ✘ | 0 | | options.success | Function  | The callback function for a successful API call | ✘ | - | | options.fail | Function  | The callback function for a failed API call | ✘ | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |

Special Arguments

| Property | Type | Description | required | Default | Supported | | --- | --- | --- | --- | --- | -- | | options.showmenu | boolean  | show longpress menu | ✘ | true | 2.13.0 | | options.images | Array<object> | Support the picture link list of the original picture. Note that the order must be consistent with the urls. images: [{url:'Small image address', origin_url:'Original image address'},...] | ✘ | - | |

saveImage

Saves images to the system album.

Supported

Usage

import { saveImage } from '@uni/image';

saveImage({
  url: 'http://img.icon.com/a.png',
});

You can also import from the big package:

import { image } from '@uni/apis';

image.saveImage({
  url: 'http://img.icon.com/a.png',
});

Methods

saveImage(options)

Arguments

| Property | Type | Description | required | Default | | --- | --- | --- | --- | --- | | options | object  | | ✔️ | - | | options.url | string  | The path to the image file. It can be a temporary or permanent file path. The path to a network image is not supported | ✔️ | - | | options.success | Function  | The callback function for a successful API call | ✘ | - | | options.fail | Function  | The callback function for a failed API call | ✘ | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | ✘ | - |

Special Arguments

| Property | Type | Description | required | Default | Supported | | --- | --- | --- | --- | --- | -- | | options.showActionSheet | boolean  | show operation menus for image | ✘ | true | |