Bug 52598

Summary: Writer ignores original picture pixel density in .jpg files, and uses 120 dpi (refer comment 19)
Product: LibreOffice Reporter: Zoltán Hegedüs <x0>
Component: WriterAssignee: Not Assigned <libreoffice-bugs>
Status: NEW --- QA Contact:
Severity: normal    
Priority: medium CC: flamingdescent, jbfaure
Version: 3.6.0.2 rc   
Hardware: All   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=65765
Whiteboard:
i915 platform: i915 features:
Attachments: The example .jpg picture with 600 dpi
My own default template for Writer
made on my 1600x900 monitor, with the screen resolution set as 800x600
made on my computer with the 1366x768 screen
on my computer with the 1600x900 monitor, with the screen resolution set to its normal resolution
Writer used 120 pixel/inch, but this picture has 600 pixel/inch, the display has 144 pixel/inch

Description Zoltán Hegedüs 2012-07-27 19:21:46 UTC
I must set the enlargement at all pictures one by one, moreover in 2 places, in turn I set the keep ratio.
Comment 1 Jean-Baptiste Faure 2012-07-28 06:35:59 UTC
Please provide a step by step scenario to reproduce your problem.
http://wiki.documentfoundation.org/BugReport

Best regards. JBF
Comment 2 Zoltán Hegedüs 2012-07-28 12:50:00 UTC
Created attachment 64820 [details]
The example .jpg picture with 600 dpi
Comment 3 Zoltán Hegedüs 2012-07-28 12:51:11 UTC
Created attachment 64821 [details]
My own default template for Writer
Comment 4 Zoltán Hegedüs 2012-07-28 12:58:01 UTC
See the 2 attachments. The bug happens in all cases:

Start Writer, if already running, open a new document (Ctrl+N).
Menu Insert/Insertion: Picture: from file. Or: with drag and drop with the mouse, from the Windows Explorer (File Manager) to the document, or maybe with opening the picture with the Writer, I did not try it. But I tried: munu Insert/Insertion: File.

Windows XP Home SP3 Hungarian.
Because of Writer uses the display resolution, if I open the saved file in an another computer, the picture size can vary. For example, the most common display resolution is 96 dpi.
Comment 5 flamingdescent 2013-06-20 16:16:49 UTC
Created attachment 81120 [details]
made on my 1600x900 monitor, with the screen resolution set as 800x600
Comment 6 flamingdescent 2013-06-20 16:17:32 UTC
Created attachment 81121 [details]
made on my computer with the 1366x768 screen
Comment 7 flamingdescent 2013-06-20 16:18:38 UTC
Created attachment 81122 [details]
on my computer with the 1600x900 monitor, with the screen resolution set to its normal resolution
Comment 8 flamingdescent 2013-06-20 16:32:21 UTC
Computer 1: operating system: Windows 7, LibO version: 4.0.3.3 release (1600x900 screen)
Computer 2: operating system: Windows 8, LibO version: 4.0.3.3 release (1366x768 screen)

Here are the steps I took to create the attached documents:
0. I downloaded your default template and the example .jpg picture.
1. In Windows Explorer, I double-clicked your default template.
2. menu Insert > Picture > From file, selected the picture
3. I saved the file.

My attachments' titles show within parentheses the screen resolution in which the document was made. (e.g.: "Picture Bug (1366x768)" was made on my 1366x768 computer). For the "Picture Bug (800x600)", I changed the screen resolution of my 1600x900 monitor.

I can't reproduce the bug, but that might be because I don't understand what you mean by "picture size". So what do you mean by picture size?
A. the size according to the LibreOffice onscreen ruler? In the combinations [800x600 screen and 800x600* document, 1600x900 screen and all three documents**, 1366x768 screen and all three documents**], the onscreen ruler shows the picture as slightly less than 4 inches high.
B. document size? All the documents are ~416 KB, though their sizes are different by a few bytes.
C. how many pixels are in the picture? For all the documents I attached, I performed these steps:
  1. I right-clicked the picture, selected "Edit with External Tool"
  2. Windows Live Photo Gallery opens. File > Open with > Paint
  3. The Paint status bar says "3200 × 1688 px"

* "800x600 document" refers to the document named "Picture Bug (800x600)
** the three documents I attached

I'm not sure whether this bug involves data loss, so I'll keep the Importance the same.

Because I need a clarification about what you mean by "the picture size can vary", I'm changing the status of this bug to NEEDINFO. When you make the clarification, change the status back to UNCONFIRMED. Thanks for reporting this bug!
Comment 9 Zoltán Hegedüs 2013-06-22 10:33:04 UTC
(In reply to comment #8)

Size of a picture: not in pixels, but for example in millimeters at printing and at the display: not the resolution, but the density: pixel/length. For example, I inserted a 600 dpi picture, but Writer regarded this 120 dpi, because of my monitor setting is 120 dpi. The resolution remained, but the size in millimeters/inches/etc expanded to 5 times.

Example for data loss: if you create this document on an another computer, on where the display resolution is 96 dpi, the picture will be larger, but you maked the same steps. I do not know if Writer stores the resolution of the pictures. If do not, close this document, and open at an another computer with different display settings: the size of the picture varies. The same document looks different on 2 computers. The resolution always remains, but the enlargement varies (the resolution density, pixel/length). For examle, a picture is 2 line height on one computer, and 3 line height on another one.
Comment 10 Zoltán Hegedüs 2013-11-16 15:09:47 UTC
Why is this unconfirmed still?
Comment 11 Jean-Baptiste Faure 2013-11-16 15:49:13 UTC
(In reply to comment #10)
> Why is this unconfirmed still?

Because probably nobody understood what is the problem.
For example, if I look at the three files provided by flamingdescent, I see the same thing. But probably he changed only the size of the screen, not its resolution. 

Could you attach two "identical" documents, one made on a computer with 120 dpi screen resolution and one made on a computer with 96 screen resolution?

Best regards. JBF
Comment 12 Zoltán Hegedüs 2013-11-16 19:14:36 UTC
(In reply to comment #11)

Pixel density (in unit pixel/inch) is stored in the .jpg file. Writer ignores this, and uses the display settings. If you insert the same file with 2 computers with different display pixel density, you will get different result in the .odt file. Reproduction: insert a .jpg file to a document, view the size in the document in inches or millimeters, save, exit from LibreOffice. View the actual display density in Windows (Control Panel, Resolution special settings). Modify it. 963 dpi is the default, for example, use 120 dpi or 144 dpi. Restart Windows. Insert the same .jpg file to a new document. The size of the picture in inches or in millimeters will be different.

Another example: the pixel density of a .jpg file is 600 pixel/inch. Insert this to a document, and view the size in the document: if the setting is original size, Writer uses 96 or 120 or 144 dpi: the picture is 5 times bigger.
Comment 13 Jean-Baptiste Faure 2013-11-16 21:07:37 UTC
Please, don't set to new a bug report you created yourself.
I understand your explanations. I just need to see an example.
And what about PNG files?

Best regards. JBF
Comment 14 Zoltán Hegedüs 2013-11-17 08:14:41 UTC
(In reply to comment #13)
> I just need to see an example.
See the attachment https://bugs.freedesktop.org/attachment.cgi?id=64820
> And what about PNG files?
I do not have any png files, so I did not test it.
Comment 15 Jean-Baptiste Faure 2013-11-17 08:42:11 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > I just need to see an example.
> See the attachment https://bugs.freedesktop.org/attachment.cgi?id=64820

No, an example of 2 documents like asked in comment https://bugs.freedesktop.org/show_bug.cgi?id=52598#c11

> > And what about PNG files?
> I do not have any png files, so I did not test it.

It's unfortunate because PNG is the preferred image format for LibreOffice.

Best regards. JBF
Comment 16 Zoltán Hegedüs 2013-11-17 10:02:00 UTC
Created attachment 89344 [details]
Writer used 120 pixel/inch, but this picture has 600 pixel/inch, the display has 144 pixel/inch

I inserted the .jpg file in the previous attachment to an empty document. The pixel density of the .jpg file is 600 pixel/inch, but Writer used 120 pixel/inch. The display pixel density setting is 144 pixel/inch at me. (Writer inserted the picture in 28% size, this is not a bug, because the picture is reduced to the width of the line.)
Comment 17 Zoltán Hegedüs 2013-11-17 10:41:23 UTC
Sorry, there was 120 dpi the display resolution when I observed this error. Writer uses always 120 dpi at inserting .jpg files, and ignores the pixel density stored in the .jpg file (600 dpi in the attachment, so Writer uses 5 times enlargement at this file). The display density is no object, I tried this with 144 and 96 pixel/inch setting. The error is not happen at inserting .png files, I tried to insert 96 and 600 dpi files (at 96 pixel/inch display setting). But the attachment converted to .png with GIMP is 5-times bigger (9 times with Paint instead of GIMP), so it is better to use .jpg files.
Comment 18 Jean-Baptiste Faure 2013-11-21 21:55:58 UTC
Not sure if it is a bug. LibreOffice and before OOo did that since the beginning.
From the point of view of text processor, you should prefer to define the size of the image in the page, not in pixels but in cm. 
Not sure too if the pixel/inch is a portable measure from paper to screen or another support. Indeed each support has its own pixel size.

Set status back to unconfirmed.

Best regards. JBF
Comment 19 Owen Genat 2014-08-01 08:45:15 UTC
(In reply to comment #9)
> ... I inserted a 600 dpi picture, but Writer regarded this 120 dpi,
> because of my monitor setting is 120 dpi. The resolution remained, but the
> size in millimeters/inches/etc expanded to 5 times.

From attachment 64820 [details]:

$ identify -verbose Vegyeskép.jpg | head -n7
Image: Vegyeskép.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 3200x1688+0+0
  Resolution: 600x600
  Print size: 5.33333x2.81333
  Units: PixelsPerInch

When I insert this image into a Writer document with a suitably large page size the resultant image is 26.67" wide. 3200 divided by 26.67 = ~120, which is the indicated DPI reported in this bug rather than the 600 DPI stored in the JPEG. If the DPI stored in the JPEG were being respected the image would be inserted at the indicated 5.33333x2.81333 inches.

The only part of the quoted statement I am concerned about is this:

> because of my monitor setting is 120 dpi

The laptop I tested this on appears to have a 100ppi LCD screen (13 9/16 inches wide @ 1366 pixels), so I am not certain the DPI is being derived from the screen. It may be set in the JPEG import filter. Anyway, confirmed under GNU/Linux x86_64 using v4.2.5.2. Status set to NEW. Platform set to All/All.
Comment 20 Owen Genat 2014-08-01 08:49:15 UTC
It may be that this is not a bug that can be fixed, but we should at least get a developer to look at this. Summary amended to point to comment 19, which contains steps to reproduce.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.