Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A guided AVIF/JPEG XL/WebP conversion utility for JPEG and PNG sources.

License

NotificationsYou must be signed in to change notification settings

Blobfolio/refract

Repository files navigation

cideps.rs
licensecontributions welcome

Refract is a cross-platform* guided image conversion tool.

It takesJPEG andPNG image sources and producesAVIF,JPEG XL, andWebP copies.

A tour of the program in action.

The program is named for and works something like an optometrist's refraction test, presenting a series of feedback-driven candidate images — what looks better, this… or this? This… or this? — until the subjective "best" option is found (or found to be impossible).

Hence "guided".

The beauty of this sort of approach is it moots the need for exhaustive testing.

Every Yay and Nay you provide halve the number of possibilities remaining to be tested. The ideal copy, whatever and wherever it might be, can be found in a handful of steps instead of a hundred.

Why?

Every image is different.

There is no such thing as a one-size-fits-all quality setting, or even a one-size-fits-all image format.

Whether you're looking for perfect copies or merely passable ones, the only way to be sure you're not producing over- or under-compressed images is touse your eyes.

Done manually, you'd need to use a lot more — your brain, for starters — but thankfully most of the rest of the processcan be automated.

That's where refract comes in.

It keeps track of the details so you don't have to.

Features

FormatDecoding (Input/Display)Encoding (Output)
JPEGYes, except CMYK and 16-bit lossless.
PNGYes
AVIFYesLossless, lossy,RGB, andYCbCr
JPEG XLYes*Lossless, lossy.
WebPYes*Lossless, lossy.

In short, Refract takes JPEG and PNG sources — either individual files or entire directory trees — and turns them into AVIF, JPEG XL, and/or WebP outputs.

Refract implementslibavif,libjxl, andlibwebp directly. This not only ensures full standards compliance and feature/performance parity with each format's official conversion tools —avifenc,cjxl, andcwebp respectively — it also means you don't need any of that crap separately installed to use it.

All conversion takes place at Pixel Level and is intended for displays with an sRGB color space (e.g. web browsers). Gamma correction, color profiles, and other metadata are ignored and stripped out when saving next-gen copies.

All conversions are performed using the maximum/slowest (general) encoder settings, ensuring the smallest possible output. Refract also explicitly tracks the input and output file sizes to save you having to review counter-productive combinations.

Usage

Refract is pretty straightforward:

  1. Open the program;
  2. Choose the output format(s) and tweak any other settings you want;
  3. Choose one or more JPEG/PNG source files to crunch;
  4. Sit back and wait for the feedback prompts;

Feedback

Lossless conversions require no human supervision. Being lossless, all that really matters is that shit gets smaller, and refract can figurethat out on its own. ;)

Lossy conversions are another matter since, by their very nature, information is lost in translation.

For those, refract will present a series of "candidate" images to you, one at a time, in a simple A/B fashion for easy comparison with the original sources.

The "feedback" comes in the form of two buttons — "reject" and "accept" — which can be thought of as answers to the question: Are you happy with this copy?

If it looks like what you want it to, great!, accept it. If not, reject it. Refract will raise or lower the quality of the next candidate accordingly.

Rinse and repeat.

The smallest of the accepted candidates, if any, will be saved to disk at the end of the process, the rest forgotten like a passing dream.

Then it's back around again for the next input/output pair!

Pro Tip

JPEG and PNG are actually quitegood and, properly encoded, can providebetter compression than some — or all — of the possible next-gen alternatives.

(This is especially true for lossless conversions; a well-optimized PNG isnot something you'd want to meet in a dark alley!)

For best — or at least more honest — results, take some time to optimize your sources with a tool likeflacabefore feeding them to refract.

Two things are twice as many things as one thing,[citation needed] but being the obsessive person you are — normal people wouldn't be doingeither — you'll sleep better knowing no bytes have gone unsaved.

CLI Usage

Refract is a graphical program, but the startup settings and/or queue can be configured via command line if desired.

refract [FLAGS] [OPTIONS]<PATH(S)>...
FlagDescription
-h /--helpPrint help information and exit.
-V /--versionPrint version information and exit.
--no-avifSkip AVIF encoding.
--no-jxlSkip JPEG-XL encoding.
--no-webpSkip WebP Encoding.
--no-losslessSkip lossless encoding passes.
--no-lossySkip lossy encoding passes.
--no-ycbcrSkip AVIF YCbCr encoding passes.
--save-autoAutomatically save successful conversions to their source paths — with new extensions appended — instead of popping a file dialogue for confirmation.
OptionDescription
-l /--listRead (absolute) image and/or directory paths from this text file, one path per line. Set to "-" to read from STDIN. This is equivalent to specifying the same paths as trailing arguments, but can be cleaner if there are lots of them.

Installation

Pre-built packages for x86-64 CPU architectures are available for Debian and Ubuntu users on therelease page, and to Arch Linux users viaAUR.

To use refract in other environments, it'll needs to be built from source.

Thankfully,Rust/Cargo make this pretty easy:

# Install the build dependencies. Ubuntu and Debian users, for example,# can run:sudo apt-get install -y cmake g++ gcc git make nasm ninja-build# Build and install refract:cargo install \    --git https://github.com/Blobfolio/refract.git \    --bin refract

Build Dependencies

The extra build dependencies (required by all the damn image codecs) will vary by environment, but at a minimum you'll need up-to-date C and C++ compilers,cmake,git (obviously),make,nasm, andninja-build.

Cargo should pop an error if anything's missing. If that happens, just find/install the missing dep and givecargo install another shot.

If you wind up needing something not on this list, pleaseopen an issue so it can be given a mention. ;)

Runtime Dependencies

On Linux, the file dialogues require one ofxdg-desktop-portal-[gnome, gtk, kde] orzenity, user's choice.

In theory,None of the Above should work too, provided you use the CLI to enqueue image paths and enable automatic saving with the--save-auto flag (along with any other settings tweaks you might want):

refract --save-auto /path/to/image.jpg

About

A guided AVIF/JPEG XL/WebP conversion utility for JPEG and PNG sources.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

[8]ページ先頭

©2009-2025 Movatter.jp