Issue 10: assert len(palette) % 3 == 0
Status:  Fixed
Owner:
Closed:  Oct 2009
Reported by lev.bishop, Oct 28, 2009
(Please select a label starting with Optimize- in ``Labels:'' below, and
remove this paragraph.)

What command do you run to optimize the PDF?
user@ubuntu804server:~/pdfsizeopt$ ./pdfsizeopt.py --use-pngout=false
--use-jbig2=true --use-multivalent=true --do-unify-fonts=false vrabimintest.pdf

What does pdfsizeopt display when running the command above?
info: This is pdfsizeopt.py r95.
info: loading PDF from: vrabimintest.pdf
info: loaded PDF of 94956 bytes
info: separated to 39 objs
info: found 0 Type1 fonts loaded
Traceback (most recent call last):
  File "./pdfsizeopt.py", line 6027, in ?
    main(sys.argv)
  File "./pdfsizeopt.py", line 6016, in main
    pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
  File "./pdfsizeopt.py", line 4804, in OptimizeImages
    if not PdfObj.IsGrayColorSpace(colorspace):
  File "./pdfsizeopt.py", line 1503, in IsGrayColorSpace
    assert len(palette) % 3 == 0
AssertionError

What's wrong with the optimized PDF?
There isn't one!

vrabimintest.pdf
92.7 KB   Download
Oct 31, 2009
Project Member #1 pts...@gmail.com
Please update to r97 and try again. It should work.

By the way, the PDF generator is buggy, because it generates and RGB palette of size
25 (with an extra \n at the end). Nevertheless, r97 of pdfsizeopt.py now accepts this
buggy PDF, and ignores the extra \n.
Oct 31, 2009
#2 lev.bishop
Doesn't seem to be working:
user@ubuntu804server:~/pdfsizeopt$ ./pdfsizeopt.py vrabimintest.pdf
info: This is pdfsizeopt.py r101.
info: loading PDF from: vrabimintest.pdf
info: loaded PDF of 94956 bytes
info: separated to 39 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
Traceback (most recent call last):
  File "./pdfsizeopt.py", line 6121, in ?
    main(sys.argv)
  File "./pdfsizeopt.py", line 6107, in main
    pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
  File "./pdfsizeopt.py", line 4844, in OptimizeImages
    if name == 'DecodeParms' and '/JBIG2Globals' in value:
TypeError: iterable argument required

The pdf generator is windows' acrobat 7.0.5 distiller (via the Adobe pdf converter
printer driver in), printed from wolfram mathematica 6.0.0
Oct 31, 2009
Project Member #3 pts...@gmail.com
Please update to r102. It should work now.
Oct 31, 2009
Project Member #4 pts...@gmail.com
(No comment was entered for this change.)
Status: Fixed
Oct 31, 2009
#5 lev.bishop
Confirm fixed.