danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

Windows binaries unable to open paths with Unicode characters #118

Closed akaleeroy closed 4 years ago

akaleeroy commented 4 years ago

Say I have a file at D:\Config\Desktop\Șmotru\test.jpg

>jpeg-recompress.exe D:\Config\Desktop\Șmotru\test.jpg output.jpg
jpeg-recompress: unable to open file: D:\Config\Desktop\?motru\test.jpg

Ș gets converted to ?, breaking the file path
I don't think it's the command prompt since @chcp 65001>nul does nothing.

zvezdochiot commented 4 years ago

This is not a problem of jpeg-recompress itself, but of the one with which the assembly was performed.

Try:

type D:\Config\Desktop\Șmotru\test.jpg output.jpg | jpeg-recompress.exe -a - testout.jpg
akaleeroy commented 4 years ago

Good workaround, thanks! I still don't get why piping in the input works... are you saying it has to do with the executable's compilation?

Anyway, here's the final compression batch file fixed of Unicode path problems:

:: drag-jpeg-to-recompress.cmd
:: Place this script in the same folder as jpeg-recompress.exe
@echo off

set path=%~d0%~p0

:start

type %1 output.jpg 2>nul | "%path%jpeg-recompress.exe" - %~nx1 || (pause && exit /b 1)

shift
if NOT x%1==x goto start