Bug 135348 - Distorted images when exporting to PNG (and possibly other formats) with transparency
Summary: Distorted images when exporting to PNG (and possibly other formats) with tran...
Status: RESOLVED DUPLICATE of bug 122155
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
6.4.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-31 17:14 UTC by msh
Modified: 2024-06-18 04:14 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Step 1 (4.80 KB, image/png)
2020-07-31 17:15 UTC, msh
Details
Step 2 (24.57 KB, image/png)
2020-07-31 17:15 UTC, msh
Details
Step 3 (19.35 KB, image/png)
2020-07-31 17:15 UTC, msh
Details
Step 4 (7.82 KB, image/png)
2020-07-31 17:16 UTC, msh
Details
Step 5 (19.28 KB, image/png)
2020-07-31 17:16 UTC, msh
Details
Step 6 (3.52 KB, image/png)
2020-07-31 17:16 UTC, msh
Details
Version info (22.42 KB, image/png)
2020-07-31 17:17 UTC, msh
Details
Transparent rectangle and circle in color to test (9.24 KB, application/vnd.oasis.opendocument.graphics)
2023-12-01 12:51 UTC, LeroyG
Details
Outcome of export selection to png (2.14 KB, image/png)
2023-12-01 12:51 UTC, LeroyG
Details
Impress slide with large margins and two drawing objects to export to PNG (48.45 KB, application/vnd.oasis.opendocument.presentation)
2023-12-02 20:50 UTC, Alistair Saywell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description msh 2020-07-31 17:14:09 UTC
Description:
When exporting to PNG (and possibly other raster formats), Draw proceeds to crop the image to its most compact shape, excluding all transparent space around it, and the produced image has the wrong width:height ratio (i.e. is distorted).

Steps to Reproduce:
Please consider the following sequence, numbered as per the attached screenshots.

1. I created this simple figure: a gray rectangle with a circle inside, placed at the recangle's right edge. No borders, only fill.
2. I took the outer rectangle and made it transparent.
3. I selected both shapes and proceeded to export to PNG.
4. Checked the "Selection" box in the save dialog, since I only want to export the selected shapes.
5. In the "PNG Options" dialog that pops up, I set the resolution to something fixed (e.g. 100 px/cm) and set one of the dimensions (in this case, width) to some fixed value (e.g. 1 cm); the other dimension gets adjusted automatically to keep it in proportion. Transparency is enabled too.
NOTE: the problem happens even if I don't touch these fields and leave them at their default values.
6. The resulting image is distorted out of ratio; the original circle now looks like an ellipse. Draw attempts to crop the image down to its most compact shape (excluding all transparent space around it), but still uses the width:height ratio of the originally selected shapes (from step 3).


Actual Results:
Generated PNG raster image is distorted/out of proportion in relation to original drawing.

Expected Results:
Aside from the fact that the wrong proportions are used (which is obviously a bug), I believe the export operation should not crop down to the most compact shape (excluding all transparent space around it), since it's very useful to be able to place a drawing inside a transparent rectangle/square and then export to a raster format with the correct overall pixel size.



Reproducible: Always


User Profile Reset: No



Additional Info:
I have tried this in LibreOffice Draw 6.4.5.2 portable (the latest official portable version available at the libreoffice.org website) on Windows 10, since unfortunately I can't install the full version in my IT-managed work computer.

This used to work just fine in 5.2.7 (unfortunately the only old version to which I can compare right now).

This bug is very annoying to me, since I need to export a large set of images with transparent space around them (so that they end up with correct pixel sizes) and I have no easy workaround to this issue. 

NOTE: this might be related to bug #134775, but I'm not sure.

I appreciate very much if you would consider fixing this.
Comment 1 msh 2020-07-31 17:15:27 UTC
Created attachment 163820 [details]
Step 1
Comment 2 msh 2020-07-31 17:15:43 UTC
Created attachment 163821 [details]
Step 2
Comment 3 msh 2020-07-31 17:15:57 UTC
Created attachment 163822 [details]
Step 3
Comment 4 msh 2020-07-31 17:16:13 UTC
Created attachment 163823 [details]
Step 4
Comment 5 msh 2020-07-31 17:16:29 UTC
Created attachment 163824 [details]
Step 5
Comment 6 msh 2020-07-31 17:16:52 UTC
Created attachment 163825 [details]
Step 6
Comment 7 msh 2020-07-31 17:17:14 UTC
Created attachment 163826 [details]
Version info
Comment 8 Julien Nabet 2020-07-31 18:08:07 UTC Comment hidden (obsolete)
Comment 9 Julien Nabet 2020-07-31 18:08:37 UTC
sorry wrong bugtracker, forget my last comment.
Comment 10 Buovjaga 2021-01-11 07:20:19 UTC
Please attach an example document.
Set to NEEDINFO.
Change back to UNCONFIRMED after you have provided the document.
Comment 11 QA Administrators 2021-07-11 03:40:38 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2021-08-11 03:59:27 UTC Comment hidden (obsolete)
Comment 13 LeroyG 2023-12-01 12:51:02 UTC
Created attachment 191176 [details]
Transparent rectangle and circle in color to test

No issue seen with:
Version: 7.5.8.2 (x86) / LibreOffice Community
Build ID: f718d63693263970429a68f568db6046aaa9df01
CPU threads: 4; OS: Windows 6.1 Service Pack 1 Build 7601; UI render: Skia/Raster; VCL: win
Locale: es-MX (es_MX); UI: en-US
Calc: threaded
Comment 14 LeroyG 2023-12-01 12:51:46 UTC
Created attachment 191177 [details]
Outcome of export selection to png
Comment 15 Alistair Saywell 2023-12-02 20:50:29 UTC
Created attachment 191197 [details]
Impress slide with large margins and two drawing objects to export to PNG

Export to PNG with transparency set exports only the parts of the slide inside the margins but the dimensions of the slide are set as the dimensions of the PNG resulting in distortion of the resulting PNG. Also applies to Draw. Attachment created as described:
    1. Open a new Impress blank slide at Screen 16:9
    2. Set the right and left margins to 10 cm, leaving an 8cm area for content
    3. Draw a 5.00 cm diameter circle, blue fill, inside the margins
    4. Copy the circle to overlap a margin and area fill circle to green
    5. Click File > Export and set PNG, ensure Transparency is ticked, leave other settings
RESULT: Exported PNG has proportions of full page but only the content within the margins are included. The blue circle is distorted to a flat ellipse and green circle is cropped, see slide 2
    6. Instead, click File > Export and set PNG, ensure Transparency is NOT ticked, leave other settings
RESULT: Exported PNG has proportions of full page and all content is complete and undistorted, see slide 3
Comment 16 Stéphane Guillou (stragu) 2024-06-18 04:14:54 UTC
Reproduced as in comment 15. Thanks for the updated steps and hints, Alistair.

Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 6f4adc1274cfac30b9097411bb193bd4386969f0
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3

Issue is tracked in bug 122155, let's mark as duplicate.

*** This bug has been marked as a duplicate of bug 122155 ***