upscale

package module
v0.0.0-...-a536650 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 8 Imported by: 0

README

AW-UPSCALE

A small library to wrap arbitrary executable upscalers for images, such as waifu2x.

Requirements

There are no requirements in general, but using the default implementation has several:

  • Python 3
  • Either:
    • ImageMagick (6 or 7) executables on your PATH.
    • gdk-pixbuf2 and PyGObject
      • Additionally, any pixbuf loaders for formats you plan to handle, like webp-pixbuf-loader.
  • waifu2x-ncnn-vulkan

Python 3 and waifu2x-ncnn-vulkan must be present on the PATH of the system running the library.

gdk-pixbuf2 will be preferred over ImageMagick when available.

When installing waifu2x-ncnn-vulkan, make sure that the directory containing the waifu2x-ncnn-vulkan binary also contains the models-cunet directory. Extracting the Windows binary release zip files already places the binary and models into the same directory, they just need to be added to your PATH.

Try running one of these lines to see if everything is working. If everything is set up correctly no errors will be printed and the last line output will similar to rose.png PNG 280x184 280x184+0+0 8-bit sRGB 88401B 0.000u 0:00.000.

ImageMagick 6:

convert rose: rose.bmp; identify rose.bmp; UPSCALE_SOURCE=rose.bmp UPSCALE_DESTINATION=rose.png UPSCALE_SCALING_FACTOR=4 python waifu2x-upscale.py; identify rose.png; rm rose.bmp; rm rose.png

ImageMagick 7:

magick convert rose: rose.bmp; magick identify rose.bmp; UPSCALE_SOURCE=rose.bmp UPSCALE_DESTINATION=rose.png UPSCALE_SCALING_FACTOR=4 python waifu2x-upscale.py; magick identify rose.png; rm rose.bmp; rm rose.png

Alternative Upscalers

An upscaler is just an executable which is provided with a set of environment variables. See waifu2x-upscale.py to modify it or create your own.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Upscaler

type Upscaler struct {
	// contains filtered or unexported fields
}

Upscaler wraps an external executable that can upscale images. It can be reused multiple times with the same parameters.

func New

func New(executable string) *Upscaler

New returns a new upscaler that will use the provided executable. If the provided executable is empty, it will use the default embedded python script.

func (*Upscaler) Process

func (u *Upscaler) Process(source, destination string) error

Process will apply the configured operations to the source image and create the destination image.

func (*Upscaler) SetDenoise

func (u *Upscaler) SetDenoise(denoise bool) *Upscaler

SetDenoise sets whether denoising is to be done on the image. It's possible that a particular upscaler may not support this.

func (*Upscaler) SetMinRes

func (u *Upscaler) SetMinRes(width, height int) *Upscaler

SetMinRes specifies the resolution to target using the "fill container" strategy. After scaling the image's width AND height will BOTH be at least the width or height specified. If either width or height is zero, they will be ignored. This unsets the scale setting.

func (*Upscaler) SetScale

func (u *Upscaler) SetScale(scale int) *Upscaler

SetScale sets the multiplication factor that will be applied to all the dimensions of the image. This unsets the target resolution.

func (*Upscaler) SetTargetRes

func (u *Upscaler) SetTargetRes(width, height int) *Upscaler

SetTargetRes specifies the resolution to target using the "fit to container" strategy. After scaling the image's width OR height will be at least the width or height specified. If either width or height is zero, they will be ignored. This unsets the scale setting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL