Bug 109143 - image exported to pdf is not being cropped correctly
Summary: image exported to pdf is not being cropped correctly
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
5.2.1.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Miklos Vajna
URL:
Whiteboard: target:6.1.0 target:6.0.5
Keywords: bibisected, bisected, regression
: 117756 118126 (view as bug list)
Depends on: 45168
Blocks: PDF-Export JPEG-compression-regressions
  Show dependency treegraph
 
Reported: 2017-07-16 12:15 UTC by 張修銘
Modified: 2019-03-16 19:19 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
odt file containing the cropped image (2.34 MB, application/vnd.oasis.opendocument.text)
2017-07-16 12:19 UTC, 張修銘
Details
the image file (2.32 MB, image/jpeg)
2017-07-16 12:22 UTC, 張修銘
Details
the exported pdf file (2.33 MB, application/pdf)
2017-07-16 12:24 UTC, 張修銘
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 張修銘 2017-07-16 12:15:58 UTC
Description:
After I inserted an image to Libreoffice Writer and cropped it, I exported the document to pdf. But the image in the pdf file is not cropped correctly. You can download a sample document on google drive. I am using Libreoffice 5.3.4 on Manjaro Linux.

Steps to Reproduce:
1. Open a new document in Writer
2. Click Insert > Image... to insert the image
3. Right click on the image and click Crop
4. Crop the black region on the right and left(so the margin of image contacts the margin of the microsope's view)
5. Save the document and export to pdf

Actual Results:  
The image in the exported pdf is not cropped correctly. In the right side and left side of the microsope's view, there is black region.

Expected Results:
The margin of image contacts the margin of the microsope's view, same as seen in writer.


Reproducible: Always

User Profile Reset: Yes

Additional Info:
same result whether "Use OpenGL for all rendering" is enabled


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
Comment 1 張修銘 2017-07-16 12:19:27 UTC
Created attachment 134658 [details]
odt file containing the cropped image
Comment 2 張修銘 2017-07-16 12:22:00 UTC
Created attachment 134659 [details]
the image file
Comment 3 張修銘 2017-07-16 12:24:04 UTC
Created attachment 134660 [details]
the exported pdf file
Comment 4 V Stuart Foote 2017-07-25 12:54:18 UTC Comment hidden (obsolete)
Comment 5 Martin 2018-02-03 07:00:48 UTC
(In reply to V Stuart Foote from comment #4)
> 
> *** This bug has been marked as a duplicate of bug 45168 ***

Sorry, but this is definitely a different problem than bug +45168. +45168 is only about document size, the problem here is that the exported PDF looks different than the original document. 

By the way, I've had the same problem with Impress presentation and version 6.0.0. The presentation contains a few pictures, some of them cropped to show only a small detail. The exported PDF then not only contains but _shows_ the whole pictures. To make things worse, the aspect ratio of the picture is adjusted to that of the cropped picture
Comment 6 V Stuart Foote 2018-02-03 14:57:49 UTC
OK, subtle but current export to PDF does not honor the image clip and instead inserts the full image into frame holding the image on document canvas--distorting it. 

The example document here, the clip applied was only horizontal, and results on export PDF image squeezed to fit into the frame.

The resulting size of PDF export includes the whole unclipped image, initial issue of bug 45168, but restated in https://bugs.documentfoundation.org/show_bug.cgi?id=45168#c10

The same document printed to PDF (with a PS based flow) correctly clips the image, and its size is reduced.

Scope of bug 45168 would impact this.
Comment 7 Xisco Faulí 2018-04-04 21:51:52 UTC
Regression introduced by:

author	Michael Meeks <michael.meeks@collabora.com>	2016-02-08 14:24:15 +0000
committer	Michael Meeks <michael.meeks@collabora.com>	2016-02-09 00:09:08 +0000
commit 76ec54e8c9f3580450bca85236a4f5af0c328588 (patch)
tree 1c4d36e921be16426fc8a61c7a85bdc006e0fafa
parent e07ffae5046e9c91ef96026435cab84c3bcb4534 (diff)
tdf#97662 - Try to preserve original compressed JPEGs harder.
Avoiding de-compressing and re-compressing them saves lots of time too.

Bisected with: bibisect-linux-64-5.2

Adding Cc: to Michael Meeks
Comment 8 MichaelB 2018-04-12 08:59:36 UTC
Same problem here.. We add product images in a presentation (impress) with many slides. We crop a little the sides of images and resize.

On screen it appear fine but when exporting to PDF, all images are not in the correct proportion and is unusable (images is lengthened).

Version: 6.0.3 (but exist also in past versions)
Comment 9 Miklos Vajna 2018-04-27 13:27:05 UTC
I can reproduce the problem, I plan to take a look at this.
Comment 10 Commit Notification 2018-05-02 16:14:01 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=be3ef7b0e5e51c1d97309ce3b6d5cac1fbd025d0

tdf#109143 PDF export: don't reuse compressed bitmaps for cropped images

It will be available in 6.1.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 11 MichaelB 2018-05-03 06:55:26 UTC
Thanks Miklos Vajna for your patch.

Is it also possible to backport it to 5.4.x and 6.0.x ?
Comment 12 Miklos Vajna 2018-05-03 07:36:43 UTC
I've proposed the fix for 6.0.x at https://gerrit.libreoffice.org/53772, will consider 5.4.x if 6.0.x is in.
Comment 13 Xisco Faulí 2018-05-03 10:39:22 UTC
Verified in

Version: 6.1.0.0.alpha1+
Build ID: f1579d3d6c5f5f3a651825e035b93bee7a4f43c6
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

@Miklos, thanks for fixing this!

I'm wondering if you would be interested in the other bugs introduced by 76ec54e8c9f3580450bca85236a4f5af0c328588 listed in meta bug 116840
Comment 14 Commit Notification 2018-05-04 15:28:11 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e0ae55f7cefe74039f8ade1696d1861e90d73c04&h=libreoffice-6-0

tdf#109143 PDF export: don't reuse compressed bitmaps for cropped images

It will be available in 6.0.5.

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

Affected users are encouraged to test the fix and report feedback.
Comment 15 Aron Budea 2018-05-23 12:34:35 UTC
*** Bug 117756 has been marked as a duplicate of this bug. ***
Comment 16 Roman Kuznetsov 2019-03-16 19:19:12 UTC
*** Bug 118126 has been marked as a duplicate of this bug. ***