Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help.Wanted('Pixel region gimpPy')
#10
Hi. Thank you two i finally managed to edit pixels a and with half a day create a little plugin  Big Grin
Supper helpful that you gave a pointer to run the gimp through terminal for error code. Getting the gimp to work at 'core' level moves my core too, orchestra code is the best Cool 
Bellow is my master piece. If you would like to try it, try it at different image widths like 180, 360 361, 60 for weird effect. The hue is based on an number that goes up to 360 and start at zero again. Remember to use an alpha layered image. Smile


Code:
#!/usr/bin/env python

from gimpfu import *

def FindColor(hue, opac):
   if hue < 60:
       return list((255, int(255*(hue/60.0)), 0, opac))
   elif hue >= 60 and hue < 120:
       return list((255-int(255*((hue%60)/60.0)), 255, 0, opac))
   elif hue >= 120 and hue < 180:
       return list((0, 255, int(255*((hue%60)/60.0)), opac))
   elif hue >= 180 and hue < 240:
       return list((0, 255-int(255*((hue%60)/60.0)), 255, opac))
   elif hue >= 240 and hue < 300:
       return list((int(255*((hue%60)/60.0)), 0, 255, opac))
   elif hue >= 300:
       return list((255, 0, 255-int(255*((hue%60)/60.0)), opac))

def hueGrade(image, drawable, alphaVal):
   gimp.progress_init("Hue chart'n " + image.name + "...")

   srcRgn = drawable.get_pixel_rgn(0, 0, image.width, image.height, True, False)

   y = image.width*image.height
   for x in range(y):
       srcRgn[(int(x%image.width), int(x/image.width))] = str(bytearray(FindColor(x%360, int(alphaVal))))
       gimp.progress_update(1.0 * x / y)

   drawable.update(0,0,image.width,image.height)
   pdb.gimp_progress_end()
   print('done')

register(
   "python-fu-hueGrade",
   "Takes an RGBA and produces a hue that covers the whole image",
   "Goes along width then down generating a hue based on steped pixel sum; Hue goes from 0 to 359 then repeats",
   "FloppaDisk", "FloppaDisk", "2020",
   "Hue chart",
   "RGBA", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
   [
       (PF_IMAGE, "image", "takes current image", None)
       , (PF_DRAWABLE, "drawable", "Input layer", None)
       , (PF_SLIDER, "alphaVal", "Alpha value", 255, [0, 255, 10])
   ],
   [],
   hueGrade, menu="<Image>/Filters/Extra")  # second item is menu location

main()
Reply


Messages In This Thread
RE: Help.Wanted('Pixel region gimpPy') - by FloppaDisk - 03-29-2020, 06:02 PM

Forum Jump: