How to convert photos to paintings with Deep Learning in Node.js

Cloudmersive
2 min readMay 27, 2019

For this exercise, our goal is to automatically convert a photograph like this one:

Into interpretive, stylistic works of art like these — digital art:

To get started, we need to add a reference to the library we will use:

"dependencies": {
"cloudmersive-image-api-client": "^1.1.4"
}

Now, all we need to do is call the right method, artisticPainting:

var CloudmersiveImageApiClient = require('cloudmersive-image-api-client');
var defaultClient = CloudmersiveImageApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveImageApiClient.ArtisticApi();var style = "udnie"; // String | The style of the painting to apply.var imageFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile.jpg").buffer); // File | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported.var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.artisticPainting(style, imageFile, callback);

That’s it! Here are some examples generated using this approach:

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.