netcore在CentOS7 下使用处理图片的问题
请看代码,当你在centos下要把图片转为Base64的时候
MemoryStream ms = new MemoryStream();
try
{
Bitmap bmp = new Bitmap(filePath);
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] arr = new byte[ms.Length];
ms.Position = ;
ms.Read(arr, , (int)ms.Length);
return Convert.ToBase64String(arr);
}
catch (Exception ex)
{
Core.Helpers.Log4NetHelper.WriteError(typeof(string),ex);
return "";
}
finally
{
ms.Close();
}
明明你在本地或windows服务器是正常的,可是在linux下就会抛出如下异常:
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.
at System.Runtime.InteropServices.FunctionWrapper`.get_Delegate()
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromFile(String filename, IntPtr& bitmap)
at System.Drawing.Bitmap..ctor(String filename, Boolean useIcm)
看了报错信息知道 linux没有 libgdiplus
解决方案:
#locate libdl
#cd /usr/lib64 #ln -s libdl-2.17.so libdl.so
如果 locate libdl 报以下错误:
-bash: locate: command not found
其原因是没有安装mlocate这个包
安装一下包:#yum -y install mlocate
再更新一下库:#updatedb
最后最关键的是安装一下 libgdiplus 库,搞定!
yum install libgdiplus-devel
netcore在CentOS7 下使用处理图片的问题的更多相关文章
- CentOS7下mysql5.6修改默认编码
参考原文教程:Centos7下修改mysql5.6编码方式 解决网站中文显示问号 解决办法: 修改MySQL数据库字符编码为UTF-8,UTF-8包含全世界所有国家需要用到的字符,是国际编码. 具体操 ...
- centos7下使用yum安装mysql
CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/m ...
- CentOS7下搭建邮件服务器(dovecot + postfix + SSL)
CentOS 花了基本上两天的时间去配置CentOS7下的邮件服务器.其中艰辛太多了,一定得总结下. 本文的目的在于通过一系列配置,在CentOS 7下搭建dovecot + postfix + ...
- CentOS7 下 安装 supervisor以及使用
CentOS7 下 安装 supervisor 以及使用 手动安装 [注] linux环境必须安装 python 1.获取supervisor包:[https://pypi.python.org/py ...
- Linux CentOs7 下安装 redis
Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装 命令如下 $ yum install gcc-c++ $ wget ht ...
- [转]Centos7下caffe的安装
Centos7下caffe的安装 原文地址:http://blog.csdn.net/s2392735818/article/details/49796017 版权声明:本文为博主原创文章,未经博 ...
- Centos7下搭建LAMP平台环境
1.启用Apache2 Centos7默认已经安装httpd服务,只是没有启动.如果你需要全新安装,可以yum install -y httpd 启动服务:systemctl start httpd. ...
- CentOS7下Firewall防火墙配置用法详解
官方文档地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide ...
- Centos7下安装配置Redsocks
Redsocks是一个开源的网络程序,代码依赖开源的libevent网络库.Redsocks允许你将所有TCP连接重定向到SOCKS或HTTPS代理,比如Shadowsocks(Centos7下安装配 ...
随机推荐
- asp.net core 从 3.0 到 3.1
asp.net core 从 3.0 到 3.1 Intro 今天 .net core 3.1 正式发布了,.net core 3.1 正式版已发布,3.1 主要是对 3.0 的 bug 修复,以及一 ...
- Spring Boot中使用Jpa的findOne方法不能传入id
最近通过慕课网学习spring boot,视频中通过jpa的findOne方法以id为参数查询出对应的信息, 而当我自己做测试的时候却发现我的findOne方法的参数没有Integer类型的id,而是 ...
- 小白的springboot之路(四)、mybatis-generator自动生成mapper和model、dao
0-.前言 在用mybatis开发项目中,数据库动辄上百张数据表,如果你一个一个去手动编写,比较耗费时间:还好,我们有mybatis-generator插件,只需简单几步就能自动生成mybatis的m ...
- Layui下拉3级联动
这里我就不给大家详细说明了直接附图: js代码: layui.use(['layer', 'form','xform','layer'], function () { var element = la ...
- webpack4.0各个击破(6)—— Loader篇【华为云技术分享】
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/devcloud/article/detai ...
- 目不识丁的我使用Python编写汉字注音小工具
一万点暴击伤害 人懒起来太可怕了,放了个十一充分激发了我的惰性.然后公众号就这么停了半个月,好惭愧- 新学期儿子的幼儿园上线了APP,每天作业通过app布置后,家长需要陪着孩子学习,并上传视频才算完成 ...
- 英飞凌TC297 PSPR与DSPR
TC297的系统架构图如下,3个核CPU0/1/2有各自的RAM,分为程序RAM和数据RAM,即PSPR和DSPR.PSPR(或者叫做PRAM)主要用于放置静态函数,提高函数执行效率,或放置flash ...
- UVA-11995
There is a bag-like data structure, supporting two operations:1 x Throw an element x into the bag.2 ...
- Ceph 提供iSCSI存储
Tgtd+Ceph部署 一.yum安装tgt [root@c720181 ~]# yum --enablerepo=epel -y install scsi-target-utils libxslt ...
- 【JS】394- 简明 JavaScript 函数式编程-入门篇
转载自公众号"程序员成长指北" 写在开头 本文较长,总共分为三大部分:(对于函数式编程以及其优点有一定理解的童鞋,可以直接从 第二部分 开始阅读) 第一部分:首先会通过实际代码介绍 ...