Last active
October 15, 2022 02:21
-
-
Save ugovaretto/a7322ac9a95769a8241b5a40346a589d to your computer and use it in GitHub Desktop.
Convert HEIC to JPG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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