Help.Wanted('Pixel region gimpPy') - 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: Help.Wanted('Pixel region gimpPy') (/Thread-Help-Wanted-Pixel-region-gimpPy) Pages:
1
2
|
Help.Wanted('Pixel region gimpPy') - FloppaDisk - 03-26-2020 Hi. Having a rough time understanding have to manipulate individual pixel's trough gimp python. So far i have found this constructor drawable.get_pixel_rgn(x, y, w, h, [dirty, [shadow]) an been able to set a variable to it and call member from sayd variable but that about it. Found a Gnome site with descriptive information. Did try to install numpy into gimp with no luck. But don't think i need that module for now. What my end goal comprise of is to be able to edit individual pixel RGB values along side it's alpha/opacity. A little information on have to set rgb if that is with a 3-tuple or an hue int, with how/were opacity is set would be nice also RE: Help.Wanted('Pixel region gimpPy') - Ofnuts - 03-26-2020 Seen https://www.gimp-forum.net/Thread-Gimp-python-and-numpy ? RE: Help.Wanted('Pixel region gimpPy') - FloppaDisk - 03-26-2020 Did read it, but did not understand where to install pip or numpy relevant to gimp. I have pip installed on python but pretty sure that is not the gimp's python, but the general one. I run ubuntu desktop. Did try "sudo apt install python numpy" from home directory with no luck. Added the numpyops.py script to plug-ins folder with no luck. ~Know i need the numpy module first. The post that makes most sense of what should be done, but this is beyond what i understand. Also seam to be for windows RE: Help.Wanted('Pixel region gimpPy') - Ofnuts - 03-27-2020 Also on (K)Ubuntu desktop. If you installed Gimp from a .deb, then it uses the standard Python runtime from your desktop and a general pip install numpy (system level with sudo or user level) should work. If you installed a snap or a flatpak, then you may have to install numpy for your specific Python runtime (assuming one has been packaged). Starting Gimp in a terminal makes all the error output appear in the terminal. Very helpful to figure out what went wrong. Don't forget to make the Python script executable... RE: Help.Wanted('Pixel region gimpPy') - FloppaDisk - 03-27-2020 Hi. I have installed gimp through 'Ubuntu software center', guesses that is a snap install Gimp version is 2.10.18 Python version for ubuntu: Python 2.7.17 Python version for gimp: 2.7.? When running gimp through terminal the out put is: Quote:ln: failed to create symbolic link '/home/userName/snap/gimp/252/.config/gtk-2.0/gtkfilechooser.ini': File exists Found a .deb package for Gimp 2.8.22 and tryed to install it via aptitude, but it was not found: sudo aptitude install gimp_2.8.22-1_amd64.deb #Unsuccessful Runned this command from terminal and installed numpy. Which is a weird because i had already done that. But : sudo -H pip install numpy Terminal~:Successfully installed numpy-1.16.6 Would be very helpful if i should get a bit assistance installing gimp.deb that work with the rest of softwares or adding numpy to gimp environment. Thank in advance. RE: Help.Wanted('Pixel region gimpPy') - Ofnuts - 03-27-2020 Simplest solution if you are on a reasonably recent Ubuntu (18.04 or later) is add this PPA to you software sources (fimm instructions on the page). https://launchpad.net/~otto-kesselgulasch/+archive/ubuntu/gimp Then you have a full-featured Gimp that is normally integrated with your system (uses the standard Python environment). You can also installa a couple of other useful packages from there( GMIC, gimp-plugin-registry (resynthesize...)). RE: Help.Wanted('Pixel region gimpPy') - rich2005 - 03-28-2020 Quote:...Would be very helpful if i should get a bit assistance installing gimp.deb that work with the rest of softwares ... Always useful to check the distro version in a console use Code: uname -a The package you downloaded is for bionic https://packages.ubuntu.com/bionic/amd64/gimp/download Are you using bionic (Ubuntu 18.04) ? The default Gimp for bionic is already Gimp 2.8.22 and you would install it Code: sudo apt install gimp Installing local packages such as gimp_2.8.22-1_amd64.deb Use dpkg but you will need all the other gimp packages; gimp-data , libgimp2.0 libgegl-0.3 (I think) With all the packages in a folder, run in a terminal. Output will tell you if anything is missing. Dodgy because you can (will) end up with broken packages. Code: sudo dpkg -i *.deb To be honest, I use kubuntu 18.04 and the first thing I installed was the old package manager synaptic and generally install via that. For Gimp 2.10 as Ofnuts post, use the PPA The instructions are top of the web page. You might need to first install 'add-apt-repository' then it is straight forward. For some screenshots (out of date, but still applicable what ever 'buntu / Gimp version) see: https://www.gimp-forum.net/Thread-Gimp-2-10-10-and-Ubuntu-18-04-LTS RE: Help.Wanted('Pixel region gimpPy') - FloppaDisk - 03-28-2020 Thanks for replays. How now deleted snap gimp and installed apt gimp, did use 'sudo apt install gimp' For me using gimp 2.8 is fine. Now able to import numpy without an error message and got numpyPlug-in working. My Ubuntu version is 18.04.4 Did look at the code of this plug-in to try and replicate how one goes about editing a pixel with no luck. Are getting an error message TypeError: string is wrong length. dir() or help() was not able to support me further. Getting closer to the end goal whoho, and learn allot thanks to you guys Now my questions are:
RE: Help.Wanted('Pixel region gimpPy') - Ofnuts - 03-28-2020 Forgetting numpy for a while... The data to set a pixel in the pixel region is exactly the same as the one you get from the pixel region. Indexing a pixel region returns a string, but it's best converted to a bytearray. For instance, assuming a blue pixel at (0,0): Code: ➤> region[0,0] To alter the pixel, for instance to set its green channel: Code: ➤> pixel[1]=255 You can also set values from scratch, a half-transparent yellow pixel: Code: ➤> region[0,0]=str(bytearray([255,255,0,127])) Looking at the results, don't trust your eyes too much, there are obviously display refresh issues (the layer looks unchanged, but if slightly alter its opacity, is suddenly displays the changes...). This said, iterating pixels is slow, a simple image has nearly a million pixels. The big advantage of numpy is that the operations are performed on the whole array with machine code. The median filter example is about twice as fast as the median filter in GMIC. RE: Help.Wanted('Pixel region gimpPy') - FloppaDisk - 03-29-2020 Hi. Thank you two i finally managed to edit pixels a and with half a day create a little plugin 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 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. Code: #!/usr/bin/env python |