Skip to content

Commit b15412d

Browse files
author
SDKAuto
committed
CodeGen from PR 3481 in test-repo-billy/azure-rest-api-specs
Merge a4869b96d075273b7a6cf5e4a1e6637807235490 into c221294c903b4bcbe7b1ee4bce901322a7056943
1 parent 2d3de3e commit b15412d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+802
-2629
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 425 additions & 483 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/vision/ai-vision-image-analysis-rest/.eslintrc.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

sdk/vision/ai-vision-image-analysis-rest/CHANGELOG.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# Release History
2-
3-
## 1.0.0-beta.4 (Unreleased)
4-
5-
### Features Added
6-
1+
## 1.0.0-beta.1 (2024-08-22)
2+
73
### Breaking Changes
84

9-
### Bugs Fixed
10-
11-
### Other Changes
5+
- Operation AnalyzeFromImageData.post has a new signature
6+
- Operation AnalyzeFromImageData.post has a new signature
7+
8+
# Release History
129

1310
## 1.0.0-beta.3 (2024-07-18)
1411

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2024 Microsoft
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 20 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,196 +1,46 @@
1-
# Azure AI Vision Image Analysis client library for JavaScript
1+
# Azure ImageAnalysis REST client library for JavaScript
22

3-
The Image Analysis service provides AI algorithms for processing images and returning information about their content. In a single service call, you can extract one or more visual features from the image simultaneously, including getting a caption for the image, extracting text shown in the image (OCR) and detecting objects. For more information on the service and the supported visual features, see [Image Analysis overview][image_analysis_overview], and the [Concepts][image_analysis_concepts] page.
43

5-
Use the Image Analysis client library to:
6-
* Authenticate against the service
7-
* Set what features you would like to extract
8-
* Upload an image for analysis, or send an image URL
9-
* Get the analysis result
104

11-
[Product documentation][image_analysis_overview]
12-
| [Samples](https://aka.ms/azsdk/image-analysis/samples/js)
13-
| [Vision Studio][vision_studio]
14-
| [API reference documentation](https://aka.ms/azsdk/image-analysis/ref-docs/js)
15-
| [Package (npm)](https://aka.ms/azsdk/image-analysis/package/npm)
16-
| [SDK source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/vision/ai-vision-image-analysis-rest/src)
5+
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
6+
7+
Key links:
8+
9+
- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-vision-image-analysis)
10+
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-vision-image-analysis?view=azure-node-preview)
1711

1812
## Getting started
1913

2014
### Currently supported environments
2115

22-
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
23-
- Latest versions of Safari, Chrome, Edge, and Firefox.
24-
25-
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
16+
- LTS versions of Node.js
2617

2718
### Prerequisites
2819

29-
- An [Azure subscription](https://azure.microsoft.com/free).
30-
- A [Computer Vision resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision) in your Azure subscription.
31-
* You will need the key and endpoint from this resource to authenticate against the service.
32-
* You can use the free pricing tier (`F0`) to try the service, and upgrade later to a paid tier for production.
33-
* Note that in order to run Image Analysis with the `Caption` or `Dense Captions` features, the Azure resource needs to be from one of the following GPU-supported regions: `East US`, `France Central`, `Korea Central`, `North Europe`, `Southeast Asia`, `West Europe`, or `West US`.
20+
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
3421

3522
### Install the `@azure-rest/ai-vision-image-analysis` package
3623

37-
Install the Image Analysis client library for JavaScript with `npm`:
24+
Install the Azure ImageAnalysis REST client REST client library for JavaScript with `npm`:
3825

3926
```bash
4027
npm install @azure-rest/ai-vision-image-analysis
4128
```
4229

43-
### Browser support
44-
45-
#### JavaScript Bundle
46-
47-
To use this client library in the browser, first, you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
48-
49-
## Key concepts
50-
51-
Once you've initialized an `ImageAnalysisClient`, you need to select one or more visual features to analyze. The options are specified by the enum class `VisualFeatures`. The following features are supported:
52-
53-
1. `VisualFeatures.Caption`: ([Examples](#analyze-an-image-from-url) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/vision/ai-vision-image-analysis-rest/samples)) Generate a human-readable sentence that describes the content of an image.
54-
1. `VisualFeatures.Read`: ([Examples](#extract-text-from-an-image-url) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/vision/ai-vision-image-analysis-rest/samples)) Also known as Optical Character Recognition (OCR). Extract printed or handwritten text from images.
55-
1. `VisualFeatures.DenseCaptions`: Dense Captions provides more details by generating one-sentence captions for up to 10 different regions in the image, including one for the whole image.
56-
1. `VisualFeatures.Tags`: Extract content tags for thousands of recognizable objects, living beings, scenery, and actions that appear in images.
57-
1. `VisualFeatures.Objects`: Object detection. This is similar to tagging, but focused on detecting physical objects in the image and returning their location.
58-
1. `VisualFeatures.SmartCrops`: Used to find a representative sub-region of the image for thumbnail generation, with priority given to include faces.
59-
1. `VisualFeatures.People`: Locate people in the image and return their location.
60-
61-
For more information about these features, see [Image Analysis overview][image_analysis_overview], and the [Concepts][image_analysis_concepts] page.
62-
63-
### Supported image formats
64-
65-
Image Analysis works on images that meet the following requirements:
66-
67-
* The image must be presented in JPEG, PNG, GIF, BMP, WEBP, ICO, TIFF, or MPO format
68-
* The file size of the image must be less than 20 megabytes (MB)
69-
* The dimensions of the image must be greater than 50 x 50 pixels and less than 16,000 x 16,000 pixels
30+
### Create and authenticate a `ImageAnalysisClient`
7031

71-
### ImageAnalysisClient
32+
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token),
33+
provide an instance of the desired credential type obtained from the
34+
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library.
7235

73-
The `ImageAnalysisClient` is the primary interface for developers interacting with the Image Analysis service. It serves as the gateway from which all interaction with the library will occur.
36+
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity)
7437

75-
## Examples
38+
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use.
39+
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential)
40+
can be used to authenticate the client.
7641

77-
### Authenticate the client
78-
79-
Here's an example of how to create an `ImageAnalysisClient` instance using a key-based authentication.
80-
81-
82-
```javascript Snippet:const endpoint = "<your_endpoint>";
83-
const key = "<your_key>";
84-
const credential = new AzureKeyCredential(key);
85-
86-
const client = new ImageAnalysisClient(endpoint, credential);
87-
88-
const { ImageAnalysisClient } = require("@azure-rest/ai-vision-image-analysis");
89-
const { AzureKeyCredential } = require('@azure/core-auth');
90-
91-
const endpoint = "<your_endpoint>";
92-
const key = "<your_key>";
93-
const credential = new AzureKeyCredential(key);
94-
95-
const client = new ImageAnalysisClient(endpoint, credential);
96-
```
97-
98-
#### Create ImageAnalysisClient with a Microsoft Entra ID Credential
99-
100-
Client subscription key authentication is used in most of the examples in this getting started guide, but you can also authenticate with Microsoft Entra ID (formerly Azure Active Directory) using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][azure_identity_dac] provider shown below,
101-
or other credential providers provided with the Azure SDK, please install the Azure.Identity package:
102-
103-
```
104-
npm install @azure/identity
105-
```
106-
107-
```javascript Snippet:ImageAnalysisEntraIDAuth
108-
const endpoint = "<your_endpoint>";
109-
const credential = new DefaultAzureCredential();
110-
111-
const client = new ImageAnalysisClient(endpoint, credential);
112-
```
113-
### Analyze an image from URL
114-
115-
The following example demonstrates how to analyze an image using the Image Analysis client library for JavaScript.
116-
117-
```javascript Snippet:ImageAnalysisFromUrl
118-
const imageUrl = "https://example.com/image.jpg";
119-
const features = ["Caption", "DenseCaptions", "Objects", "People", "Read", "SmartCrops", "Tags"];
120-
121-
async function analyzeImageFromUrl() {
122-
const result = await client.path("/imageanalysis:analyze").post({
123-
body: {
124-
url: imageUrl,
125-
},
126-
queryParameters: {
127-
features: features,
128-
"smartCrops-aspect-ratios": [0.9, 1.33],
129-
},
130-
contentType: "application/json",
131-
});
132-
133-
console.log("Image analysis result:", result.body);
134-
}
135-
136-
analyzeImageFromUrl();
137-
```
138-
139-
### Analyze an image from a local file
140-
141-
In this example, we will analyze an image from a local file using the Image Analysis client library for JavaScript.
142-
143-
```javascript Snippet:ImageAnalysisFromLocalFile
144-
const fs = require("fs");
145-
146-
const imagePath = "./path/to/your/image.jpg";
147-
const features = ["Caption", "DenseCaptions", "Objects", "People", "Read", "SmartCrops", "Tags"];
148-
149-
async function analyzeImageFromFile() {
150-
const imageBuffer = fs.readFileSync(imagePath);
151-
152-
const result = await client.path("/imageanalysis:analyze").post({
153-
body: imageBuffer,
154-
queryParameters: {
155-
features: features,
156-
"smartCrops-aspect-ratios": [0.9, 1.33],
157-
},
158-
contentType: "application/octet-stream",
159-
});
160-
161-
console.log("Image analysis result:", result.body);
162-
}
163-
164-
analyzeImageFromFile();
165-
```
166-
167-
### Extract text from an image Url
168-
This example demonstrates how to extract printed or hand-written text for the image file [sample.jpg](https://aka.ms/azsdk/image-analysis/sample.jpg) using the ImageAnalysisClient. The method call returns an ImageAnalysisResult object. The ReadResult property on the returned object includes a list of text lines and a bounding polygon surrounding each text line. For each line, it also returns a list of words in the text line and a bounding polygon surrounding each word.
169-
``` javascript Snippet:readmeText
170-
const client: ImageAnalysisClient = createImageAnalysisClient(endpoint, credential);
171-
172-
const features: string[] = [
173-
'Read'
174-
];
175-
176-
const imageUrl: string = 'https://aka.ms/azsdk/image-analysis/sample.jpg';
177-
178-
client.path('/imageanalysis:analyze').post({
179-
body: { url: imageUrl },
180-
queryParameters: { features: features },
181-
contentType: 'application/json'
182-
}).then(result => {
183-
const iaResult: ImageAnalysisResultOutput = result.body as ImageAnalysisResultOutput;
184-
185-
// Process the response
186-
if (iaResult.readResult && iaResult.readResult.blocks.length > 0) {
187-
iaResult.readResult.blocks.forEach(block => {
188-
console.log(`Detected text block: ${JSON.stringify(block)}`);
189-
});
190-
} else {
191-
console.log('No text blocks detected.');
192-
}
193-
```
42+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
43+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
19444

19545
## Troubleshooting
19646

@@ -205,19 +55,3 @@ setLogLevel("info");
20555
```
20656

20757
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
208-
209-
## Next steps
210-
211-
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/vision/ai-vision-image-analysis-rest/samples) directory for detailed examples that demonstrate how to use the client libraries.
212-
213-
## Contributing
214-
215-
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
216-
217-
## Related projects
218-
219-
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
220-
221-
[image_analysis_overview]: https://learn.microsoft.com/azure/ai-services/computer-vision/overview-image-analysis?tabs=4-0
222-
[image_analysis_concepts]: https://learn.microsoft.com/azure/ai-services/computer-vision/concept-tag-images-40
223-
[vision_studio]: https://aka.ms/vision-studio/image-analysis

sdk/vision/ai-vision-image-analysis-rest/api-extractor.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"mainEntryPointFilePath": "./types/src/index.d.ts",
3+
"mainEntryPointFilePath": "./dist/esm/index.d.ts",
44
"docModel": {
55
"enabled": true
66
},
@@ -28,4 +28,4 @@
2828
}
2929
}
3030
}
31-
}
31+
}

sdk/vision/ai-vision-image-analysis-rest/assets.json

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
2+
3+
export default [
4+
...azsdkEslint.configs.recommended,
5+
{
6+
rules: {
7+
"@azure/azure-sdk/ts-modules-only-named": "warn",
8+
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
9+
"@azure/azure-sdk/ts-package-json-types": "warn",
10+
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
11+
"@azure/azure-sdk/ts-package-json-module": "off",
12+
"@azure/azure-sdk/ts-package-json-files-required": "off",
13+
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off",
14+
"tsdoc/syntax": "warn"
15+
}
16+
}
17+
];

0 commit comments

Comments
 (0)