-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - alttextify #17029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - alttextify #17029
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b059d8
alttextify init
luancazarine 293d8cc
[Components] alttextify #16964
luancazarine a8e69b0
pnpm update
luancazarine a2f4c83
some adjusts
luancazarine 2c6370f
Update components/alttextify/actions/submit-image/submit-image.mjs
michelle0927 d32394b
some adjusts
luancazarine f048409
Merge branch 'master' into issue-16964
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
components/alttextify/actions/delete-image/delete-image.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import alttextify from "../../alttextify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "alttextify-delete-image", | ||
| name: "Delete Image Alt Text", | ||
| description: "Delete the generated alt text for a specific image using the asset ID. [See the documentation](https://apidoc.alttextify.net/#api-Image-DeleteImage)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| alttextify, | ||
| assetId: { | ||
| type: "string", | ||
| label: "Asset ID", | ||
| description: "The ID of the asset for retrieving or deleting alt text.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.alttextify.deleteAltTextByAssetId({ | ||
| $, | ||
| assetId: this.assetId, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully deleted alt text for asset ID: ${this.assetId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/alttextify/actions/get-alttext-by-asset-id/get-alttext-by-asset-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import alttextify from "../../alttextify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "alttextify-get-alttext-by-asset-id", | ||
| name: "Retrieve Alt Text by Asset ID", | ||
| description: "Retrieve alt text for a previously submitted image using the asset ID. [See the documentation](https://apidoc.alttextify.net/#api-Image-GetImageByAssetID)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| alttextify, | ||
| assetId: { | ||
| type: "string", | ||
| label: "Asset ID", | ||
| description: "The ID of the asset for retrieving alt text.", | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.alttextify.retrieveAltTextByAssetId({ | ||
| $, | ||
| assetId: this.assetId, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved alt text by Asset ID: ${this.assetId}`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/alttextify/actions/get-alttext-by-job-id/get-alttext-by-job-id.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import alttextify from "../../alttextify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "alttextify-get-alttext-by-job-id", | ||
| name: "Retrieve Alt Text by Job ID", | ||
| description: "Retrieve alt text for a previously submitted image using the job ID. [See the documentation](https://apidoc.alttextify.net/#api-Image-GetImagesByJobID)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| alttextify, | ||
| jobId: { | ||
| type: "string", | ||
| label: "Job ID", | ||
| description: "The ID of the job for retrieving alt text.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.alttextify.retrieveAltTextByJobId({ | ||
| $, | ||
| jobId: this.jobId, | ||
| }); | ||
| $.export("$summary", `Successfully retrieved alt text by Job ID: ${this.jobId}`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; |
107 changes: 107 additions & 0 deletions
107
components/alttextify/actions/submit-image-from-url/submit-image-from-url.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import alttextify from "../../alttextify.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "alttextify-submit-image-from-url", | ||
| name: "Submit Image from URL to Alttextify", | ||
| description: "Upload or submit an image URL to Alttextify for alt text generation. [See the documentation](https://apidoc.alttextify.net/#api-Image-UploadImageURL)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| alttextify, | ||
| alert: { | ||
|
Check warning on line 11 in components/alttextify/actions/submit-image-from-url/submit-image-from-url.mjs
|
||
| type: "alert", | ||
| alertType: "info", | ||
| content: "Supported formats: JPEG, PNG, GIF, WEBP, BMP\nMaximum file size: 16 MB\nMinimum dimensions: 50 x 50 (smaller images may not be able to generate alt text).", | ||
| }, | ||
| async: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "async", | ||
| ], | ||
| }, | ||
| image: { | ||
| type: "string", | ||
| label: "Image URL", | ||
| description: "The URL of the image to upload.", | ||
| }, | ||
| lang: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "lang", | ||
| ], | ||
| }, | ||
| maxChars: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "maxChars", | ||
| ], | ||
| }, | ||
| assetId: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "assetId", | ||
| ], | ||
| }, | ||
| keywords: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "keywords", | ||
| ], | ||
| }, | ||
| ecommerceRunOCR: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceRunOCR", | ||
| ], | ||
| }, | ||
| ecommerceProductName: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductName", | ||
| ], | ||
| }, | ||
| ecommerceProductBrand: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductBrand", | ||
| ], | ||
| }, | ||
| ecommerceProductColor: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductSize", | ||
| ], | ||
| }, | ||
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ecommerceProductSize: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductSize", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.alttextify.uploadImageFromUrl({ | ||
| $, | ||
| data: { | ||
| async: this.async, | ||
| image: this.image, | ||
| lang: this.lang, | ||
| maxChars: this.maxChars, | ||
| assetId: this.assetId, | ||
| keywords: this.keywords, | ||
| ecommerce: { | ||
| run_ocr: this.ecommerceRunOCR, | ||
| product: { | ||
| name: this.ecommerceProductName, | ||
| brand: this.ecommerceProductBrand, | ||
| color: this.ecommerceProductColor, | ||
| size: this.ecommerceProductSize, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully submitted image to Alttextify for alt text generation with Asset ID: ${response.asset_id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
112 changes: 112 additions & 0 deletions
112
components/alttextify/actions/submit-image/submit-image.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import fs from "fs"; | ||
| import alttextify from "../../alttextify.app.mjs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "alttextify-submit-image", | ||
| name: "Submit Image to Alttextify", | ||
| description: "Upload or submit an image to Alttextify for alt text generation. [See the documentation](https://apidoc.alttextify.net/#api-Image-UploadRawImage)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| alttextify, | ||
| alert: { | ||
|
Check warning on line 13 in components/alttextify/actions/submit-image/submit-image.mjs
|
||
| type: "alert", | ||
| alertType: "info", | ||
| content: "Supported formats: JPEG, PNG, GIF, WEBP, BMP\nMaximum file size: 16 MB\nMinimum dimensions: 50 x 50 (smaller images may not be able to generate alt text).", | ||
| }, | ||
| async: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "async", | ||
| ], | ||
| }, | ||
| image: { | ||
| type: "string", | ||
| label: "Image Path", | ||
| description: "The path to the image file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| lang: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "lang", | ||
| ], | ||
| }, | ||
| maxChars: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "maxChars", | ||
| ], | ||
| }, | ||
| assetId: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "assetId", | ||
| ], | ||
| }, | ||
| keywords: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "keywords", | ||
| ], | ||
| }, | ||
| ecommerceRunOCR: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceRunOCR", | ||
| ], | ||
| }, | ||
| ecommerceProductName: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductName", | ||
| ], | ||
| }, | ||
| ecommerceProductBrand: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductBrand", | ||
| ], | ||
| }, | ||
| ecommerceProductColor: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductColor", | ||
| ], | ||
| }, | ||
| ecommerceProductSize: { | ||
| propDefinition: [ | ||
| alttextify, | ||
| "ecommerceProductSize", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const imagePath = checkTmp(this.image); | ||
| const image = fs.readFileSync(imagePath, "base64"); | ||
|
|
||
| const response = await this.alttextify.uploadImage({ | ||
| $, | ||
| data: { | ||
| async: this.async, | ||
| image: `data:image/${imagePath.split(".")[1]};base64,${image}`, | ||
michelle0927 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| lang: this.lang, | ||
| maxChars: this.maxChars, | ||
| assetId: this.assetId, | ||
| keywords: this.keywords, | ||
| ecommerce: { | ||
| run_ocr: this.ecommerceRunOCR, | ||
| product: { | ||
| name: this.ecommerceProductName, | ||
| brand: this.ecommerceProductBrand, | ||
| color: this.ecommerceProductColor, | ||
| size: this.ecommerceProductSize, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully submitted image to Alttextify for alt text generation with Asset ID: ${response.asset_id}`); | ||
| return response; | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.