How to Call the DreamStudio API in Pipedream?

I apologize for the confusion earlier. Here’s the continuation of the corrected and complete code for the Pipedream component: (error, response) => { if (error) { reject(error); } else { resolve(response); } }); // Wait for the upload to complete const uploadedImage = await result; // Return the uploaded image URL return { upscaledImageUrl: uploadedImage.url, }; ```
}, });

To push an image URL to BannerBear, you can use the “Create an Image” action in Pipedream. Here’s how to do it: 1. In your Pipedream workflow, search for the Bannerbear app from the step menu. 2. Select the “Create an Image” action. 3. Connect your Bannerbear account. 4. Set the “Template” field to “V4WN6JDx0w2ND3Gqjk” or use the appropriate template UID. 5. For the “Modifications” field, pass the following JSON, replacing <YOUR_IMAGE_URL> with the URL path from the previous step: ```
on [ { “name”: “image_container_rectangle_2”, “image_url”: “<YOUR_IMAGE_URL>” }, { “name”: “rectangle_4 Duplicate 5”, “color”: null }, { “name”: “Book_Title”, “text”: “You can change this text”, “color”: null, “background”: null }, { “name”: “Author Name”, “text”: “You can change this text”, “color”: null, “background”: null } ]

It looks like you’re using the “on” keyword at the beginning of your JSON object, which is causing the configuration error. Please remove the “on” keyword and try again. Your “Modifications” should look like this: ```
on [ { “name”: “image_container_rectangle_2”, “image_url”: “{{steps.Send_to_ImageKit.$return_value.finalImageUrl}}” }, { “name”: “rectangle_4 Duplicate 5”, “color”: null }, { “name”: “Book_Title”, “text”: “{{steps.trigger.event.newRow[0]}}”, “color”: null, “background”: null }, { “name”: “Author Name”, “text”: “Paige Turner”, “color”: null, “background”: null } ]

Did not manage to get the upscaler working at all – but that’s okay. I am now working without it.

My next step is to use the imagga API to pull the color profile for images. Here is the info:

/colors
GET Request:
curl --user “acc_62606e731a1ac79:03acd65c496f9abf46b0c0ab86c2c13a” “https://api.imagga.com/v2/colors?image_url=https://imagga.com/static/images/tagging/wind-farm-538576_640.jpg
POST Request:
curl --user “acc_62606e731a1ac79:03acd65c496f9abf46b0c0ab86c2c13a” -F “image=@/path/to/image.jpg” “https://api.imagga.com/v2/colors
Example Response:
{
“result”: {
“colors”: {
“background_colors”: [
{
“b”: 47,
“closest_palette_color”: “light bronze”,
“closest_palette_color_html_code”: “#8C5E37”,
“closest_palette_color_parent”: “skin”,
“closest_palette_distance”: 1.70506228322597,
“g”: 92,
“html_code”: “#8C5C2F”,
“percent”: 48.0033950805664,
“r”: 140
},
{
“b”: 146,
“closest_palette_color”: “cerulean”,
“closest_palette_color_html_code”: “#0074A8”,
“closest_palette_color_parent”: “blue”,
“closest_palette_distance”: 5.53350780052479,
“g”: 116,
“html_code”: “#467492”,
“percent”: 39.0454025268555,
“r”: 70
},
{
“b”: 30,
“closest_palette_color”: “dark bronze”,
“closest_palette_color_html_code”: “#542E0C”,
“closest_palette_color_parent”: “skin”,
“closest_palette_distance”: 5.47689735887696,
“g”: 48,
“html_code”: “#4F301E”,
“percent”: 12.9512014389038,
“r”: 79
}
],
“color_percent_threshold”: 1.75,
“color_variance”: 36,
“foreground_colors”: [
{
“b”: 147,
“closest_palette_color”: “larkspur”,
“closest_palette_color_html_code”: “#6E7E99”,
“closest_palette_color_parent”: “blue”,
“closest_palette_distance”: 8.60114706674971,
“g”: 125,
“html_code”: “#577D93”,
“percent”: 52.3429222106934,
“r”: 87
},
{
“b”: 145,
“closest_palette_color”: “pewter”,
“closest_palette_color_html_code”: “#84898C”,
“closest_palette_color_parent”: “grey”,
“closest_palette_distance”: 1.75501013175431,
“g”: 142,
“html_code”: “#898E91”,
“percent”: 30.0293598175049,
“r”: 137
},
{
“b”: 42,
“closest_palette_color”: “brownie”,
“closest_palette_color_html_code”: “#584039”,
“closest_palette_color_parent”: “brown”,
“closest_palette_distance”: 4.99189248709017,
“g”: 58,
“html_code”: “#593A2A”,
“percent”: 17.6277160644531,
“r”: 89
}
],
“image_colors”: [
{
“b”: 146,
“closest_palette_color”: “cerulean”,
“closest_palette_color_html_code”: “#0074A8”,
“closest_palette_color_parent”: “blue”,
“closest_palette_distance”: 7.85085588656478,
“g”: 121,
“html_code”: “#547992”,
“percent”: 48.3686981201172,
“r”: 84
},
{
“b”: 46,
“closest_palette_color”: “light bronze”,
“closest_palette_color_html_code”: “#8C5E37”,
“closest_palette_color_parent”: “skin”,
“closest_palette_distance”: 3.05634270891355,
“g”: 86,
“html_code”: “#83562E”,
“percent”: 47.9353446960449,
“r”: 131
},
{
“b”: 46,
“closest_palette_color”: “navy blue”,
“closest_palette_color_html_code”: “#2B2E43”,
“closest_palette_color_parent”: “navy blue”,
“closest_palette_distance”: 6.62790662069936,
“g”: 27,
“html_code”: “#1F1B2E”,
“percent”: 3.60131478309631,
“r”: 31
}
],
“object_percentage”: 20.790994644165
}
},
“status”: {
“text”: “”,
“type”: “success”
}
}
Analyse and extract the predominant colors from images.

GET https://api.imagga.com/v2/colors

Query Parameters
Parameter Description
image_url Image URL to perform color-extraction on.
image_upload_id You can also directly send image files for color-extraction by uploading them to our /uploads endpoint and then providing the received content identifiers via this parameter.
extract_overall_colors (default: 1) Specify whether the overall image colors should be extracted. The possible values are 1 for 'yes’, and 0 for 'no’.
extract_object_colors (default: 1) Specify if the service should try to extract object and non-object (a.k.a. foreground and background) colors separately. The possible values are 1 for 'yes’, and 0 for 'no’.
overall_count (default: 5) Specify the number of overall image colors the service should try to extract.
separated_count (default: 3) Specify the number of separated colors (foreground and background) the service should try to extract.
deterministic (default: 0) Whether or not to use a deterministic algorithm to extract the colors of the image.
save_index (optional) The index name in which you wish to save this image for searching later on. This parameter require you to also use deterministic algorithm.
save_id (optional) The id with which you wish to associate your image when putting it in a search index. This will be the identificator which will be returned to you when searching for similar images. (If you send an image with an already existing id, it will be overriden as if an update operation took place. Consider this when choosing your ids.) - In order for the image to be present in the search index later on, you need to train it with the /similar-images/colors/<index_id>(/<entry_id>) endpoint
features_type (overall or object) extract color information from foreground object(value: object) or overall image(value: overall) to use for comparison with other photos when using a search index.

Can you please help me write a POST request for Imagga?

I apologize for any confusion earlier. To help you with the Imagga API, I’ll provide you with a Pipedream component that makes a POST request to the /colors endpoint using an image file. First, make sure you have connected your Imagga account to Pipedream. Then, use the following component: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageFile: { type: "string", label: "Path to Image File", }, }, async run({ steps, $ }) { const formData = new FormData(); formData.append("image", fs.createReadStream(this.imageFile)); const response = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: { "Content-Type": "multipart/form-data", }, data: formData, }); return response; }, }); Make sure to replace this.imageFile with the path to your image file. This component will make a POST request to the Imagga /colors endpoint and return the color profile for the image.

I apologize for the oversight in my previous response. It seems I missed importing the fs module. Here’s the corrected Pipedream component code: import { axios } from "@pipedream/platform"; import fs from "fs"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageFile: { type: "string", label: "Path to Image File", }, }, async run({ steps, $ }) { const formData = new FormData(); formData.append("image", fs.createReadStream(this.imageFile)); const response = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: { "Content-Type": "multipart/form-data", }, data: formData, }); return response; }, }); Make sure to replace this.imageFile with the path to your image file. This component will make a POST request to the Imagga /colors endpoint and return the color profile for the image.

when I try to run this code, I get this:

Pipedream Internal Error
Please retry your event or reach out to Pipedream support at https://pipedream.com/support/

I apologize for the issue you’re experiencing. It’s difficult for me to diagnose the problem without more information about your workflow and the specific code you’re trying to run. Could you please provide more details about the code you’re using and any specific error messages you’re encountering? This will help me better understand the issue and provide a solution. If you continue to experience issues, please reach out to Pipedream support at https://pipedream.com/support for further assistance.

I am getting an internal server error from this code:

import { axios } from@pipedream/platform”;
import fs from “fs”;

export default defineComponent({
props: {
imagga: {
type: “app”,
app: “imagga”,
},
imageFile: {
type: “string”,
label: “Path to Image File”,
},
},
async run({ steps, $ }) {
const formData = new FormData();
formData.append(“image”, fs.createReadStream(this.imageFile));

**const** response = **await** axios($, {
  method: "POST",
  url: "https://api.imagga.com/v2/colors",
  auth: {
    username: `${**this**.imagga.$auth.api_key}`,
    password: `${**this**.imagga.$auth.api_secret}`,
  },
  headers: {
    "Content-Type": "multipart/form-data",
  },
  data: formData,
});

**return** response;

},
});

I apologize for the confusion earlier. It seems that the issue is related to the missing FormData import. In Node.js, you can use the form-data package to handle form data. Please install the package by adding this import at the beginning of your code: import FormData from "form-data"; Here’s the updated Pipedream component code: import { axios } from "@pipedream/platform"; import fs from "fs"; import FormData from "form-data"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageFile: { type: "string", label: "Path to Image File", }, }, async run({ steps, $ }) { const formData = new FormData(); formData.append("image", fs.createReadStream(this.imageFile)); const response = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: { "Content-Type": "multipart/form-data", }, data: formData.getBuffer(), headers: formData.getHeaders(), }); return response; }, }); This updated component should resolve the internal server error. Make sure to replace this.imageFile with the path to your image file.

Error:

TypeError
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of DelayedStream
DETAILS

    at null.__node_internal_captureLargerStackTrace (node:internal/errors:490:5)
    at null.NodeError (node:internal/errors:399:5)
    at Function.from (node:buffer:339:9)
    at FormData.FormData.getBuffer (/tmp/__pdg__/dist/code/fa9d420629f3e3a7bd4a946f33c20b32a64c0ea8018294d7c5fa66578ecb9f6c/node_modules/.pnpm/form-data@4.0.0/node_modules/form-data/lib/form_data.js:333:57)
    at Object.run (file:///tmp/__pdg__/dist/code/fa9d420629f3e3a7bd4a946f33c20b32a64c0ea8018294d7c5fa66578ecb9f6c/component.mjs:30:22)
    at null.executeComponent (/var/task/launch_worker.js:229:53)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the confusion earlier. It seems the issue is related to using formData.getBuffer() which is not the correct way to send the form data with axios. Instead, you should pass the formData directly as the data property and use formData.getHeaders() for the headers. Here’s the updated code: import { axios } from "@pipedream/platform"; import fs from "fs"; import FormData from "form-data"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageFile: { type: "string", label: "Path to Image File", }, }, async run({ steps, $ }) { const formData = new FormData(); formData.append("image", fs.createReadStream(this.imageFile)); const response = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: formData.getHeaders(), data: formData, }); return response; }, }); This updated component should resolve the error. Make sure to replace this.imageFile with the path to your image file.

I see the issue now. The error is occurring because the code is trying to read the image file from the local file system, but the image is actually hosted on a remote server. To fix this, you’ll need to download the image first and then pass it to the FormData. Here’s the updated code: import { axios } from "@pipedream/platform"; import fs from "fs"; import FormData from "form-data"; import stream from "stream"; import { promisify } from "util"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageUrl: { type: "string", label: "Image URL", }, }, async run({ steps, $ }) { const pipeline = promisify(stream.pipeline); const response = await axios($, { method: "GET", url: this.imageUrl, responseType: "stream", }); const tempFile = `/tmp/temp-image-${Date.now()}.png`; await pipeline(response.data, fs.createWriteStream(tempFile)); const formData = new FormData(); formData.append("image", fs.createReadStream(tempFile)); const colorsResponse = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: formData.getHeaders(), data: formData, }); return colorsResponse; }, }); This updated component should resolve the error. Make sure to replace this.imageUrl with the URL of your image.

TypeError
The “body” argument must be of type function or an instance of Blob, ReadableStream, WritableStream, Stream, Iterable, AsyncIterable, or Promise or { readable, writable } pair. Received undefined
DETAILS

    at null.__node_internal_captureLargerStackTrace (node:internal/errors:490:5)
    at null.NodeError (node:internal/errors:399:5)
    at null.duplexify (node:internal/streams/duplexify:199:9)
    at Function.Duplex.from (node:internal/streams/duplex:146:10)
    at null.pipelineImpl (node:internal/streams/pipeline:292:22)
    at null.null (node:stream/promises:31:5)
    at null.Promise (null:null:null)
    at null.pipeline (node:stream/promises:20:10)
    at Object.run (file:///tmp/__pdg__/dist/code/6e9d8f405fa207a88570ae016e22d08453a88aa7ba5fe9e2bd93281ceed6c2c6/component.mjs:27:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at null.executeComponent (/var/task/launch_worker.js:229:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:726:28)

I apologize for the confusion earlier. It seems there’s an issue with the way the image is being passed to FormData. Let’s try a different approach using axios to download the image as a Buffer and then append it to FormData. Here’s the updated code: import { axios } from "@pipedream/platform"; import fs from "fs"; import FormData from "form-data"; export default defineComponent({ props: { imagga: { type: "app", app: "imagga", }, imageUrl: { type: "string", label: "Image URL", }, }, async run({ steps, $ }) { const response = await axios($, { method: "GET", url: this.imageUrl, responseType: "arraybuffer", }); const imageBuffer = Buffer.from(response.data, "binary"); const formData = new FormData(); formData.append("image", imageBuffer, { filename: "image.png", contentType: "image/png", }); const colorsResponse = await axios($, { method: "POST", url: "https://api.imagga.com/v2/colors", auth: { username: `${this.imagga.$auth.api_key}`, password: `${this.imagga.$auth.api_secret}`, }, headers: formData.getHeaders(), data: formData, }); return colorsResponse.data; }, }); This code should now properly download the image as a Buffer and append it to FormData before making the request to Imagga API. Make sure to replace this.imageUrl with the URL of your image.

I noticed a syntax error in your modifications JSON. There’s a missing comma between the “color” and “background” properties in the “BT” object. Here’s the corrected JSON: ```
on [ { “name”: “Letterbox”, “color”: “{{steps.node.$return_value.result.colors.image_colors[3].html_code}}” }, { “name”: “Inner Background”, “color”: “{{steps.node.$return_value.result.colors.image_colors[2].html_code}}” }, { “name”: “image_container_rectangle_2”, “image_url”: “{{steps.Send_to_ImageKit.$return_value.finalImageUrl}}” }, { “name”: “BT”, “text”: “{{steps.trigger.event.newRow[0]}}”, “color”: “{{steps.node.$return_value.result.colors.image_colors[4].html_code}}”, “background”: null }, { “name”: “Author Name”, “text”: “PG”, “color”: “{{steps.node.$return_value.result.colors.image_colors[4].html_code}}”, “background”: null } ]

Running into a triggering issue for the workflow.

My workflow is triggered on creation of a new Google Sheets row (instant). It is live, and I have tested it several times.

I added 20 new rows, and nothing has happened.

When I go to edit the workflow and select the trigger events, I see that there are 20 new events that I can use to test.

However, on the activated workflow, there are no events queued up.

Any ideas?

Any issue

I’m sorry to hear you’re experiencing issues with the Google Sheets trigger. To help you troubleshoot this issue, please follow these steps: 1. Double-check that the Google Sheets trigger is correctly configured with the right spreadsheet and worksheet. 2. Ensure that your Pipedream account is still connected to your Google account and has the necessary permissions. 3. Check the event history for your workflow to see if any events were received or if there were any errors. If you’re still facing issues after trying these steps, please visit https://pipedream.com/support for more support options.