Re: [hackers] [farbfeld] Mandate "ProPhoto RGB" color space for farbfeld and handle ICC profiles || FRIGN

2016-01-17 Thread FRIGN
On Sun, 17 Jan 2016 10:10:19 +
Dimitris Papastamos  wrote:

> Commit message reads like a diary.

That's because it is a diary. :P

-- 
FRIGN 



[hackers] [farbfeld] Mandate "ProPhoto RGB" color space for farbfeld and handle ICC profiles || FRIGN

2016-01-16 Thread git
commit 3bc6c69ae8ff25377848b76a25494aa4a0055544
Author: FRIGN 
AuthorDate: Sun Jan 17 01:39:36 2016 +0100
Commit: FRIGN 
CommitDate: Sun Jan 17 02:11:54 2016 +0100

Mandate "ProPhoto RGB" color space for farbfeld and handle ICC profiles

I've literally been thinking about this for quite a while now. The
initial motivation behind defaulting to sRGB was the idea that most data
on the web was in sRGB anyway.
However, my assumption was weakened in the sense that the development
is clearly moving towards images with supplied ICC profiles and software
slowly catching up to handle this. My tests have shown that more and
more people even do that on the web, even though it's been a "tradition"
that Photoshop users "Save for Web" and convert the gamut lossy into
sRGB to bring a consistent color-"experience" even to those clients not
supporting ICC profiles and which always assume sRGB.

What made this decision so difficult is that converting to "ProPhoto
RGB" requires some advanced knowledge on this topic, however, I came to
the conclusion to implement it given the *2ff- and ff2*-tools handle it
silently and well in the background, and given the little cms library is
actually quite okay to use.
When converting from ff to png, a proper "Pro Photo RGB" ICC V4-profile is
automatically included in the exported png by ff2png. V4 is not as
widespread as V2, but in the worst case (no V4 support somewhere) the
colors will just be a little off.

As an added bonus, any input files for png2ff which include ICC profiles
are also correctly handled and the color space conversions are executed
as expected.

Accordingly, the FORMAT-specification has been changed. While at it,
I added the note on alpha-multiplication. Now the format is very exact
and shouldn't leave any ambiguities.

jpeg supports ICC profiles as well, but I hadn't had the chance to look
into it (not as trivial as PNG probably, help appreciated :)), so I'm
always assuming sRGB here.

Rationale
-
It is not obvious why one would go through the lenghts of supporting
this big-gamut colorspace and not just stick with sRGB. In 99% of the
cases, there's no reason to do that, but with even more extreme
developments in the OLED-sector and other advances display hardware is
slowly getting more powerful than sRGB, asking for color information
which is suitable for the task and actually uses the full potential.
The decision in this regard was not difficult in farbfeld because we
always use 16-Bit anyway and won't have to fear posterization in a big-
gamut color-space.

diff --git a/FORMAT b/FORMAT
index 5966df8..6821ab2 100644
--- a/FORMAT
+++ b/FORMAT
@@ -1,14 +1,15 @@
 
   FARBFELD IMAGE FORMAT SPECIFICATION
 
-  ++---+
-  | Bytes  | Description   |
-  ++---+
-  | 8  | "farbfeld" magic value|
-  ++---+
-  | 4  | 32-Bit BE unsigned integer (width)|
-  ++---+
-  | 4  | 32-Bit BE unsigned integer (height)   |
-  ++---+
-  | [] | 4*16-Bit BE unsigned integers [RGBA] / pixel, row-aligned |
-  ++---+
+  ++---+
+  | Bytes  | Description   |
+  ++---+
+  | 8  | "farbfeld" magic value|
+  ++---+
+  | 4  | 32-Bit BE unsigned integer (width)|
+  ++---+
+  | 4  | 32-Bit BE unsigned integer (height)   |
+  ++---+
+  | [] | 4*16-Bit BE unsigned integers [RGBA] / pixel  |
+  || pixels in rows, ProPhoto RGB, not alpha-premultiplied |
+  ++---+
diff --git a/config.mk b/config.mk
index 37ad05f..55264b0 100644
--- a/config.mk
+++ b/config.mk
@@ -13,8 +13,11 @@ PNGINC = /usr/local/include
 JPGLIB = /usr/local/lib
 JPGINC = /usr/local/include
 
-INCS = -I${PNGINC} -I${JPGINC}
-LIBS = -L${PNGLIB} -L${JPGLIB} -lpng -ljpeg
+LCMSLIB = /usr/local/lib
+LCMSINC = /usr/local/include
+
+INCS = -I${PNGINC} -I${JPGINC} -I${LCMSINC}
+LIBS = -L${PNGLIB} -L${JPGLIB} -L${LCMSLIB}