And why dont you give support to images with alpha channel, why? i thought img2pdf is full fledge library, please give support to this #103
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Image contains transparency which cannot be retained in PDF.
img2pdf will not perform a lossy operation.
You can remove the alpha channel using imagemagick:
$ convert input.png -background white -alpha remove -alpha off output.png
Traceback (most recent call last):
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 511, in
window = MainWindow()
File "/home/warlord/projects/JPG2PDF/src/jpg2pdf.py", line 113, in init
f.write(img2pdf.convert(tt, colorspace=img2pdf.Colorspace.L))
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 2102, in convert
) in read_images(rawdata, kwargs["colorspace"], kwargs["first_frame_only"]):
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1483, in read_images
imgdata, imgformat, default_dpi, colorspace, rawdata
File "/home/warlord/projects/jpg2pdf_env/lib/python3.6/site-packages/img2pdf.py", line 1189, in get_imgmetadata
raise AlphaChannelError("Refusing to work on images with alpha channel")
img2pdf.AlphaChannelError: Refusing to work on images with alpha channel
Even i on on my ubuntu os, i took some screenshot images(officailycaptured by ubuntu ss), img2pdf is failed to convert it to pdf. says Refusing to work on images with alpha channel
Yes, and the error message you pasted explains why this is and what you can do about it. Where is the bug?
I was trying to make GUI application for jpg2pdf, but this library disappoint me, i will have to start from strach with PIL
it should handle images with alpha channel all i am trying to say
img2pdf is for lossless conversion. If you do not require lossless conversion, then there are many existing libraries that do the job. You should use the right tool for the task at hand and if you want to be able to convert images and loose information, then either you manually remove the alpha channel (for example with
Image.convert()
from PIL) or img2pdf is the wrong library for you.Also, please note, that img2pdf already has a rudimentary GUI. If you want to make a img2pdf GUI, you could consider improvin the existing GUI that is based on Tkinter to be platform independent.
The reason I wrote img2pdf is not because there was no software to do so before. There are plenty of tools that do this job. Have a look at the bottom of the
README.md
for a list. The one thing that img2pdf does different from all the other tools is, that it is always lossless. Removing the alpha channel is a lossy operation and that's why img2pdf refuses to operate on images with alpha channels. If you use img2pdf, then you are guaranteed to not loose any pixel color information. If you don't need that then either perform the lossy operation of removing the alpha channel yourself before handing the image to img2pdf or use one of the many different libraries or applications that exist and which will happily convert images to pdf at the cost of either loosing information or needlessly increasing the output pdf size.i have seen that GUI, it is radiculus, Tkinter is good for learning purpose (very limited ), i use Pyqt5 (full fledge lib for gui), you should consider it
Cool! looking forward to your code! 😀
where are you from btw ?
I live in Germany. Why do you ask? :)
okay, germany is good country, my application mostyly downloaded in germany and USa
i make apps for linux (snap package)
some apps i published https://snapcraft.io/search?q=rishabh
FWIW, if rishabh3354 uses PyQt5 in his/her snaps then this looks like a license violation:
Versus:
(source: https://pypi.org/project/PyQt5/ )
Also, the developer homepage link is currently broken:
Hello gms,
first of all, Jpg2pdf is not a commercial application. its a open source app, and it uses PySide(quite similiar binding) not pyqt and it is available under the LGPL (like Qt itself), and thus can be used by proprietary programs provided that you carefully read and abide by the terms of the LGPL.
And about the https://warlordsoftwares.in , it was under maintainence, i had to migrate my django version. Now working like a charm.
And jpg2pdf is very useful application developed by me. More than 5000+ users are currently using it across various linux distribution.
Thanks!
Why is it marked as
Proprietary
on snapcraft then and sold on your website ("Purchase license: $1.99/only"
)? If you call it open source, why is the code not publicly available on some development platform such as GitHub or GitLab?Furthermore, if your software is really written with PySide, why then claim in the description of your website that you are using PyQt? This all sounds very dubious to me.
Concerning alpha channels:
It is simple. If you do not need to preserve the alpha channel, just remove it with PIL, and forward the output byte stream to img2pdf. I can provide some code if necessary.
Otherwise, it will be a bit more difficult. I recommend to check out an example shared by Jay Berkenbilt.
Moreover, img2pdf might support alpha channels in the future, at least for some types of images (#106)