The Conley-Morse Graphs Software
Functions | Variables
pngsmall.cpp File Reference

This is a small utility program which decreases in size a PNG file (if necessary) in order to make it fit within the given size. More...

#include <exception>
#include <cstring>
#include <cstdio>
#include "chomp/system/config.h"
#include "chomp/system/textfile.h"
#include "chomp/system/timeused.h"
#include "chomp/system/arg.h"
#include "pngimage.h"

Go to the source code of this file.

Functions

int pngSmall (const char *inName, const char *outName, int maxWidth, int maxHeight, int scalingFactor)
 The main function of the program "pngsmall". More...
 
int main (int argc, char *argv[])
 The main procedure of the program. More...
 

Variables

const char * title
 The title of the program which is displayed every time the program is launched. More...
 
const char * helpinfo
 The help information about the program which is displayed if the program is launched without command-line arguments or with incorrect arguments. More...
 

Detailed Description

This is a small utility program which decreases in size a PNG file (if necessary) in order to make it fit within the given size.

Author
Pawel Pilarczyk

Definition in file pngsmall.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

The main procedure of the program.

Returns: 0 = Ok, -1 = Error, 1 = Help displayed, 2 = Wrong arguments.

Definition at line 210 of file pngsmall.cpp.

References helpinfo, pngSmall(), and title.

◆ pngSmall()

int pngSmall ( const char *  inName,
const char *  outName,
int  maxWidth,
int  maxHeight,
int  scalingFactor 
)

The main function of the program "pngsmall".

This function downscales the given PNG image and saves the result as another PNG image. The scaling factor is determined on the basis of the provided maximal allowed width and/or height of the image, unless specified explicitly. Returns 0, or throws an error message in case of failure.

Definition at line 87 of file pngsmall.cpp.

Referenced by main().

Variable Documentation

◆ helpinfo

const char* helpinfo
Initial value:
= "\
This program reads a given PNG image and writes another PNG image\n\
which is the original one scaled down so that the provided width\n\
and height are not exceeded. The down-scaling factors are limited\n\
to the integer numbers for optimal efficiency. The colors of output\n\
pixels are computed by means of an arithmetic average of the input ones.\n\
Command line arguments:\n\
input.png - the name of the input PNG image file to be down-scaled,\n\
output.png - the name of the output PNG file (rewrites the input if none),\n\
-w width - the maximal allowed width of the output PNG image,\n\
-h height - the maximal allowed height of the output PNG image,\n\
-s scaling - the downscaling factor (overrides max width/height settings),\n\
--quiet - makes the program run quietly, without any output messages,\n\
--help - shows this brief help information on the program's usage.\n\
For more information consult the accompanying documentation (if available)\n\
or ask the program's author at http://www.PawelPilarczyk.com/."

The help information about the program which is displayed if the program is launched without command-line arguments or with incorrect arguments.

Definition at line 59 of file pngsmall.cpp.

Referenced by main().

◆ title

const char* title
Initial value:
= "\
PNGSMALL, ver. 0.01, 04/10/08. Copyright (C) 1997-2014 by Pawel Pilarczyk.\n\
This is free software. No warranty. Consult 'license.txt' for details."

The title of the program which is displayed every time the program is launched.

Definition at line 52 of file pngsmall.cpp.

Referenced by main().