问题描述:

在使用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 的解决方案的更多相关文章

  1. Linux下jetty报java.lang.OutOfMemoryError: PermGen space及Jetty内存配置调优解决方案

    Linux下的jetty报java.lang.OutOfMemoryError: PermGen space及Jetty内存配置调优解决方案问题linux的jetty下发布程序后再启动jetty服务时 ...

  2. macOS VMWare Fusion报错”找不到可以连接的有效对等进程”的解决方案

    macOS VMWare Fusion报错”找不到可以连接的有效对等进程”的解决方案 我的是macOS 10,默认情况下不允许未知身份的软件安装 默认情况,如下图所示: 解决办法: sudo spct ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 解决 git pull 报错 fatal: refusing to merge unrelated histories

    我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传. 先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法p ...

  7. 报错fatal: refusing to merge unrelated histories

    提交到远程仓库的时候报错如下 是因为远程仓库有东西更新,但本地仓库没有更新造成提交失败 需要先把远程仓库给拉取下来,执行命令git pull origin master,又报错了如下 是因为两个仓库提 ...

  8. git远程建立仓库后,将本地项目推到远程报错 fatal: refusing to merge unrelated histories

    出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库,假如之前是直接clone的方式在本地仓库就不会有这个问题了. 解决方式是在命令后紧跟 --allow-unrelated-hi ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. iOS 为 textView 添加 placeholder

    OC : //自定义一个 placeholder 样式的 label UILabel *placeholder = [UILabel new]; placeholder.text = @"请 ...

  2. 【redis-cli】常用命令

    -- 查看数据库下key存储数 redis-cli INFO | grep ^db -- 选择数据库 select [0-15] -- 列出所有key keys * -- 列出key模糊匹配 keys ...

  3. win电脑查看wifi密码的方法

    1.使用电脑连接需要查看的WiFi,鼠标右击电脑桌面右下角[WiFi图标],在弹出的菜单中点击[打开"网络和internet"设置]. 2.在弹出的设置窗口中点击[网络和共享中心] ...

  4. springboot项目打成jar包,启动指定外部的yml文件

    java -jar xxx.jar --spring.config.local=application.yml

  5. 树莓派启动后自动发送本地IP 到指定邮箱

    在 /etc/init.d   目录下建立 GetLocalip.py 文件 #coding: utf-8 import smtplib from email.mime.text import MIM ...

  6. 微信小程序 css overflow :hidden 子元素不生效

    原css  .item .right {     width: 70%; }    .item .right .name {     font-size: 32rpx;     font-family ...

  7. 关于在html中不能正确的打出字符

    由于在html中一些字符不能正确的使用,例如大于号或者小于号,浏览器在解析的过程中会将其误认为标签,那html也是非我们提供了一些预留字符,如下(部分): 1.大于号(>):&gt 2. ...

  8. sql server clr json to table

    背景 SQL SERVER 2016 之前版本不支持 直接解析json 步骤: 1 vs 数据库项目 2 生成dll 3 加入信任 DECLARE @hash AS BINARY(64) = (SEL ...

  9. 2020.4.28关于pta的总结

    0.前言 这次作业针对的是oo程序设计第二单元(5-8周)的作业,在整体当中属于第4到第6次作业. 此三次作业的知识要点为:继承类,多态性,字符串,结构类,接口类. 此三次作业的时间为20.4.12- ...

  10. java 多线程 数据通信

    1.司机等乘客全部上车后再启动车子 import java.util.concurrent.CountDownLatch;public class A { public static void mai ...