Bug 142781 - HTML import: base64 PNG image is stretched on import (height is scaled to 200% and aspect ratio not kept)
Summary: HTML import: base64 PNG image is stretched on import (height is scaled to 200...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
6.2.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.3.0
Keywords:
Depends on:
Blocks: HTML-Import
  Show dependency treegraph
 
Reported: 2021-06-11 06:21 UTC by stragu
Modified: 2021-11-17 07:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
example HTML document (745.95 KB, text/html)
2021-06-11 06:22 UTC, stragu
Details
Screenshot of Writer 7.2 after opening the HTML file (54.91 KB, image/png)
2021-06-11 06:23 UTC, stragu
Details
screenshot of HTML document opened in Firefox 89 (40.56 KB, image/png)
2021-06-11 06:23 UTC, stragu
Details
PNG picture exported from Firefox, for reference (18.90 KB, image/png)
2021-06-11 06:25 UTC, stragu
Details
image import html (79.53 KB, image/png)
2021-07-08 11:55 UTC, paulo g.
Details
Screenshot: fixed in LO 7.3 alpha1 (58.78 KB, image/png)
2021-11-17 07:14 UTC, stragu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stragu 2021-06-11 06:21:41 UTC
Description:
Importing a HTML file with a picture encoded in base64 results in a very large picture that didn't conserve the aspect ratio.

Steps to Reproduce:
1. Open attached HTML page with Writer (a report created from an R Markdown document)

Actual Results:
Picture is stretched vertically (maybe?) and squashed horizontally. The aspect ratio is not kept.

Expected Results:
Aspect ratio should at least be kept, and height should probably not be as big.


Reproducible: Always


User Profile Reset: No



Additional Info:
Versions tested:

Version: 7.2.0.0.alpha1+ / LibreOffice Community
Build ID: 7f3c9da5a0a8f27e3fe63c39a30fc08e34246420
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-06-10_17:32:52
Calc: threaded

Version: 7.1.3.2 / LibreOffice Community
Build ID: 47f78053abe362b9384784d31a6e56f8511eb1c1
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Version: 7.0.6.2
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

7.1.3 opened in Web View, but still the same size issue.
Comment 1 stragu 2021-06-11 06:22:50 UTC
Created attachment 172783 [details]
example HTML document

This HTML document is the output of an R Markdown file.
Comment 2 stragu 2021-06-11 06:23:25 UTC
Created attachment 172784 [details]
Screenshot of Writer 7.2 after opening the HTML file
Comment 3 stragu 2021-06-11 06:23:53 UTC
Created attachment 172785 [details]
screenshot of HTML document opened in Firefox 89
Comment 4 stragu 2021-06-11 06:25:55 UTC
Created attachment 172786 [details]
PNG picture exported from Firefox, for reference
Comment 5 stragu 2021-07-08 07:03:39 UTC
Reproduced in earlier version as well:

Version: 6.2.5.2
Build ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: en-AU (en_AU.UTF-8); UI-Language: en-US
Calc: threaded

One can restore the right aspect ratio by going to: image context menu > Crop tab > Click "Original size"

The issue seems to be that, when opening the file, the height of the picture is scaled to 200% (but the width is 100%).
Comment 6 paulo g. 2021-07-08 11:49:24 UTC
it does in ubuntu 20.04...
Comment 7 paulo g. 2021-07-08 11:55:38 UTC
Created attachment 173445 [details]
image import html
Comment 8 paulo g. 2021-07-08 11:59:59 UTC
(In reply to paulo g. from comment #7)
> Created attachment 173445 [details]
> image import html

i have test it in 7.3
Comment 9 stragu 2021-07-09 12:43:36 UTC
Paulo, given that you reproduced the bug, could you please set the status to "NEW"? Cheers :)
Comment 10 Andreas Heinisch 2021-11-12 20:07:16 UTC
Just a question/remark about the problem. What do we expect should LO do in the following cases:

1) Width/Height given -> take both values for Writer
2) Height/width given -> calculate the respective width/height and automatically keep the aspect ratio?
3) Nothing given -> take the original size
Comment 11 stragu 2021-11-13 05:32:01 UTC
(In reply to Andreas Heinisch from comment #10)
> Just a question/remark about the problem. What do we expect should LO do in
> the following cases:
> 
> 1) Width/Height given -> take both values for Writer
> 2) Height/width given -> calculate the respective width/height and
> automatically keep the aspect ratio?
> 3) Nothing given -> take the original size

What is the difference between 1) and 2) ?
Comment 12 Andreas Heinisch 2021-11-13 08:21:35 UTC
Sry, was not specific enough. If you have given only the width, calculate the respective height keeping the aspect ratio and vice versa.
Comment 13 Commit Notification 2021-11-16 16:13:26 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7a2d8ee2b45b8dd0f614614368ae90878e51a645

tdf#142781 - Calculate width/height keeping aspect ratio

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Andreas Heinisch 2021-11-16 16:15:58 UTC
This patch still does not address some corner cases during the import of an image in an html document. For instance, if the width/height is explicitly set to 0, LO tries to retrieve some default value for the image, whereas a modern browser does not show the image.

Maybe there will be some follow ups for this fix, if there are any new bug reports for importing an html document including images.
Comment 15 stragu 2021-11-17 07:14:35 UTC
Created attachment 176305 [details]
Screenshot: fixed in LO 7.3 alpha1

Thank you Andreas!

Verified as fixed in:

Version: 7.3.0.0.alpha1+ / LibreOffice Community
Build ID: eec32be26d5d5805c1cb8cb53ce9702c04829819
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded