[Tutorial] Some useful hints on using images

Forum rules
No question in this forum please
For any question related to a topic, create a new thread in the relevant section.
Post Reply
Posts: 9096
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

[Tutorial] Some useful hints on using images

Post by John_Ha »

 Edit: Continuously being updated to add information and clarify - some section numbers may change.

While it began life as "How do I reduce image file sizes in Writer documents so as to minimise the document file size?" it has gradually changed into a general discussion about using images in AOO/LO.

Much applies to Calc, Impress and Draw as well as Writer. 
It is often best to optimise the images you insert into Writer, Impress and Calc as large images will dramatically increase the .odt, .odp or .ods file size. These suggestions are based on minimising the image file size in the file while maintaining the highest sensible quality and are in addition to the information given in
May I suggest you bookmark the pages.

It is strongly recommended that you always work in, and save, all files as .odt/.ods/.odg /.odp etc files - see See [Tutorial] Differences between Writer and MS Word files for the many reasons. Use .odp files for Impress, not .ppt.

It is far better to process your images in an image editor so that they are exactly how you want them to appear before inserting them into AOO.

00. right-click an image or graphic to bring up the context menu

The context menu has lots of useful commands like Anchor, Wrap, Align etc. It also gives access to the image or graphic Properties menu which give yet more control allowing you to set gap to text, borders, position etc.

0. It is often useful to switch on the Pictures toolbar

Go View > Toolbars ..., and tick Picture to bring up the Pictures toolbar. The toolbar now appears whenever an image is selected. You can only prevent the Toolbar appearing by deselecting it while an image is highlighted, so select any image so it is highlighted > View > Toolbars ..., and un-tick Picture.

1. Know the difference between a photo image and a graphic image

A photo image is a photo (or a painting).

A graphics image is anything which is not a photo ...

... and is clip art, diagrams, things with large blocks of colour, drawings, logos, line art and anything with text etc. The image below is composite: the left part is photo, but it is overlaid with a graphic. (I had to reduce the quality and pixel count to get it to upload as it had to be less than 128kB).

A photo should always be saved as a JPG file. The term "JPEG" is an acronym for the Joint Photographic Experts Group, which created the standard.

A graphic should always be saved as a PNG (preferably), GIF or TIFF file as these are compressed. A graphic should never be saved as a JPG file as doing so will destroy the image quality, blur edges, make text difficult to read and add artefacts like blotches etc.

Never use BMP for anything as BMP files are not compressed and are huge.

2. Always insert photos by Insert > Picture > From file ..., or by dragging the photo JPG file from your PC (not from the web - see 13) into Writer.

Never insert photos or JPG files by copy and paste. Never - not even once ... but see below.

When you insert a photo JPG file by Insert > Picture > From file ..., or by dragging the photo JPG file into the document, Writer knows it is a JPG file and saves the image as a JPG file in the .odt file: this is the smallest file size possible. If you Copy a photo to the Windows Clipboard and Paste it into Writer, Writer does not know that the image on the clipboard is a photo. Writer therefore (correctly) saves the image as a PNG file inside the .odt document so as to guarantee that no quality is lost. Photos saved as PNG files are likely to be MUCH larger - 3x or 4x larger is typical - than the same photo saved as a JPG file.

You can insert graphics files in any way: by Insert > Picture > From file ..., or by dragging the graphic file into Writer, or by Copy and Paste. Whichever way you choose, they will be stored either as their original file format, or as PNG files if you Copy/Paste.

There is one minor exception to this rule: When you copy an image from an AOO document, presentation, spreadsheet etc; and paste it to another AOO document, presentation, spreadsheet etc; it seems that AOO copies the actual image JPG file or PNG file which is stored in the document. AOO does not appear to do the conventional thing of placing the image on the Clipboard as pixels and pasting the Clipboard pixels.

There is another minor exception to this rule: I was extremely surprised to find that when you paste a JPG into Impress it is saved as a JPG file! I have no idea why it is different ...

3. Know how many pixels you need - camera and phone images are huge so resample them.

Images from 6 or 14 or 20 Million pixel cameras are enormous (October 2018 - Huawei's latest phone takes 40 million pixel images!) and ideally need to be processed or re-sampled before inserting them into Writer so as to reduce their pixel count and/or number of colours. Note that it is much better to process images in an image editor and insert the finalised image into Writer. Image editors do what they say on the tin - they edit images. Writer is a word processor - its image editing capability is limited.

How do I re-sample an image?

I use the excellent, free IrfanView image editor/viewer for 99% of my graphics work. It is excellent and I think it has a better re-sampling algorithm than Writer's internal re-sampling algorithm used when creating PDFs. Image > Resize/Resample ..., allows you to reduce the pixel count.

If your document is to be printed ...

... then assume an image will be, say, four inches wide when printed. You need to check with your printer what resolution (in dpi, or dots per inch, where one dot = one pixel) they will be printing at. If they say they will be printing at 150 dpi, where 150 dpi is good quality, 300 dpi is very good quality and 600 dpi is fantastic quality, then the four inch wide image only needs to be 4 inches x 150 dots per inch = 600 dots (pixels) wide. If the image is more than 600 pixels wide (and remember a 6 mega-pixel photo is over 3,000 pixels wide!) then the extra pixels are wasted and they will just clog up the .odt file and make things slower.

So re-sample the image to be 600 pixels wide using an image editor. An image which is 600 pixels wide will have a file which is 25x smaller than the same image at 3,000 pixels wide. Open the image in IrfanView (or any image editor) and go Image > Resize/Resample.

In the image below I re-sampled a 4,320 pixel wide image from my camera (6.8 MBytes, QF = 100) down to 600 pixels wide, which made the file 52x smaller (600/4,320) * (600/4,320) = 51.84x smaller (actually 58x smaller, 118 kBytes at QF = 85).

If your document is intended to be viewed on a PC screen ...

... think about how wide it will be displayed. A 20" display which is 2,000 pixels wide has only 100 pixels per inch so it is completely pointless (no pun intended) to have an image greater than 100 dpi.

If your presentation is intended to be projected onto a large screen ...

... keep as many pixels as you can although it is pointless keeping more pixels than the projector can project.

If your document is to be exported as a PDF ...

... you can resample the images sent to the PDF by the File > Export as PDF > General > Images ..., dialogue. I have found Writer's resampling algorithm (used when creating a PDF) to produce worse results (spurious lines and bands of colour) than IrfanView's resampling.

It can be useful to use huge pixel count images in PDFs. For example, say you have an A0 drawing which is 119cm x 84cm. If it is 4,000 pixels wide, you can insert it on an A4 page as, say, 15cm wide. However, the viewer can expand it up to its full size without losing any quality.

Minimising image file sizes in Impress

Impress allows you to minimise image file sizes automatically. Go Tools > Minimise presentation ..., and follow the instructions.

PixCompress Add-on

The AOO add-on PixCompress will compress all the images in a file. I believe that LibreOffice is shipped with this add-on included.

3A. How do I change the image "size on paper" in my document to make it bigger or smaller?

What size (in inches or mm) is an image when I insert it?

Image files sometimes contain information about the "size on paper" or Canvas Size of the image and this is read by AOO if available, and used if possible; otherwise AOO fits the image to the space available.

How do I change the "size on paper" of an inserted image?

1. Left-click the image to bring up the green "grab handles"
2. Use the drag handles to drag the image to the size you want.
3. If you hold down SHIFT while dragging, the image keeps its aspect ratio and is effectively magnified or reduced in size. (Slightly different in LO)

If you mistakenly forget and drag without holding down SHIFT, either press Ctrl+Z to undo the change, or right click the image > Picture > Type ..., and press Original size. This resets the image to its original size. Now drag it to the size you want.

4. Make sure you are using compressed file formats

JPG files use lossy compression where fine detail is lost when the file is saved. JPG is excellent for photos but virtually useless for graphics as the lossy compression blurs edges, add artefacts like blotches etc (blotches are added to assist the compression and, while they are invisible in photos, they are very visible in graphics images).

PNG files, GIF files and Compressed TIF (or compressed TIFF) use lossless compression, where no data is lost, and are excellent for graphics. But lossless compression PNG, GIF, TIF are virtually useless for photos as they don't compress the files size much if at all, and they may actually increase the file size compared with JPG - and by 3x or more!

GIF files are typically about 3x smaller than the equivalent PNG or TIF file. This is because PNG and TIF files can store 16 million colours and they therefore use 24 bits to store a pixel. GIF files can only store 256 colours so they use only 8 bits to store a pixel. If you can accept only 256 colours - and for graphics there is no reason why not - then GIF is a good format to use. See Item 7 below.

BMP files. Never use BMP as it is not a compressed file format.

5. If image size is still a problem while editing, create reduced pixel count draft images. (Also see using linked, reduced pixel count images in 6 below. Also see 10 below

Stretch the reduced pixel count image to be the same size as the proper image. The image will be recognisable even though the quality will be rubbish, but a 100 pixel wide image file will be 36x smaller than even the 600 pixel file and 900x smaller than the 3,000 pixel image, and Writer will fly while you are editing. When you are finished and ready to publish, replace the draft images with the higher quality images. See the second image below which I re-sampled down to 100 pixels wide - it is only 6 kBytes but recognisable even when stretched to the original size. (Note: If you highlight the original image, and then paste the reduced image; the pasted image is stretched to the exact size of the highlighted image and replaces it precisely).

6. Using linked images instead of embedded images reduces the document file size ...
... but means you need to manage the images location, and send the images separately if you send the file to someone

When you insert an image it can be inserted as an embedded image or as a linked image.

Images are embedded by default so if you drag an image into AOO, or paste (a graphic file!), the image is embedded. If you wish to link an image you must go Insert > Picture > From File ..., and tick the Link box on the file selection pop-up. The tick is sticky. I always use embedded images.

An embedded image is stored in the document and is therefore always available. The document file is larger because it contains the image files. This is the default for inserting images.

A linked image is not stored in the document - instead the document stores the location of the image. Whenever the document is opened, Writer goes to that location and gets the image, be it a web page or folder on the PC. If the image is no longer at that location, Writer cannot get it, and only its placeholder is shown. The .odt document file is smaller because it does not contain the image files. You insert linked images by Insert > Picture > From file ..., and ticking the Link box. Linked images are also useful if you have a document where an image is repeatedly updated over time - the document will always pick up the updated image.

If you send a document with linked images to someone else you must also send them the images, and tell them where to store the images on their PC so that Writer can find them and the receiver can see them. Similarly, if you move the document on your PC you must move the images too. For example, you might keep images in a subfolder named Images under the folder containing the document. The recipient of the file needs to put the images in a subfolder with the same name, Images, under the folder containing the document. If you right-click a linked image > Properties > Picture ..., you see the link address. You can use Properties > Picture > Browse button ..., to link to a different image. See Chapter 8 - Working with Graphics for more information.

It is probably much simpler to place the images in the same folder as the document and insert them from there. That way, the images must always be in the same folder as the document and recipients do not need to create a folder to contain them.

You can use linked images to reduce the file size when editing by the following trick:
  • Place all the full size images in a folder called Images and insert an image by linking to the image stored in the folder Images.
  • Now create a second folder of reduced pixel count images with the identical image names.
  • Stop Writer, replace the images in the Images folder with the low resolution images, and restart Writer. Writer will now pick up the low resolution, much smaller images.
  • When you want to see the proper images, put the full sized images back into the Images folder.
Check the OOo v3.3 Writer Manual for information on using linked images.

I prefer always to embed images in the document as they are then always available.

Are my images linked or embedded? How do I convert my linked images to embedded images?

If you want to check whether any images are linked, go Edit > Links ..., which shows which images are linked. If your images are linked Edit > Links > Break link ..., allows you to break the link(s) and embed the image(s) in the document.

7. Use 256 colour (8 bit) images instead of 16 million colour (24 bit) images if possible

If your images permit it, convert them to 256 colours (or greyscale for black and white) because the file sizes will be 3x smaller again. Change the colour depth in IrfanView by Image > Decrease colour depth.

Note: You cannot do this for JPG files. (Thanks JeJe).

You can do it for graphics images (PNG etc) but you sometimes get strange effects when you reduce the number of colours. This is because image editors like IrfanView are primarily designed for photos, and the method used to reduce the number of colours is non-linear - it emphasises the most used colours in the image and can eliminate less used colours completely. This is exactly what you want for photos, but it often has strange effects for graphics where you can get a green cast over the white in the image, and/or some colours can disappear completely. If this happens, just save the graphic as a .GIF file. GIF files only store 8 bit (256 colours) - they cannot save 24 bit images - and the IrfanView colour mapping from 24 bit to 8 bit is linear, giving excellent results.

8. Choose an appropriate Quality Factor when you save a JPG photo

When you save a JPG file (in IrfanView and other editors) you can choose the Quality Factor for the file (0 = worst, 100 = best). The higher the QF, the better the quality of the image BUT the larger the file. QF = 85 is a good compromise for normal photos, 90 to 95 might be necessary of you have very fine detail in the photo, or a composite image with photo and text. JPG images from my camera seem to have been saved at QF = 100 as saving them at QF = 85 reduces the file size enormously.

9. Increase the size of the AOO Graphics Cache

The default value of the Graphics Cache is only 20 MB (AOO 4.1.3). PCs have much more memory these days, so it is well worth while increasing it to 200 MBytes (256 MBytes is the maximum) as shown in the image below. Tools > Options > OpenOffice > Memory ...

10. Turn off graphics display

It may also help to turn off graphics display: Tools > Options > OO Writer > View > Display > Graphics & Objects: OFF

The images are not brought into the document while you are editing the text and show as empty rectangular placeholders labelled "graphic". The images are shown in File > Page Preview ..., and are printed when you print the document or create a PDF. [Thanks to acknak]

11. Learn about Anchor and Wrap options - get it wrong and your images will keep moving :crazy:

When you insert an image into Writer it is always anchored to something. Right-click an image > Anchor ..., and you see the Anchor options, where you can
  • Anchor to the page
  • Anchor to a paragraph
  • Anchor TO a character
  • Anchor AS a character
Anchor to a paragraph

Writer uses Anchor to a paragraph as the default option when you insert an image by dragging it into Writer, by going Insert > Picture > From file ..., or by pasting (a PNG!) image. When you drag in an image it anchors to the start of the paragraph where you drop it. When you Insert > Picture > From file ...; or paste in an image; the image anchors to the start of the paragraph where the cursor is.

The image and its anchor must be on the same page. If the paragraph begins on a previous page the image will be located on the previous page anchored to the paragraph start. The image will actually appear above the text but is anchored to "where the paragraph would start if the image was not there". If the image is too big to be inserted on the previous page the start of the paragraph and the image will be spilled to the next page.

Be careful if you are using new lines instead of paragraph returns (you should not for many reasons) because your paragraphs will be huge and the start of the actual paragraph may be a long way away. A new line does not create a new paragraph.

If you move the item to which the image is anchored, the anchor and hence image moves with it; if you delete the item with the anchor, the anchor is deleted and so is the image. If you drag an image beyond its paragraph its anchor will move to the appropriate paragraph start.

I prefer the default Anchor to a paragraph for all my images, where the anchor is located at the start of the paragraph and I always make sure that the image is located close to (say, within a few lines) the start of the paragraph containing the anchor. Note that dragging an image will cause the anchor to jump to the next appropriate available place. When the anchor is where you want it to be, fine-tune the image location to position the image. If the paragraph is very long you may need to insert a redundant new paragraph just so that the image and its anchor are close together. Make sure the Anchor is on the same page as the image.

There is a disadvantage of using Anchor to a paragraph with very large documents (hundreds or thousands of pages) with lots of images because if you edit and, say, delete half a page of text on, say, page 7, then every page after page 7 has to get laid out again and this can cause images to spill to the next page - see Item 11A for the problem this can cause. In this case it may be better to Anchor to the page so that the images don't spill. However, if you want your image to be close to a paragraph of text it might lose contact with it - delete five pages of earlier text and your text will slip back five pages but your image won't move with the text because it is anchored to its page.

Anchor AS a character gives the least flexibility for locating the image, but gives very stable image location because the image is treated as "a big, special character". If you Anchor AS a character after the " a " in the word "cat", the image will always be located " c a [image] t". Obviously, you cannot Wrap text around an image Anchored AS a character.

Anchor to the page gives a very stable location for the image. However, if, say, you delete five pages of text earlier, your text will move up five pages but your image will stay put.

See Help and the manual for more information.

Wrap options

Similarly, right-click an image > Wrap ..., and you see the options which allow you to control how the text flows round the image, is prevented from flowing round the image, or is allowed to flow over the image.

No wrap means that the text ends above the image, and begins again below the image.

I find Optimal Page Wrap the most useful as the text now flows round the image. It is best to right-click the image > Picture > Wrap ..., and set gaps between the image and the flowed text.

Wrap in background allows you to overtype text on top on the image.

right-click an image > Picture > Type ..., gives many options and, for example, allows you to type the position offsets which is very useful to nudge the picture small distances; or accurately align or size more than one image; and set a gap between image and flowed text.

See Chapter 8 - Working with Graphics in the OOo v3.3 Writer Manual for a full description of the options available in Writer and Chapter 4 - Adding and Formatting Pictures in the Impress Guide for a full description of the options available in Impress. May I suggest you bookmark the pages.

11A. Why is my page count so high? Why does my page count keep changing? Why do white gaps appear in my document?

Occasionally, if an image in anchored to a paragraph, and the anchor is poorly located, Writer can get into a loop for several (or more) seconds. Large white gaps may appear and the page count may be variable and much higher than expected.

What seems to happen is that Writer tries to position an image on, say, page 4. There is not enough space for the image > so Writer spills some text to make room for the image > the spilled text takes the image anchor with it > which pulls the image down to page 5 > which leaves a gap on page 4 > so Writer pulls up some text to fill the gap > which pulls up the image anchor > which pulls up the image > but there is not enough space for the image > so Writer spills some text > which takes down the anchor ..., and so on ad infinitum. Writer eventually drops out of this loop with the image located where it was positioned when Writer pulled out and often a white space gap is left in the text. This is particularly noticeable when using Master Documents where the entire document is laid out each time the document is opened or updated.

While not related to images, this "layout problem" can also happen with footnotes for the same reason - see [Solved] AOO stops responding when opening this one document. Similarly, tables can split with large gaps between the parts.

If you have a very large document with many hundreds or thousands of pages AOO can take 30 minutes to lay out the document.

How do you stop it happening?

You need to help Writer to layout the pages. First, ensure that your images are close to their anchors. If your paragraph is long and the image is a long way from the anchor add a redundant new paragraph for the anchor to use. Try adding an extra, redundant paragraph break (or breaks) or redundant page break(s) so as to stop the spilling, or to force the spilling. But don't forget that, if you add or delete text before where the problem is, you might cause it to happen again. Change the anchor to page or character.

12. Inserting multiple images - why do they all stack up like crazy?

Remember when you drag in an image it anchors to the start of the paragraph where you drop it and when you Insert > Picture > From file ..., it anchors to the start of the paragraph where the cursor is.

Say, for example, you create a new, empty document and then insert three images. By default, images are inserted Anchored to a paragraph. As there is only one (empty) paragraph in the new document, all three images will be anchored to it, and all three images will overlay each other. This is a sure recipe for endless frustration and confusion, and for random moving and even losing images. Note that you cannot drag an image to a new page because there is no new page to drag it to. If you insert a new page and drag an image to it, its anchor will move to that page.

If you create a new, empty document and want to add multiple images it is much better to put in lots of empty paragraphs (press Enter multiple times) and anchor each image to its own, nearby paragraph. Be sure to anchor each image to its own anchor - do not anchor more than one image to any one anchor location..

It is also very easy inadvertently to delete a highlighted image by inserting another image while the first is highlighted. The new image promptly deletes the highlighted image and takes its place (and resizes itself to be the same size as the replaced image).

13. Copying and pasting text and images from the internet - the images don't appear or things go funny

There are numerous different ways a web page can be coded to display an image and what happens if that image is copied or dragged so it is impossible to give precise advice apart from follow the suggestion below: copy the image into an image editor > process as required > insert into AOO or LO.

The problem is made worse because there are inconsistencies between AOO and LO when copying and pasting images from the web; and LO sometimes succeeds where AOO fails. There are further inconsistencies and different behaviours depending on the browser being used, on whether copying from http:\\ or https:\\ sites, and whether an image is copied or dragged (AOO sometimes stores dragged PNG or JPG images as huge BMP files!).

The best way to copy images from the web (copyright permitting) is to download the image, process it as required in an image editor, save it as a JPG, PNG etc as appropriate and then insert the image file as normal. Alternatively, take a copy of the image (r-click it) and paste the copy into an Image Editor like IrfanView as this strips any associated web coding. Save the image as a PNG, GIF, JPG etc as appropriate and insert the saved PNG, GIF or JPG image file as normal. If you don't you are likely to run into some problems.

First, never drag images from a web page into Writer as the results are unreliable and browser dependent. There is (2020) a bug in Firefox which means that all images dragged from the web are stored in the .odt file (AOO) as huge BMP images. A test shows that dragging a typical 3,264 x 2,448 pixel JPG, which is 2.96 MBytes as a JPG, stores the image as a 32 MByte BMP. As a BMP of a photo compresses poorly, the .odt file with just the image and nothing else is a staggering 15.8 MBytes. Downloading the JPG file first and then dragging it from the desktop is fine - it gets saved as a 2.96 MBytes JPG file inside the .odt.

Second, if you copy and paste images from the internet they are often inserted as linked images, which means that only the location of the web image is stored in the document. Each time the document is opened, the document goes to that web page and pulls down the specified image. If you are not connected to the web, or if the site is down, or if the page has been changed, or if the image has been removedremoved, the image cannot be pulled down and is not displayed. But you read Points 1 and 2 so you won't be pasting any photo images, will you ...

Third, you will often find that if you copy "a range of text including some images" some or all of the images do not paste into the document, or things "go funny". This is because there are different ways to code a web page to display an image, and some of those methods do not survive the copy/paste. It is far better practice to download the images to your PC, process them, and insert them in the document that it is simply to "paste what was on the web page". Right-click the image > Save image as ..., and save the image (photos as JPG, others as PNG). Now insert the saved image. Similarly, copy the text and strip all formatting during the paste by Edit > Paste Special > Unformatted Text. There seems to be a bug in Firefox/AOO which does not cope with all web page image codings so other browsers may be better.

14. Rotating images

You cannot rotate an image using Writer. Either open the image with an image editor like IrfanView, and rotate it there; or copy the image into Draw, and rotate it there (r-click image > Position and size > Rotation) and copy it back. Strangely, you can rotate an "image copied from Draw into Writer" by right-clicking the image > Position and size > Rotation ..., and set the angle. Presumably the copied image brings in the rotate attribute? from Draw and you now have access to changing it.

15. VERY important. Do not be too quick in slamming the laptop lid shut after saving the file
 Edit: March 2021. It has now been confirmed that there is a bug in AOO where AOO does not prevent a PC shutting down while a file is being written. 
Give AOO plenty of time to close gracefully, and to save the file properly, and then to save the profile file (which is the last thing it does). When you close a file, AOO continues to write the file for some time - it could be seconds - after the moving green bar has stopped. An AOO file of 80 MBytes takes a LONG time to write - several (many tens of?) seconds. Files which are slow to paginate (eg with many images or footnotes or use a Table of Contents) can take minutes to open or save. Long save times are very noticeable if you save to a network disk where even small files can take 30 seconds or more on a slow network. Do a simple check: Start TaskManager and watch the soffice.bin CPU usage when you save your large file. Wait till soffice.bin is using no CPU (ie pagination, layout and ToC is complete). Now Save - it isn't saved till soffice.bin CPU use falls to zero.

There is some evidence to suggest that problems arise when people either slam the laptop lid shut while the file is still being written, or else say "Oh! I forgot to ...", and then try to open the file which is still being saved. And, of course, always eject any USB memory stick properly to ensure any cached data is moved to the USB memory.

16. Lost images ... and a word of caution about using AutoRecovery. LibreOffice 6.1 and later is now probably better than AOO

Case 1 - user error A silly but common reason for losing images occurs when many images share the same anchor location as in 11 and 12 above, or the anchor is a long way away. Make certain that each image has its own anchor and make certain that each image is positioned close to its anchor and not, for example, on a different page.

Case 2 - random loss at any time There seems to be a problem with AOO (and with older versions of LO) where images occasionally get lost. It seems to be quite random although it seems more common when many large images are inserted in one session - I have seen it happen on adding over 50 x 1.5 MB images. You scroll up through the document and find that images are missing, or you open a saved document and images are missing - all you get is a small box with Read Error. It seems to be random and with no apparent user or program cause. It seems to happen more often if many images are added between saves. Sometimes it happens when you open a previously good file and you find some or all images are missing. It happens in Writer and Impress and no doubt in all modules as the image handling code with the bugs is common to all.

I reported Issue 126970 - Lost images while editing a Writer .odt file - two scenarios but there are numerous other bug reports about it.

Recommendation. Lost images cannot be recovered from the .odt file so always keep of separate copy of any images you insert just in case you lose them from the file.

Case 3 - loss when an AutoRecovery save is made Another rare case is where images are lost at the precise moment at which an AutoRecovery save is made. If you set Tools > Options > Load/Save > General > AutoRecovery ..., to, say, five minutes, then Writer saves your document in a temporary file every five minutes to protect you from PC crashes, AOO failures etc. I normally recommend that people set AutoRecovery to ON and I have it set to ON on my PC. However, there are some extremely unusual cases (I have seen it occur) where some or all of the images in a file are lost at the precise moment at which an AutoRecovery save takes place. Strangely, it seems to be file dependent and, while it can be replicated on specific files, it never happens on other almost identical files (eg that file with a few small edits). I have raised a bug report with an example file where the images are lost when an AutoRecovery save takes place on AOO 3.4. Strangely that same file was fine on AOO 4.1.

Recommendation. Try LibreOffice. If you want to continue with AOO then try turning off Graphics Display and AutoRecovery ...

... by Tools > Options > OO Writer > View > Display > Graphics & Objects: OFF; and Tools > Options > Load/Save > General. I think this is likely to prevent image loss because the images are not displayed while you are editing so they are not swapped in and out of memory as you scroll. The images are shown with placeholders while you edit, and are shown in Preview mode, and print as usual. I would save the document before printing or using Preview as, if that causes image loss, you can abandon the file and go back to the saved copy.

Second, backup, backup and backup and keep separate backup copies of images you insert. See the Timestamp Backup extension which is designed for LO but (2018) works with AOO. When you use it, every time you save your file, you save it as normal but, in addition, you save a time stamped version of it in a separate backup folder. You need to delete older versions in the backup folder yourself.

I do not think that using linked images will be any more reliable than using embedded images because, judging by what happens to content.xml when an image is lost, I think you will lose the link if the problem occurs. However, a major advantage of using linked images is that the images themselves will not be lost and they will still be in their original folder(s). If you use linked images and you want embedded images in the final document you can easily break the links when the document is complete which embeds the images. Do so by Edit > Links > Break link.

After that, then be aware of it. If you have a lot of images in your document where losing them would be a major headache, then take special care. Perhaps split the document into smaller documents, where each has a manageable number of images if you lose them - replacing them will not be a major task. Keep original copies of your images in case you do need to replace them. You could switch off AutoRecovery and train yourself (or get a reminder utility) to save the document frequently while you are editing it - Ctrl+S saves with a keystroke.
 Edit: The image handling code in LO (inherited from OOo and as still used by AOO 4.1.7) was recently (2018/2019) completely rewritten to address the image handling problems and LO may therefore now be more reliable than AOO in image handling. LO spent 40,000 Euros on having a professional programmer rewrite the image handling code so it was probably about six person-months of work suggesting it was a lot of work. The bug report states
The code we've inherited [from OOo] that deals with image caching, swapping in, out, lifecycle management of images via strings, swapping in and out to documents etc. is broken beyond belief. This is a tracker bug to start aggregating these horrors.
While substantial improvements were made to LO it appears there are still "a few problems remaining" - see Comment 41
See LO Bug 47148 (Image-Caching) - [META] Image handling problems,
Image handling rework for LibreOffice – Collabora’s tender results (June 2018),
How TDF uses its tendering process to improve LibreOffice and share knowledge with the community,
Has LibreOffice 6 just killed the indispensable "Memory" options? and
Bug 110448 - Remove "Memory" page from Options dialog; only adjust the settings using Expert Configuration.
 Edit: If you are using AOO then making the following adjustments in Tools > Options > OpenOffice > Memory ..., may reduce the probability of image loss by minimising the risk that images are moved from memory to disk. Note however that LO has removed these settings from casual user change and placed them in Advanced Settings.

1. Minimise the images file size (ie MBytes as stored in the AOO file) - see this tutorial. It is the size of the JPG file (not pasted!!) or the PNG file.
2. Set the Graphics cache to 255 MB - it is the maximum allowed
3. If the maximum image file size is 1.5MB, then set Memory per object to 1.6 or 2.0 MB - this allows more images to remain in memory
4. If you set Memory per object to 2MB in 3. above, set Number of objects to 255/2 = 127 images.

That maximises the chance of all images staying in memory and none being swapped out to disk when it is suspected the images are lost. 

Go Tools > Options > Load/Save > General > Always Create Backup Copy ..., as this creates a backup copy of the file as it was when you opened it and saves it in the Backup folder (the default is C:UsersxxxxxAppDataRoamingOpenOffice4userbackup). The backup is not overwritten if, while editing, you Save the file but, if you close the file, the backup copy is overwritten when you next open the file.

If you do lose your images while you are editing the file, you can at least save your image-less file with a new name. Now open the backup file, and then copy the new text into it. Be careful not to save the image-less document under its original name as this will overwrite the backup if you re-open the image-less document. Do some tests to ensure you understand when you will over-write your backup copy so that, if you get a problem, you don't overwrite it before you need to use it!
Using IrfanView to re-sample a photo from 4,320 pixels wide (jpg = 6.8 MBytes) to 600 pixels wide (jpg = 0.12 MBytes).<br />Note:  the image shown has reduced quality to allow it to be uploaded here
Using IrfanView to re-sample a photo from 4,320 pixels wide (jpg = 6.8 MBytes) to 600 pixels wide (jpg = 0.12 MBytes).
Note: the image shown has reduced quality to allow it to be uploaded here
Original photo resampled to 100 pixels wide is only 40 kBytes.  <br />Image stretched in AOO to 4x larger is blurred but easily recognisable<br />The 100 pixel image is 150x smaller than the original photo (40kBytes compared with 6MBytes).<br />Reducing the QF or reducing the number of colours would make it 500x smaller without any significant further change.
Original photo resampled to 100 pixels wide is only 40 kBytes.
Image stretched in AOO to 4x larger is blurred but easily recognisable
The 100 pixel image is 150x smaller than the original photo (40kBytes compared with 6MBytes).
Reducing the QF or reducing the number of colours would make it 500x smaller without any significant further change.
Reset graphics cache to 200 MB or more
Reset graphics cache to 200 MB or more
Last edited by John_Ha on Wed Sep 28, 2022 12:02 pm, edited 119 times in total.
LO, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
Hagar Delest
Posts: 30683
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Tutorial] Some useful hints on using images

Post by Hagar Delest »

In addition to IrfanView, there are also:
- XnViewMP, equivalent to IrfanView. It is Multi-Platform, very good looking and efficient. Available in many languages.
- GIMP, which is an image editor (equivalent to Photosop), useful to improve pictures very precisely.
LibreOffice 7.2.6 on Xubuntu 22.04 and 7.2.6 portable on Windows 10
Posts: 9096
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Tutorial] Some useful hints on using images

Post by John_Ha »

Other free Image Editors include (though there are many!)

- paint.net and
- FastStone Image Viewer (Faststone has a fantastic Heal tool which clones while taking account of the texture - it is truly magic)

Both are similar to IrfanView, in that they are powerful, but much easier to use than the much more comprehensive GIMP (free), and PhotoShop.
Last edited by John_Ha on Fri Apr 13, 2018 3:48 pm, edited 2 times in total.
LO, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Posts: 9096
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

How to use a shape to frame an image

Post by John_Ha »

This is based on this post [Solved] Framing Images with Shapes

1 Download a suitable heart image.

2 Download a suitable image editor - I use the free and excellent IrfanView and edit the heart image.
- Image > Decrease colour depth ..., to reduce the image to two colours - black and white (this avoids the "black edge" line you otherwise get)
- Image > Negative ..., to invert the colours so the heart is black and the background is white
- Image > Resize/Resample..., to, say, 500 x 500 pixels
3 Save As ...
- choose PNG >>> you must choose PNG here because PNG supports transparency.
- click Save Transparent Colour.
- choose the black heart shape as the transparent colour.

You now have a 500 x 500 pixel heart shaped "mask", where the heart shape is transparent, and the background border (in my image) is white. Note how in the image below, the heart is transparent and therefore shows the page blue background.
heart.png (1.73 KiB) Viewed 40643 times
4 Open the cat photo with IrfanView
- Image > Resize/Resample..., to, say, 500 pixels high - ie similar to the heart mask as pixel overlays pixel
- Edit > Insert Overlay/Watermark..., and navigate to heart.png
- Click Preview..., and adjust the mask position etc as required. I didn't make any adjustment - I should have lowered the cat a bit.

5 Save. You can save it as any format - JPG, PNG etc - because you do not now need transparency. However, you must save the transparent mask as a PNG file in Step 3.
cat in heart.jpg
Note: The example image quality is poor so as to keep the file sizes small. The original heart image was 2,000 x 2,000 pixels and the heart was red.

You will appreciate the simplicity of doing this with software which is designed to do it. Writer is, unsurprisingly, primarily a text editor, and not an image editor. That is why I stated that users are strongly recommended to do all their image processing using a good image editor before loading the completed, final image into Writer.

The forum places the image files as in-line images, not download files - see the ZIP file in the next post for all three files.
Last edited by John_Ha on Wed Apr 08, 2020 2:37 pm, edited 3 times in total.
LO, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Posts: 9096
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

How to use a shape to frame an image - files

Post by John_Ha »

These are the image files - download and double-click the file to extract them.
mask files.ZIP
(77.81 KiB) Downloaded 556 times
LO, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Posts: 210
Joined: Tue Apr 18, 2017 8:23 am
Location: Germany

Re: [Tutorial] Some useful hints on using images

Post by erbsenzahl »

... I only did it on Draw, heart shaped tomcat*.
* It's because of our beloved tomcat at home, named Ratzinger. ;)
LibreOffice current versions 7 and OpenOffice 4.1.13
on LinuxMint 19 or 20 Mate, W10-64 pro
Posts: 2056
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Tutorial] Some useful hints on using images

Post by JeJe »

7. Use 256 colour (8 bit) images instead of 16 million colour (24 bit) images if possible

If your images permit it, convert them to 256 colours (or greyscale for black and white) because the file sizes will be 3x smaller again. Change the colour depth in IrfanView by Image > Decrease colour depth.

You can do this for photos (JPG) where the difference is often almost impossible to see.
I was getting the same file size doing that and looking into it it seems that JPEG doesn't use a reduced color palette, just 24 bit.
Openoffice 4.1.6
Windows 8
User avatar
Hagar Delest
Posts: 30683
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Tutorial] Some useful hints on using images

Post by Hagar Delest »

+1. That part is rather misleading indeed. It works for lossless formats like png but not for jpg.
LibreOffice 7.2.6 on Xubuntu 22.04 and 7.2.6 portable on Windows 10
Posts: 9096
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Tutorial] Some useful hints on using images

Post by John_Ha »

JeJe, Hagar

Thanks. I have corrected it as, for anything a typical user does, JPG will remain at 24 bit.

Researching it I was surprised to find that the Extended form of JPG supports 12 bit.
There are also many medical imaging, traffic and camera applications that create and process 12-bit JPEG images both grayscale and color. 12-bit JPEG format is included in an Extended part of the JPEG specification. The libjpeg codec supports 12-bit JPEG and there even exists a high-performance version.
LO, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Post Reply