Bug 148295 - Inserting rotated JPEG image takes several seconds
Summary: Inserting rotated JPEG image takes several seconds
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.1.3 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL: https://ask.libreoffice.org/t/insert-...
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Images
  Show dependency treegraph
 
Reported: 2022-03-31 17:30 UTC by Claudio Bogado
Modified: 2025-02-24 20:06 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
ODT and JPEG files (15.93 MB, application/x-zip-compressed)
2022-04-20 18:30 UTC, Claudio Bogado
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Claudio Bogado 2022-03-31 17:30:17 UTC
Description:
When inserting a JPEG file tagged as rotated, Writer first loads the image and then rotates the image, tanking several seconds on the process.

Steps to Reproduce:
1. Insert image

Actual Results:
The image is inserted after waiting up to 15 seconds.

Expected Results:
Image inserted instantly.


Reproducible: Always


User Profile Reset: No



Additional Info:
It takes more time when images have bigger resolution and wheen the file has already more than a 100 images inserted. If the image file is not tagged as rotated, the insertion takes no time at all.
Comment 1 Dieter 2022-04-14 05:14:19 UTC
Thank you for reporting the bug. As Mike Kaganski wrote in Lo Ask "If you can, please file a bug with a sample images attached, which are rotated and non-rotated, and which show the described problem. Thanks."

So please attach some images. Thank you
=> NEEDINFO
Comment 2 Claudio Bogado 2022-04-20 18:30:26 UTC
Created attachment 179688 [details]
ODT and JPEG files

I attached three files:
Two JPEG files, one that is rotated and the other files that is not rotated.
One ODT file, with the two images inserted inside table cells.
The issue can be repeated inserting the images in any ODT file.
I think this issue can be solved if there is a JPEG library that can load the image rotated instead of rotating the image after beeing loaded.
Comment 3 QA Administrators 2022-04-21 03:40:36 UTC Comment hidden (obsolete)
Comment 4 Dieter 2022-04-21 07:22:19 UTC
I confirm it with

Version: 7.4.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: d34d1db55978bdcff082af1e0f75b18fa6fc94f4
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL

Actual result:
Inserting image took around 22 seconds

Expected result:
< 3 seconds
Comment 5 QA Administrators 2024-06-06 03:17:25 UTC Comment hidden (obsolete)
Comment 6 Dieter 2024-12-26 10:23:04 UTC
It still takes 15 seconds to insert rotated image with

Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 0480e84e4c0b43d3829d83746636ad7a7037e76e
CPU threads: 12; OS: Windows 11 X86_64 (build 22631); UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL threaded
Comment 7 Telesto 2025-01-17 12:55:26 UTC
Likely fixed in the Master build of tomorrow. See bug 137848
Comment 8 tmacalp 2025-02-24 17:45:25 UTC
I believe I ran into this bug today using
Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: bb3cfa12c7b1bf994ecc5649a80400d06cd71002
CPU threads: 72; OS: Linux 4.18; UI render: default; VCL: x11
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

* This seems to affect exif-rotated images and is likely a wide-spread issue.  Recent Samsung phones(tested on S22 and A52) take portrait photos as landscape and just use EXIF metadata to tell the viewer to rotate the image.

* When LibreOffice inserts these images, it takes forever because it is CONVERTING THEM INTO PNG.  This blows up the drawing size, turning a 3.5MB image into a 12.6MB drawing.  And that was a single image!

* You can verify the image has been converted into PNG by right-clicking on the image in Draw/Writer and clicking "Compress...".  You'll see its "Type" under "Image Information" is now a PNG image, not JPG.

* This affects not only Writer, but Draw, Calc, and any other LO component when using Insert -> Image


Note: 
* It only converts to PNG if I use Image -> Insert.  I don't experience this issue if I drag and drop an image from another application (file-manager, image viewer, copy/paste).  When I drag/drop from another application it ignores the rotation EXIF metadata and inserts the image un-rotated, but at least keeps it as a JPG.

* In the "Compress..." dialog, you can change the image back to JPG compression to reduce file size.

* If you run "jhead -autorot" on the images before-hand, you can apply the rotation and avoid LibreOffice converting them into PNG.
Comment 9 Telesto 2025-02-24 18:56:48 UTC
I'm unable to reproduce the issue with
Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a8ec21adf255b70bb6eeb0a1717190df303d8b26
CPU threads: 4; OS: Windows 10 X86_64 (build 19045); UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL threaded

When using Insert -> Image. So probably fixed in 25.8.0

I do still reproduce the issue when inserting an image with drag & drop
Comment 10 tmacalp 2025-02-24 20:06:37 UTC
I just tested it in last night's nightly and can still reproduce the problem.

I tested in:
Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 1fc03eaed2899ac041f660f54cb1facb71390ccf
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: x11
Locale: en-US (en_US.utf8); UI: en-US
Calc: threaded

For giggles, I confirmed this is also reproducible under Windows 24.2.5.2, so it definitely is the same issue that I'm seeing under Linux.

If you need help reproducing, make sure you're testing with IMG_20220404_143722388.jpg from the attached example files, since IMG_20220404_143656478.jpg isn't rotated and doesn't experience the issue.

* New Drawing
* Insert -> Image...
* IMG_20220404_143722388.jpg from attached files
* Right Click inserted image -> Compress...
* Look at "Type" (should be JPEG, not PNG)