SkillAgentSearch skills...

Imageworsener

A utility for processing PNG, JPEG, BMP, and WebP images. Features include resize/resample, dither, grayscale, apply background color, subpixel rendering.

Install / Use

/learn @jsummers/Imageworsener
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ImageWorsener is a raster image scaling and processing utility. Version 1.3.5 Copyright (c) 2011-2022 Jason Summers jason1@pobox.com

Web site: https://entropymine.com/imageworsener/

All nontrivial automated image processing causes a loss of information. While ImageWorsener will degrade your images, its goal is to degrade them as little as possible.

===========================================================================

This program is distributed under an MIT-style license. Refer to the included COYPING.txt file for more information.

Versions up to 1.1.0 used the GPLv3+ license.

If source code is not included in this package, it may be downloaded from the web site at https://entropymine.com/imageworsener/.

===========================================================================

If this package contains executable binaries, we need to state the following:


This software is based in part on the work of the Independent JPEG Group.


This software may include code from libwebp (part of the WebM project), which has the following license:

| Copyright (c) 2010, Google Inc. All rights reserved. | | Redistribution and use in source and binary forms, with or without | modification, are permitted provided that the following conditions are | met: | | * Redistributions of source code must retain the above copyright | notice, this list of conditions and the following disclaimer. | | * Redistributions in binary form must reproduce the above copyright | notice, this list of conditions and the following disclaimer in | the documentation and/or other materials provided with the | distribution. | | * Neither the name of Google nor the names of its contributors may | be used to endorse or promote products derived from this software | without specific prior written permission. | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

===========================================================================

For additional information about ImageWorsener, see the file technical.txt.

Primary features:

  • Resize
  • Posterize (reduce the number of colors)
  • Dither
  • Convert to grayscale
  • Apply background colors
  • "Channel offset"

ImageWorsener is focused on correctness, and not on performance. It is relatively slow. Among the things it (hopefully) does right:

  • Gamma correction, and the sRGB colorspace (not just the gamma=2.2 approximation).
  • Conversion to grayscale.
  • Processing of transparency.
  • All the image scaling algorithms that it implements.

Other information:

  • The command-line utility fully supports PNG, JPEG, BMP, and WebP files, and has partial support for GIF, TIFF, MIFF, and PPM/PGM/PBM/PAM.
  • The library is (more or less) not specific to a particular file format.
  • Full support for high color depth (16 bits per sample).
  • Some options can be set differently for the different dimensions (horizontal vs. vertical) or color channels (red, green, blue).
  • Has several options to enable "hacks" to make it behave differently. This can be useful if you're trying to make it behave the same as another application.
  • The package includes a simple regression testing script. The script requires a Unix-ish environment.
  • Intended to be compatible with Windows, Linux, and Cygwin. Includes project files for Visual Studio 2019.

The ImageWorsener C library

Unfortunately, there is no documentation for the library, aside from the comments in the imagew.h header file. The original idea was to have a well- designed, stable, and documented library, but that hasn't worked out very well. The API won't be broken for no reason, but I can't make promises about compatibility between versions.

Documentation for the "imagew" command line utility

Synopsis imagew [options] <input-file> <output-file>

Options may appear anywhere on the command line, even after the file names. The order of the options usually does not matter.

<input-file> and <output-file> can be prefixed with a "scheme" and a colon, so that resources other than regular files can be supported. If your filename may contain a colon, prefix it with "file:". In the Windows version, you can use "clip:" to refer to the clipboard.

A scheme of "stdin:" or "stdout:" means the standard input or output stream (this may not be supported for all formats). As a shortcut, a file name of "-" may be used instead.

Numbers on the command line may be specified as rational numbers, using a slash. For example, instead of "-w x0.666666666", you can use "-w x2/3".

Options:

-w <width> -h <height> (or -width <width> -height <height>) -s <width>,<height> -S <width>,<height> The width and height of the output image. <width> or <height> is normally a number of pixels.

Using the -s option, or specifying only one of the width or height, will cause the "bestfit" feature to be enabled. Using the -S option, or specifying both the height and width, will cause "bestfit" to be disabled, so the image will have the exact size you request.

If you use a prefix of "x", for example "-w x1.5", then the new size will instead be that number multiplied by the size of the source image.

-bestfit -nobestfit Explicitly enable or disable the "bestfit" feature. If enabled, the image's shape will not be changed.

-noresize Ensures that the image will not be resized at all. This is only useful if the source image may have non-square pixels. Incompatible with -bestfit and the sizing options.

-imagesize <width>,<height> The other sizing options set the size of the entire output image. Normally, the region of that image corresponding to the input image will be that same size. However, you can use -imagesize to make that region be a different size. For example, you can shrink the image, to effectively add a border around it. Note that <height> and <width> do not have to be integers. If you use -imagesize, you should probably also use -translate and "-edge t".

-infmt <fmt> -outfmt <fmt> Specifies the image file format of the input or output file. If not used, imagew will try to figure out the format based on the contents of the file, or the file name.

Valid values for <fmt>: png: PNG jpeg, jpg: JPEG webp: WebP bmp: Windows BMP gif: GIF (-infmt only) tiff, tif: TIFF (-outfmt only) miff: MIFF (experimental; limited support) pnm, ppm, pgm, pbm: Netpbm formats (only the binary formats are supported, not the rare "plain"/ASCII variants)

-depth <n> (-depthgray, -depthalpha) -depth <r>,<g>,<b>[,<a>] -depthcc <cc> The general number of bits of precision used per color channel in the output image. Valid values for <n>: "8" is the default for most formats. "16" is supported for PNG and TIFF formats. "32" is used with MIFF format (floating point). Other depths are supported in some special cases. Use with caution -- this can be useful, but it may not do what you expect, and may disable optimizations. Consider whether you should use -cc instead. With BMP format, requesting an unusual depth will cause a 16 bits/pixel image to be written if the total number of bits is no more than 16, or a 32 bits/pixel image otherwise. The total number of bits may not be more than 32, and no channel may have more than 16 bits. Depths "5,6,5" and "5,5,5" are the most common and most portable. PNG format supports arbitrary depths (from 1 to 16), using "sBIT" chunks, but these are ignored by most image viewers. The PPM and PGM formats support any bit depth from 1 to 16. If you use a depth less than 8, consider using -dither.

Within the overall depth, you can reduce the number of colors that will actually be used, by using the "-cc" options. Note that this doesn't necessarily determine the depth used in the output file. If the image can be encoded at a smaller depth with no loss of information, IW may choose to do that (see also -noopt).

The -depthcc option sets the depth based on the number of color levels, instead of the number of bits used to represent a color level. For example, "-depthcc 32" is equivalent to "-depth 5". This allows for greater flexibility, if the output format supports it. Currently, it's only useful with PPM, PGM, and PAM formats.

-sampletype <type> Request that the output samples be written as unsigned integers (type="u"), or floating-point (type="f"). This option currently has no effect.

-filter <name> (-filterx -filtery) The resizing algorithm to use. (It would be more accurate if this option were named "-resizealgorithm", but that's too hard to type.) Default is "auto".

With -filterx and -filtery, you can use different algorithms for the horizontal and vertical dimensions. (This is possible because IW supports only "separable" resizing algorithms.) This may occasionally be useful for something, such as if you need to enlarge an image in one dimension while reducing it in the other.

IW uses the filter even if the image size isn't being changed. Many filters will leave the i

Related Skills

View on GitHub
GitHub Stars279
CategoryDevelopment
Updated12d ago
Forks31

Languages

C

Security Score

80/100

Audited on Mar 18, 2026

No findings