img2pdf 报 img2pdf.AlphaChannelError: Refusing to work on images with alpha channel 的解决方案
问题描述:
在使用img2pdf转换png到pdf时候,报了如下错误
img2pdf.AlphaChannelError: Refusing to work on images with alpha channel

解决方案:
通过一番查找,发现是pngAlpha通道的问题,
不少解决方案都是自己写的函数去除这个通道,但尝试了,行不通。
最后找到个工具--Pngcrush,然后完美解决了这个问题。
来到官网
https://pmt.sourceforge.io/pngcrush/

下载二进制压缩文件
本地解压后,上传服务器(Ubuntu)
文件目录如下,是C语言的程序,后续需要构建编译

编译:
make -j8
注:-j8是指多线程执行,提高效率

编译后的结果:生成pngcrush文件

执行pngcrush:
./pngcrush

将pngcrush设置环境变量,待后续去除png的Alpha通道用:
export PATH=$PATH:/root/wwww/selenium_screenshot/pngcrush-1.8.11/pcr010811/

去除png图片(1234.png)的Alpha通道,重命名为4321.png:
pngcrush 1234.png 4321.png

然后再重新调用img2pdf,对4321.png进行转换,转换成outputl.pdf文件

大功告成! !
参考链接:
https://blog.csdn.net/qq_43668007/article/details/87197774
https://pmt.sourceforge.io/pngcrush
https://mlog.club/article/4090462
img2pdf 报 img2pdf.AlphaChannelError: Refusing to work on images with alpha channel 的解决方案的更多相关文章
- Linux下jetty报java.lang.OutOfMemoryError: PermGen space及Jetty内存配置调优解决方案
Linux下的jetty报java.lang.OutOfMemoryError: PermGen space及Jetty内存配置调优解决方案问题linux的jetty下发布程序后再启动jetty服务时 ...
- macOS VMWare Fusion报错”找不到可以连接的有效对等进程”的解决方案
macOS VMWare Fusion报错”找不到可以连接的有效对等进程”的解决方案 我的是macOS 10,默认情况下不允许未知身份的软件安装 默认情况,如下图所示: 解决办法: sudo spct ...
- pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])
1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.S ...
- navicat连接远程数据库报错'client does not support authentication protocol requested by server consider ...'解决方案
[1.cmd终端连接远程mysql数据库方法] mysql -uhello -pworld -h192.168.1.88 -P3306 -Dmysql_oa mysql -u用户名 -p密码 -h ...
- open数据库报错ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 3880 Session ID: 125 Serial number: 3
1.今天打开数据时,失败,报错 ERROR at line 1:ORA-03113: end-of-file on communication channelProcess ID: 3880Sessi ...
- 解决 git pull 报错 fatal: refusing to merge unrelated histories
我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传. 先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法p ...
- 报错fatal: refusing to merge unrelated histories
提交到远程仓库的时候报错如下 是因为远程仓库有东西更新,但本地仓库没有更新造成提交失败 需要先把远程仓库给拉取下来,执行命令git pull origin master,又报错了如下 是因为两个仓库提 ...
- git远程建立仓库后,将本地项目推到远程报错 fatal: refusing to merge unrelated histories
出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库,假如之前是直接clone的方式在本地仓库就不会有这个问题了. 解决方式是在命令后紧跟 --allow-unrelated-hi ...
- Linux配置环境报“/usr/local/develop-tools/apache-maven-3.3.9/bin: 是一个目录“的解决方案
安装Maven中 配置系统环境变量: # vi + profile M2_HOME=/usr/local/develop-tools/apache-maven- export M2_HOME PATH ...
- appium 运行报错:...... Attempt to re-install io.appium.settings without first uninstalling解决方案
报错形式: Failed to install D:\AutoTest\appium\Appium\node_modules\appium\build\settings_apk\settings_ap ...
随机推荐
- Django基础篇 03- Models的属性与字段
1.models字段类型 AutoField():一个IntegerField,根据可用ID自动递增.如果没指定主键,就创建它自动设置为主键. IntegerField():一个整数: FloatFi ...
- SQL Sever ——基础篇之数据库的基本操作
数据库定义:对数据进行存储喝管理 数据库的系统模型:层次型,网状型,关系型(主流)和对象关系型. 关系型:Realation model 关系-->行列交叉.形式:表示实体和实体间相互联系的数据 ...
- CI框架 between and sql语句
1.在文档里没有找到关于where() between and 相应的说明 每次组合查询 要么写原生 要么连续调用where方法. 可用以下方式组合 $condition = array(); $co ...
- C#/.Net 部分缩写
CTS(Common Type System):通用类型系统:指定最基本类型便于.Net Framework的各种语言之间进行交互. CLR(Common Language Runtime):.Net ...
- CSS 层叠式-理解层叠性和继承性
CSS的概念中,除了前面提到的样式外,还有一个重要的概念就是层叠式,层叠式是贯穿整个css的一个性质,包含继承性和层叠性. 继承性: • 如果一个标签没有设置过一些样式,它的某个祖先级曾经设置过,在浏 ...
- git的基础指令练习
#版本回退 git reset commitId --hard
- Charles4.5.1抓取HTTPS请求
Charles下载以后发现 抓取http请求是成功的: 抓取https请求是失败的: 按照失败提示设置即可: 1.点击 Help -> SSL Proxying -> install ch ...
- js对象常用的方法
1. Object.assign()方法用于将所有可枚举属性的值从一个或多个源对象复制到目标对象,它将返回目标对象. 语法: Object.assign(target, ...sources) ...
- MSSQL T-SQL 基础 (创建、增、删、改)
1.创建数据库 create database StudentAchievementMS ----创建数据库,可以只执行此行来创建数据库,但以下属性都是默认 on primary --主数据文件 ( ...
- JS实现一个函数getType获取所有的数据类型
1 function getType(obj) { 2 if (obj === null) { 3 return String(obj) 4 } 5 const toType = (obj) => ...