Menu

#757 PDB writer is completelly wrong - same problem as ImageMagick

v1.0_(example)
open
nobody
None
5
2025-10-12
2025-10-12
No

The same problem exists in GraphicsMagick: https://github.com/imagemagick/ImageMagick/issues/8248

Sample images are stored here: https://github.com/user-attachments/files/21137153/images.zip


gm convert finderExtensionPrompt.pdb finder6.pdb

gcomp finderExtensionPrompt.pdb finder6.pdb
 <<< GComp >>> Compare two graphical images (c)1997-2025 F&TSoft, version 2.81
Loading
Comparing   Image types I1:100 (pl:4)(ch:1); I2:100 (pl:4)(ch:1) 
 [84 0]: F 0 
 [85 0]: F 0 
 [86 0]: F 0 
 [87 0]: F 0 
 [88 0]: F 0 
 [89 0]: F 0 
 [90 0]: F 0 
 [91 0]: F 0 
 [92 0]: F 0 
 [93 0]: F 0 
And more ...
Found 15473 mismatches!

ANOTHER TEST, only PNG's are compared, same error.

Look at the file attached. My writer does not contain this kind of flaws.

This piece of code is completelly wrong:

      literal++;
        repeat=0;
        if (0x7f < literal)
          {
            q=EncodeRLE(q,buffer,(literal < 0x80 ? literal : 0x80),0);
            (void) memmove(buffer,buffer+literal+repeat,0x80); 
            literal-=0x80;
          }

// Memmove must not copy 0x80 bytes, but offseting 0x80. "repeat" is 0 and it is nonsense to add this variable.

Discussion

  • Jaroslav Fojtik

    Jaroslav Fojtik - 2025-10-12

    Get utility gcomp from here just for a case if you need it: https://ftsoft.com.cz/pictures/pictures.html

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2025-10-12

    This bit of code was inherited directly from ImageMagick in 2002.
    While Palm devices were very popular for a while, it seems that the market dramatically changed as modern cell phones emerged and Palm devices were immediately discarded. The files on them must not have been very valuable. Sample files have been very difficult to find.

    From looking at the files from the provided images.zip (thank you!), it seems likely that there are issues in the PDB reader as well. GraphicsMagick seems to do slightly better than ImageMagick with these files (it can at least open all of the files), but I see that the right-hand side of the converted image is likely corrupted. If the reader works properly, then it is easier to validate the writer.

    Are you able to provide a source patch to fix the reader so it is easier to verify the writer?

     
  • Jaroslav Fojtik

    Jaroslav Fojtik - 2025-10-12

    It looks like a reader is OK in both branches GM and IM, my utility https://ftsoft.com.cz/pictures/pictures.html has both workable reader and writer. It can be used to verify a code until it can test itself. Unfortunatelly it can produce only compressed output. You can generate as many PDB samples as you need.

    you can type
    gconvert image.png image.pdb
    to produce any additional sample.

    and then
    gcomp image.png image.pdb
    to verify whether images are identical

    There exists several online www services on internet, that can be also used for getting PDB samples.

     

    Last edit: Jaroslav Fojtik 2025-10-12

Log in to post a comment.

MongoDB Logo MongoDB