Bug 100146 - Embedded images export / convert with degraded resolution
Summary: Embedded images export / convert with degraded resolution
Status: CLOSED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.1.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-30 19:12 UTC by Scott
Modified: 2016-05-31 17:31 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Minimal document with an image that fails to export as expected (1.02 MB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-05-30 19:12 UTC, Scott
Details
png as exported with --format=html ; blurry text (61.25 KB, image/png)
2016-05-30 20:09 UTC, Scott
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Scott 2016-05-30 19:12:05 UTC
Created attachment 125397 [details]
Minimal document with an image that fails to export as expected

Latest Version tested with this issue: 5.1.2.2

The image in the source docx is clear and legible, the image in the html or pdf export is very degraded.  Oddly, exporting to rtf doesn't seem to suffer from this bug.
Comment 1 V Stuart Foote 2016-05-30 20:00:59 UTC
On windows 10 Pro 64-bit en-US with
Version: 5.1.3.2 (x64)
Build ID: 644e4637d1d8544fd9f56425bd6cec110e49301b
CPU Threads: 8; OS Version: Windows 6.19; UI Render: default; 
Locale: en-US (en_US)

Can not confirm. Of three embedded images, one is PNG and the others are WMF. The main composition is a WMF at 345 x 221 px in 24-bit color. It renders correctly when exported to PDF (lossless compression) with no sign of resampling or pixelation.
Comment 2 Scott 2016-05-30 20:09:59 UTC
Created attachment 125400 [details]
png as exported with --format=html ; blurry text
Comment 3 Scott 2016-05-30 20:10:13 UTC
# unoconv --format=html Thermo\ Test.docx
generates an html file with the image encoded in base64 (as expected) but the text is blurry (compressed).  Take a look at the 31.8 °C.  It is blurry and looks almost out of phase.

# unoconv --format=rtf Thermo\ Test.docx
Open the generated RTF file.  Take a look at the 31.8 °C.  It is clear, as expected.
Comment 4 Scott 2016-05-30 20:35:58 UTC
I tested PDF export as you stated by doing:
    # unoconv --format=pdf -eUseLosslessCompression=true Test.docx
and it appears to function as you mentioned in Comment 1.

Please adjust my bug report to be export to HTML *only*.

Thanks for that!
Comment 5 Scott 2016-05-30 21:17:53 UTC
I believe the issue is that the dpi of the raster image (PNG) is low.  When the vector data (text) is placed into the low dpi image it is thus lacking the pixels to be clear.

To get around this, one can open the .docx as .zip, copy out the .wmf files.

# unoconv --format=pdf imageN.wmf
# unoconv --format=svg imageN.pdf

Oddly, one tries to export from .wmf to .svg directly there are some alignment issues.  You may wish to open a new bug report up for this (if it doesn't already exist).
Comment 6 V Stuart Foote 2016-05-30 22:07:24 UTC
I did see the mis-alignment of  wmf -> svg text when converted headless with a LibreOffice "convert-to svg". But going to close this NAB...

For doing these graphic format conversions the ImageMagick Convert utility, with a Ghostscript present, provides very clean format conversions--in fact internally LibreOffice makes use of these helper programs.

So for example:
"C:\Program Files\ImageMagick-7.0.1-Q16\convert.exe" image1.wmf image1.svg

Other wise not sure there is any issue here. Taking a 345 x 221 px Windows Meta File--a vector format (the image is raster, but text is not)--and converting to raster format PNG, there will be loss of fidelity between the vector font of the WMF and the rasterized font of the resulting PNG used in the HTML conversion.

RTF of course is a vector format.

=-note-=
And for Windows users, rather than unoconv --format=FTYPE <sourceFile>, the CLI is:

soffice.exe --headless --convert-to FTYPE <sourceFile> [<outputFile>]
Comment 7 Scott 2016-05-31 17:31:38 UTC
On Ubuntu 16.04 the conversion fails as follows:

# convert image4.wmf image4.svg
ERROR: player/record.h (28): Bad record - unexpectedly short!
ERROR: player/record.h (28): Bad record - unexpectedly short!
ERROR: player/record.h (28): Bad record - unexpectedly short!
ERROR: player/record.h (28): Bad record - unexpectedly short!
ERROR: player/record.h (101): Bad record - unexpectedly short!
convert: failed to scan file `image4.wmf' @ error/wmf.c/ReadWMFImage/2706.
convert: no images defined `image4.svg' @ error/convert.c/ConvertImageCommand/3210.

# convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-04-18 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib

-=note=-
The convert package isn't at version 7 as it was in your testing.

The work around is as mentioned in Comment 5