![]() |
Get layer by uncompressed size with script - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Get layer by uncompressed size with script (/Thread-Get-layer-by-uncompressed-size-with-script) |
Get layer by uncompressed size with script - lenainjaune - 09-02-2025 Hi all ![]() With Gimp, the most part of time I works on photos to simply add extra layers and export the result (maps, explanations, mechanisms, and so). In this case I do not alter the original and keep it. Recently I realized the most part of my XCF projects take more than 20MB per file vs the originals which take 2MB max. After digging I understood the problem : projects keep the original raw uncompressed photo on a layer which is a waste of storage as I can include again the original. In definitive I want to keep the original photo, the exported one and all that allowed to obtain the exported result. I imagined an external batch process to open the targeted files, remove the usefulness layer, archive the original with the lighted project. I discovered script-fu language (LISP scheme) and followed tutorial script-fu and experimented it with success. But I did not found a way to achieve this : get the uncompressed layer size I found the following procedures which are not "size related" : - gimp-image-get-layer-by-name - gimp-image-get-layer-by-tattoo Is it possible to do this with script-fu ? Is it possible in another way ? Extra question, is there a way to attach a file to a XCF project (I suppose no) like we usually do it with the email attachments method ? I hoped this could be achieved with an add-on ... Thank you in advance for the time you will spend to me ![]() With adelphity lnj RE: Get layer by uncompressed size with script - rich2005 - 09-03-2025 I am sure that someone will come along with a more technical answer, however my simple view on this is with variations on saving / exporting. Quote:...snip.... In definitive I want to keep the original photo, the exported one and all that allowed to obtain the exported result. If you export to lossy format jpeg / webp you will get a small file size but lose the data. Some file size comparisons: 00-from-camera.jpg 7.0 MB - 96 compression 01-save.xcf 51.5 MB 02-save.xcf.gz 40 MB 03-save-better.xcf 33.6 MB The original (00) is a jpeg and small - open in Gimp and it shows as 167 MB Any extra layers adds to that, however without any editing. A Save in lossless xcf format with options . A straight Save (01) is large, you can get a smaller file size with secondary compression, a .xcf.gz (02) and smaller again using Gimp 3 "better compression" option. All those are lossless. With editing and adding layers / masks / groups will add to the saved file size, however it is worth using Gimp 3 layer effects (fx) where it seems to add only a small overhead and are still editable. This one is better-with-effects.xcf is 40 MB compared to 33.6 MB. Obviously all depends on the image and editing, add text for example is adding layers and increased file size. [attachment=13854] RE: Get layer by uncompressed size with script - Ofnuts - 09-03-2025 The storage size of any layer is the number of pixels (so, width ✕ height), multiplied by the number of channels (from one for grayscale without alpha to four for RGB with alpha) multiplied by the number of bytes per channel value (one if 8-bit integer, to four if 32-bit floating point). When you export to Gimp recent format, you can get compression, which usually results in about one third of the original size. The latest version, (Gimp 3.1.4) supports "link layers", where layers are the contents of an existing image file, so this could solve your problem more directly (but then as it is new it could have bugs...). RE: Get layer by uncompressed size with script - rich2005 - 09-03-2025 Quote:..With Gimp, the most part of time I works on photos to simply add extra layers and export the result (maps, explanations, mechanisms, and so).....snip..... As Ofnuts - new features in Gimp 3.1.4 development version - and there is an appimage for linux to try out https://download.gimp.org/gimp/v3.1/linux/ If you can keep mainly to vectors (paths, arrows, text, svg shapes ) then it is possible to make an editable overlay with a small file size. This example - the base file is 5.4 MB and the overlay is 26 KB [attachment=13855] For what its worth a 2 minute demo: https://i.imgur.com/nTY5rdS.mp4 The only snag at the moment is you need to load the overlay first otherwise you lose the original path (s) That might just be an oversight by the developers. |