Bug 66006

Summary: EDITING: rotated images damaged when width%16>0
Product: LibreOffice Reporter: janaco
Component: WriterAssignee: janaco
Status: RESOLVED FIXED    
Severity: major CC: i.gnatenko.brain, quikee
Priority: medium    
Version: 4.1.0.4 release   
Hardware: Other   
OS: Windows (All)   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=137848
Whiteboard: BSA target:4.2.0 target:4.1.1
Crash report or crash signature: Regression By:
Attachments: Document with included image 1000x667px, rotated clockwise and then saved
additional testcase for Bug 66006

Description janaco 2013-06-21 11:51:38 UTC
Created attachment 81163 [details]
Document with included image 1000x667px, rotated clockwise and then saved

Problem description: 

Steps to reproduce:
1. open writer
2. insert image with width not exactly a multiple of 16 (eg 1000px)
3. rotate the image clockwise with Rightklick->rotate 90°
4. save document, close document and reopen it

Current behavior:
from the image a stripe wide (width % 16) is cropped from the left side and appears on the right of the rotated image.

Expected behavior:
the image should be untouched and only rotated
              
Operating System: Windows XP
Version: 4.1.0.0.beta1
Comment 1 Igor Gnatenko 2013-06-21 19:11:41 UTC
Couldn't reproduce.
If other have this bug - reopen please.
Comment 2 Tomaz Vajngerl 2013-06-22 09:35:54 UTC
Hi,

Can you provide the original picture you used in the document?

Thanks, 
Tomaž
Comment 3 Igor Gnatenko 2013-06-22 09:39:26 UTC
(In reply to comment #2)
> Hi,
> 
> Can you provide the original picture you used in the document?
> 
> Thanks, 
> Tomaž
I used you attached document.
Comment 4 janaco 2013-06-24 20:20:42 UTC
Created attachment 81363 [details]
additional testcase for Bug 66006

Testcase added.

Pictures: used for Testing:
green.jpg (1000x667px)
green2.jpg (667x1000px)
green3.jpg (992x656px)

Other extreme-variants to show, that only JPEG is affected:
square.(jpg|png|bmp|tif)

To test use the old 4-point-list or:

- open "test1-unrotated-and-saved.odt"
- rotate the image 90°-right (Original is green.jpg)
- save the document
- even NOW: when rotating image back 90°-left, the image is damaged because a 11-pixel-bottom-block is moved to the top of the image. This applies too for the image saved in the altered document.

---

the "square"-images show, that only rotating an inserted JPEG with dimensions not in 8/16px-Raster has the problem. And (maybe another bug) a TIFF can only be rotated clockwise and this has no effect.

Hope it helps...
Comment 5 Igor Gnatenko 2013-06-25 04:55:37 UTC
(In reply to comment #4)
> Created attachment 81363 [details]
> additional testcase for Bug 66006
> 
> Testcase added.
> 
> Pictures: used for Testing:
> green.jpg (1000x667px)
> green2.jpg (667x1000px)
> green3.jpg (992x656px)
> 
> Other extreme-variants to show, that only JPEG is affected:
> square.(jpg|png|bmp|tif)
> 
> To test use the old 4-point-list or:
> 
> - open "test1-unrotated-and-saved.odt"
> - rotate the image 90°-right (Original is green.jpg)
> - save the document
> - even NOW: when rotating image back 90°-left, the image is damaged because
> a 11-pixel-bottom-block is moved to the top of the image. This applies too
> for the image saved in the altered document.
> 
> ---
> 
> the "square"-images show, that only rotating an inserted JPEG with
> dimensions not in 8/16px-Raster has the problem. And (maybe another bug) a
> TIFF can only be rotated clockwise and this has no effect.
> 
> Hope it helps...
Yes! This testcase good. I can confirm this bug.
Comment 6 janaco 2013-07-11 21:00:41 UTC
Bug stays in 4.1.0.2 RC

I suggest to disable image rotating before release because users can irreversibly damage a document by rotating a JPEG even if loading a document later and editing/formatting the images. And this damage can first be seen when document has been saved and it is too late to undo the rotation.

Because this feature is a new and long awaited many users will use and test it a lot and will complain about the damaged images in their documents.
Comment 7 Tomaz Vajngerl 2013-07-12 07:32:50 UTC
(In reply to comment #6)
> Bug stays in 4.1.0.2 RC
> 
> I suggest to disable image rotating before release because users can
> irreversibly damage a document by rotating a JPEG even if loading a document
> later and editing/formatting the images. And this damage can first be seen
> when document has been saved and it is too late to undo the rotation.
> 
> Because this feature is a new and long awaited many users will use and test
> it a lot and will complain about the damaged images in their documents.

Hi,

I will change jpeg rotation that only the images with width that is multiple of 16 are allowed to be rotated with lossless jpeg rotation. If it is not multiple of 16, then I will rotate the image and compress to png so that the image quality is preserved. 

Regards, Tomaž
Comment 8 janaco 2013-07-25 07:48:18 UTC
> Hi,
> I will change jpeg rotation that only the images with width that is multiple
> of 16 are allowed to be rotated with lossless jpeg rotation. If it is not
> multiple of 16, then I will rotate the image and compress to png so that
> the image quality is preserved. 
> Regards, Tomaž

Bug stayed in 4.1.0.3 RC and even in 4.1.0.4 RC

@Tomaž: will your workaround make it into the final?
Comment 9 Commit Notification 2013-07-28 14:16:01 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "master":

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

fdo#66006 Convert to PNG for JPEG that can't be losslessly rotated



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 10 Commit Notification 2013-07-29 11:08:36 UTC
Tomaž Vajngerl committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2f2b3fff8997f9da14d64053afd19aa971e7829c&h=libreoffice-4-1

fdo#66006 Convert to PNG for JPEG that can't be losslessly rotated


It will be available in LibreOffice 4.1.1.

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.