Drupal integration with external binary program to convert an image? Using Drupal 8. On a cloud based site, I have a program for converting images into svgs that takes, at times, a few hours of run time. I can easily run the external binary program (configured to run through java as a commandline). At the end I have the program spit out the relevant files. I need to integrate this with Drupal and am wondering the best procedures.

What do I use to grab the image and have an actual file on disk? How can I get the files back into drupal whenever this program finishes. I can easily add in commands to run after the program finishes, and can get the program to run with an exec() but how do I hook the rest of it up? A working proof of concept would be great. Even better if it could run on a spun up virtual computer on google cloud services.
Not anything near a working proof of concept, but a hint in the right direction:

You could use FileEntities for the upload of the Files, for example via a FileField on a node.

In hook_node_insert() and or hook_node_update() you can get the path to the file in the filesystem via:

$file = $node-&gt;field_source-&gt;entity;
$path = FileSystem::realpath($file-&gt;getFileUri());


You could than trigger the execution of your external program. By using hook_cron() you could regularly check for results. You could than attach the resulting file to the node like this

// Create FileEntity from a local file.
$uri  = file_unmanaged_move($path, 'public://'.$result_filename, FILE_EXISTS_RENAME);
$file = File::Create([
    'uri' =&gt; $uri,
]);
$file-&gt;save();
// Load node and attach the file.
$node = Node::load($nid);
$node-&gt;field_result-&gt;setValue([
    'target_id' =&gt; $file-&gt;id(),
]);
$node-&gt;save();