How can I crop or resize an asset through the API

For cropping, you will need to use these two endpoints:

  1. Create Crop - POSThttps://api.mediavalet.com/crop/:assetId  - send your desired crop coordinates in the body (top, left, width and height), this will return crop id as payload

  2. Retrieve Crop - GEThttps://api.mediavalet.com/crop/:cropId- use the crop id you got from 1. , and this will retrieve the cropped image url in payload

For resizing, you will need to follow these steps:
  1. Create Crop Template  - POSThttps://api.mediavalet.com/crop/templates- create template by defining x and y (width and height) , name of the template and sendDimensionas type , this will return crop template id in response payload

  2. Create Crop From Template - POSThttps://api.mediavalet.com/cropWithTemplate/:assetId- along with template id from 1., send your desired crop coordinates in the body (top, left, width and height - width and height should be the same as in template created in step 1.) as well as scaledHeight and scaledWidth (these are the sizes to which you want to scale the image up, they need to be bigger than defined height and width from 1. , but not bigger than total height and width of the original image), this will return crop id as payload

  3. Retrieve Crop - GEThttps://api.mediavalet.com/crop/:cropId- use the crop id you got from 1. , and this will retrieve you cropped image url in payload
Was this article helpful?
0 out of 1 found this helpful