Skip to content

phao/imgsplit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OVERALL
=======
imgsplit is a program to split a region of an image into several smaller
images as if this region "was cut by a slicing grid".

For example, `imgsplit -s 100,50 -w 128 -h 64 -r 5 -c 6 -p tree_ trees.png`
will take the image in trees.png and generate 5*6=30 output images, each
containing 128x64 pixels. The input regions that get assigned to each output
image is what you'd expect, starting at (left=100,top=50) you have regions
of 128x64 pixels offset according to the grid cell dimensions and their
specific (column,row) position in the grid. Each image is placed into its own
output file.

Each image file then will have the format PREFIX_ROW_COLUMN.png, for example
tree_1_3.png.

SMALL REFERENCE
===============
Usage:

  imgsplit [-s start_pos]
           -w cell_width
           -h cell_hight
           -r rows_count
           -c columns_count
           [-p output_images_prefix]
           [-1]
           [-2]
           [--]
           input_file

If you don't specify a prefix, the name of the file without the extension will
be used. If the input file doesn't have an extension, its name as a whole will
be the prefix.

If you don't specify a start position, '0,0' will be used.

To specify the start position, you should give an unsigned integer number
followed by another unsigned integer number having only a comma in between
them. Specifically, no spaces are allowed in between the numbers, and they
also should be placed in the same command line argument. For example,
syntactically valid ones include: "400,12", "1,1", "0,0".

If you don't specify the cell width, cell height, rows count, or columns
count, they will be computed for you if possible based on other provided
values. For example, if rows isn't provided but cell height (H) is, then the
number of rows is computed to be the maximum number of rows possible, which is
(IMG_HEIGHT-START_Y) div H, where 'div' is the integer division operator (i.e.
the maximum number of rows that would still have the grid inside the input
image). Similar calculations happen for when you don't specify other values.
If you don't specify rows, but you also don't specify cell height, then
imgsplit will issue an error.

The -1 option tells imgsplit to output file names with suffixes that are
sequences of numbers from 0 to rows*columns-1. So, your output files will
be PREFIX_N.png where N equals r*C+c where r is its row number, C is how
many columns per row in the grid there are, and c is its column number. This
is to make the numbering scheme for the output one-dimensional.

The -2 option tells imgsplit to output each image having the suffix as
in the example above (in the OVERALL description). It's the default behavior.
It's only useful to override a "previously set -1" (e.g. if you're generating
the command string via another program by computation). If you specify -2
(or if you don't specify -2 but also don't specify -1), output images file
names will have a _r_c.png suffix where r is their row number and c is their
column number.

PROGRAM DEPENDENCIES
====================
This program depends on the SDL2 and SDL2_image libraries.

The build system (make files) is only required to work with gnu make.

It uses the C (C99) language.

C API
=====
It should be easy for someone to take the ImgSplit.h and ImgSplit.c files and
drop them into his/her own project.

The C API is simple, but it's specified in its own file. Check the C_API file.

BUGS AND OTHER PROBLEMS
=======================
Please notify me if you find problems with the code or the documentation for
this project.

About

An image (grid) splitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published