Reduce size of file with images?

  • Is it possible to reduce the size of the rtf file when the document includes pictures? It is not important if the images can not be read by for instance Ms Word.
    An example file with one image has file size 48 kB in doc-format, 858 kB in RTF saved by Word and 801 kB when saved by WPRichText. I would like the RTF file size to approach the doc size.

  • I'm new to WPTools so take what I say with a grain of salt. But I don't think there's any way you're going to get much better compression if you're embedding the images into your document. Encoding of images in ASCII RTF files just takes up too much space, any way you do it.

    The solution would be to keep the images in binary format and save them (by streaming) to a blob field in the database. Retrieve the images from the blob field at the same time as you retrieve the main document (reconstructing them from a stream), and link them to the RTF document dynamically at that point. You would thus probably want to use linking of images, rather than embedding.

    This method would take some code, but it would avoid the ballooning of RTF files with embedded images.

    Maybe someone out there has a better idea, or has sample code for how they've already implemented something similar.

    Oh, and if you weren't even saving things to a database, then one of two things: (1) Just stop worrying about the large size and realize this is best you will get, or (2) Link the images and save them to disk as separate files that must be available for document to be viewed correctly.

    -- Herbert Sitz

    • Offizieller Beitrag

    Hi,

    Yes, linking the images is a good way to do.

    But if you are embedding images you should use JPEG images. Those can be embedded in RTF in compressed form and they will be also saved binary (not hex encoded) if you activate that option in Header.StoreOptions.