Meziantou.Prebuilt 3.17.3

Prefix Reserved
dotnet add package Meziantou.Prebuilt --version 3.17.3
                    
NuGet\Install-Package Meziantou.Prebuilt -Version 3.17.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Prebuilt" Version="3.17.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Prebuilt" Version="3.17.3" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Prebuilt" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Prebuilt --version 3.17.3
                    
#r "nuget: Meziantou.Prebuilt, 3.17.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Prebuilt@3.17.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Prebuilt&version=3.17.3
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Prebuilt&version=3.17.3
                    
Install as a Cake Tool

Meziantou.Prebuilt

Lists the tools published by meziantou/prebuilt and downloads them to a local cache.

The package version is the GitHub release version: Meziantou.Prebuilt 3.0.0 downloads the files of the 3.0.0 release. The size and SHA-256 of every file is embedded in the package and checked after each download.

using Meziantou.Prebuilt;

// Download ffmpeg for the current OS/architecture (or reuse the cached copy) and get its full path
string ffmpeg = await PrebuiltTools.Ffmpeg.GetOrDownloadAsync();

// List the tools, their version and checksum
foreach (var tool in PrebuiltTools.All)
{
    foreach (var asset in tool.Assets)
    {
        Console.WriteLine($"{tool.Name} {tool.Version} {asset.RuntimeIdentifier} {asset.Sha256} {asset.DownloadUrl}");
    }
}

// Use another cache folder or HttpClient, or another runtime identifier
var cache = new PrebuiltToolCache(cacheDirectory: "/tmp/tools", httpClient: myHttpClient);
string cwebp = await cache.GetOrDownloadAsync(PrebuiltTools.Cwebp, runtimeIdentifier: "linux-arm64");

Tools: Zopfli, Oxipng, Pngout, Pngquant, MozjpegCjpeg, MozjpegJpegtran, Ffmpeg, Ffprobe, X265, Kvazaar, Cwebp, Dwebp, Webpmux, WebpAnimDump, Avifenc, Avifdec, Cjxl, Djxl, Jxlinfo, JxlFromTree, Ssimulacra2, Butteraugli, JxlOxide, HbShape, HbInfo, HbSubset, HbVector, HbRaster, Woff2Compress, Woff2Decompress, Woff2Info, OpjCompress, OpjDecompress, OpjDump, OjphCompress, OjphExpand, ExrHeader, ExrInfo, ExrMakeTiled, ExrMetrics, ExrStdAttr, ExrCheck, ExrMultiPart, ExrMultiView, ExrEnvMap, ExrMakePreview, ExrManifest, Exr2Aces, ExrFromRaw, ExrToRaw, IsoJpeg, Pvalue, RadianceGetInfo, Pflip, Protate, RaXyze, RaRgbe, RaPpm, RaBmp, Magick, PsdTools, Astcenc, Basisu, Ktx, Toktx, Ktx2Check, DcrawEmu, RawIdentify, UnprocessedRaw, HmScmEncoder, HmScmDecoder, Texconv, Texdiag, Texassemble, IccFromXml, IccToXml, IccFromJson, IccToJson, IccDumpProfile, IccRoundTrip, IccApplyNamedCmm, IccApplyToLink, OpenCvOracle, OiioTool, Iinfo, DngValidate, Dec265, HeifEnc, HeifDec, HeifInfo, HmEncoder, HmDecoder, Qpdf, Mutool, Pdftoppm, Pdftotext, Pdffonts, Pdfinfo, Pdfsig, ArlingtonTestGrammar, VeraPdf, PdfiumTest, Zint, ZXingReader, ZBarImg, SevenZip, Unrar. Not every tool is available for every runtime identifier; use tool.IsSupported() or tool.Assets to check.

On win-arm64, a tool that is not built for Arm64 (e.g. pngout) falls back to its win-x64 build, which Windows on Arm runs through emulation. Pass allowEmulation: false to GetAsset, IsSupported or GetOrDownloadAsync to only get native builds:

string pngout = await PrebuiltTools.Pngout.GetOrDownloadAsync(allowEmulation: false); // throws PlatformNotSupportedException on win-arm64

IsoJpeg

PrebuiltTools.IsoJpeg is the jpeg command-line tool of thorfdbg/libjpeg, the ISO JPEG reference codec: a JPEG encoder and decoder that shares no code with libjpeg-turbo, with arithmetic coding, 12-bit samples, and the progressive and hierarchical processes. It is published as iso-jpeg, as jpeg says too little: the cached file is iso-jpeg (iso-jpeg.exe on Windows).

  • Its version is the last release of the README.history file of libjpeg followed by the commit it is built from (1.72+702114c): libjpeg has no release tag, and the tool prints no version.
  • libjpeg is available under the GNU General Public License, version 3 or later, or under the ITU software license, which covers evaluation and conformance testing. See README.license.gpl and README.license.itu.
  • It exits with 0 when a conversion fails: it prints the error and leaves an empty output file, or does not touch it, so a file that was there before the conversion can still be there. Delete the output file first, and check it afterwards, not the exit code:
string isoJpeg = await PrebuiltTools.IsoJpeg.GetOrDownloadAsync();

// iso-jpeg -q 85 -a input.ppm output.jpg encodes with arithmetic coding; iso-jpeg input.jpg output.ppm decodes
File.Delete("output.jpg");
using var process = Process.Start(isoJpeg, ["-q", "85", "-a", "input.ppm", "output.jpg"]);
await process.WaitForExitAsync();
if (process.ExitCode != 0 || !File.Exists("output.jpg") || new FileInfo("output.jpg").Length == 0)
{
    throw new InvalidOperationException("iso-jpeg failed");
}

Radiance

Pvalue, RadianceGetInfo (getinfo), Pflip, Protate, RaXyze (ra_xyze), RaRgbe (ra_rgbe), RaPpm (ra_ppm) and RaBmp (ra_bmp) are the picture tools of Radiance, built from the sources of a release, without the renderer, X11 and libtiff (no ra_tiff). They read and write Radiance pictures (.hdr): RGBE or XYZE pixels, with a text header and a resolution string.

  • Their version is the one of Radiance followed by the release tag, the first 8 digits of its commit (6.1a+5b2a2154): the tools print no version.
  • Radiance is available under the Radiance Software License, Version 2.0, a BSD 3-Clause-style license (License.txt).
  • Scan lines: pvalue -r and ra_rgbe -r write the new-style run-length encoding, and pvalue -r -u, ra_rgbe and ra_xyze (without -c) flat scan lines; a scan line shorter than 17 or longer than 32767 pixels is always flat. Every tool reads the old-style run-length encoding, and none writes it.
  • Values: pvalue -h -H -df dumps the pixels as little-endian floats (-dF: big-endian), in the order of the file, and pvalue -r -h -df -y <height> +x <width> writes a picture from them; a mantissa m with the exponent e is (m + 0.5) * 2^(e - 136), and the exponent 0 is 0. pvalue -o divides the values by the EXPOSURE of the header; for XYZE, -O divides them by 179 lm/W. pvalue -r -pXYZ writes XYZE.
  • Orientation: the order of the -y/+y and +x/-x options of pvalue -r is the resolution string it writes (-Y N +X M is the usual top to bottom, left to right; +X M -Y N has the columns first), and pvalue +di gives the image coordinates of each pixel (y is 0 at the bottom). Without -c, pflip and protate change the order of the scan lines and the resolution string, and the image stays the same; with -c, they flip or rotate the image.
string pvalue = await PrebuiltTools.Pvalue.GetOrDownloadAsync();

// The pixels of a picture as little-endian floats, R G B for each pixel in the order of the file:
// pvalue -h -H -df input.hdr > pixels.f32
// A run-length encoded picture of 3 x 2 pixels from them, top to bottom:
// pvalue -r -h -df -y 2 +x 3 pixels.f32 > output.hdr

PSD

Magick (magick, ImageMagick 7, Q16 HDRI) and PsdTools (psd-tools, the psd-tools Python library) read and write PSD and PSB files, and share no code: each one reads what the other writes. magick is built with zlib, LittleCMS 2, libpng and libtiff only, to read the source images (PNG, TIFF, PNM, BMP, raw samples). psd-tools is an archive with a Python runtime: the Linux runtimes need glibc 2.28.

  • magick writes RGB, CMYK, grayscale, indexed (-type Palette) and bitmap (-type Bilevel -depth 1) files, with 8 or 16 bits (a depth above 16 is written with 16 bits), raw or RLE (-compress RLE) samples, the image as the composite and as a layer (-define psd:write-layers=false: the composite only), the images after the first as layers (-repage offsets, -set label names), alpha, an ICC profile (-profile) and PSB (PSB:out.psb). Write with -endian MSB after the input images: ImageMagick writes the blend mode of a little-endian image (raw input, xc:) backwards. Do not use -compress Zip: its composite is rejected by other readers.
  • magick reads 32-bit files, and raw and RLE composites (not ZIP: it merges the layers instead). Read with -define psd:alpha-unblend=off to get the colors of a composite with alpha as stored: magick -define psd:alpha-unblend=off in.psd[0] -depth 16 -endian LSB rgb:out.raw; in.psd[1] is the first layer, with its opacity applied to its alpha.
  • psd-tools dump [--no-layers] <file> <folder> writes header.json and the samples of the composite (composite.raw) and of each layer (layer-<n>.raw, layer-<n>-mask.raw), and the ICC profile (icc.icc). psd-tools write <header.json> <file> writes a file from such a description: every color mode, 1, 8, 16 and 32 bits, raw, RLE, ZIP and ZIP with prediction, PSB, layers (in the layer info, or in the Lr16 and Lr32 blocks of 16 and 32-bit files, as Photoshop writes them), masks, a palette, an ICC profile, and files without a real composite ("hasComposite": false, "Maximize Compatibility" off; "composite": null writes a white one).
  • The raw files hold the samples of each pixel, row by row, the channels of a pixel in the order of channels: unsigned bytes for 8 bits, unsigned 16-bit little-endian samples for 16, little-endian floats for 32, and one byte per pixel for 1 bit (bitmap), the stored bit: 1 is black. They are the stored samples: CMYK samples are inverted (255 is no ink), indexed ones are indexes into palette.
{
  "version": 1,
  "width": 4, "height": 2, "depth": 8,
  "colorMode": "RGB",
  "channels": 4,
  "compression": "RLE",
  "composite": "composite.raw",
  "hasComposite": true,
  "iccProfile": "icc.icc",
  "palette": null,
  "transparentIndex": null,
  "mergedAlpha": true,
  "layerBlock": "layerInfo",
  "layers": [
    {
      "name": "Layer 1", "top": 0, "left": 1, "bottom": 2, "right": 3,
      "opacity": 255, "visible": true, "blendMode": "norm", "clipping": 0,
      "channels": [0, 1, 2, -1], "compression": "RLE", "file": "layer-0.raw",
      "mask": { "top": 0, "left": 1, "bottom": 1, "right": 3, "defaultColor": 0, "compression": "RAW", "file": "layer-0-mask.raw" }
    }
  ]
}

version is 1 for PSD and 2 for PSB; colorMode is BITMAP, GRAYSCALE, INDEXED, RGB, CMYK, MULTICHANNEL, DUOTONE or LAB; compression is RAW, RLE, ZIP or ZIP_WITH_PREDICTION, for the composite, and for the channels of a layer (one for every channel, or a list); hasComposite is the version info resource (null when there is none); mergedAlpha is a negative layer count: the first extra channel of the composite is its transparency; the layers are from the bottom one up, the channel -1 is the transparency, and layerBlock is where they are: layerInfo, Lr16 or Lr32. The other sections of a file are not described, and write writes none of them.

string psdTools = await PrebuiltTools.PsdTools.GetOrDownloadAsync();

// The description and samples of a file:
// psd-tools dump input.psd output-folder
// A 32-bit file from them:
// psd-tools write output-folder/header.json output.psd

OpenEXR

ExrHeader, ExrInfo, ExrMakeTiled, ExrMetrics, ExrStdAttr, ExrCheck, ExrMultiPart, ExrMultiView, ExrEnvMap, ExrMakePreview, ExrManifest and Exr2Aces are the utilities of the OpenEXR release, built from its source tarball with the libdeflate, zstd and OpenJPH it comes with, and the Imath it pins. ExrFromRaw (exr-from-raw) and ExrToRaw (exr-to-raw) are two programs of this repository, built with the same OpenEXR: the first writes an EXR file from raw samples and a JSON description of its header, the second dumps the header of an EXR file as JSON and its decoded samples as raw files, bit for bit. The JSON that exr-to-raw writes is a description exr-from-raw reads, and exr-from-raw writes the same file again from it.

string fromRaw = await PrebuiltTools.ExrFromRaw.GetOrDownloadAsync();
string toRaw = await PrebuiltTools.ExrToRaw.GetOrDownloadAsync();

// r.raw has the 64 x 32 HALF samples of the R channel, little-endian, row by row
File.WriteAllText("image.json", """
    {"dataWindow": [0, 0, 63, 31], "compression": "PIZ",
     "channels": [{"name": "R", "pixelType": "HALF", "file": "r.raw"}]}
    """);
using (var process = Process.Start(fromRaw, ["image.json", "image.exr"]))
{
    await process.WaitForExitAsync();
}

// dump/header.json describes the header, dump/part0.channel0.raw has the decoded samples of R
using (var process = Process.Start(toRaw, ["image.exr", "dump"]))
{
    await process.WaitForExitAsync();
}

Samples

A sample file has the samples of one channel, in the pixel type of the channel, without any conversion, little-endian: HALF is 2 bytes (the bits of the half), FLOAT 4 bytes (the bits of the float, NaN payloads included), UINT 4 bytes.

  • Scan line part: the samples of the data window, row by row from its top (yMin) to its bottom, whatever the line order of the file. A channel with xSampling and ySampling has the samples of the pixels whose x is a multiple of xSampling and whose y is a multiple of ySampling only.
  • Tiled part: the samples of every level, one level after the other, each one as a scan line part of the data window of the level. MIPMAP_LEVELS levels are in order; RIPMAP_LEVELS levels are (0, 0), (1, 0) ... (nx-1, 0), (0, 1) ...
  • Deep part: the sample count file has the number of samples of each pixel, as UINT, in the same order; the file of a channel has the samples of the first pixel, then those of the second pixel...

exr-from-raw

exr-from-raw <description.json> <output.exr> writes output.exr. It exits with 0 when the file is written, 1 when OpenEXR refuses the header or the samples, and 2 when the command line or the description is invalid; it deletes the output file when it fails. The description is an object with parts, an array of parts, or a part itself for a single-part file; a file with more than one part is a multi-part file. A part is an object with:

Member Value
type scanlineimage (default), tiledimage (default when tiles is given), deepscanline or deeptile
name optional; required for every part of a multi-part file
dataWindow [xMin, yMin, xMax, yMax], required
displayWindow [xMin, yMin, xMax, yMax], the data window by default
compression NONE, RLE, ZIPS, ZIP (default), PIZ, PXR24, B44, B44A, DWAA, DWAB, HTJ2K256, HTJ2K32, LJ2K or ZSTD; deep parts accept NONE, RLE, ZIPS and ZSTD only
lineOrder INCREASING_Y (default), DECREASING_Y or RANDOM_Y (tiled parts)
pixelAspectRatio 1 by default
screenWindowCenter [x, y], [0, 0] by default
screenWindowWidth 1 by default
tiles {"xSize", "ySize", "levelMode", "roundingMode"}: levelMode is ONE_LEVEL (default), MIPMAP_LEVELS or RIPMAP_LEVELS, roundingMode ROUND_DOWN (default) or ROUND_UP
zipCompressionLevel, dwaCompressionLevel, zstdCompressionLevel optional settings of the encoder, not stored in the file (OpenEXR uses 4, 45 and 5 by default)
channels [{"name", "pixelType", "xSampling", "ySampling", "pLinear", "file"}]: pixelType is HALF (default), FLOAT or UINT, the sampling 1 by default, pLinear false by default, and file the sample file; without file, the samples are zeros
sampleCounts deep parts: the sample count file; without it, every pixel has no sample
attributes [{"name", "type", "value"}] or [{"name", "type", "data"}]: any other attribute
  • The paths of the sample files are relative to the folder of the description, and their size must be the size the header gives them.
  • An attribute with a value is of a type exr-from-raw knows: box2i and box2f ([xMin, yMin, xMax, yMax]), chromaticities ([redX, redY, greenX, greenY, blueX, blueY, whiteX, whiteY]), compression, lineOrder, envmap (LATLONG, CUBE) and deepImageState (MESSY, SORTED, NON_OVERLAPPING, TIDY) by name, double, float, int, floatvector, keycode ([filmMfcCode, filmType, prefix, count, perfOffset, perfsPerFrame, perfsPerCount]), m33f, m33d, m44f and m44d (the values row by row), preview ({"width", "height", "pixels"}, the RGBA bytes in hexadecimal), rational ([numerator, denominator]), string, stringvector, tiledesc (as tiles), timecode ([timeAndFlags, userData]), v2i, v2f, v2d, v3i, v3f and v3d. A float or double can be "NaN", "Infinity" or "-Infinity". With data, the bytes of the value in hexadecimal, an attribute can be of any type, and its bytes are written as they are, even when they are not a valid value of its type: OpenEXR then refuses to read the file.
  • The members of a part (channels, compression, dataWindow, displayWindow, lineOrder, pixelAspectRatio, screenWindowCenter, screenWindowWidth, tiles, name, type, chunkCount) cannot be attributes.
  • A single-part file is written as OpenEXR's OutputFile, TiledOutputFile, DeepScanLineOutputFile and DeepTiledOutputFile write it, a multi-part file as MultiPartOutputFile does: the type attribute is written for the parts of a multi-part file and for deep parts only. The attributes are sorted by name, as OpenEXR writes them.
  • The tiles of a RANDOM_Y part are written in an order shuffled with a fixed seed, the same on every run and every platform; the tiles of the other parts in the order of their line order.

exr-to-raw

exr-to-raw [--header-only] <input.exr> <output-directory> writes header.json, and, unless --header-only, the sample files: partP.channelC.raw for channel C of part P (C is the index of the channel in channels, which is sorted by name, as in the file) and partP.sampleCounts.raw for a deep part. It exits with 0 when the file is dumped, 1 when OpenEXR cannot read it, and 2 for a usage error. It does not rebuild a damaged offset table, which OpenEXR does by default: such a file is an error.

header.json is the description of exr-from-raw, with these additions, which exr-from-raw ignores:

  • openexr, the OpenEXR version; versionField, the version field of the file, and flags: {"tiled", "longNames", "nonImage", "multiPart"}.
  • In each part: chunkCount when the file has it; levels for a tiled part, the level ([lx, ly]) and the dataWindow of every level, in the order of the sample files; chunkTableOffset, the file offset of the offset table of the part, and chunkTable, its entries as they are in the file (the file offset of each chunk, in the order of the table, not of the chunks in the file).
  • attributes has the attributes of the header that are not members of the part, as they are in the file and in its order, read from the bytes of the file (the OpenEXR APIs report attributes that are not in the file: a type for every single-part file, a version for every part of a file with deep data). Each one has its type, its value when OpenEXR reads it as a value of a known type with the same bytes, and always its data, the bytes of the value in hexadecimal.
  • Floats are written with the shortest decimal that reads back as the same value.

What else to know

  • The decoded samples of the lossy compressions (PXR24 for FLOAT, B44 and B44A for HALF, DWAA, DWAB and LJ2K for the R, G and B channels) are the same on every runtime identifier: OpenEXR is compiled with -ffp-contract=off, so that no multiplication and addition is fused on Arm64 only, and without the x64 SIMD code of OpenEXR and OpenJPH (the SSE2 and AVX DCTs and color conversions of DWAA and DWAB, the SSE to AVX-512 wavelet transforms of LJ2K), which rounds differently from the scalar code Arm64 runs. An OpenEXR library built with that SIMD code can decode samples that differ slightly from these tools on x64. UINT channels, and the channels the DWA and LJ2K compressions do not compress lossily, are lossless.
  • A chunk that a compression does not make smaller is stored uncompressed, lossy compressions included: DWAA leaves random HALF samples as they are, and LJ2K small tiles.
  • exrmetrics --convert -z <compression> -o <output> <input> writes a file again with another compression, and --pixelmode half or --pixelmode float with another pixel type.
  • exrcheck reports some files OpenEXR reads as bad: a file with a BY or RY channel that is not subsampled 2x2, a deep tiled file whose levels do not have as many rows of tiles as columns, and a multi-part file with an image part and a deep part. exrcheck -c, the checks of OpenEXRCore, accepts the last one.
  • exrmultipart -combine leaves the offset tables of the parts it combines filled with zeros (all of them on Linux, all but the first on macOS): OpenEXR rebuilds them when it reads the file, and exr-to-raw refuses it. Write multi-part files with exr-from-raw.
  • OpenEXR and Imath are available under the BSD 3-Clause License, OpenJPH under the BSD 2-Clause License, libdeflate under the MIT License, and zstd under the BSD License.

Barcode tools

Zint writes barcodes and their module matrix, ZXingReader (zxing-cpp) and ZBarImg (ZBar) read them back from image files:

string zint = await PrebuiltTools.Zint.GetOrDownloadAsync();
string reader = await PrebuiltTools.ZXingReader.GetOrDownloadAsync();

// A version 2 QR Code, level M, mask 3: --dump prints its module matrix, -o writes it
using (var process = Process.Start(zint, ["-b", "58", "--vers=2", "--secure=2", "--mask=3", "-d", "Hello, World!", "--scale=4", "-o", "qr.png"]))
{
    await process.WaitForExitAsync();
}

// ZXingReader -1 qr.png prints: qr.png QR Code "Hello, World!"
using (var process = Process.Start(new ProcessStartInfo(reader, ["-1", "qr.png"]) { RedirectStandardOutput = true }))
{
    string result = await process.StandardOutput.ReadToEndAsync();
    await process.WaitForExitAsync();
}
  • zint --dump prints one line per row of modules, in hexadecimal, 4 modules per digit with the first one in the high bit, in groups of 2 digits, the last group with the digits the row needs only: FE 5B F8 is the 21 modules 111111100101101111111.
  • ZXingReader prints the version, error correction level and mask of a QR Code, Micro QR or rMQR symbol, and -symbol the module matrix it sampled. It reports UPC-A as EAN-13 unless -formats UPC-A, and exits with 0 when it cannot load an image.
  • ZBarImg reads EAN/UPC (with -Sean2.enable and -Sean5.enable for the add-ons, reported as separate EAN-2 and EAN-5 symbols), DataBar, Code 128, Code 93, Code 39, Codabar, Interleaved 2 of 5 and QR Code, not Micro QR or rMQR. It reads PNG, BMP, GIF, PCX, PNM and TGA files, and exits with 4 when it finds no barcode. ZBar is available under the GNU Lesser General Public License, version 2.1 or later; its sources are the ZBar release of the version of the tool.

Archive tools

SevenZip (7zz) writes and reads 7z, xz, bzip2, gzip, zip and tar files, and Unrar (unrar) extracts RAR 4 and RAR 5 archives:

string sevenZip = await PrebuiltTools.SevenZip.GetOrDownloadAsync();
string unrar = await PrebuiltTools.Unrar.GetOrDownloadAsync();

// 7zz a -t7z -m0=LZMA2 -mx=9 archive.7z <files>; -p<password> never asks for a password
using (var process = Process.Start(sevenZip, ["a", "-t7z", "-m0=LZMA2", "-mx=9", "-bd", "archive.7z", "file.txt"]))
{
    await process.WaitForExitAsync();
}

// unrar x -o+ -p- archive.rar output/: the trailing separator makes output/ the destination folder
using (var process = Process.Start(unrar, ["x", "-o+", "-p-", "archive.rar", "output/"]))
{
    await process.WaitForExitAsync();
}
  • Neither tool has a version option: run without arguments, 7zz prints 7-Zip (z) 26.06 (x64) : Copyright ... (7-Zip (a) 26.06 (x64) on Windows) and unrar prints UNRAR 7.23 freeware (UNRAR 7.23 x64 freeware on Windows), before their usage. Both exit with 0.
  • On win-x64, SevenZip is 7za.exe, the standalone console 7-Zip of the 7-Zip Extra package: it packs and unpacks 7z, xz, bzip2, gzip, zip and tar, and unpacks lzma, cab and zstd only. It has no RAR codec; use Unrar.
  • Without -p, both tools ask for the password of an encrypted archive on the console: pass -p<password> (or -p- to unrar) so that they fail instead.
  • 7-Zip is available under the GNU Lesser General Public License, version 2.1 or later, with the unRAR license restriction for its RAR code and the BSD 3-Clause and 2-Clause licenses for some code; unrar under the freeware unRAR license. rar, the RAR archiver, is proprietary and not available.

PNG and JPEG compression

Pngquant (pngquant) makes PNG files smaller with a palette of at most 256 colors, and MozjpegCjpeg (mozjpeg-cjpeg) and MozjpegJpegtran (mozjpeg-jpegtran), the cjpeg and jpegtran of mozjpeg, encode and optimize JPEG files:

string pngquant = await PrebuiltTools.Pngquant.GetOrDownloadAsync();
string cjpeg = await PrebuiltTools.MozjpegCjpeg.GetOrDownloadAsync();
string jpegtran = await PrebuiltTools.MozjpegJpegtran.GetOrDownloadAsync();

// pngquant exits with 98 (--skip-if-larger) or 99 (--quality) and writes nothing when the result is not worth it
using (var process = Process.Start(pngquant, ["--quality", "65-80", "--speed", "1", "--strip", "--skip-if-larger", "--force", "--output", "output.png", "input.png"]))
{
    await process.WaitForExitAsync();
    bool converted = process.ExitCode == 0; // 98 or 99: keep input.png
}

// cjpeg reads PNG, PPM, BMP, Targa and JPEG files; it is progressive with optimized scans by default
using (var process = Process.Start(cjpeg, ["-quality", "82", "-outfile", "output.jpg", "input.jpg"]))
{
    await process.WaitForExitAsync();
}

// jpegtran is lossless: it keeps the DCT coefficients and drops the metadata
using (var process = Process.Start(jpegtran, ["-copy", "none", "-optimize", "-progressive", "-outfile", "optimized.jpg", "input.jpg"]))
{
    await process.WaitForExitAsync();
}
  • pngquant --version prints its version (3.0.3). It reads PNG files only, any color type, converts the pixels of a file with an ICC profile to sRGB (LittleCMS), and keeps the alpha channel in a tRNS chunk. It exits with 98 when --skip-if-larger skips a file the conversion does not make small enough (smaller than the input, and much smaller when the quality drops), with 99 when the minimum of --quality cannot be met, with 2 when it cannot read the input and with 25 when the input is not a PNG file; it writes no output file then. Without --force, it does not overwrite an output file (exit code 15).
  • cjpeg reads JPEG files, so a JPEG file does not have to be decoded to PNG first. cjpeg decodes it to pixels and encodes these again, with the options: the output has the quantization tables of -quality, and is a new lossy generation of the image (at a lower quality than the one of the input, the output can even be larger). cjpeg copies the COM and APPn markers of a JPEG input (EXIF, ICC profile, XMP) to the output: run jpegtran -copy none on the result to drop them. The alpha channel of a PNG input is dropped.
  • cjpeg exits with 0 after a warning of its JPEG reader, a truncated or corrupt JPEG input among them, even with -strict, and prints the warning (Premature end of JPEG file) on the standard error. jpegtran exits with 2 after a warning: running jpegtran -copy none on a JPEG input first tells whether it is damaged.
  • -version prints mozjpeg version 4.1.5 (build <date>) on the standard error. Pass -outfile, or redirect the standard output to a file: the tools write binary data to it.
  • pngquant is available under the GNU General Public License, version 3 or later, and so is libimagequant. mozjpeg is available under the IJG License, the Modified (3-clause) BSD License and the zlib License; this software is based in part on the work of the Independent JPEG Group.

Tools with their files

Some tools need more than their executable: VeraPdf comes with a Java runtime, ArlingtonTestGrammar with the TSV files of the Arlington PDF Model, and PdfiumTest with the fonts of the PDFium pixel tests. Their release file is a .tar.gz archive (PrebuiltToolAsset.IsArchive), with the executable at its root. GetOrDownloadAsync extracts it and still returns the path of the executable; the other files are in the same folder:

string testGrammar = await PrebuiltTools.ArlingtonTestGrammar.GetOrDownloadAsync();
string tsv = Path.Combine(Path.GetDirectoryName(testGrammar)!, "tsv", "latest");

// TestGrammar --tsvdir <tsv> --pdf file.pdf: the problems are the "Error:" lines, the exit code is 0
using var process = Process.Start(testGrammar, ["--no-color", "--tsvdir", tsv, "--pdf", "file.pdf"]);
await process.WaitForExitAsync();
  • ArlingtonTestGrammar is built from a commit of the master branch of pdf-association/arlington-pdf-model, whose last release is from 2021: its version is the version of TestGrammar followed by the commit (0.81+d148fee). The archive has the TSV files of every PDF version (tsv/1.0 to tsv/2.0, and tsv/latest).

  • VeraPdf runs veraPDF with the Java runtime of the archive. The Linux runtimes need glibc. veraPDF writes its configuration to a config folder next to the executable the first time it runs, so the cache folder must be writable. It exits with 0 when every file is compliant and with 1 otherwise.

  • PdfiumTest is configured as the PDFium pixel tests are run, so that its rasters can be compared with the PDFium expectations. Its folder has test_fonts/ (third_party/test_fonts) and fonts/ (testing/resources/fonts): the pixel tests run pdfium_test --send-events --png --md5 --time=1399672130 --font-dir=<folder>/test_fonts --croscore-font-names <file>.pdf, or --font-dir=<folder>/fonts/ahem and fonts/symbolneu for the tests whose folder names say use_ahem or use_symbolneu. Its version is the N of the PDFium chromium/N branch it is built from. The Linux builds need glibc and libgcc_s.

Cache

The default cache folder is Meziantou.Prebuilt in the local application data folder (%LOCALAPPDATA% on Windows, ~/.local/share on Linux, ~/Library/Application Support on macOS). Files are stored at:

<cache>/<tool>/<version>-<rid>-<first 16 chars of the SHA-256>/<tool>[.exe]

Versions and builds never collide, and identical files are shared between package versions. A file is downloaded to a temporary file next to its final path, verified, made executable, and then moved into place. An archive is verified, extracted to a temporary folder, and that folder is then moved into place: the executable exists only once every file of the archive does. Concurrent calls for the same file within a process share a single download; concurrent downloads from several processes are also safe.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.17.3 0 11/22/2026
3.17.2 0 11/22/2026
3.17.1 0 11/22/2026
3.16.0 4,310 11/16/2026
3.15.0 946 11/15/2026
3.14.0 1,628 11/14/2026
3.13.1 3,111 11/11/2026
3.13.0 10,915 10/27/2026
3.12.0 548 10/25/2026
3.11.0 706 10/23/2026
3.9.0 109 10/23/2026
3.7.0 3,515 10/14/2026
3.6.0 1,417 10/12/2026
3.5.0 694 10/12/2026
3.4.0 831 10/11/2026
3.3.0 888 10/10/2026
3.2.0 186 10/10/2026
3.1.3 238 10/10/2026
3.1.2 100 10/10/2026
3.1.1 189 10/10/2026
Loading failed