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 🙏

© 2026 – Pkg Stats / Ryan Hefner

unpic-qcloud

v1.0.12

Published

Unpic image provider for Tencent Cloud COS Image Processing API

Downloads

1,162

Readme

unpic-qcloud

npm version CI License: MIT

An unpic image provider for the Tencent Cloud COS Image Processing API (imageMogr2).

Features

  • Transform COS image URLs with resize, crop, format conversion, quality control, and more
  • Supports the full imageMogr2 operation set
  • Works with both standard COS endpoints (cos.{region}.myqcloud.com) and CI endpoints (pic.{region}.myqcloud.com)
  • Merge new operations on top of existing URL parameters without losing context
  • Fully typed with TypeScript

Installation

npm install unpic-qcloud

unpic is a peer dependency. If you use the transform function with the @unpic/core transformer API, install it too:

npm install unpic

Usage

transform(src, operations) — primary API

The transform function is the main entry point. It merges new operations on top of any existing imageMogr2 parameters already present on the URL.

import { transform } from "unpic-qcloud";

// Basic resize
transform("https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg", {
  width: 800,
});
// → "https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg?imageMogr2/thumbnail/800x"

// Resize + format conversion + quality
transform("https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg", {
  width: 800,
  format: "webp",
  quality: 85,
});
// → "https://...?imageMogr2/thumbnail/800x/format/webp/quality/85"

// CSS object-fit: cover equivalent
transform("https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg", {
  width: 400,
  height: 300,
  thumbnailMode: "cover",
});
// → "https://...?imageMogr2/crop/400x300"

// Merge onto an existing processed URL
transform(
  "https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg?imageMogr2/thumbnail/400x/format/jpg/quality/70",
  { width: 800, format: "webp" },
);
// → "https://...?imageMogr2/thumbnail/800x/format/webp/quality/70"

Non-COS URLs are returned unchanged, making it safe to use as a universal transformer.

generate(src, operations) — build a URL from scratch

Generates a COS processing URL from a base object URL. Any existing processing parameters on src are discarded.

import { generate } from "unpic-qcloud";

generate("https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg", {
  width: 400,
  height: 300,
  format: "avif",
  quality: 90,
});
// → "https://...?imageMogr2/thumbnail/400x300/format/avif/quality/90"

extract(url) — parse a processed URL

Extracts the base URL and existing operations from an already-processed COS URL.

import { extract } from "unpic-qcloud";

const result = extract(
  "https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg?imageMogr2/thumbnail/400x/format/webp/quality/85",
);
// result.src       → "https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg"
// result.operations → { width: 400, format: "webp", quality: 85 }

Returns null when the URL is not a COS URL or does not contain imageMogr2 parameters.

isCosUrl(url) — detect COS URLs

import { isCosUrl } from "unpic-qcloud";

isCosUrl("https://bucket-1250000000.cos.ap-beijing.myqcloud.com/photo.jpg"); // true
isCosUrl("https://example.com/photo.jpg"); // false

Operations reference

| Field | Type | Description | |---|---|---| | width | number | Target width in pixels | | height | number | Target height in pixels | | thumbnailMode | "fit" \| "cover" \| "force" \| "shrinkOnly" \| "enlargeOnly" | How width/height are applied (default: "fit") | | format | QCloudCosFormat | Output format (jpg, png, webp, gif, avif, …) | | quality | number \| string | Absolute quality 0–100. Append "!" to force (e.g. "90!") | | rquality | number | Relative quality 0–100 (result = original × rquality / 100) | | lquality | number | Minimum quality 0–100 | | autoOrient | boolean | Auto-orient based on EXIF data (recommended before WebP conversion) | | rotate | number | Clockwise rotation in degrees (0–360) | | flip | "vertical" \| "horizontal" | Mirror flip direction | | iradius | number | Inner-circle crop radius in pixels | | rradius | number | Round-corner crop radius in pixels | | ignoreError | boolean | Return original image instead of error on processing failures |

thumbnailMode values

| Value | Behaviour | COS parameter | |---|---|---| | "fit" (default) | Fit within WxH, preserving aspect ratio | thumbnail/WxH | | "cover" | Scale to fill WxH, center-crop excess | crop/WxH | | "force" | Force exact WxH, ignoring aspect ratio | thumbnail/WxH! | | "shrinkOnly" | Fit within WxH only if the image is larger | thumbnail/WxH> | | "enlargeOnly" | Fit within WxH only if the image is smaller | thumbnail/WxH< |

Supported formats

Standard formats work on all buckets: jpg/jpeg, png, webp, gif, bmp, tiff, apng.

Advanced compression formats require CI Advanced Compression to be enabled on the bucket: avif, heif, heic, tpg, astc.

Use "src" to keep the original format.

Using with @unpic/core

import { transform } from "unpic-qcloud";

// Pass as a custom transformer
const url = transform(src, { width: 800, format: "webp", autoOrient: true });

License

MIT