Skip to content

Instantly share code, notes, and snippets.

@ugovaretto
Last active October 15, 2022 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugovaretto/a7322ac9a95769a8241b5a40346a589d to your computer and use it in GitHub Desktop.
Save ugovaretto/a7322ac9a95769a8241b5a40346a589d to your computer and use it in GitHub Desktop.
Convert HEIC to JPG
#!/usr/bin/env rdmd
int convert(string path) {
import std.file, std.algorithm, std.path, import std.parallelism;
import std.process : execute
import std.uni: toLower;
auto dFiles = dirEntries(path, SpanMode.breadth).filter!(f=>f.name.toLower.endsWith(".heic"));
foreach (d; parallel(dFiles)) {
auto f = d.name;
auto status = execute(["convert", f.baseName, f.baseName ~ ".jpg"]);
if (status.status != 0) return status.status;
}
return 0;
}
int main(string[] args) {
import std.stdio;
if( args.length < 2) {
stderr.writeln("Usage: %s <path>", args[0]);
return 1;
}
return convert(args[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment