ugcinc 4.23.0 → 4.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -1
- package/dist/media-analysis.d.ts +4458 -1638
- package/dist/media-analysis.js +31 -2
- package/dist/media.d.ts +5 -2
- package/dist/media.js +10 -1
- package/dist/render/compositions/IMessageDmComposition/types.d.ts +2 -2
- package/dist/tools/media.js +3 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -398,3 +398,54 @@ const excerpt = await client.media.transcribeAudio({url: videoUrl, range: {start
|
|
|
398
398
|
Both operations accept mono/stereo8–192kHz, source files<=100MiB and source duration<=30minutes. Each request covers at most120seconds; larger sources require an explicit smaller range. Range end is exclusive. Times are relative to the first displayed video frame, or the first decoded audio frame for audio-only files. Original audio PTS/timebase, audio offset, native channel layout and source hash are retained. Coverage distinguishes intervals with audio from video intervals without an audio stream; missing audio is not measured silence. Boundaries are rounded inward to decoded samples with the tolerance reported. Unsupported discontinuous audio timestamps fail explicitly. No source gain normalization is applied to level measurement.
|
|
399
399
|
|
|
400
400
|
Both return `ApiResponse<MediaAnalysisJob>`, with the existing polling behavior and `getMediaAnalysis({jobId})` continuation. Owned JSON manifests retain results. Failed jobs never return incomplete analysis as complete. Recognition can miss words under music/overlap; timing precision and recognition accuracy must be evaluated separately.
|
|
401
|
+
|
|
402
|
+
### Image colors and layout
|
|
403
|
+
|
|
404
|
+
Quick reference: `client.media.sampleColors({url})`, `client.media.measureLayout({url, elements})`; tools `sample_colors`, `measure_layout`. Both return analysis jobs; poll `client.media.getMediaAnalysis({jobId})` if still pending.
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
const colors = await client.media.sampleColors({url: imageUrl, point: {x: 20, y: 30}});
|
|
408
|
+
const palette = await client.media.sampleColors({url: imageUrl, box: {x: 10, y: 20, width: 200, height: 100}, maxColors: 8});
|
|
409
|
+
const layout = await client.media.measureLayout({url: imageUrl, elements: [
|
|
410
|
+
{id: 'headline', box: {x: 40, y: 60, width: 600, height: 100}},
|
|
411
|
+
{id: 'face', box: {x: 160, y: 200, width: 360, height: 500}},
|
|
412
|
+
]});
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
`POST /media/analysis/sample-colors`: HTTPS image URL, optional **one** of integer `point`, `box`, or `mask`; omitted selector samples the whole image. `maxColors` defaults to 8, range 1–32. Coordinates refer to display-oriented source pixels after EXIF orientation. Boxes are continuous half-open rectangles and include pixel centers. The point returns straight RGBA bytes. Palettes exclude transparent pixels and weight partial alpha by alpha/255. If observed unique colors fit the limit, returns exact colors; otherwise returns the most populated 5-bit sRGB bins with alpha-weighted mean RGB, rounded to bytes. Proportions always use all selected alpha mass; `otherProportion` reports unreturned bins. Means are in encoded sRGB, not linear light. Empty or fully transparent selections return an empty palette. This measures decoded pixels, not guaranteed original design hex values, especially after compression or antialiasing.
|
|
416
|
+
|
|
417
|
+
`POST /media/analysis/measure-layout`: HTTPS image URL plus 1–32 `elements`, each with a unique `id` (1–80 characters) and either `box` or `mask`. Returns bounds, normalized bounds, canvas margins, box centers, mask area and visible centroid, plus pairwise alignment deltas (B minus A), signed axis gaps, box intersection/IoU and mask intersection/IoU. Positive gap means separated, zero touching, negative means interval intersection length. Box area is not visible subject area: visible measurements are null without masks, and visible intersections require two masks. Empty masks have zero area and null bounds/centroids. This tool measures supplied geometry; it does not find elements or judge design intent. Preview numbers correspond to input element order.
|
|
418
|
+
|
|
419
|
+
Masks for either tool are `{width, height, counts}` matching the full display-oriented image dimensions. `counts` is **row-major** binary run-length encoding, alternating background/foreground starting with background; only the first count may be zero. Runs sum to width×height; maximum 100,000 runs total per request. This is not COCO's column-major encoding. Mask pixel centers determine centroids; each included pixel contributes one square pixel of area, regardless of source alpha.
|
|
420
|
+
|
|
421
|
+
Both tools accept single-frame PNG (up to 8-bit channels), JPEG and WebP, at most 4096 pixels per side and the shared 100MiB download limit. Embedded ICC profiles convert to sRGB using relative-colorimetric intent; untagged RGB/grayscale assumes sRGB. Unsupported/invalid profiles, untagged CMYK, unsupported bit depth/mode, animation, mismatched masks and out-of-bounds geometry fail explicitly. No resizing precedes measurement. Results include source byte hash, color/coordinate policies, a bounded annotated preview and JSON manifest. No model or hosted inference is used.
|
|
422
|
+
|
|
423
|
+
### Match text style
|
|
424
|
+
|
|
425
|
+
Quick reference: `client.media.matchTextStyle({url, box, text?})`; agent tool `match_text_style`. `POST /media/analysis/match-text-style` submits the same authenticated analysis-job flow. Poll `getMediaAnalysis` if the SDK returns a pending/processing job.
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
const match = await client.media.matchTextStyle({
|
|
429
|
+
url: referenceImageUrl,
|
|
430
|
+
box: {x: 20, y: 30, width: 700, height: 200},
|
|
431
|
+
text: 'Build better habits\nSleep well tonight', // optional; preserves intended line breaks
|
|
432
|
+
});
|
|
433
|
+
if (match.ok && match.data.result?.operation === 'match_text_style') {
|
|
434
|
+
const candidate = match.data.result.candidates[0];
|
|
435
|
+
if (candidate) {
|
|
436
|
+
// candidate.element uses original source coordinates.
|
|
437
|
+
// candidate.previewConfig is a complete crop-sized ImageEditorNodeConfig.
|
|
438
|
+
const rendered = await submitImageRenderJob({
|
|
439
|
+
config: candidate.previewConfig, imageUrls: {}, textValues: {},
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
The existing `submitImageRenderJob` server SDK function requires your configured `UGC_RENDER_URL`; matching itself uses the authenticated public API. Returned `surface: 'image-editor-element'` settings use the real `font`, `outlineWidth`, `textAlign` and positioning properties, with a compatible `previewConfig` ready for the supported image renderer. `element` coordinates refer to the source image; preview-config coordinates refer to the selected crop. Do not mix these coordinate spaces.
|
|
446
|
+
|
|
447
|
+
Inputs: HTTPS image URL and integer display-oriented pixel `box` with a small plain-background margin around one text block. Crop width16–1536, height16–512. Optional exact `text` supports 1–160 printable ASCII characters and up to four lines. Without text, local English OCR supplies the text and line breaks; unreadable/unsupported recognition returns `status: 'unavailable'` with a reason. Source-image size/type/color constraints match color/layout analysis. Transparency is composited over white for fitting.
|
|
448
|
+
|
|
449
|
+
Fitting runs locally through the installed UGC ImageEditorComposition, searching the supported TikTok Sans, SF Pro and Arial-stack choices, weight, size, spacing, line height, alignment and outline. Fill/background/outline colors are estimated from the crop. Arial may use a system fallback; original font identity is always `unverified`. No custom font upload, gradients, perspective, mixed styles, emoji or shadow setting is inferred. Busy borders, blank crops and clipped foreground return explicit unavailable results. These checks do not prove that every remaining crop is suitable: inspect residuals and preview.
|
|
450
|
+
|
|
451
|
+
Returns up to three candidates, renderable settings, `maskIoU`, `foregroundMae` (mean absolute RGB error on the union of reference/rendered ink, scaled0–1), and an owned reference/render/difference preview plus JSON manifest. `quality: 'close'` means IoU>=0.9 and foreground MAE<=0.1; otherwise `approximate`. These are image-fit measures, not font-recognition probabilities or content-quality scores. Single-line alignment/padding cannot be uniquely recovered; returned geometry reproduces visible positioning. Render count, installed UGC version and bundled font hashes are included. Search is capped at320 renders and a480-second search budget within existing job limits; resource failures are explicit failed jobs. The renderer bundle is reused unchanged, with no hosted inference or new font downloads.
|
package/dist/index.d.ts
CHANGED
|
@@ -86,5 +86,5 @@ export type { SuccessResponse, ErrorResponse, ApiResponse, } from './types';
|
|
|
86
86
|
export type { CropBoundary, CropAxisConfig, DynamicCropConfig, BorderRadiusConfig, VerticalAnchor, HorizontalAnchor, HorizontalSelfAnchor, VerticalSelfAnchor, RelativePositionConfigX, RelativePositionConfigY, } from './render/types';
|
|
87
87
|
export type { PublicPostFailureCode, PublicPostRecovery, PublicPostNextAction, PublicPostFailure } from './post-failure';
|
|
88
88
|
export type { ListProfilePostsParams, ListProfilePostsResult, DownloadSocialPostParams, DownloadSocialPostResult, SocialReferencePost, SocialReferenceAsset } from './social-acquisition';
|
|
89
|
-
export type { TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
|
|
90
|
-
export { transcribeAudioSchema, measureAudioLevelsSchema, audioTranscriptResultSchema, audioLevelsResultSchema, readImageTextSchema, readVideoTextSchema, imageTextResultSchema, videoTextResultSchema, extractFramesSchema, detectScenesSchema, mediaAnalysisStatusSchema, mediaAnalysisResultSchema } from "./media-analysis";
|
|
89
|
+
export type { MatchTextStyleParams, MatchTextStyleResult, SampleColorsParams, MeasureLayoutParams, SampleColorsResult, MeasureLayoutResult, TranscribeAudioParams, MeasureAudioLevelsParams, AudioTranscriptResult, AudioLevelsResult, ReadImageTextParams, ReadVideoTextParams, ImageTextResult, VideoTextResult, ExtractFramesParams, DetectScenesParams, FramesResult, ScenesResult, MediaAnalysisResult, MediaAnalysisJob } from "./media-analysis";
|
|
90
|
+
export { matchTextStyleSchema, matchTextStyleResultSchema, sampleColorsSchema, measureLayoutSchema, sampleColorsResultSchema, measureLayoutResultSchema, binaryMaskSchema, transcribeAudioSchema, measureAudioLevelsSchema, audioTranscriptResultSchema, audioLevelsResultSchema, readImageTextSchema, readVideoTextSchema, imageTextResultSchema, videoTextResultSchema, extractFramesSchema, detectScenesSchema, mediaAnalysisStatusSchema, mediaAnalysisResultSchema } from "./media-analysis";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.hasMissingTriggerError = exports.getPortErrorsForNode = exports.getErrorNodeIds = exports.validateWorkflow = exports.getCapturedNodes = exports.getNodesDownstreamOfSet = exports.getDownstreamNodes = exports.checkCrossContextViolation = exports.getForEachContext = exports.getConnectedSource = exports.cleanupStaleConnections = exports.removeNodeConnections = exports.removeConnection = exports.addConnection = exports.deriveConnections = exports.createNode = exports.getOutputSchema = exports.getNodeByType = exports.getAllNodes = exports.getInputPreviewValue = exports.computeAllNodePortsWithPreviews = exports.computeAllNodePorts = exports.computePortsWithPreviews = exports.computePortsForNode = exports.areTypesCompatible = exports.parseRemotionPropsJson = exports.REMOTION_COMPOSITION_IMPORTS = exports.remotionCompositionPortSchema = exports.remotionCompositionNodeSchema = exports.remotionCompositionSchema = exports.submitIMessageDmRenderJob = exports.submitInstagramDmRenderJob = exports.submitAutoCaptionRenderJob = exports.submitRemotionCompositionRenderJob = exports.submitScreenshotAnimationRenderJob = exports.submitSceneSplitJob = exports.submitDeduplicationJob = exports.getRenderJobStatus = exports.submitVideoRenderJob = exports.submitImageRenderJob = exports.BillingClient = exports.CommentsClient = exports.MediaClient = exports.AutomationsClient = exports.OrganizationClient = exports.StatsClient = exports.PostsClient = exports.TasksClient = exports.AccountsClient = exports.UGCClient = void 0;
|
|
9
9
|
exports.parseOpenAPIOutputPath = exports.parseOpenAPIInputs = exports.mapOpenAPIType = exports.nodeConfigToCaptionStyle = exports.HttpMethods = exports.prepareImageComposerInput = exports.substituteVariables = exports.processTemplate = exports.extractTemplateVariables = exports.PortIdSchema = exports.normalizeToPortId = exports.portIdToTitle = exports.isValidPortId = exports.portId = exports.selectFromPool = exports.getModelDurations = exports.getModelAspectRatios = exports.ALL_VIDEO_MODELS = exports.getAvailableInputModes = exports.hasReferenceVariant = exports.getReferenceModelId = exports.hasFirstLastFrameVariant = exports.getFirstLastFrameModelId = exports.hasImageToVideoVariant = exports.getImageToVideoModelId = exports.isImageToVideoModel = exports.IMAGE_ASPECT_RATIOS = exports.ALL_IMAGE_MODELS = exports.getEditModelId = exports.isEditModel = exports.getCapturedSourceNodeTypes = exports.getFlowControlNodeTypes = exports.getAllNodeDefinitions = exports.getNodeDefinition = exports.isPortType = exports.formatPortType = exports.isAsyncExecutor = exports.internalNodeTypes = exports.nodeDefinitions = exports.extractWorkflowConfig = exports.generateNodeName = exports.shuffleNodePreview = exports.getPreviewValue = exports.removePreviewForConnection = exports.updatePreviewMapForConnection = exports.computePreviewMap = exports.computeAllNodePreviews = exports.resolveNodePreview = exports.getWorkflowOutputSchema = exports.hasMissingTerminalError = void 0;
|
|
10
|
-
exports.mediaAnalysisResultSchema = exports.mediaAnalysisStatusSchema = exports.detectScenesSchema = exports.extractFramesSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.audioLevelsResultSchema = exports.audioTranscriptResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.prepareVideoComposerInput = exports.formatDateTag = exports.outputFieldsToZod = exports.outputFieldToZod = exports.LLMProviders = exports.applyLogicOperator = exports.IfLogicOperators = exports.resolvePath = exports.indexExpressionToString = exports.indexExpressionToIndexes = exports.resolveUnknownPath = exports.getOutputTypeFromCategory = void 0;
|
|
10
|
+
exports.mediaAnalysisResultSchema = exports.mediaAnalysisStatusSchema = exports.detectScenesSchema = exports.extractFramesSchema = exports.videoTextResultSchema = exports.imageTextResultSchema = exports.readVideoTextSchema = exports.readImageTextSchema = exports.audioLevelsResultSchema = exports.audioTranscriptResultSchema = exports.measureAudioLevelsSchema = exports.transcribeAudioSchema = exports.binaryMaskSchema = exports.measureLayoutResultSchema = exports.sampleColorsResultSchema = exports.measureLayoutSchema = exports.sampleColorsSchema = exports.matchTextStyleResultSchema = exports.matchTextStyleSchema = exports.prepareVideoComposerInput = exports.formatDateTag = exports.outputFieldsToZod = exports.outputFieldToZod = exports.LLMProviders = exports.applyLogicOperator = exports.IfLogicOperators = exports.resolvePath = exports.indexExpressionToString = exports.indexExpressionToIndexes = exports.resolveUnknownPath = exports.getOutputTypeFromCategory = void 0;
|
|
11
11
|
// =============================================================================
|
|
12
12
|
// Client Exports
|
|
13
13
|
// =============================================================================
|
|
@@ -175,6 +175,13 @@ Object.defineProperty(exports, "formatDateTag", { enumerable: true, get: functio
|
|
|
175
175
|
var video_composer_1 = require("./automations/nodes/video-composer");
|
|
176
176
|
Object.defineProperty(exports, "prepareVideoComposerInput", { enumerable: true, get: function () { return video_composer_1.prepareVideoComposerInput; } });
|
|
177
177
|
var media_analysis_1 = require("./media-analysis");
|
|
178
|
+
Object.defineProperty(exports, "matchTextStyleSchema", { enumerable: true, get: function () { return media_analysis_1.matchTextStyleSchema; } });
|
|
179
|
+
Object.defineProperty(exports, "matchTextStyleResultSchema", { enumerable: true, get: function () { return media_analysis_1.matchTextStyleResultSchema; } });
|
|
180
|
+
Object.defineProperty(exports, "sampleColorsSchema", { enumerable: true, get: function () { return media_analysis_1.sampleColorsSchema; } });
|
|
181
|
+
Object.defineProperty(exports, "measureLayoutSchema", { enumerable: true, get: function () { return media_analysis_1.measureLayoutSchema; } });
|
|
182
|
+
Object.defineProperty(exports, "sampleColorsResultSchema", { enumerable: true, get: function () { return media_analysis_1.sampleColorsResultSchema; } });
|
|
183
|
+
Object.defineProperty(exports, "measureLayoutResultSchema", { enumerable: true, get: function () { return media_analysis_1.measureLayoutResultSchema; } });
|
|
184
|
+
Object.defineProperty(exports, "binaryMaskSchema", { enumerable: true, get: function () { return media_analysis_1.binaryMaskSchema; } });
|
|
178
185
|
Object.defineProperty(exports, "transcribeAudioSchema", { enumerable: true, get: function () { return media_analysis_1.transcribeAudioSchema; } });
|
|
179
186
|
Object.defineProperty(exports, "measureAudioLevelsSchema", { enumerable: true, get: function () { return media_analysis_1.measureAudioLevelsSchema; } });
|
|
180
187
|
Object.defineProperty(exports, "audioTranscriptResultSchema", { enumerable: true, get: function () { return media_analysis_1.audioTranscriptResultSchema; } });
|