Skip to content

Instantly share code, notes, and snippets.

@valioDOTch
Created December 15, 2016 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valioDOTch/b051463a4a78a70d56293118f7136983 to your computer and use it in GitHub Desktop.
Save valioDOTch/b051463a4a78a70d56293118f7136983 to your computer and use it in GitHub Desktop.
Gimp loading bar script
images = gimp.image_list()
layers = images[0].layers
width = gimp.pdb.gimp_image_width(images[0])
height= gimp.pdb.gimp_image_height(images[0])
opacity = 100
parent_layer = None
above_active_layer = -1
for x in range(0,width):
gimp.pdb.gimp_image_select_rectangle(images[0],CHANNEL_OP_REPLACE,x,0,1,height)
gimp.pdb.gimp_edit_cut(layers[0])
newlayer = gimp.pdb.gimp_layer_new(images[0],1,height,RGBA_IMAGE,"x"+str(x),opacity,NORMAL_MODE)
gimp.pdb.gimp_image_insert_layer(images[0],newlayer,parent_layer,above_active_layer)
gimp.pdb.gimp_edit_paste(newlayer,FALSE)
floating=gimp.pdb.gimp_image_get_floating_sel(images[0])
gimp.pdb.gimp_floating_sel_anchor(floating)
gimp.pdb.gimp_layer_set_offsets(newlayer,x,0)
@valioDOTch
Copy link
Author

valioDOTch commented Dec 15, 2016

This is a Python-Fu Gimp script that creates a loading bar

How to use:

  1. Open some image with Gimp
  2. In the menu select "Filters" > "Python-Fu" > "Console" (a Python-Fu console window should open)
  3. Copy-Paste this code into the console & press "Enter" (this will start the Script which will take some seconds to minutes to execute)
  4. Optionally: open the same image again, apply some filter to it (e.g. grayscale) and copy it to the image which we were working on as a new layer. Then set it as the first layer (you can press the shift key and click on the down-arrow icon in the "Layers" window)
  5. Save the image as loading.xcf and export loading.gif. Select "Save as Animation", deselect "Loop forever", change the value for the delay to some fitting value. Consider the total length that you expect the loading process to take. E.g. if you think it is about 3.5seconds and you have an image of 115 pixels width, the delay for each frame should be 3.5 seconds / 115 which is about 30ms.
    gimp-export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment