We send an image that is publicly available at a URL to a web service that generates a thumbnail and sends it back as a Blob. Angular will read that Blob and convert that to an image and display it.
- Image at a public url
- Access to a web service that we can generate a thumbnail of an image and return it
This example uses Microsft Cognitive Services' Computer Vision API . Please create a new account there. It's $0 if you have Azure Account.
After subscribing to the Computer Vision and added, the keys can retrieved from Azure as below:
- The service URL
https://southcentralus.api.cognitive.microsoft.com/vision/v2.0/generateThumbnail?width=100&height=100&smartCropp
can also be tested at Microsoft Cognitive Services Computer Vision API page
- Go to this file
/src/app/services/blob.service.ts
, change the value forOcp-Apim-Subscription-Key
This project was generated with Angular CLI version 1.6.8.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
If the application builds and runs successfully, you should see an output as below:
Git thumbnail above is fetched from the service. The actual full sized image is here