Compress images

Good morning and again a strange question.
I am writing a little book that is scheduled to be published as an ebook.
The formatting instructions from the publisher (Smashwords) are
exclusively based on the use of Word.
There is a 10 MB file size limit, which my book exceeds due to the
included pictures.

The instructions urge (I did not know that trick) to "compress all
images in the file".
And this works.

IS there something like that in LO?
I saw mentioning of "Presentation minimizer" on the page
https://www.libreoffice.org/features/extensions/
but a search for that extension gives "no results".

Anyway, this is meant for Impress. Is there a trick to do that in Writer?

Thank you.
Thomas

There is a 10 MB file size limit, which my book exceeds due to the
included pictures.

Thomas, beginning with LibreOffice 4.1 there is a new feature where if
you right-click on an image in your document you will see the option
"Compress Graphic...".

This opens a dialogue box where you are provided with information about
that image (including its current size), proposed compression settings,
and a Calculate button to see the new size of that image if you were to
accept those settings.

I have not found a way to do this on all the images at once.

Because the changes are permanent, I suggest you *first* save a copy of
the original (large) document. That way you can try again if you
compress the images too much and loose too much image quality.

Dale.

What format and compression "level" are you using for your images?

You could always use JPG and make the image "compressed" to the greatest
level that still a good viewable quality. Also, make sure you images are
the "exact" size you want for the document and not need to resize it to
a smaller size in the document to fit the image area you are using. That
will reduce the amount of "space" in the file needed to store the image.
I have seen too many documents with nearly full page size images that
are reduced to a visible one of less that 2 inches. That just add a lot
of file size to the document that is not needed.

So, make you image out side your document the visible size and
compression level you want/need first, then you do not need to resize it
in the document and add unneeded file space/size in your document.

Kracked_P_P---webmaster wrote:

There is a 10 MB file size limit, which my book exceeds due to the
included pictures.

Thomas, beginning with LibreOffice 4.1 there is a new feature where if
you right-click on an image in your document you will see the option
"Compress Graphic...".

This opens a dialogue box where you are provided with information about
that image (including its current size), proposed compression settings,
and a Calculate button to see the new size of that image if you were to
accept those settings.

I have not found a way to do this on all the images at once.

Because the changes are permanent, I suggest you *first* save a copy of
the original (large) document. That way you can try again if you
compress the images too much and loose too much image quality.

Dale.

What format and compression "level" are you using for your images?

You could always use JPG and make the image "compressed" to the greatest
level that still a good viewable quality. Also, make sure you images are
the "exact" size you want for the document and not need to resize it to
a smaller size in the document to fit the image area you are using. That
will reduce the amount of "space" in the file needed to store the image.
I have seen too many documents with nearly full page size images that
are reduced to a visible one of less that 2 inches. That just add a lot
of file size to the document that is not needed.

So, make you image out side your document the visible size and
compression level you want/need first, then you do not need to resize it
in the document and add unneeded file space/size in your document.

Many image formats, especially jpeg images downloaded from digital
cameras, contain metadata tags (eg camera maker/model, time/date and
many others). Removing all these metadata tags can sometimes make a
worthwhile contribution to reducing the size of your image files.

A handy little program I use for resizing, compressing and stripping
metadata from images before inserting them into a document is "FastStone
Image Viewer": http://www.faststone.org/FSViewerDetail.htm Not OSS, but
free for personal use. A Windows only program, but undoubtedly there are
equal or better ones for other platforms.

Dave

Yes, the whole idea is to reduce all of the file size of the image before you use it in your document. I keep forgetting about stripping the Metadata from the image.

I use Faststone Image Viewer in Ubuntu running it in Wine. I use it to sort and rename pictures for websites. There is also a free Windows program called Easy Thumbnails, which works great for resizing pictures and also making high quality thumbnails. I also run it in Ubuntu using Wine. Both have several quirks in Wine, but nothing making them not usable. I've not found any Linux equivalents for these. Another option in Linux running gnome would be to install the nautilus image converter which allows you to resize pictures directly in a folder by right clicking on the photo or photos, and then resizing directly from the menu without even needing to open a program.

Don

Some photo/image software has "save for the web" type of options. Last time I used one of those Windows image editors, it did reduce the size of the image's file by a lot and still made the visual image look good. I think many of the more "professional" - i.e. not free - packages do have some type of image size reduction procedure to prepare the image for the web. That way the user does not have to download large images files, and saves bandwidth.

Yes, I do have a few paid Windows packages, even though I am a Ubuntu user by default. Still there are a lot of free stuff out there for Windows and Ubuntu that can do the same thing. You just have to look for them and look for their image reduction for the web option. Sometimes it is buried, or at least the last time I look for them they tended to be.

I do it the hard/easy way.

Look through your document for the largest image. While doing that,
guesstimate the average size of your images.

Put all images you are using into a folder.

Download Fast Image (JPG) Resizer for Java at http://fir4j.sourceforge.net/

This will...
mass resize all JPEG/JPG images in a directory

resize images
resize + crop images
resize + fill with background color to get the desired image dimensions
rotate images

Resize images somewhere half way between largest and estimated average
size. Pick your favorite statistical method.

Most images will be of better quality. If you are concerned about
watermarking, it will help there too.

Re-Import into document.

This assumes you have not linked to images.

If images are linked and in same directory, re-size all images into
sub-directory and paste sub-directory extension to URL/address.

Hope this helps.

Gimp also does a very good job in resizing and maintaining image quality, but it is picture by picture. Before I went to Ubuntu and was running Windows, Paint Shop Pro was my photo editing program. It doesn't, or at least didn't, work in Wine. I was happy with it. I found though, with Gimp, I could have an equal or better quality 450 x 600 photo in an equal or smaller size than I could get in a 375 x 500 photo reduced and compressed in Paint Shop Pro.

Don

I too am very familiar with the various third party methods mentioned below, but we must try to address the problem from the point of view of the OP. He was made aware of a very simple tool in Word that did exactly what he wanted. *How* it achieved it appeared to be of no interest. He was asking about the possible existence of a similar tool in LO.

Personally I believe LO needs an equivalent tool, because most of the people whom we are trying to convert to LO/OO have no knowledge and no interest in the round-about methods detailed below. If there was an easy method to perform automatic or one-click cropping and resolution reduction *after* the document was compiled, why wouldn't that be the preferred method for all users, regardless of their competency with other editing tools?

Hm. Probably because there is no "obvious" way to do it that would combine:
- ease of use
- efficiency in all case
- low development cost

I don't know how often this feature is requested for odt files. I know that
for pdf you can set parameters for the image compression, and it make sense
since the resulting file is unlikely to undergo future changes, but it's
less obvious for file formats that are not at the "end" of the editing
line. It's probably better to work with the "highest" resolution needed,
and produce smaller files as needed. Hmm.

As a "proof of concept", I put together a java program that take an odt
file as input. You can then set the "requested" DPI and jpeg quality, and
save. At this point, every pictures that are larger than needed (that's why
we need DPI) are resized, and all pictures are compressed using either jpg
or png, whichever gives the smalles size. Something as simple as that
already have issues, like when there's transparency involved.
Also, it's only tested on a few files (including
https://wiki.documentfoundation.org/images/9/96/WG40-WriterGuideLO.odt for
funsies).

If anyone want to give it a try here's the jar. It's highly unlikely to
corrupt your source file (the source file is never ever written), but
there's also no guarantee that the output will work :wink:
<http://cleyfaye.net/share/odtcompress.jar>
For example, on the writer guide linked before, it goes from 13MB to 9MB
with default settings. Of course it's not the best example: all pictures
are already reasonably sized, and it's mostly screenshots so the quality
drop is very noticeable...

Anyway, if anyone want to look at the source code (without reversing the
jar :D) I'll provide them. But know that it's mostly an ugly hack just to
see how well it would work :slight_smile:

I don't know how often this feature is requested for odt files. I know that for pdf you can set parameters for the image compression, and it make sense since the resulting file is unlikely to undergo future changes, but it's less obvious for file formats that are not at the "end" of the editing line. It's probably better to work with the "highest" resolution needed, and produce smaller files as needed.

Fair point. However most documents reach a finished state, at which point they do not need to stay bloated.

Hmm. As a "proof of concept", I put together a java program that take an odt file as input. You can then set the "requested" DPI and jpeg quality, and save. At this point, every pictures that are larger than needed (that's why we need DPI) are resized, and all pictures are compressed using either jpg or png, whichever gives the smalles size. Something as simple as that already have issues, like when there's transparency involved. Also, it's only tested on a few files (including https://wiki.documentfoundation.org/images/9/96/WG40-WriterGuideLO.odt for funsies). If anyone want to give it a try here's the jar. It's highly unlikely to corrupt your source file (the source file is never ever written), but there's also no guarantee that the output will work :wink: <http://cleyfaye.net/share/odtcompress.jar> For example, on the writer guide linked before, it goes from 13MB to 9MB with default settings. Of course it's not the best example: all pictures are already reasonably sized, and it's mostly screenshots so the quality drop is very noticeable... Anyway, if anyone want to look at the source code (without reversing the jar :D) I'll provide them. But know that it's mostly an ugly hack just to see how well it would work :slight_smile:

Cley, a good "proof of concept". It needs lots of work but certainly as a concept it gains my approval.

Dale.

Hi :slight_smile:
* I don't think this helps but when you export to Pdf there are
option on how much over all compression and under that is an option to
compress images more or less.

* I think i would prefer the approach of gathering all the images
into a single sub-folder (i tend to do that anyway jic i lose an image
from the document) then create radically smaller copies and put the
smaller copies into the file itself. Then zip the sub-folder so that
it's just 1 file for emailing or copying. Then it's 3 files to email
or copy; the zipped images, the editable document, the PDF. The Pdf
shows how it is meant to look. The editable document and images let
them use their expertise to quickly get the result they can cope with.

* For an ebook it might be worth joining in with the LibreOffice
Documentation Team and ask them for suggestions as they have looked
into doing ebooks a few times and might have some good advice. The
might also be quite appreciative if you experiment with their books to
test-drive the processes to find the best way.

* As with my 2nd bullet-point, still use Gimp or something to get the
images smaller but instead of just doing thumbnails as place-holders
just figure out what scale is optimal for each image and use those.

There are many photo and image editors out there. Gimp is one of the free ones
http://www.gimp.org/
Personally i really like it despite being happy to grumble about a few
things. I haven't tried some of the alternatives but tend to find
more grumbles about anything else i have tried. On balance i
personally find Gimp is the best for me unless i'm doing svgs (logos
and such) in which case i'm currently happy with Inkscape.

There are a lot of formats and it might be that a different format
might be better for some images. Each has their own niche.

Gifs are tiny and good if there is clear distinction between colours
and a limited range of colours (ie less than 8 is great). It's not
great if there is shading or smooth transition between colours

Pngs are great if you can index them but again that would mean no
smooth merging of colours. Alternatively it's great if you start an
image from scratch as a png. If cameras took pngs instead of jpgs
then the file-sizes would be smaller. Converting photos from jpg to
png usually means larger file-size until you do a lot of work.
Probably there are people who could advise on a good way to drop the
file-size easily but i haven't got it working yet.

Jpg is the normal format for most cameras and it's a good general
purpose format. It's compression can make a nasty mess of bits of
images where there is clear distinction between different colours.

Regards from
Tom :slight_smile:

Hi :slight_smile:
How about as an add-on/Extension for Draw?

Do we really need more bloat in Writer to make it into yet another
image editor? I'm happier using dedicated programs and thus making
the images available for use elsewhere and in other programs. Just
because Word does something bad doesn't mean we have to follow. Part
of the extra advantage of LibreOffice is that it works on low spec
systems that MS Office can't cope with.
Regards from
Tom :slight_smile:

Hi :slight_smile:
How about as an add-on/Extension for Draw?

Sounds clunky.

Do we really need more bloat in Writer to make it into yet another
image editor?

Most of the functionality already exists in Writer, and we are not talking about image editing in the literal sense, only about resizing and cropping. It need not contribute significantly to bloat if well written. Have you ever looked at IrfanView (a very capable and well regarded Windows image manipulation program) that is only 2.0 MB (installed size) with capabilities that go way beyond anything we are talking about.

I'm happier using dedicated programs and thus making
the images available for use elsewhere and in other programs.

Of all the images that I have processed for use in Writer, I have never used the same processed image elsewhere. Your usage may be different.

Just because Word does something bad doesn't mean we have to follow.

FUD? Who said anything about *that* functionality being bad?

Regards,
Dale.

​For the curious ones, I put this "tool" on github (binary & source) :
<https://github.com/CleyFaye/LOFiles/releases/tag/v0.1-alpha>​

This kind of tool is particularly useful if you're working with high-res
images, but intend to produce output at lower res. This way, you can keep
your original, and generate a file with images adequate for printing at
150dpi, another adapted to 90dpi, etc...

​As said, it should not damage anything; the worst outcome​ possible is the
output file being incorrect, so as long as you don't choose to save over an
existing file, you should be safe to try. If there is a high demand I might
keep on improving the code... :slight_smile: maybe also expand it with more tools,
like basic recovery of damaged files, things like that.

(2014/03/05 12:23), Cley Faye wrote:

If anyone want to give it a try here's the jar. It's highly unlikely to
corrupt your source file (the source file is never ever written), but
there's also no guarantee that the output will work :wink:
<http://cleyfaye.net/share/odtcompress.jar>

That looks very promising, but, please forgive the stupid question, how do you use it?
I downloaded the thing (whatever a "jar" may be) and when I click on it, a window opens,
asking me about the desired image quality.
But I do not know, how to specify source and/or target files.
How do you do that?

Hmm. I might have forgotten to include instructions in the jar, althouth
there's a readme... in the source repository :\​​

​There should be a "File" menu ​at the top of the window with "Open" and
"Save" entries. On different systems the menu might show up somewhere else
(I'm thinking mac and unity...)
Also, I see you're replying to my first message; if you want to give it a
try I highly suggest you use the last link I provided, as this version have
a few bug fixed:
<https://github.com/CleyFaye/LOFiles/releases>

Hi :slight_smile:
You generally put the source file straight after a command and then
the target file (hopefully avoiding over-writing an existing file!)
after that. So it's typically

command parameter (tags and such) existing-file resulting-file

usually written in instructions as

command source target

On a unix-based command-line the number of spaces doesn't seem to
matter but people generally only use 1 space. I've used more just to
make it clearer. Errr, did someone say they just clicked on it??

Regards from
Tom :slight_smile:

I am in the same boat as the OP. I have searched for a quick, simple
solution to this for several years, always smiling at the discussion boards
dismissal of it as a needed add-on... Just now decided the current solution
remains to find someone with a copy of Word and use it for the 5 minutes it
would take to do this. The 300 images in the documents I am working with are
secondary to the text, but they are nice to have. The .odt file is
occasionally emailed back and forth for editing of the text. The original
file I am working with was created by others less technical and they
embedded huge images. The production process will eventually led to an
InDesign or Web based product but for now the ability to email the files
back and forth is important. A single menu option to "Save As and Compress"
to A. Small, B. Smaller or C. Smallest Image size would be awesome. But
today I'll just take the files on a flashdrive to my neighbor next door...