File perl-PDL-Transform-Color.spec of Package perl-PDL-Transform-Color
#
# spec file for package perl-PDL-Transform-Color
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define cpan_name PDL-Transform-Color
Name: perl-PDL-Transform-Color
Version: 1.010
Release: 0
License: Artistic-1.0 OR GPL-1.0-or-later
Summary: Useful color system conversions for PDL
URL: https://metacpan.org/release/%{cpan_name}
Source0: https://cpan.metacpan.org/authors/id/E/ET/ETJ/%{cpan_name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: perl
BuildRequires: perl-macros
BuildRequires: perl(ExtUtils::MakeMaker) >= 6.48
BuildRequires: perl(PDL) >= 2.094
BuildRequires: perl(PDL::Graphics::ColorSpace) >= 0.203
BuildRequires: perl(Test::More) >= 0.88
Requires: perl(PDL) >= 2.094
Requires: perl(PDL::Graphics::ColorSpace) >= 0.203
%{perl_requires}
%description
PDL::Transform::Color includes a variety of useful color conversion
transformations. It can be used for simple hacks on machine-native color
representations (RGB <-> HSV, etc.), for simple encoding/decoding of
machine-native color representations such as sRGB, or for more
sophisticated manipulation of absolute color standards including
large-gamut or perceptual systems.
The color transforms in this module can be used for converting between
proper color systems, for gamma-converting pixel values, or for generating
pseudocolor from one or two input parameters. In addition to transforming
color data between different representations, Several named "color maps"
(also called "color tables") are provided.
The module uses linearized sRGB (lsRGB) as a fundamental color basis. sRGB
is the standard color system used by most consumer- to mid-grade computer
equipment, so casual users can use this color representation without much
regard for gamuts, colorimetric standards, etc.
Most of the transform generators convert from lsRGB to various other
systems. Notable simple ones are HSV (Hue, Saturation, Value), HSL (Hue,
Saturation, Lightness), and CMYK (Cyan, Magenta, Yellow, blacK).
If you aren't familiar with PDL::Transform, you should read that POD now,
as this is a subclass of PDL::Transform. Transforms represent and
encapsulate vector transformations -- one- or two-way vector functions that
may be applied, composed, or (if possible) inverted. They are created
through constructor methods that often allow parametric adjustment at
creation time.
If you just want to "manipulate some RGB images" and not learn about the
esoterica of color representations, you can treat all the routines as
working "from RGB" on the interval [0,1], and use 't_srgb' to import/export
color images from/to "24-bit color" that your computer probably expects. If
you care about the esoterica, read on.
The output transfer function for sRGB is nonlinear -- the luminance of a
pixel on-screen varies somewhat faster than the square of the input value
-- which is inconvenient for blending, merging, and manipulating color.
Many common operations work best with a linear photometric representation.
PDL::Transform::Color works with an internal model that is a floating-point
linear system representing pixels as 3-vectors whose components are
proportional to photometric brightness in the sRGB primary colors. This
system is called "lsRGB" within the module.
Note that, in general, RGB representations are limited to a particular
narrow gamut of physically accessible values. While the human eye has three
dominant colorimetric input channels and hence color can be represented as
a 3-vector, the human eye does not cleanly separate the spectra responsible
for red, green, and blue stimuli. As a result, no trio of physical primary
colors (which must have positive-definite spectra and positive-definite
overall intensities) can represent every perceivable color -- even though
they form a basis of color space.
But in digital representation, there is no hard limit on the values of the
RGB vectors -- they can be negative or arbitrarily large. This permits
representation of out-of-gamut values using negative or over-unity
intensities. So floating-point lsRGB allows you to represent literally any
color value that the human eye can perceive, and many that it can't. This
is useful even though many such colors can't be rendered on a monitor. For
example, you can change between several color representations and not be
limited by the formal gamut of each representation -- only by the final
export standard.
Three major output formats are supported: sRGB (standard "24-bit color"
with the industry standard transfer function); bRGB (bytescaled RGB with a
controllable gamma function (default 2.2, matching the average gamma value
of most CRTs and calibrated flat monitors); or CMYK (direct linear
inversion of the RGB values, with byte scaling). These are created by
applying the transforms 't_srgb', 't_brgb', and 't_cmyk', respectively, to
an lsRGB color triplet.
The 't_srgb' export routine will translate represented colors in
floating-point lsRGB to byte-encoded sRGB (or, if inverted, vice versa),
using the correct (slightly more complicated than gamma functions)
nonlinear scaling. In general, you can use '!t_srgb' to import existing
images you may have found lying around the net; manipulate their hue, etc.;
and re-export with 't_srgb'.
If you prefer to work with direct gamma functions or straight scaling, you
can import/export from/to byte values with 't_brgb' instead. For example,
to export a color in the CIE RGB system (different primaries than sRGB),
use 't_brgb() x t_ciergb'.
There are also some pseudocolor transformations, which convert a single
data value to normalized RGB. These transformations are 't_pc' for
photometric (typical scientific) values and 't_pcp' for perceptual (typical
consumer camera) values. They are described below, along with a collection
of named pseudocolor maps that are supplied with the module.
%prep
%autosetup -n %{cpan_name}-%{version}
%build
perl Makefile.PL INSTALLDIRS=vendor
%make_build
%check
make test
%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist
%files -f %{name}.files
%doc CHANGES TODO
%license LICENSE
%changelog