ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: StarGeek on March 06, 2017, 09:55:51 PM

Title: Redirection/Pipe binary corruption with Windows PowerShell
Post by: StarGeek 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 (https://brianreiter.org/2010/01/29/powershells-object-pipeline-corrupts-piped-binary-data/)
un-messing Unicode in PowerShell (https://blogs.msdn.microsoft.com/sergey_babkins_blog/2016/12/29/un-messing-unicode-in-powershell/)
Title: Re: Redirection/Pipe binary corruption with Windows PowerShell
Post by: Phil Harvey on March 07, 2017, 07:59:08 AM
Wow.  That's a serious bug.

- Phil