Bug 429294 - Filesize of importing animation frames
Summary: Filesize of importing animation frames
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Animation (show other bugs)
Version: 4.4.1
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-18 10:03 UTC by Shaheen
Modified: 2022-01-05 23:44 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shaheen 2020-11-18 10:03:14 UTC
SUMMARY
Hi,

I’ve been using Krita animation for a while, and it’s sometimes necessary to import animation frames into the Krita files.

But the filesize bloats up very heavily while importing the image sequences.

For example, even if the .PNGs that I imported were around 60mb, the .KRA file gains 400mb.
(Even if it’s just a few black lines on a transparent background)
Eventually, the file gets too heavy and restricts this type of workflow.

Is there any way that the .kra filesize can be reduced and kept in control? Maybe even re-optimizing the images after import?


STEPS TO REPRODUCE
I’ve made an example here if anyone wants to check:
https://1drv.ms/u/s!AuS-azz3l43fn5RX9xuJ6mf8Lmooig?e=hrML02

In it,
01_draw_in_krita.kra ----> is a 1mb file in which I animated.
02_exported_png ----> is 1.89mb exported alpha png sequence.
03_imported_png.kra ----> is 10mb file when I reimported the same pngs.

So that’s 10 times the filesize! This is just a tiny test example.

But in actual bigger animation production, this problem intensifies very heavily very quickly. And this happens while importing images from other softwares too. So I don’t think it’s a particular .png format issue.


OBSERVED RESULT
Even RAM usage increases:
If I import the .png frames as an additional layer, then the RAM usage goes from 31MB -> 525 MB and after Save and reopen it’s 505MB with a
.kra file size of 11.4MB.

If I simply duplicate the original layer, to give exactly the same content as by importing frames, then the RAM usage goes
from 31 MB -> 45MB and after Save and reopen it’s 45MB with a
.kra file size of 2.2 MB.

I think this is kinda expected. If you draw in Krita a blob, Krita will remember just the blob and some area around. If you import a PNG, even if it’s mostly fully transparent, it will remember the whole rectangle that Krita imported, not just the blob.


EXPECTED RESULT
Some post-import optimization would be good. So that we can animate in Krita without worrying too much about huge filesize and RAM usage. It might end up being useful for non-animation-importing too.


SOFTWARE/OS VERSIONS
Windows: 10

ADDITIONAL INFORMATION
Comment 1 Tiar 2020-12-10 22:53:33 UTC
That would be good to have and not that difficult to do (just run "Trim to layer content" on every paint device that will become frames).
Comment 2 Eoin O'Neill 2022-01-05 23:44:17 UTC
Git commit ec089d615e2916610614524a4adc3a8380bbe7f0 by Eoin O'Neill, on behalf of Bip Boop.
Committed on 05/01/2022 at 23:32.
Pushed by eoinoneill into branch 'master'.

Crop imported animation frames to content

* Reduces file size
* Reduces ram usage

Optimization attempt of calculateExactBoundsImpl

Purge default pixels unconditionaly on import frame

Add a checkbox in settings/general/filehandling
to disable croping default pixels on frames import

* The option to trim frames on import means that the frame is cropped to the document's dimensions
* purgeDefaultPixels is called on each imported frame unconditionally

M  +6    -8    libs/image/kis_paint_device.cc
M  +1    -1    libs/ui/actions/KisPasteActionFactories.cpp
M  +8    -0    libs/ui/dialogs/kis_dlg_preferences.cc
M  +1    -0    libs/ui/dialogs/kis_dlg_preferences.h
M  +11   -1    libs/ui/forms/wdggeneralsettings.ui
M  +7    -0    libs/ui/kis_animation_importer.cpp
M  +9    -0    libs/ui/kis_config.cc
M  +3    -0    libs/ui/kis_config.h
M  +1    -1    plugins/impex/csv/csv_loader.cpp

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