Author Topic: Redirection/Pipe binary corruption with Windows PowerShell  (Read 1669 times)


  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3956
Redirection/Pipe binary corruption with Windows PowerShell
« on: March 06, 2017, 09:55:51 PM »
Just a note in case anyone else has this problem.

Windows Powershell is not a good choice to use with exiftool if you plan on redirecting/piping binary data.  I just helped a person over on StackExchange who was trying to extract a PreviewImage from some raw files and not getting images.  He sent me the raw file and I couldn't replicate the problem.  I was able to properly extract the PreviewImage.  But then I tested it on Powershell and it exactly duplicated the corrupted preview file.

After some searching, it turns out that if PS doesn't think that the output is unicode, it will assume that it's ASCII and convert it to unicode. 

PowerShell’s Object Pipeline Corrupts Piped Binary Data
un-messing Unicode in PowerShell
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: Redirection/Pipe binary corruption with Windows PowerShell
« Reply #1 on: March 07, 2017, 07:59:08 AM »
Wow.  That's a serious bug.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).