Issue 62269 - jpg graphics imported distorted when cropped
Summary: jpg graphics imported distorted when cropped
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: open-import (show other issues)
Version: OOo 3.2
Hardware: PC Windows XP
: P3 Trivial with 8 votes (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 11:53 UTC by matthias007
Modified: 2017-05-20 11:15 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
shows procedure to get error, includes test picture (687.12 KB, application/x-compressed)
2006-02-19 12:07 UTC, matthias007
no flags Details
test file to show problem, unfortunately picture 01.jpg is bigger than 1MB, so I cant add this here. (468.97 KB, text/plain)
2010-06-01 08:58 UTC, matthias007
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description matthias007 2006-02-19 11:53:51 UTC
a jpg is imported in writer and shown correctly. When cut using the built in
menu the cut picture is shown correctly in the preview window but it will be
shown distorted in the text. The export to pdf will be distorted. But a copy of
the picture using cut and paste to a graphics program will be undistorted. A
test file including test procedure has been sent to Michael Hoehne and Robert
Grosskopf. Robert Grosskopf verified this problem on his system. So it is not
related to Win2k. The cut option did work when the picture was converted to png
or tif.
Comment 1 matthias007 2006-02-19 12:07:59 UTC
Created attachment 34283 [details]
shows procedure to get error, includes test picture
Comment 2 edeku 2006-02-20 07:46:55 UTC
*** Issue 62269 has been confirmed by votes. ***
Comment 3 michael.ruess 2006-02-20 08:58:07 UTC
MRU->OD: I was only able to see the problem in Writer. Isert the graphic into a
WRiter document, crop with with similar values as in the sample document and the
graphic's content will be distorted.
Comment 4 Oliver-Rainer Wittmann 2006-06-23 13:46:03 UTC
adjust target milestone to OOo 2.x
Comment 5 Oliver-Rainer Wittmann 2006-08-01 13:44:26 UTC
Defect not reproducable in OOo 2.0.3, if the picture is newly inserted (existing
picture in given document still corrupted).
There seems to be a problem in previous version on importing JPEG graphic file -
the size of picture isn't imported correct. Thus, the cropping algorithm doesn't
work as excepted.
Comment 6 Oliver-Rainer Wittmann 2006-08-01 13:46:09 UTC
re-assign to MRU for verification
Comment 7 Oliver-Rainer Wittmann 2006-08-01 13:46:57 UTC
set status to WORKSFORME
Comment 8 michael.ruess 2006-08-03 11:38:52 UTC
Yes, in OO2.0.3 this will work.
Comment 9 matthias007 2006-08-09 06:04:48 UTC
the cutting of the jpg works correctly if it is embedded as a graphics.

But when I import the above example graphic with the file not being embedded (by
clicking on the 2 fields "Verknüpfen" and "Vorschau" in the picture embedding
menue) it wont work. The picture then will be unfortunately shown distorted as
before.  
Comment 10 michael.ruess 2006-08-09 14:20:15 UTC
MRU->OD: Matthias is right, the bug still occurs inserting the graphic linked
into a document. Then cropping with same values as in the sample will give a
kind of stretched graphic.
Comment 11 Oliver-Rainer Wittmann 2006-08-09 15:16:30 UTC
Yes, I've missed this difference.

Further investigations reveals that the original size between the embedded
graphic and the linked graphic differ. The one for the linked graphic is much
bigger.
I tried another JPEG file. The original size of this JPEG file doesn't differ in
embedded and in linked case. Thus, no problems during cropping.
I opened JPEG file <stoerfeld.jpg> with MSPaint and saved it with another
filename. I also can't reproduce the described defect with the resaved JPEG file.
I opened JPEG file <stoerfeld.jpg> with IrfanView and after adjusting the DPI
values I saved it with another filename. With this JPEG file I either can't
reproduce the described defect.
Thus, it seems that the JPEG file <stoerfeld.jpg> is somehow corrupt. Probably
the JPEG header data isn't consistent in its value of pixel size and DPI - only
a suggestion.
Comment 12 Oliver-Rainer Wittmann 2006-08-09 15:19:13 UTC
OD->MRU:
Please verify my investigation, that the described defect only occurs this the
attached JPEG file and close this issue as WONTFIX
Comment 13 matthias007 2006-08-09 19:35:06 UTC
the interesting thing is that the cutting of the picture 
really does work correctly when the picture is imported.

The cutting is also shown correctly in the preview window.

The only problem occurs when these 2 boxes are marked.

It is still not very clear for me if this is really a problem of 
the jpg file itself. 
Comment 14 sven.jacobi 2006-08-10 16:34:16 UTC
sj->od: The problem is that the crop attribute depends to the original graphic
size. And as I found out, in Writer the original graphic size of jpegs vary
between jpegs using the logical size and jpegs using the pixel resolution (as it
is standard in html).

By default our jpeg import filter is using the logical size, in case of
SvxBrushItems the jpeg graphic is imported using pixel resolution.

If you want to reproduce this phenomenon, then please break in
svtools/source/filter.vcl/jpeg/jpeg.cxx at following line:

pJPEGReader = new JPEGReader( rStm, pCallerData, ( nImportFlags &
GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG ) != 0 );

If nImportFlags is having the value 1, then jpegs are imported using the logical
size, otherwise if the value is 2 the pixelsize is used.

From my point of view it is a Writer problem.
Comment 15 matthias007 2006-08-13 07:04:23 UTC
if I "save as" the above file to word 97/2000/XP and then 
have a look at the picture it looks as distorted as before.

In Writer the scaling in the "cut"-menue is given with 
40 to 40% for width and height. In the exported Word file,
opened up in Word the cut values for width and height 
are given correctly als in Writer but the scaling 
is given (incorrect) with 694 to 94% which explains 
why the picture looks such distorted. 

When I change the scaling to 94 to 94% in Word it looks 
much better, but still is not what was shown in the writer preview. 
 
Comment 16 Mathias_Bauer 2007-12-03 14:48:35 UTC
according to release status meeting -> 3.x
Comment 17 matthias007 2010-06-01 08:54:14 UTC
now I have OO 3.2. Since my first report 4 years have passed.
I got jpg files from a scanner and embedded them in an 
odt file. Then I wanted to crop one picture. This was
shown correctly in the preview but not in the document
as you can see in the attached file. 

So this is not solved yet - waiting 4 years for a fix.
8 votes are there? Will there be a fix in the next year?
Or no fix at all? I really would like to know about.  
Comment 18 matthias007 2010-06-01 08:58:09 UTC
Created attachment 69746 [details]
test file to show problem, unfortunately picture 01.jpg is bigger than 1MB, so I cant add this here.
Comment 19 matthias007 2010-06-01 12:53:24 UTC
The link to the picture file is this: 
http://www.cshare.de/file/99ec44339334f3199a68963daa3bc68f/01.jpg.html
normally this will be deleted in 30 days. 
Comment 20 matthias007 2010-06-01 12:59:20 UTC
the problem with the jpg picture remains when
I use Irfan to resave it as another jpg. 
Comment 21 Oliver-Rainer Wittmann 2010-06-04 13:27:27 UTC
Investigation of the newly provided JPEG file reveals the same as four years ago:
- saving the given JPEG file in MSPaint somehow corrects its. The given size
resolutions in the JPEG seems to be inconsistent.

But, as SJ already pointed out the problem can be also workaround in the Writer
by using adjusting its usage of the JPEG reader.
I will have a closer look.
Comment 22 Oliver-Rainer Wittmann 2010-06-04 15:56:53 UTC
I figured out that for the picture format dialog when it is used from the Writer
for linked graphics is filled with a more or less "empty" <SvxBrushItem>
instance. Thus, an import of the intrinsic graphic is triggered by the
<SvxBrushItem> instance. This import, as SJ figured out, triggers a JPEG read
process using the pixel resolution to determine the graphic size.
This is not necessary. The <SvxBrushItem> instance can be filled as in the case
for an embedded graphic.

I will perform the corresponding change to the code in cws sw33bf05.
Comment 23 Oliver-Rainer Wittmann 2010-06-04 16:38:03 UTC
fixed in cws sw33bf05 - changed file:
/sw/source/ui/shells/grfsh.cxx, change set 93841f4f9ae2
Comment 24 Oliver-Rainer Wittmann 2010-06-08 11:43:48 UTC
od->mru: Checked in internal installation set of cws sw33bf05 - please verify.

Please have a close look at the complete graphic format dialog and its tab
pages, especially for linked graphics.
Comment 25 Oliver Specht 2010-06-15 07:08:37 UTC
->mru/od: The changesets of this fix have been removed from the cws. 
The crop dialog worked for newly inserted jpg pictures, only. After storing and
reloading the document the crop dialog didn't work anymore.
Comment 26 michael.ruess 2010-06-17 10:32:09 UTC
MRU->OD: the fix has to be adjusted. Problem is, that when inserting a linked
image, saving and reloading all controls in the crop dialog will be disabled.
Comment 27 Oliver-Rainer Wittmann 2010-06-29 07:28:59 UTC
That is bad - according to Murphy such things happens and I was on vacation.
In the meanwhile the development for OOo 3.3 is closed -
http://wiki.services.openoffice.org/wiki/OOoRelease33 -> adjusting target
Comment 28 Martin Hollmichel 2011-03-16 11:42:10 UTC
set target 3.x since not relevant for 3.4 release.
Comment 29 Marcus 2017-05-20 11:15:37 UTC
Reset assigne to the default "issues@openoffice.apache.org".