Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions components/alttextify/actions/delete-image/delete-image.mjs
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;
},
};
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.",
},
},
async run({ $ }) {
const response = await this.alttextify.retrieveAltTextByAssetId({
$,
assetId: this.assetId,
});
$.export("$summary", `Successfully retrieved alt text by Asset ID: ${this.assetId}`);

return response;
},
};
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;
},
};
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

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 11 in components/alttextify/actions/submit-image-from-url/submit-image-from-url.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props
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",
],
},
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 components/alttextify/actions/submit-image/submit-image.mjs
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

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 13 in components/alttextify/actions/submit-image/submit-image.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop alert must have a description. See https://pipedream.com/docs/components/guidelines/#props
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)",
},
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}`,
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;
},
};
Loading
Loading