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]

 



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




[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