RSS/Atom feed Twitter
Site is read-only, email is disabled

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

Martin Nordholts
2009-01-26 06:53:54 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Hi

I have attached a patch to "Bug 74224 – Add support for 16 bits per channel" [1] that makes it possible to use GIMP for opening, color correcting and saving 16-bits-per-channel PNGs using the operations under the Colors menu that are ported to GEGL such as Color Balance or Levels. For a technical description of the patch, refer to the bug report.

This was a weekend hack and raises an interesting question: shall we go for some kind of 16-bit support for GIMP 2.8? I think we should as I am confident we will be able to come up with something useful in the realm of high bit depths for 2.8. I don't think it will be hard to add support for loading some additional 16-bit image formats, allowing creation of 16-bit images and adding 16-bit capabilities to a set of basic tools. Even if we certainly won't be able to completely port everything to 16-bit in one release cycle it would show that we are making progress in this area. Just being able to color correct 16-bit PNGs covers one use case already.

To convince yourself of that the patch actually makes GIMP do stuff in high bit depth:

1. Apply the patch, requires SVN trunk of GIMP, GEGL and babl.

2. Open a 16-bit PNG with a white-to-black gradient such as this [2] one I created using Krita.

3. Enable GEGL for the projection and color tools, the legacy code can't handle 16-bit image data. View -> Use GEGL and Colors -> Use GEGL.

4. Use Colors -> Levels and map the entire range of input to the output range [120, 135]. This will make the image look completely gray. Apply.

5. Use Colors -> Levels and map the input range [120, 135] to the full output range [0, 255]. Apply.

After doing 5 the gradient will look intact if you do this on the 16-bit PNG with GEGL. If you do this on 8-bit data using the 8-bit legacy code paths the results will look terrible.

Welcome to the start of the 16-bit GIMP era ;)

BR, Martin

[1] http://bugzilla.gnome.org/show_bug.cgi?id=74224 [2] http://www.chromecode.com/temp/gradient-16-bit.png

Hal V. Engel
2009-01-27 10:05:58 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

On Sunday 25 January 2009 21:53:54 Martin Nordholts wrote:

Hi

I have attached a patch to "Bug 74224 – Add support for 16 bits per channel" [1] that makes it possible to use GIMP for opening, color correcting and saving 16-bits-per-channel PNGs using the operations under the Colors menu that are ported to GEGL such as Color Balance or Levels. For a technical description of the patch, refer to the bug report.

This was a weekend hack and raises an interesting question: shall we go for some kind of 16-bit support for GIMP 2.8? I think we should as I am confident we will be able to come up with something useful in the realm of high bit depths for 2.8. I don't think it will be hard to add support for loading some additional 16-bit image formats, allowing creation of 16-bit images and adding 16-bit capabilities to a set of basic tools. Even if we certainly won't be able to completely port everything to 16-bit in one release cycle it would show that we are making progress in this area. Just being able to color correct 16-bit PNGs covers one use case already.

I think Martin's proposal has merit. I know that comparisons to Photoshop are to some extent considered off topic here but in this case I will do it because the history of Photoshop has some parallels. The approach that Martin is advocating (IE. having high bit depth support for loading, saving and some color correction operations) is how the first versions of Photoshop with high bit depth support worked. This started with version 6 I believe and the support for high bit depth images improved with each follow on version until it was complete. Even though these earlier versions were somewhat frustrating because only some operations were supported for high bit depth images it was none the less a significant step forward and this progress was well received by it's users. I am sure that that would also be the case for GIMP users.

To convince yourself of that the patch actually makes GIMP do stuff in high bit depth:

1. Apply the patch, requires SVN trunk of GIMP, GEGL and babl.

2. Open a 16-bit PNG with a white-to-black gradient such as this [2] one I created using Krita.

3. Enable GEGL for the projection and color tools, the legacy code can't handle 16-bit image data. View -> Use GEGL and Colors -> Use GEGL.

4. Use Colors -> Levels and map the entire range of input to the output range [120, 135]. This will make the image look completely gray. Apply.

5. Use Colors -> Levels and map the input range [120, 135] to the full output range [0, 255]. Apply.

After doing 5 the gradient will look intact if you do this on the 16-bit PNG with GEGL. If you do this on 8-bit data using the 8-bit legacy code paths the results will look terrible.

Welcome to the start of the 16-bit GIMP era ;)

BR, Martin

Just curious. Since GEGL has support for more high bit depth formats than just 16 bit int/channel how much more work would be needed to support a wider range of formats? For example tif files can use a number of different representations including 32 bit int/channel and 32 and 64 bit float/channel as well as 8 and 16 bit int/channel and probably some other representation formats. Once 16 bit int/channel is working how much additional work is needed to support these other image formats? Or is this trivial to implement and therefore almost free at that point?

Hal

Michael Schumacher
2009-01-27 12:02:09 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Von: "Hal V. Engel"

I think Martin's proposal has merit. I know that comparisons to Photoshop are to some extent considered off topic here but in this case I will do it because the history of Photoshop has some parallels. The approach that Martin is advocating (IE. having high bit depth support for loading, saving and some color correction operations) is how the first versions of Photoshop with high bit depth support worked.

"We do not want the frustrating partial support of Photoshop, we want everything from the start" has been the decision in the last discussion about this topic, IIRC.

HTH, Michael

David Gowers
2009-01-27 13:31:33 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Hi,

On Tue, Jan 27, 2009 at 7:35 PM, Hal V. Engel wrote:

On Sunday 25 January 2009 21:53:54 Martin Nordholts wrote: Just curious. Since GEGL has support for more high bit depth formats than just 16 bit int/channel how much more work would be needed to support a wider

For proper 16bit support, levels/colors/etc dialogs need to talk in terms of 0..65535 range rather than 0..255 when they are working on 16bit data, and so should then be able to talk in terms of 0..4294967295 for 32bit int.
If I understand this patch correctly, once a system for working with 'native' ranges is implemented and the basic system implemented by the patch is proven, support for 32bit int/channel should be relatively simple. Whether floating point support would require more work, I do not know.

There are also various rough spots to consider; we should be able to enter hex colors with 16bit or even 32bit per channel precision, if we can edit 16bit images.

Sadly I haven't been able to try this patch yet -- my GIMP doesn't want to compile, due to babl/gegl synchronization issues.

David

Martin Nordholts
2009-01-27 18:16:23 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Hal V. Engel wrote:

Just curious. Since GEGL has support for more high bit depth formats than just 16 bit int/channel how much more work would be needed to support a wider range of formats?

Support for 16 bits per channel implemented properly will give us at least any other RGB format we want more or less for free except perhaps 64-bit floats per channel since the internal processing happens with 32-bit floats. Sure, you could easily process 64-bit float data but since it has to pass through 32-bit float pipes it's quite pointless.

The patch was pretty thoroughly discussed yesterday on the IRC channel and the consensus was that we want to give higher bit depths a shot for 2.8. Note that the patch is very rough and sketchy. The purpose of it was just to show that it is pretty easy to add elementary support for higher bit depths in GIMP now thanks to the previous of porting of core components to GEGL.

- Martin

Sven Neumann
2009-01-31 20:18:46 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Hi,

there are two issues with your patch that we should try to solve. The first is that your approach doesn't follow the roadmap we've set for this. Our decision was not to introduce high bit depths before we haven't changed all tools, all core operations and at least provide an API for plug-ins to work in higher bit depths. But then you are probably right that we need to start somewhere...

The other problem I see with your approach is that image loading is done by the core. That is something that we should try to avoid by all means. I suggest that we add a plug-in API that allows file loaders to pass the location of a disk-backed GeglBuffer to the core. That should be a reasonable way to get layer data to the core without the risk of crashing the core due to some problem in the file loader.

It would be nice if you could keep us up-to-date with regard to your hacking. Perhaps you could send an updated patch to the list?

Sven

Martin Nordholts
2009-01-31 21:51:31 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Sven Neumann wrote:

I suggest that we add a plug-in API that allows file loaders to pass the location of a disk-backed GeglBuffer to the core. That should be a reasonable way to get layer data to the core without the risk of crashing the core due to some problem in the file loader.

Hi Sven

A disk-backed GeglBuffer API for transfering high bit depth data to the core was what I had in mind as well.

There are two things I am aiming for getting into 2.8 that I believe will lay a good foundation for more complete support for higher bit depths in GIMP:

* The possibility to convert images (or rather, the data in the image) freely between 8, 16 and 32 bits/channel.

* Elementary load/save support for formats that support higher bit depths such as PNG, TIFF and OpenEXR.

It would also be nice to be able to specify the bit depth when creating a new image (trivial to implement) and being able to use a couple of tools such as the Bucket Fill Tool on HBD layers. That is however not essential. The Color-tools are already ported to GEGL and higher bit depths are of particular use to exactly that set of tools. Just being able to load, color correct and save HBD images is quite useful already.

As we have discussed, in a completely GEGL-based GIMP the user would not have to manually manage the bit-depth at all, we would simply never destroy any data and work exclusively in RGBA float with sources being in any format supported by babl.

That said, during the transition period to a completely GEGL-based GIMP I don't see how we can get away with offering manual conversion to/from 8 bpc which is why I am aiming for adding that. As long as the dirty details is kept in the core I don't think it will obstruct us from continuing our pursue for a completely GEGL-based GIMP later. In fact, I think what we learn by doing the above will give us important insights into exactly to make GIMP completely GEGL-based.

I will attach new patches to the bug report [1], so people interested in following the code writing process can subscribe to that report.

Would love to get your comments in this plan

BR, Martin

[1] http://bugzilla.gnome.org/show_bug.cgi?id=74224

Sven Neumann
2009-02-01 13:08:05 UTC (almost 16 years ago)

[Patch] Opening, color correcting and saving 16-bits-per-channel PNGs

Hi,

On Sat, 2009-01-31 at 21:51 +0100, Martin Nordholts wrote:

* Elementary load/save support for formats that support higher bit depths such as PNG, TIFF and OpenEXR.

As far as I can see GEGL does not have a TIFF load and save operation yet. So anyone who is interested in being able to load and save TIFF files in higher bit depths should consider to contribute that code to GEGL.

There is likely support for other file formats missing in GEGL. It would be nice if this could be improved. Interested developers, please join the gegl-developer mailing-list...

Sven