Menu

xfig 3.2.9a: Unable to insert pictures

2025-01-06
2025-02-05
  • Peter Smith

    Peter Smith - 2025-01-06

    I recently installed xfig 3.2.9a in a brand new mac pc. When I try to insert a png file, I get the error message:
    libpng error: invalid distance too far back
    Errors occurred when reading PNG file /Users/..... /

    If I try to insert a jpg image, I get the error:
    Corrupt JPEG data: 4094 extraneous bytes before marker 0xd9
    JPEG datastream contains no image
    Errors occurred when reading JPEG file /Users/..... /

    Trying another JPEG image, I get the error:
    Corrupt JPEG data: premature end of data segment
    Invalid JPEG file structure: two SOI markers

    I am only able to insert PDF images.

    In my old mac with an old xfig version I don't have any of these issues.

     
  • tkl

    tkl - 2025-01-06

    Xfig links into libpng and libjpeg. The errors above stem from these libraries. Thus, probably a binary was installed that was linked with a different version of the libraries than is present on the machine. If xfig was compiled from sources, I do not yet know what could be the issue.

     
  • Peter Smith

    Peter Smith - 2025-01-06

    I have used the macports utility to install xfig:

    sudo port install xfig

    Is there another straightforward procedure to install xfig in a mac PC?

     
  • tkl

    tkl - 2025-01-07

    I cannot reproduce these errors. Maybe you should report the issues to the distributor of the binaries, macports in this case. Apart from that, I only can think of workarounds. For instance, trying a different distribution (fink or homebrew). Less straightforward than setting up macports in the first place, since this would be a secondary source of binaries. Another option is to compile from sources, even more involved. (But if the latter fails, with the same or similar errors, it would definitely be a xfig bug.)

     
  • Peter Smith

    Peter Smith - 2025-02-03

    I have contacted macports, they reproduced the problem but were not able to fix it:

    https://trac.macports.org/ticket/71818#comment:2

     
  • tkl

    tkl - 2025-02-04

    Thank you for following up the issue. As long as the issue persists, there are only workarounds. For instance, by converting images to a format that is inserted by xfig without calling a library. These formats would be eps, pdf, ppm, or pcx. A conversion program could be ImageMagick's convert, e.g.,convert img.jpg img.pdf. The pdf format natively supports jpg (and jbig2 as well as tif in b/w ccitt format), hence in this case the pdf would only be a wrapper around the original jpg. For png, a real conversion would occur, probably significantly increasing the file size. Anyhow, all only workarounds.

     
  • Peter Smith

    Peter Smith - 2025-02-04

    Thanks for the tips. The annoying thing is that I am not able to open / edit my old xfig files. I might need to buy a new pc, with ubuntu, to do this work, or use my old mac that works well with an old xfig version.

     
  • tkl

    tkl - 2025-02-05

    The old xfig files with images embedded do not even open? On my machine, I created a fig file with an embedded jpg, invalidated the jpg (by truncating it to the first 4000 bytes) and opened the fig file with xfig. There is correctly an error message and the image is not displayed, or only partially displayed, but the remainder of the fig file opens.

     
  • Peter Smith

    Peter Smith - 2025-02-05

    I did no explain myself well. Sorry. Old fig files open and I can edit them, but the embedded (png, gif, etc) pictures do not show up. Everything else in the image is ok, and can be edited. Pop up error messages appear, like this one:

    Errors occurred when reading JPEG file /path/to/file/name.jpg
    Corrupt JPEG data: premature end of data segment
    Invalid JPEG file structure: two SOI markers

    So, the workaround is to remove the jpeg, gif images from xfig files, substituting them by equivalent pdfs. Re-sizing pictures also has to be done, to fit the orignal xfig layout. I have too many xfig files to do this by hand, though.

     

    Last edit: Peter Smith 2025-02-05

Log in to post a comment.

MongoDB Logo MongoDB