Inkscape 在本地计算机上工作但在 docker 容器上不工作

Inkscape 在本地计算机上工作但在 docker 容器上不工作
FROM python:3.10

RUN apt-get update && apt-get install -y inkscape

WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 5000

CMD ["gunicorn", "--workers", "8", "--bind", "0.0.0.0:8484", "wsgi:app"]

上面是我的docker文件。

下面是我的代码

   image_name = re.sub(r'[^\w\s-]', '', title)
             svgchart  = chart_pygal.render()
             inkscape_process = subprocess.Popen(['inkscape', '-z', '-e', '-', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
             png_data, error = inkscape_process.communicate(input=svgchart)
             png_io = BytesIO(png_data)
             return send_file(png_io ,mimetype='image/png', download_name=image_name+'.png', as_attachment=True) 

我正在进行 svg 到 png 的转换,它在我的机器上运行良好,但在 docker 容器上不起作用。出现以下错误:抱歉,照片无法打开此文件,因为不支持格式或文件已被下载且下载的图像大小为 0kb

相关内容