Skip to content

Instantly share code, notes, and snippets.

@foxxyz
Created April 7, 2018 00:36
Show Gist options
  • Save foxxyz/1b9258ca204d7e3e6d2dd9964e9f092a to your computer and use it in GitHub Desktop.
Save foxxyz/1b9258ca204d7e3e6d2dd9964e9f092a to your computer and use it in GitHub Desktop.
Spitting iPhone X Portrait Mode Photos To Get Depth Data
#!/usr/bin/perl
# Running this script with the JPG file as the first argument should produce three images:
# - out1.jpg: The original color photo (4032x3024 px)
# - out2.jpg: A thumbnail of the original color photo (160x120 px)
# - out3.jpg: A grayscale depth map (768x576 px)
#
# Thanks to hfs's perl hex splitting script (https://stackoverflow.com/a/11293884)
#
undef $/;
$_ = <>;
$n = 0;
for $content (split(/(?=\xFF\xD8)/)) {
open(OUT, ">out" . ++$n . ".jpg");
print OUT $content;
close(OUT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment