Lossless ? #24

Closed
dbuenzli opened this Issue Jan 18, 2012 · 11 comments

Comments

Projects
None yet
5 participants
@dbuenzli

Hello,

I tried jbig2enc on some files but the result ends with unwanted letter swaps (n/u, b/h, I can provide a test file if needed).

Is it possible to get lossless compression with jbig2enc ? Tried with -r but it tells me to bug agl.

Thanks,

Daniel

@agl

This comment has been minimized.

Show comment Hide comment
@agl

agl Jan 20, 2012

Owner

If you don't pass -s then it's lossless mode.

Owner

agl commented Jan 20, 2012

If you don't pass -s then it's lossless mode.

@agl agl closed this Jan 20, 2012

@dbuenzli

This comment has been minimized.

Show comment Hide comment
@dbuenzli

dbuenzli Jan 20, 2012

Ah yes thanks. I think I got confused by my reading of the Refinement section in jbig2enc.html.

So I guess what I really want is perceptually lossless to avoid the letter swaps. And if I understand correctly refinement would bring me that, so the question is, is it implemented and working (even if it's only via the API) ?

Thanks.

Ah yes thanks. I think I got confused by my reading of the Refinement section in jbig2enc.html.

So I guess what I really want is perceptually lossless to avoid the letter swaps. And if I understand correctly refinement would bring me that, so the question is, is it implemented and working (even if it's only via the API) ?

Thanks.

@agl

This comment has been minimized.

Show comment Hide comment
@agl

agl Jan 20, 2012

Owner

On Fri, Jan 20, 2012 at 3:17 PM, Daniel Bünzli
reply@reply.github.com
wrote:

Ah yes thanks. I think I got confused by my reading of the Refinement section in jbig2enc.html.

So I guess what I really want is perceptually lossless to avoid the letter swaps. And if I understand correctly refinement would bring me that, so the question is, is it implemented and working (even if it's only via the API) ?

I typically found that symbol encoding + perfect refinement was
basically the same size as generic region encoding, which is why I
didn't pursue it too far.

Last time I touched it (years ago!), I believe that the code actually
worked, but that Acrobat crashed when trying to render it.

I'm afraid better symbol distinction would be nice, it's just not
something that I got around to doing.

Cheers

AGL

Adam Langley agl@imperialviolet.org http://www.imperialviolet.org

Owner

agl commented Jan 20, 2012

On Fri, Jan 20, 2012 at 3:17 PM, Daniel Bünzli
reply@reply.github.com
wrote:

Ah yes thanks. I think I got confused by my reading of the Refinement section in jbig2enc.html.

So I guess what I really want is perceptually lossless to avoid the letter swaps. And if I understand correctly refinement would bring me that, so the question is, is it implemented and working (even if it's only via the API) ?

I typically found that symbol encoding + perfect refinement was
basically the same size as generic region encoding, which is why I
didn't pursue it too far.

Last time I touched it (years ago!), I believe that the code actually
worked, but that Acrobat crashed when trying to render it.

I'm afraid better symbol distinction would be nice, it's just not
something that I got around to doing.

Cheers

AGL

Adam Langley agl@imperialviolet.org http://www.imperialviolet.org

@dbuenzli

This comment has been minimized.

Show comment Hide comment
@dbuenzli

dbuenzli Jan 20, 2012

Ok. Thanks for the answer.

Best.

P.S. Email me if you are interested in a nice letter swap example -- beyond that, the results are still impressive.

Ok. Thanks for the answer.

Best.

P.S. Email me if you are interested in a nice letter swap example -- beyond that, the results are still impressive.

@annulen

This comment has been minimized.

Show comment Hide comment
@annulen

annulen Nov 3, 2015

Is it possible to generate PDF with lossless compression? pdf.py doesn't seem to work without symbols file

annulen commented Nov 3, 2015

Is it possible to generate PDF with lossless compression? pdf.py doesn't seem to work without symbols file

@agl

This comment has been minimized.

Show comment Hide comment
@agl

agl Nov 4, 2015

Owner

@annulen Using generic region coding is lossless.

pdf.py is an example of the more complex PDF integration. Generic region coding is just like any other image file, however, and should be simple enough to embed in a PDF.

Owner

agl commented Nov 4, 2015

@annulen Using generic region coding is lossless.

pdf.py is an example of the more complex PDF integration. Generic region coding is just like any other image file, however, and should be simple enough to embed in a PDF.

@annulen

This comment has been minimized.

Show comment Hide comment
@annulen

annulen Nov 4, 2015

Sorry for possibly off-topic question, but what open source tools should I use to bundle PDF from these generic coded JBIG2 files? Google search gives me only jbig2 -s + pdf.py option

annulen commented Nov 4, 2015

Sorry for possibly off-topic question, but what open source tools should I use to bundle PDF from these generic coded JBIG2 files? Google search gives me only jbig2 -s + pdf.py option

@rhatlapa

This comment has been minimized.

Show comment Hide comment
@rhatlapa

rhatlapa Nov 4, 2015

Quite long time ago I've created project using IText and PDFBox libraries to replace images in PDF with their recompressed versions using JBIG2 [1]. Maybe it could be useful for your usecase or you could get some inspiration how to use those libraries and write some simple PDF generator.

[1] https://code.google.com/p/pdfrecompressor/

rhatlapa commented Nov 4, 2015

Quite long time ago I've created project using IText and PDFBox libraries to replace images in PDF with their recompressed versions using JBIG2 [1]. Maybe it could be useful for your usecase or you could get some inspiration how to use those libraries and write some simple PDF generator.

[1] https://code.google.com/p/pdfrecompressor/

@annulen

This comment has been minimized.

Show comment Hide comment
@annulen

annulen Nov 4, 2015

@rhatlapa, thanks for trying to help but it seems like pdfrecompressor uses the same dictionary coding (-s) as pdf.py, and I don't see any way to disable it to use lossless encoding.

@agl: from what you've written it seems that bundling generic coded JBIG2 files into one PDF is simpler task than what pdf.py does. What tool are you using for this task?

annulen commented Nov 4, 2015

@rhatlapa, thanks for trying to help but it seems like pdfrecompressor uses the same dictionary coding (-s) as pdf.py, and I don't see any way to disable it to use lossless encoding.

@agl: from what you've written it seems that bundling generic coded JBIG2 files into one PDF is simpler task than what pdf.py does. What tool are you using for this task?

@agl

This comment has been minimized.

Show comment Hide comment
@agl

agl Nov 14, 2015

Owner

I think that pdf.py can reasonably easily be tweaked to bundle standalong JBIG2 images into a PDF but I don't have anything lying around.

Owner

agl commented Nov 14, 2015

I think that pdf.py can reasonably easily be tweaked to bundle standalong JBIG2 images into a PDF but I don't have anything lying around.

@kmlyvens

This comment has been minimized.

Show comment Hide comment
@kmlyvens

kmlyvens Apr 2, 2016

Indeed, here is a very quick version of the pdf.py script that takes a list of jbig2 files as arguments and produces a pdf to stdout – I only had to remove DecodeParms reference to the symbols file:
https://gist.github.com/kmlyvens/b532c7aec2fe2bd8214ae2b3faf8f741

Now I am able to produce a pdf by these commands:

for f in *.pbm; do jbig2 -p -v "$f" > "${f%.pbm}.jb2"; done
~/pkg/jbig2enc/pdfsimp.py *.jb2 > foo.pdf

kmlyvens commented Apr 2, 2016

Indeed, here is a very quick version of the pdf.py script that takes a list of jbig2 files as arguments and produces a pdf to stdout – I only had to remove DecodeParms reference to the symbols file:
https://gist.github.com/kmlyvens/b532c7aec2fe2bd8214ae2b3faf8f741

Now I am able to produce a pdf by these commands:

for f in *.pbm; do jbig2 -p -v "$f" > "${f%.pbm}.jb2"; done
~/pkg/jbig2enc/pdfsimp.py *.jb2 > foo.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment