We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

Convert base64 to webp using curl and shell

My goal is to use ASPOSE to convert a base64 or PNG file to a webp file.
I would like to execute the conversion in a shell (mac vsh or windows10 PowerShell).
curl is a reasonable choice for either environment.
I have a Client Id and a Client Secret.

I believe the basic curl structure looks like this:

curl -X POST “https://api.aspose.cloud/connect/token
-d “grant_type=client_credentials&client_id=XXclient_secret=YY”
-H “Content-Type: application/x-www-form-urlencoded”
-H “Accept: application/json”

Here are my questions (let’s assume Win10 and POSH):
How to update the curl statement to read the source file (base64 file or file.png) on the local machine?
How to update the curl statement to write to a specific location on the local machine?

The idea location is on my local file system.
But if I have to write to ASPOSE Internal Storage (with a 24-hour retention window) that’s OK too, but not sure how to specify Internal Storage or how to access it.

Thanks for guidance and assistance here.

/jay gray


Please find a sample cURL command to convert a PNG file from local drive to webp and save the output back to local drive using CreateConvertedImage API method. Hopefully, it will help to accomplish your requirement. However, if you need base64 file conversion then we may log a feature request for it.

# First get Access Token
# Get Customer Key and Customer ID from https://dashboard.aspose.cloud/
curl -X POST "https://api.aspose.cloud/connect/token" 
-d "grant_type=client_credentials&client_id=xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxx" 
-H "Content-Type: application/x-www-form-urlencoded" 
-H "Accept: application/json"

# Convert image form one format to other format with out storage
curl -X POST "https://api.aspose.cloud/v3.0/imaging/convert?format=webp" 
-H "accept: application/json" 
-H "authorization: Bearer [Access_Token]" 
-H "Content-Type: multipart/form-data" 
-H "x-aspose-client: Containerize.Swagger" 
-F "imageData"="@C:/Temp/10.png"
--output C:/Temp/10.webp

To save the output image to Aspose Internal Storage you will use outPath parameter for the purpose. And please note if you are using the default Aspose Internal Storage in the API call then you may omit the storage parameter value. Otherwise, you need to pass the storage name associated with your account in the API call.

thank you for your help here.

We’ll use manual methods to convert base64 to PNG, and then use your service.
We’ll also take the ‘local storage approach’ rather than using your storage
Thank you for the ImageAPI link - had missed that earlier; obviously need/want to use those controls.
BBTY as we progress.

1 Like