Re: Need help with Python plugin exporting to raw file (using Gimp 2.9)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21 February 2015 at 10:35, Partha Bagchi <partha1b@xxxxxxxxx> wrote:
> Hi João,
>
> What's your timeframe for modifying pygimp to use introspection? I
> have not yet built glib and friends with introspection because it's a
> pain and it's finicky. :)

No idea on "timeframes" . Introspection as it is now, since GIMP
itself does not make use of it,
is mostly needed for the UI parts of Pygimp.  (i.e. changing from
traditional pygtk
to gobject introspection gtk)  - but I jsut remebered the major blocker there:
GUI building with gobject introspection is known not to work well with
GTK2 - we'd
need to change pygimp to gtk3.

That would not be a problem for Linux systems (hey, Pygimp used
TCL based Tk widgets when it first debut), it should be a nono for
packagers for Mac OS X and Windows.

Can someone who works on the installers  give me some feedback on that?



>
> Thanks,
> Partha
>
>
> On Fri, Feb 20, 2015 at 11:54 PM, Joao S. O. Bueno <gwidion@xxxxxxxxx> wrote:
>> Hi  -
>> I've actually comitted the above method - but beware it is subject to
>> some changes.
>>
>> I've added the "precision" read-only property to gimp-images, and the
>> "get_data" method
>> to drawables (layers and channels) -
>> get_data returns a Python array.array object - it even features
>> conveninent methods
>> to write itself to a file (https://docs.python.org/2/library/array.html) -
>> For now, it  takes an optional string argument representing a BABL pixel format
>> (http://gegl.org/babl/BablFishPath.html) and will return an array of
>> the apropriate data type.
>> The default is "RGBA float" - but I think it would be better to change
>> it to default to the
>> drawable native data type- still allowing an explicit format to be passed.
>>
>>
>> I will probably keep it the return type an array, but possibly
>> subclass it to an object that can
>> take in 2D indexes to ease pixel access, as  currently existing python
>> "pixel_region" object allows
>> (thus: data[100, 50] will be as valid as data[50 * drawable.width +
>> 100] to get to a single pixels.
>>
>> On the short term roadmap there is a "set_data"  - (or maybe "blit ")?
>>
>> And at the point in time it is possible to use gobject introspection along
>> pygimp (it can't be done in a straightforward way), make
>> drawable.get_buffer directly available and returning a Gegl buffer
>> wrapped in a convenient Python object.
>>
>> On 21 February 2015 at 00:49, Joao S. O. Bueno <gwidion@xxxxxxxxx> wrote:
>>> Getting there... no need to poke me for now -
>>>
>>> GIMP 2.9.1 Python Console
>>> Python 2.7.5 (default, Nov  3 2014, 14:26:24)
>>> [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)]
>>>>>> img = gimp.image_list()[0]
>>>>>> a = img.layers[0].get_data()
>>>>>> len(a)
>>> 1228800
>>>>>> a[0:300]
>>> array('f', [0.0003035269910469651, 0.0003035269910469651,
>>> 0.0003035269910469651, 0.6235294342041016, 0.0003035269910469651,
>>> 0.0003035269910469651, 0.0003035269910469651, 0.6235294342041016,
>>> 0.0003035269910469651,...]
>>>
>>> On 20 February 2015 at 09:50, Joao S. O. Bueno <gwidion@xxxxxxxxx> wrote:
>>>> Hi Alek_
>>>>
>>>> it turns out that the Python bindings for GIMP had not been updated to
>>>> deal with higher precision images as of yet.
>>>>
>>>> Don't despair - since you had built GIMP master, this is as good time
>>>> as any to get it going. :-)
>>>>
>>>> You can get to know the image precision (and even set it) thorugh the
>>>> PDB, though, with a call to:
>>>>
>>>> pdb.gimp_image_get_precision
>>>>
>>>> Now - for the actual business: I think there are two ways to go - one
>>>> short term, with
>>>> a "get" and "set" buffer method on Python drawables that will just
>>>> copy the inner image data
>>>> and make it available in a Python array. That would suffice for most
>>>> needs like yours, I guess.
>>>>
>>>> The other, longer term and proper way, is to write calls to get the
>>>> proper GEGL Buffer objects
>>>> in Python, using GEGL Python bindings - that will allow the use of any
>>>> of GEGL's operations
>>>> on GIMP Image data and commit it back - but it will also require the
>>>> python-gegl package.
>>>>
>>>> Those bindings are currently living in my personal repo, and  could
>>>> work for you right now, as they do allow access to the buffer data -
>>>> but you have to build GEGL with the extra "--enable-introspection"
>>>> switich to get then going.
>>>> (http://github.com/jsbueno/python-gegl )
>>>>
>>>> But -- let's focus in enabling one to get the high-depth pixel
>>>> contents from GIMP without need for those for now.
>>>> Feel free to poke me again in 24 hours if there are no news on this subject.
>>>>
>>>>   js
>>>>  -><-
>>>>
>>>>
>>>> On 19 February 2015 at 23:06, Alek _ <spectatoe@xxxxxxxxxxx> wrote:
>>>>>
>>>>>
>>>>>
>>>>> I'm using Gimp 2.9 experimental build, which I downloaded from
>>>>> partha.com, to specifically have edit ability with 16-bit per channel
>>>>> images.  I originally posted in gimpforums.com and was told I should try here.
>>>>>
>>>>>
>>>>>
>>>>> I'm trying to write a Python plugin to export an image as a raw file
>>>>> (just data, no header).  The current option to export as raw image data
>>>>> (File -> Export as -> Raw image data) seems to only support writing out as 8-bit even when the image precision
>>>>>  is greater than 8-bit.  So I wanted to write a plugin so I could export
>>>>>  my 16-bit per channel image to a raw file with the 16-bit data
>>>>> preserved.
>>>>>
>>>>> My image is a 16-bit grayscale 3x3 image with a checkerboard pattern of alternating white and black pixels.
>>>>>
>>>>>
>>>>>
>>>>> I used the sample script 'test-discolour-layer-v4.py' from http://registry.gimp.org/node/28124
>>>>>  as a guide on how to iterate through every pixel.  I have some
>>>>> questions and ran into some problems.  What I have so far can be seen here (http://pastebin.com/U49VZYVT).  It just iterates through the pixels and outputs values to the
>>>>> error console.
>>>>>
>>>>>
>>>>>
>>>>> 1. How do I query for the precision?  That is, I want to know if the
>>>>> current image is 8-bit gamma integer, or 16-bit linear integer, or
>>>>> something else.  I looked at the image object's attributes and didn't
>>>>> find anything.
>>>>>
>>>>>
>>>>>
>>>>> 2. When I get the pixel value from srcTile[x,y], the value is always
>>>>> 8-bit.  With the white pixels, the value should be 65535 but I got 255.  How do I get the
>>>>> proper value?  When I use the Color Picker tool with info window, it says 65535 for white.  How do I get that value?
>>>>>
>>>>>
>>>>>
>>>>> 3. My code creates a new layer from visible and then queries the pixels from that.  In my image, all values returned are 255 even for the black pixels.  When I put my checkboard pattern on the Background layer and query that layer, I get correct values (though in 8-bit).  For any other layer other than Background, the values are always 255.  I don't know what I'm doing wrong.
>>>>>
>>>>>
>>>>> Can someone help me or point me in the right direction?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> _______________________________________________
>>>>> gimp-developer-list mailing list
>>>>> List address:    gimp-developer-list@xxxxxxxxx
>>>>> List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
>>>>> List archives:   https://mail.gnome.org/archives/gimp-developer-list
>> _______________________________________________
>> gimp-developer-list mailing list
>> List address:    gimp-developer-list@xxxxxxxxx
>> List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
>> List archives:   https://mail.gnome.org/archives/gimp-developer-list
_______________________________________________
gimp-developer-list mailing list
List address:    gimp-developer-list@xxxxxxxxx
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list





[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux