Range2json formatting

Hello,

I’m trying to make use of a new image processing api I came across on Product Hunt over the weekend called Pixaven. In order to use this, the requests must be sent in json format as shown below:

{
“resize”: {
“mode”: “auto”,
“width”: 300
}
}

See API docs here (https://docs.pixaven.com/operations/resizing)

However, I can’t seem to get this in Dashdash using range2json and I’m not sure how else to do it. Please see the screenshot below with the output from range2json.

jsonformat

It seems the default is “0” where I need it to be “resize” and the brackets are “[” instead of “{” but I’m not sure if that is a real issue?

Looking forward to hearing your thoughts on it :slight_smile:

Hey @cwinhall

You can use the PAIR2JSON formula to compose the JSON you are looking for.

Here’s how to do it:

A1: mode
B1: auto
A2: width
B2: 300
A3: json
B3: =PAIR2JSON(“resize”,PAIR2JSON(A1,B1,A2,B2))

This should do the trick :slight_smile:

Let us know if you managed to use the API. Thanks!

Thanks Henrique this worked! Just to mention one thing in this for anyone else who may need the same solution. “D2” in the formula you posted should reference “resize” in my desired outcome. :slight_smile:

2019-11-04%2016_01_07-image%20processing

1 Like

Yes, definitely. That was my bad.

Thank you for the quick correction. I will change it in the previous answer.

So :slight_smile:

Now that that is working. I’m trying to figure out the rest to get this working.

The example given for sending a request with an uploaded file is given in curl.

curl https://api.pixaven.com/1.0/upload -X POST -u your-api-key: \
-F file=@/path/to/input.jpg \
-F data='{
    "resize": {
        "width": 100,
        "height": 75
    }
}'

How do I “convert” this in to dashdash language :slight_smile:

Hi Colin,

We took a bit more time to check how this could be done to support images. Unfortunately, at this time, we do not support a multipart request where the body is an image.

We’ll add this to the backlog and will reach out when we are ready to add it to the roadmap.

Sorry I could not be more helpful here! Let me know in case I can help in anything else.