Skip to content
/ pittari Public

Determine the original resolution of scaled screenshots of retro video games, and resize them right.

Notifications You must be signed in to change notification settings

obskyr/pittari

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pittari Pixels

Have you ever taken a screenshot in an emulator that just wasn't scaled right? The infamous non-integer nearest-neighbor scale. Wonky pixels of different sizes; mamma mia. Pittari Pixels takes such screenshots and figures out the original resolution for you, so that you can resize them to your heart's content.

Before Pittari Pixels

     

After Pittari Pixels

     
 

1:1 square pixels are usually not correct for retro systems – for display purposes, these screenshots should be scaled up to a new size afterwards. See the section on resizing for more information.

Installation

  1. Obtain the program!
  2. Extract the files to their own folder, wherever you'd like.
  3. On Windows, you may want to add said folder to your PATH. This will both allow you to run the program from anywhere, and to copy the EXE (without its accompanying DLLs) to anywhere you'd like.

Usage

To determine the original resolution of a screenshot, simply pass it as an argument:

$ pittari spelunker-arcade.png 
Original resolution: 384 x 256
Scale:               2.67188 x 3
Pixel aspect ratio:  0.890625

Screenshots with horizontal or vertical bands of solid colors may thwart the resolution detection. To make the result more likely to be accurate, you can supply multiple screenshots (as long as they were all originally scaled up in the same way):

$ pittari screenshot-1.png screenshot-2.png multiple-screenshots-in-one.gif
Original resolution: 256 x 224
Scale:               2.85547 x 2.5
Pixel aspect ratio:  1.14219

The option --print (-p) lets you print a single attribute for programmatic parsing – resolution (or r), scale (or s), or pixel aspect ratio (or par).

$ pittari screenshot.png -p r # Original resolution
256x240

$ pittari screenshot.png -p s # Scale
3.42969x3

$ pittari screenshot.png -p par # Pixel aspect ratio
1.14323

There is also --custom (-c) for entirely custom print formats, as well as further options for the resolution determination algorithm itself – see pittari --help!

Resizing screenshots

To resize your wonkily scaled screenshots back to 1:1 square pixels, you can use ImageMagick (because most GUI graphics editors do nearest-neighbor scaling wrong). The relevant command is magick convert, and make sure to supply -filter point (for nearest-neighbor scaling) and to add an exclamation mark after your desired dimensions (to turn off aspect ratio correction). If pittari gave you 256x224 as the resolution, for example:

magick convert input.png -filter point -resize 256x224! output.png

To scale up an image, make sure to scale it down first – that way, you're actually scaling up the 1:1 image. For example, to take a wonkily scaled SNES screenshot and scale it to 3× at the SNES's native aspect ratio, you can do:

# For the width: 256 * 3 * 8⁄7 (an NTSC SNES's pixel aspect ratio) ≈ 878
# For the height: 224 × 3 = 672
magick convert input.png -filter point -resize 256x224! -resize 878x672! output.png

Until the advent of liquid crystal displays, most systems did not have square pixels – they may be a bit wider than they are tall, or a bit taller than they are wide. This is called the “pixel aspect ratio”, and is separate from its display aspect ratio (what you'd usually just call the “aspect ratio”). This is crucial to making emulated video (and thus screenshots) look correct, so yours truly heartily recommends taking it into account. It's as simple as multiplying the width of the image by a certain number while leaving the height untouched! Pixel aspect ratios for various systems can be found here (see the “PAR” column).

Limitations

  • Only screenshots that have been scaled up – not scaled down – are supported.
  • Only screenshots that have been scaled up with nearest-neighbor scaling are supported – bilinear is not implemented. (Do let me know if that's something you could use!)
    • However, images that are almost scaled up with nearest-neighbor scaling and have pixels that ever so slightly vary are supported using the --inexact flag. For example, screenshots of PS1 games on PS Vita (e.g. tests/254x231 fuzzy.png).

How to build

On Windows

  1. Install MSYS2.

  2. In the “MSYS2 MinGW x64” shell (C:\msys64\mingw64.exe, assuming MSYS2 was installed into the default location), run the following commands:

    # Update and upgrade all packages, if you haven't already.
    pacman -Syuu
    
    # Dependencies…
    pacman -S mingw-w64-x86_64-gcc
    pacman -S mingw-w64-x86_64-pkg-config
    pacman -S mingw-w64-x86_64-zlib
    pacman -S mingw-w64-x86_64-imagemagick
    pacman -S mingw-w64-x86_64-meson
    
    # Clone the necessary repositories…
    git clone https://github.com/obskyr/pittari.git
    cd pittari
    git clone https://github.com/argp-standalone/argp-standalone.git
    
    # Build!
    make
  3. And presto! The program is now at build/pittari.exe. If moving this elsewhere, make sure to copy the rest of the contents of the build/ directory as well, or to add the directory to your PATH. This is required for pittari.exe to be able to find its DLLs.

On Linux

  1. Run the following commands:
    # Update your package lists, if you haven't already.
    sudo apt update
    
    # Dependencies…
    sudo apt install libmagickwand-dev
    
    # Clone the repository…
    git clone https://github.com/obskyr/pittari.git
    cd pittari
    
    # Build!
    make
  2. And presto! The program is now at build/pittari.

About

Determine the original resolution of scaled screenshots of retro video games, and resize them right.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published