Script "slice using guides" and "png export" - 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: Script "slice using guides" and "png export" (/Thread-Script-slice-using-guides-and-png-export) |
Script "slice using guides" and "png export" - Lamidetlm - 10-24-2022 Hello everyone, first sorry if my English is average (I'm a stupid French). As part of a 3d project, I need to develop a small script for gimp. I hope I'm in the right place I would need a script that follows these steps; - save the file - merge all layers - slice using guides -export the different images created in .png.as it is all I can do is put the layers together and save each image in Gimp format. I've scoured the web and tried to combine the scripts found: Code: (define (script-fu-save-png Image layer) As it is all I can do is put the layers together and save each image in Gimp format. In the state I do the "slice using guides" me myself. Then the script gathers the layers and saves each image in Gimp format. I can't find the command to do the "slice using guides" nor the modification to switch to png. Any ideas ? Thank you for reading me RE: Script "slice using guides" and "png export" - Ofnuts - 10-24-2022 Merging all layers can be done with gimp-image-flatten (but this also removes any transparency). The equivalent to the "slice using guides" in the UI is plugin-guillotine gimp-file-save saves the image in whatever format is given as an extension (so as PNG if the file names ends with .png). You can also for a PNG save with gimp-png-save or file-png-save2. Note that all the save operation to "flat" files (PNG, JPG...) only apply to the specified layer. This said, I have the gut feeling that this is the wrong way to solve a problem. If you can explain the original problem we can come up with better solutions, perhaps with scripts that already exist. For instance a script of mine will cut an image in regular "tiles" and save each tile to disk (so this would be your "slice and save") and another one can save/export all the layers (so this would be you "flatten, slice and save"). RE: Script "slice using guides" and "png export" - Lamidetlm - 10-25-2022 thank you for your responsiveness (10-24-2022, 04:19 PM)Ofnuts Wrote: Merging all layers can be done with gimp-image-flatten (but this also removes any transparency).Too bad I really need transparency.. (10-24-2022, 04:19 PM)Ofnuts Wrote: The equivalent to the "slice using guides" in the UI is plugin-guillotineGood thing , it's work ! (Honestly, I don't really understand what I'm doing. I'm not a coder.) Quote:gimp-file-save saves the image in whatever format is given as an extension (so as PNG if the file names ends with .png). You can also for a PNG save with gimp-png-save or file-png-save2. Note that all the save operation to "flat" files (PNG, JPG...) only apply to the specified layer. I tried the different "png export" the only one that does not crash my code is "file-png-save-defaults". But it gives me a script that runs in a loop and always outputs .gimp files and not .png files Code: (define (script-fu-save-png Image layer) Quote:This said, I have the gut feeling that this is the wrong way .... layers (so this would be you "flatten, slice and save").I create textures that are used in several projects. On a large image of 2048*1536 pixels. The obtimal format for the engine is 512*512px, so I cut the whole thing for each export. Each project involves small variations / retouching of this image. Working on the set is very convenient in my case. But exporting 10 images manually each time is unnecessarily painful. Your scripts seem rather suitable yes. I would be interested in seeing this, at least to understand the structure of the code. If you want to share I take it with joy RE: Script "slice using guides" and "png export" - rich2005 - 10-25-2022 Quote:...Too bad I really need transparency.. Instead of Flatten you could try gimp-layer-new-from-visible and apply "Slice Using Guides" to that new layer. Then there is a script that will export all those new images sg-save-all.scm you might pick out parts of that. By hand it goes: Make layers visible / not visible With guides in place Image -> slice using guides. If required close original image Use File -> Save ALL As to export in required format. As an animation https://i.imgur.com/JADobE2.mp4 I am no script writer either, so it is up-to-you. The old Saul Goode script sg-save-all.scm attached. Unzip put in your Gimp user scripts folder. RE: Script "slice using guides" and "png export" - Lamidetlm - 10-25-2022 OK, thanks lot ! indeed, this script is almost perfect for me. I added the "plug-in-guillotine", it works. The "gimp-image-flatten" also works. But indeed it removes the alpha . So I'm trying to make the "gimp-layer-new-from-visible" work, But it's more complex and I can't find how to call it effectively it seems that it needs to be combined with "gimp-image-insert-layer". But that's beyond my skills, does anyone have an example of a piece of code where "gimp-layer-new-from-visible" is functional ? The code with "plug-in-guillotine" ; Code: ; This program is free software; you can redistribute it and/or modify RE: Script "slice using guides" and "png export" - Ofnuts - 10-26-2022 (10-25-2022, 09:29 AM)Lamidetlm Wrote: thank you for your responsiveness The ofn-tiles script can be found there (it's written in Python, but your Windows Gimp has built-in Python support). See bottom of linked page for installation instructions. See HTML doc inside the ZIP. You can use it by either specifying the tile size (512x512) or the row and columns (3 rows and 4 columns). RE: Script "slice using guides" and "png export" - Lamidetlm - 10-27-2022 Ok thank you very much, with all that, it will be very good. |