Weird situation with LO Writer

Good guess but sadly no. All the images are first stored as JPEGs. That's
how I know they in fact *are* JPEGs. :wink:

Ra wrote:

Hello,

I have noticed some unexpected (and possibly inconsistent) behavior of
documents producet with LO Writer. Here's my scenario: I have several
frames in the document and each of them has a JPEG photo as the background.
Each frame has a different image as a background. There are no other
graphics in the document, just some text. The resulting document ends up
being considerably larger than the sum of all the images and all the text
content put together.

Knowing that ODFs are really just ZIP archives, I decided to dig a little
deeper. Having opened an ODF file with an archiver I noticed most (but not
all, surprisingly!) of my JPEGs got converted to PNGs before getting
stored. I don't know much about this but up until now I believed LO stores
all external images as direct file copies, or at the very least in the
original format, so this striked me as odd.

Just a guess, but if you copy and paste an image from another file, LO
won't know what format it was in originally (all it has is bitmap data
pasted from the clipboard), so will probably use PNG since it is a lossless
format. Maybe those in JPEG format were inserted by Insert > Picture > From
file (or similar), while those in PNG format were opened in another
application, copied from there, and then pasted into LO?

I've been told the ODF specification recommends using PNGs for bitmaps and
SVG for vector graphics. This makes sense generally but is also quite
inefficient for photos as PNG photos tend to be much larger than JPEGs. It
is also weird that only some of my images got converted.

Anybody know and can explain the logic behind this? My document currently
contains about 100 such images, the JPEGs are all together about ~15MB in
size, the rest of the document is mostly plain text with some formatting,
and yet my document ends up at about ~47MB. I would like to optimize and
reduce this if possible.

In case it matters, the document was produced over several weeks in LO 4.x
or newer on Windows (XP/x86 and 7/x64) and Linux (x86).

Thank you.

Sure, but how did you then get those images into LibreOffice?

If you use Insert > Picture > From file, LO knows that the file is a JPEG and probably even copies the file as-is into the ODF file.

If you open the JPEG file in another application (such as an image editor), then copy from there and paste into LO, in this case LO will only have the bitmap data copied from the image editor. It will not know about the original image file nor what type it was, and probably uses its default format, i.e. PNG, to save that image data within the ODF file.

My suspicion is that, although you saved all the source images as JPEGs, those which appear as JPEG in the ODF file were inserted by Insert > Picture > From file, while those which appear as PNG in the ODF file were opened in another application and copied and pasted into LO Writer.

Mark.

Ra wrote:

I never insert images as pictures. The JPEG images are only ever used as
backgrounds for frames. I also never open the JPEGs in any picture editing
application and copypaste from there, the images are only ever used as
files from disk.

What I'm doing is precisely this:

File > Insert > Frame... > OK

Then

[right click on the frame created] > Frame... > Background > As: Graphic >
Browse... > [select the JPEG file from disk] > Type: Area > OK

And then repeat, many times, always selecting a different JPEG for the
background.

OK. In that case it doesn't look like what I thought. The only other thing I can think is that perhaps some of those JPEGs do come out smaller when saved as PNG and LO is doing that to reduce the file size. But that seems unlikely for photos, as you originally said. Maybe someone else here has some ideas...

Mark.

Ra wrote:

Yeah, it's not that either. I can't make sense of this either.
Just as an example, one of the original JPEGs is 568x426 and 75kB in size,
as a PNG it has the same dimensions but is 374kB in size.

Hi :slight_smile:
It might be good to post this as a bug-report to see what comments the
devs make, or use their mailing list or irc or whatever.

I'm not having the same issue at all and can't replicate the problem
at all. On my machines jpgs stay as jpgs and pngs as pngs. I just
drag and drop my images in. Not sure if that makes a difference.
Regards from
Tom :slight_smile:

Hi Ra,

Ra schrieb:

I never insert images as pictures. The JPEG images are only ever used as
backgrounds for frames. I also never open the JPEGs in any picture editing
application and copypaste from there, the images are only ever used as
files from disk.

What I'm doing is precisely this:

File > Insert > Frame... > OK

Then

[right click on the frame created] > Frame... > Background > As: Graphic >
Browse... > [select the JPEG file from disk] > Type: Area > OK

I think, that is the point. You do not insert the image directly, but use it as background image.

If you insert the image directly, it should stay in JPEG format.

Have you tried, whether other ways to make it a background (e.g. extending the palette) results in png too?

Why do you try to make it a background of the frame?

Kind regards
Regina

Hello,

True, I don't insert the images as pictures like you would expect, but I
didn't think that would make a difference since all the images are still
coming from a local disk, so therefore LO knows the format very well and
should be able to preserve it.

Why am I using frames with images as backgrounds instead of pictures? I
don't know really. I needed an image to accompany a chunk of text, this
seemed like a good idea at the time. It's kinda too late to change it now,
there are already over a hundred such frames... I might try to change it at
some later point but for now I'd like to stick with what I have.

I did not try inserting images any other way so I don't know how it would
behave. (I also don't understand what do you mean by "extending the
palette".) I did however do a little experiment. Since ODTs are just ZIP
archives, I opened my document with an archiver tool and extracted the
contents to a temporary directory. Then I converted all the PNGs to JPGs
with the same name, updated the relevant index files accordingly
(content.xml, META-INF/manifest.xml), and archived it back as ZIP. Then I
renamed the ZIP to ODT and tried opening it in Writer, and voila, it
worked! All the images are still there and visible, I didn't see any
problems. I then saved it under a different name and checked the resulting
ODT, all the stored images were still in JPEG format. So I guess this kinda
solves my problem for now, although I would still like to know how and why
it happened to begin with. I need to do more editing on the document which
means a lot more saving, so I'll keep an eye on what LO does with these
JPEGs in the future.

Coincidentally, I was looking for something else at the weekend, and came across some notes from about 5 years ago when I got a 30MB presentation down to 6MB by doing that. Had completely forgotten about it. That was with quite an old version of OpenOffice, and I may not have inserted the files properly in the first place (not sure if I was aware of the difference between copy/pasting and insert from file myself back then!) Was going to suggest it as a workaround in case it was worth the effort to you, but looks like you've already found the same trick ;o)

It would be interesting to know what triggers the different behaviour. That some are kept as JPEG while others are converted to PNG is even more strange than if they were all converted to PNG when set as a frame's background...

Ra wrote: