Bug 423741 - Saving to ORA is broken
Summary: Saving to ORA is broken
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 4.3.0
Platform: macOS (DMG) macOS
: NOR critical
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-01 13:06 UTC by Manga Tengu
Modified: 2020-07-04 22:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
my original corrupted file (257.43 KB, image/openraster)
2020-07-01 13:39 UTC, Manga Tengu
Details
a kra file that has been cropped at a moment (3.57 MB, application/x-krita)
2020-07-04 20:39 UTC, Manga Tengu
Details
an ora file after a kra file that has been cropped (3.10 MB, image/openraster)
2020-07-04 20:39 UTC, Manga Tengu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manga Tengu 2020-07-01 13:06:28 UTC
Save a file in kra format result in various data losses: in one file I had only empty layers and offset image (the offset is cropped so it's definitely lost). In some files I only had the offset...


STEPS TO REPRODUCE
1. Draw
2. save as ORA
3. open the ORA file

OBSERVED RESULT
A corrupted image. Openable with the right layer structure but missing content

EXPECTED RESULT
A useable file with everything ora supports in place

SOFTWARE/OS VERSIONS
macOS: catalina 10.15.5 on a 2018 15' macbook pro

I misstyped kra into ora (k and o are close) and I lost a drawing (completely empty layers) Maybe that's a dangerous short-circuit ?
Comment 1 Halla Rempt 2020-07-01 13:15:57 UTC
* This is only about ora, right? Not .kra like you say in the first page?
* Could you start Krita from Terminal.app like /Applications/krita/MacOS/Content/krita (or was it /Applications/krita/Content/MacOS/krita ?) and check whether there are errors like this:

libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

I have just checked by saving a complex .kra file as ora, and one layer was invalid and both the mergedimage.png and the preview.png seemed corrupt.
Comment 2 Halla Rempt 2020-07-01 13:16:41 UTC
Oh, and can you attach one of the krita files that saved as a broken file as well, or make a link so I can download them?
Comment 3 Manga Tengu 2020-07-01 13:39:11 UTC
Created attachment 129815 [details]
my original corrupted file

Sure! Here you go!
Comment 4 Manga Tengu 2020-07-01 13:40:16 UTC
since it's empty, the file was super light :D
Comment 5 Halla Rempt 2020-07-01 13:43:15 UTC
* I was able to reproduce a broken with the krita/4.3 branch
* It doesn't look like a problem with calculating the end projection, because that's fine in Manga Tengu's test file, though it was broken in mine.
Comment 7 Tiar 2020-07-04 20:06:58 UTC
Git commit 925bf97f8d4ed1101267fd86d99536069a05f969 by Agata Cacko.
Committed on 04/07/2020 at 17:33.
Pushed by tymond into branch 'master'.

Fix saving broken .ora file in case of empty layer

Before this commit, saving an empty layer to .ora would result in a
broken file because the result PNG for the layer would be 0x0.
This commit artificially increases the size of the layer with one pixel
when the layer is empty to make sure there is some data (even if
invisible) to save to PNG file.

M  +6    -0    plugins/impex/ora/kis_open_raster_stack_save_visitor.cpp

https://invent.kde.org/graphics/krita/commit/925bf97f8d4ed1101267fd86d99536069a05f969
Comment 8 Tiar 2020-07-04 20:06:58 UTC
Git commit 0401b14169964fcb69dc04cc613f6a9ef04ec3ea by Agata Cacko.
Committed on 04/07/2020 at 17:33.
Pushed by tymond into branch 'master'.

Don't save fake nodes in .ora files

Before this commit, Krita would try to save reference images layer into
.ora files. Since reference images layer doesn't have any projection
(and the name for the layer is 'No Name'...), it would result in a ghost
new layer on top of the layer stack called 'No Name'.
Since there is no projection nor other information, there is no point
in saving it to .ora files.
This commit omits reference images layer (and other fake nodes)
when saving to .ora.

M  +4    -0    plugins/impex/ora/kis_open_raster_stack_save_visitor.cpp

https://invent.kde.org/graphics/krita/commit/0401b14169964fcb69dc04cc613f6a9ef04ec3ea
Comment 9 Tiar 2020-07-04 20:12:51 UTC
Note: while I fixed Boud's issue and I cannot reproduce any visible issue with the following files:
- `hylti` from bug 423741 (this one)
- `input.kra` version 1 from bug 423088 comment 0
- `input.kra` version 2 from bug 423088 comment 1
- `input.kra` version 2 from bug 423088 comment 3
(bug 423088 was related)
in all three: Krita, Gimp and MyPaint, I didn't find and fix any reason for the damage that @Manga Tengu experienced. 
So please, if it happens again and you have a proper .kra file to see the damage, reopen this bug report and attach the .kra file that results in a broken .ora file.
Comment 10 Tiar 2020-07-04 20:16:15 UTC
Git commit ca26fdaa72cd038173200f5114720b0f595b56b9 by Agata Cacko.
Committed on 04/07/2020 at 20:16.
Pushed by tymond into branch 'krita/4.3'.

Fix saving broken .ora file in case of empty layer

Before this commit, saving an empty layer to .ora would result in a
broken file because the result PNG for the layer would be 0x0.
This commit artificially increases the size of the layer with one pixel
when the layer is empty to make sure there is some data (even if
invisible) to save to PNG file.


(cherry picked from commit 925bf97f8d4ed1101267fd86d99536069a05f969)

M  +6    -0    plugins/impex/ora/kis_open_raster_stack_save_visitor.cpp

https://invent.kde.org/graphics/krita/commit/ca26fdaa72cd038173200f5114720b0f595b56b9
Comment 11 Tiar 2020-07-04 20:17:18 UTC
Git commit 28827e81f5a1eee5326319cc7d05e3879fbfd0c1 by Agata Cacko.
Committed on 04/07/2020 at 20:17.
Pushed by tymond into branch 'krita/4.3'.

Don't save fake nodes in .ora files

Before this commit, Krita would try to save reference images layer into
.ora files. Since reference images layer doesn't have any projection
(and the name for the layer is 'No Name'...), it would result in a ghost
new layer on top of the layer stack called 'No Name'.
Since there is no projection nor other information, there is no point
in saving it to .ora files.
This commit omits reference images layer (and other fake nodes)
when saving to .ora.


(cherry picked from commit 0401b14169964fcb69dc04cc613f6a9ef04ec3ea)

M  +4    -0    plugins/impex/ora/kis_open_raster_stack_save_visitor.cpp

https://invent.kde.org/graphics/krita/commit/28827e81f5a1eee5326319cc7d05e3879fbfd0c1
Comment 12 Manga Tengu 2020-07-04 20:39:05 UTC
Created attachment 129901 [details]
a kra file that has been cropped at a moment
Comment 13 Manga Tengu 2020-07-04 20:39:37 UTC
Created attachment 129902 [details]
an ora file after a kra file that has been cropped

you can see there is data loss
Comment 14 Manga Tengu 2020-07-04 20:40:53 UTC
I linked 2 files 
myHouse.kra
myHouse.ora

I have nailed the reproduction a bit better: you need to crop the file before exporting it to ora. Then you will see the ora file cropped even more and left an empty gap
Comment 15 Tiar 2020-07-04 20:54:17 UTC
@MangaTengu - I can reproduce it in 4.3.0 but I cannot reproduce it after my changes (and InkLab's), so I think I (and/or them) fixed it :) (It's definitely a matter of incorrect bounds). Please download the next stable version and check if it's correct.

And yes, this corruption looks similar to the original corrupted file (messed up x and y), so I guess we can leave it fixed (unless you find some files that contradicts my conclusions in the Krita version after my changes).
Comment 16 Manga Tengu 2020-07-04 21:04:32 UTC
Sure will do ! Thank you ! :-)
Comment 17 Tiar 2020-07-04 22:09:16 UTC
Git commit ff86577290ffe77e0304141a375e9b6a8fcd7a22 by Agata Cacko.
Committed on 04/07/2020 at 21:32.
Pushed by tymond into branch 'krita/4.3.0'.

Fix saving broken .ora file in case of empty layer

Before this commit, saving an empty layer to .ora would result in a
broken file because the result PNG for the layer would be 0x0.
This commit artificially increases the size of the layer with one pixel
when the layer is empty to make sure there is some data (even if
invisible) to save to PNG file.

M  +6    -0    plugins/impex/ora/kis_open_raster_stack_save_visitor.cpp

https://invent.kde.org/graphics/krita/commit/ff86577290ffe77e0304141a375e9b6a8fcd7a22