kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 486 forks source link

pngquant doesn't work inside Windows Docker containers #394

Closed Antonytm closed 2 years ago

Antonytm commented 2 years ago

I have an ASP.NET MVC website, which is hosted in a Docker container based on Windows Server Core image, 1809-amd64 tag.

I want to run pngquant inside this container in order to optimize png images.

I got an exception:

"C:\tools\pngquant.exe --force --output "C:\Windows\TEMP\tmp3D51.png" -- "C:\Windows\TEMP\tmp3D50.png" exited with unexpected exit code -1073741515.

I try to troubleshoot the issue.

  1. I connect to Docker container using shell
  2. I try to run pngquant.exe using shell (at least to see help)

Expected result: I should see help information (example from the website hosted locally, not in the container) image

Actual result: The command exits silently. image

Antonytm commented 2 years ago

Are there any dependencies that are probably missed in the container?

jibsen commented 2 years ago

Looking at pngquant.exe for 2.17, it looks like you might need a Microsoft Visual C++ Redistributable to run it.

I don't know if the container has such, but a quick google gave this page.

The screenshot you have shows pngquant 2.12, so I don't know if you might need a different version for that.

Antonytm commented 2 years ago

@jibsen Thank you!

The image that I used doesn't have Microsoft Visual C++ Redistributable.

I have added these lines to my dockerbuild file:

RUN Powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
RUN choco install vcredist-all -y

(it install this choco package: https://community.chocolatey.org/packages/vcredist-all) and it started to work!

Do you know what exact version of Microsoft Visual C++ Runtime is required? recommended? enough to have? (to avoid installation of all version to my image)

jibsen commented 2 years ago

Glad to hear that worked!

Try this one: https://community.chocolatey.org/packages/vcredist140

Antonytm commented 2 years ago

Yes, it also works.

Antonytm commented 2 years ago

I think the issue could be closed, but better to document it.