# @atlas-viewer/iiif-image-api 中文文档

规范地址：https://npmcn.com/package/%40atlas-viewer/iiif-image-api/

版本：2\.2\.2
npm 元数据更新时间：2025-03-24T10:45:39.689Z
中文译文更新时间：2026-11-07T02:20:36.461Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40atlas-viewer/iiif-image-api
原文对照：https://npmcn.com/package/%40atlas-viewer/iiif-image-api/?lang=original
项目主页：https://github.com/atlas-viewer/iiif-image-api#readme
源码仓库：https://github.com/atlas-viewer/iiif-image-api

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：127 kB，8 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.14\.1
- 运行依赖：1 个
- 首次发布：2020-04-11T14:42:17.115Z
- 最新版本发布：2025-03-24T10:45:39.470Z
- 近 30 天下载量：3543（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：32（近 12 个月 0 个）

## 中文简介

与IIIF Image API合作的一系列帮助者.

## 安装

```sh
npm install @atlas-viewer/iiif-image-api
```

也可以使用：`pnpm add @atlas-viewer/iiif-image-api`、`yarn add @atlas-viewer/iiif-image-api`、`bun add @atlas-viewer/iiif-image-api`

## README

# IIIF 图像 API

与IIIF Image API合作的一系列帮助者.

## 兼容性

#### IIIF 规格

-   [IIIF 图像 3.0](https://iiif.io/api/image/3.0/) - 完全兼容
-   [IIIF 图像 2. 0](https://iiif.io/api/image/2.0/) - 完全兼容
-   [IIIF 图像 1.0](https://iiif.io/api/image/1.0/) - 无支持

#### IIIF 概况级别

看看这个 [遵守版本](https://iiif.io/api/image/3.0/compliance/) 更多信息。 此库支持检测0至2级至IIIF图像 API 3.0级.

## 文档

这个库是一个工具箱,作为更大的应用程序或库的一部分. 这些文件仍在编写中,但有打字定义被运出 您可以在您的 IDE 或编辑器中探索 API.

### 图像服务加载器

这是图书馆的主要部分。 它利用所有组件来创建一个单一的图像服务加载库.

```js
import { ImageServiceLoader } from '@atlas-viewer/iiif-image-api';

const loader = new ImageServiceLoader();

loader.loadService({
  id: 'http://some-service/some-path',
  width: 1000,
  height: 1000,
}).then(service => {
  // full image service available
  // service
});

loader.getThumbnailFromResource(
  // Content resource.
  {
    id: 'http://some-service/some-image/default.jpg',
    width: 1000,
    height: 2000,
    service: [
      {
       id: 'http://some-service/some-path',
        type: 'Service',
        profile: 'level0',
      }
    ]
  }, 
  // Thumbnail options.
  {
    maxWidth: 200,
    maxHeight: 200,
    preferFixedSize: true,
  }, 
  // Dereference image service.
  true
);
```

### 服务简介

以下剖面图将匹配并映射到IIIF的相符合水平:

-   [http://iif.io/api/image/2/level0 (英语)](http://iiif.io/api/image/2/level0)
-   [http://iiif.io/api/image/2/level 1 (英语)](http://iiif.io/api/image/2/level1)
-   [http://iiif.io/api/image/2/level2 (英语)](http://iiif.io/api/image/2/level2)
-   [http://library.stanford.edu/iif/image-api/遵义.html#level0](http://library.stanford.edu/iiif/image-api/compliance.html#level0)
-   [http://library.stanford.edu/iif/image-api/遵义.html#level1 (中文(简体) )](http://library.stanford.edu/iiif/image-api/compliance.html#level1)
-   [http://library.stanford.edu/iif/image-api/遵义.html#平分2级](http://library.stanford.edu/iiif/image-api/compliance.html#level2)
-   [http://library.stanford.edu/iif/image-api/conformance.html#level0 (英语)](http://library.stanford.edu/iiif/image-api/conformance.html#level0)
-   [http://library.stanford.edu/iif/image-api/conformance.html#level1 (中文(简体) )](http://library.stanford.edu/iiif/image-api/conformance.html#level1)
-   [http://library.stanford.edu/iif/image-api/conformance.html#level2 (中文(简体) )](http://library.stanford.edu/iiif/image-api/conformance.html#level2)
-   [http://library.stanford.edu/iif/image-api/1.1/遵义.html#level0](http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0)
-   [http://library.stanford.edu/iif/image-api/1.1/遵规.html#level1](http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1)
-   [http://library.stanford.edu/iif/image-api/1.1/遵义.html#level2](http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2)
-   [http://library.stanford.edu/iif/image-api/1.1/conformance.html#level0 (中文(简体) )](http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0)
-   [http://library.stanford.edu/iif/image-api/1.1/conformance.html#level1 (中文(简体) )](http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1)
-   [http://library.stanford.edu/iif/image-api/1.1/conformance.html#level2 (中文(简体) )](http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2)
-   [http://iif.io/api/image/1/level.json (英语)](http://iiif.io/api/image/1/level0.json)
-   [http://iiif.io/api/image/1/profiles/level0.json 页面存档备份,存于互联网档案馆](http://iiif.io/api/image/1/profiles/level0.json)
-   [http://iiif.io/api/image/1/level1.json (英语)](http://iiif.io/api/image/1/level1.json)
-   [http://iiif.io/api/image/1/profiles/level1.json (英语)](http://iiif.io/api/image/1/profiles/level1.json)
-   [http://iiif.io/api/image/1/level2.json (英语)](http://iiif.io/api/image/1/level2.json)
-   [http://iiif.io/api/image/1/profiles/level2.json (英语)](http://iiif.io/api/image/1/profiles/level2.json)
-   [http://iiif.io/api/image/2/level0.json (英语)](http://iiif.io/api/image/2/level0.json)
-   [http://iif.io/api/image/2/profiles/level0.json (英语)](http://iiif.io/api/image/2/profiles/level0.json)
-   [http://iif.io/api/image/2/level1.json (英语)](http://iiif.io/api/image/2/level1.json)
-   [http://iiif.io/api/image/2/profiles/level1.json 页面存档备份,存于互联网档案馆](http://iiif.io/api/image/2/profiles/level1.json)
-   [http://iiif.io/api/image/2/level2.json (英语)](http://iiif.io/api/image/2/level2.json)
-   [http://iiif.io/api/image/2/profiles/level2.json (英语)](http://iiif.io/api/image/2/profiles/level2.json)
-   0级
-   级别1
-   级别2

### 图像服务

在图像服务对象中接受,如果是支持的图像服务,则返回真实值 .

```js
import { isImageService } from '@atlas-viewer/iiif-image-api';

isImageService({
  id: 'http://some-service/some-path',
  type: 'Service',
  profile: 'level0',
}); // true

```

### 警犬服务

将图像服务端点规范化,以确保它具有 `info.json` 附录.

```js
import { canonicalServiceUrl } from '@atlas-viewer/iiif-image-api';

canonicalServiceUrl('http://some-service/some-path'); // http://some-service/some-path/info.json

```

### 提取FixedSize 缩放

鉴于图像大小和高度与宽度的列表,这按照输入的顺序返回每个大小的尺度.

```js
import { extractFixedSizeScales } from '@atlas-viewer/iiif-image-api';

extractFixedSizeScales(1000, 2000, [
  { width: 100, height: 200 },
  { width: 500, height: 1000 }
]); // [ 10, 2 ]

```

### 缩放

与此相反的行动 `extractFixedSizeScales` 从缩放列表中返回大小列表.

```js
import { extractFixedSizeScales } from '@atlas-viewer/iiif-image-api';

extractFixedSizeScales(1000, 2000, [10, 2]);
// returns:
// [ { width: 100, height: 200 }, { width: 500, height: 1000 } ]
```

### 从服务中获取自定义大小

鉴于服务, 这将返回一个对象, 给使用该服务生成图像带来限制 配置文件以及可用的最大宽度和最大高度属性。 如果服务包含平板, 将使用 瓷砖的定义.

整个这个库使用的回放值是用来描述一个可以用来创建真实图像的图像候选人.

```js
import { getCustomSizeFromService } from '@atlas-viewer/iiif-image-api';

getCustomSizeFromService({
  id: 'http://some-service/some-path',
  profile: 'image2',
  tiles: [
    { width: 256, height: 256 },
    { width: 512, height: 512 },
  ]
});

const returns = [
  {
    id: 'http://some-service/some-path',
    type: 'variable',
    minHeight: 0,
    minWidth: 0,
    maxHeight: 256,
    maxWidth: 256,
  },
  {
    id: 'http://some-service/some-path',
    type: 'variable',
    minHeight: 0,
    minWidth: 0,
    maxHeight: 512,
    maxWidth: 512,
  }
];
```

### 从图像中获取FixedSize

这需要内容资源 – 通常在 IIIF 演示文稿表的注解或缩略图属性正文中 – 并试图找到资源大小。 这只是表示资源大小,不应用作 一个真相的来源。 在内部,这用于检测潜在的非常大图像并避免渲染.

```js
import { getFixedSizeFromImage } from '@atlas-viewer/iiif-image-api';

// Normal image resources.
getFixedSizeFromImage({
  id: 'http://some-service/some-path/image.jpg',
  type: 'Image',
  width: 100,
  height: 200,
});

const returns = {
  id: 'http://some-service/some-path/image.jpg',
  type: 'fixed',
  width: 100,
  height: 200,
};

// Unknown size.
getFixedSizeFromImage('http://some-service/some-path/image.jpg');

const returns = {
  id: 'http://some-service/some-path/image.jpg',
  type: 'unknown',
};

```

### 从服务中获取FixedSizes

### 候选人

### 获得图像 候选人从服务

### 从图像来源获取图像

### 从Id获得图像服务员

### 图像服务

### 获取最小尺度的图像

### 从Url引出

### 是最佳游戏

### 图像服务

### 从候选人中选择最佳

### 抽样 Tiles- Tiles

### 大小比对

### 支持自定义Sizes

## 常见问题

### @atlas-viewer/iiif-image-api 是什么？

与IIIF Image API合作的一系列帮助者\.

### 如何安装 @atlas-viewer/iiif-image-api？

在项目目录运行 npm install @atlas-viewer/iiif-image-api，或使用 pnpm add / yarn add / bun add。

### @atlas-viewer/iiif-image-api 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @atlas-viewer/iiif-image-api 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @atlas-viewer/iiif-image-api 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.14\.1。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @atlas-viewer/iiif-image-api 可以商用吗？

@atlas-viewer/iiif-image-api 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @atlas-viewer/iiif-image-api 的下载量有多少？

根据 npm 官方下载统计，@atlas-viewer/iiif-image-api 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,543 次，日均约 118 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @atlas-viewer/iiif-image-api 还在维护吗？

最新版本 2\.2\.2 发布于 2025/03/24（1\.6 年前）；至今共发布 32 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/04/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

