你在windows上使用图像组件没有任务问题,但部署到linux之后,将注意以下几点:
- 安装nuget包ZKWeb.System.Drawing
- 项目里还是引用System.DrawingCore,这点不用改
- 安装gdiplus插件,这个需要根据linux类型不同,有不同的方法,大叔做了一下总结
安装gdiplugs的方法
大叔总结的方法
ubuntu && debian
1 2 3
| sudo apt-get install libgdiplus cd /usr/lib sudo ln -s libgdiplus.so gdiplus.dll
|
centos
1
| yum whatprovides libgdiplus && yum install -y epel-release && yum install -y libgdiplus-2.10-9.el7.x86_64 && yum install -y libgdiplus-devel
|
官方提供的方法:
Ubuntu 16.04:
1 2 3
| apt-get install libgdiplus cd /usr/lib ln -s libgdiplus.so gdiplus.dll
|
Fedora 23:
1 2 3
| dnf install libgdiplus cd /usr/lib64/ ln -s libgdiplus.so.0 gdiplus.dll
|
CentOS 7:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| yum install autoconf automake libtool yum install freetype-devel fontconfig libXft-devel yum install libjpeg-turbo-devel libpng-devel giflib-devel libtiff-devel libexif-devel yum install glib2-devel cairo-devel yum install git git clone https://github.com/mono/libgdiplus cd libgdiplus yum -y install ftp ./autogen.sh yum -y install gcc automake autoconf libtool make yum -y install gcc gcc-c++ make make install cd /usr/lib64/ ln -s /usr/local/lib/libgdiplus.so gdiplus.dll
|
Docker:
1 2 3 4
| RUN apt-get update RUN apt-get install -y libgdiplus RUN cd /usr/lib RUN sudo ln -s libgdiplus.so gdiplus.dll
|
例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base WORKDIR /app EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
RUN apt-get update RUN apt-get install -y libgdiplus RUN cd /usr/lib RUN sudo ln -s libgdiplus.so gdiplus.dll
WORKDIR /src COPY ["DC_MMS_API/DC_MMS_API.csproj", "DC_MMS_API/"] COPY ["Core/Core.csproj", "Core/"] COPY ["Infrastructure/Infrastructure.csproj", "Infrastructure/"] RUN dotnet restore "DC_MMS_API/DC_MMS_API.csproj" COPY . . WORKDIR "/src/DC_MMS_API" RUN dotnet build "DC_MMS_API.csproj" -c Release -o /app
FROM build AS publish RUN dotnet publish "DC_MMS_API.csproj" -c Release -o /app
FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "DC_MMS_API.dll"]
|