NAME
Image::PNG::Data - manipulate the image data part of PNGs
SYNOPSIS
use Image::PNG::Data;
VERSION
This documents version 0.00_01 of Image-PNG-Data corresponding to git commit 75781a2ef00d28abc7c805ec49e95176682f94bd released on Wed Feb 3 23:18:05 2021 +0900.
DESCRIPTION
This module provides various utilities for manipulating and testing the image data part of a PNG image. This is a companion module to Image::PNG::Libpng by the same authors.
FUNCTIONS
alpha_used
if (alpha_used (read_png_file ('some.png')) {
Is the alpha channel in the image used or not? This function returns a true value if the PNG has an alpha channel and it is not being used.
any2gray8
my $wpng = any2gray8 ("any.png");
Convert any type of PNG file whatsoever into a bit-depth 8 grayscale image without an alpha channel (PNG_COLOR_TYPE_GRAY
). The return value is a write structure as made by "create_write_struct" in Image::PNG::Libpng.
Currently the tRNS
chunk (see "tRNS" in Image::PNG::Libpng) is ignored by this.
By default the alpha channel is set to either the value of the bKGD
chunk (see "bKGD" in Image::PNG::Libpng) if there is one, or white if not. You can set another background using the option bkgd
:
my $wpng = any2gray8 ('any.png', bkgd => {red => 255, green => 0, blue => 99});
This will of course be ignored if any.png does not contain an alpha channel. RGB to gray conversion is done using "set_rgb_to_gray" in Image::PNG::Libpng with the default values.
This function is not supported for versions of libpng earlier than 1.6.14.
bwpng
my $png = bwpng (\@rows, sq => 20);
Convert boolean-style data into a black and white PNG.
bwpng (\@rows, black => '#CFF', white => '#C00');
rgb2gray
my $gray_png = rgb2gray ('colorful.png');
Convert RGB to gray.
Options:
grayonly
rmalpha
my $png = rmalpha ('file.png');
Remove the alpha channel of the PNG. If the input PNG has a color type other than GRAY_ALPHA
or RGB_ALPHA
, a warning is printed and the return value is undefined. The return value is an Image::PNG::Libpng structure for writing with the alpha channel data removed.
split_alpha
Copy from IPL.
DEPENDENCIES
SEE ALSO
Online PNG tools
- https://onlinepngtools.com/convert-png-to-grayscale
-
Converts your PNG to grayscale via JavaScript. This actually resizes the image to the size of its box, but you can save the image with the Save as... link and you get the original size back.
- https://pinetools.com/grayscale-image
AUTHOR
Ben Bullock, <bkb@cpan.org>
COPYRIGHT & LICENCE
This package and associated files are copyright (C) 2021 Ben Bullock.
You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.