Easily display all SVG files in a single image
That takes a lot to place all the SVG files in one picture.
Measuring how much space they have to take, sorting out how to form a grid from it.
Oh, and if it has to be numerated, file-named, hundreds of SVG's can be a tragedy for your solid patience.
You can use my utility to combine all SVG files in a one PNG image.
For example,
SvgGridImageGenerator.generateSvgGridImage();
will show you this in terminal
Searching for .svg files...
249 files found. They will be shown in a 16x16 grid.
Processing final image (249/249)...
Done! Check for the output file svg_grid_output.png
249 files processed successfully. 0 files skipped.
and create you a file named svg_grid_output.png
in your project directory.
- Clone the project to your IDE (e.g. for IntellJ IDEA: "File" - "New" - "Project from Version Control..." - "URL" - paste
https://github.com/hoteymaks/svg-grid-image-generator.git
in URL field) - Create any folder inside
src/java/
and paste SVG files there, or just paste without creating a folder - Open
SvgGridImageGenerator.java
and adjust utility settings by changing values of static fields, likeMODE
,CELL_WIDTH
,CELL_HEIGHT
, etc. - Run my code
- Wait until the process finishes
- Check the results in the project directory.
svg_grid_output.png
lays in the root directory of your project./
Utility supports basic static methods for external use. This means that you can access next methods from your project classes:
// Default path (project directory), numerating cells by default (1, 2, 3...)
generateSvgGridImage()
// Default path, picking custom labeling mode: NONE, FILE_NAME or NUMERATE
generateSvgGridImage(LabelMode)
// Custom path, numerating cells by default (1, 2, 3...)
generateSvgGridImage(Path)
// Custom path, custom labeling mode: NONE, FILE_NAME or NUMERATE
generateSvgGridImage(Path, LabelMode)
- Utility goes through every file in the directory it is in. So make sure you're not running it from your system's root directories.
- It handles only SVG files, other files are ignored and don't cause exception crashes.
- Files that couldn't be processed during generating are listed in the terminal output and skipped. The total count of skipped files will be displayed in the end as well.
SVG files are imported in alphabetical order.
Feel free to pull request order support static methods!
Parameter | Description | Default Value |
---|---|---|
MODE |
Labeling mode:
|
LabelMode.NUMERATE |
CELL_WIDTH |
Width of each cell in the grid (in pixels) | 250 |
CELL_HEIGHT |
Height of each cell in the grid (in pixels) | 250 |
PADDING |
Padding around each cell (in pixels) | 10 |
NUMBER_PADDING |
Padding between number/text and SVG shape (in pixels) | 5 |
FONT_SIZE |
Font size for the label text (in points) | 20 |
FONT_NAME |
Name of the font used for labeling | Arial |
NUMBER_COLOR |
Color of the text/number labels | Color.BLACK |
BORDER_COLOR |
Color of the border around each cell | new Color(211, 211, 211) (it's light-gray) |
ANTI_ALIASING |
Improves font rendering quality. Should generally remain enabled unless custom fonts render poorly | true |