Skip to content

Commit

Permalink
New size and bare image format path variables
Browse files Browse the repository at this point in the history
- Use %z and %i to include bare size and image format details in your output directory structure.
- Updated the documentation to include these improvements.
- Moved an old changelog to /docs and linked it so it's actually visible.
  • Loading branch information
dzuk-mutant committed Feb 13, 2020
1 parent d1d1838 commit 8f2aa67
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ A longer guide with simpler language for those who are less techincally inclined
* @AndrewMontagne - imagemagick support
* @shello - caching

[Old changelog from 0.1.0 to 0.2.0](docs/old_changelog.md)

# License

orxporter is licensed under the [Cooperative Non-Violent License (CNPL) v4](license.txt).
21 changes: 20 additions & 1 deletion dest_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,28 @@ def format_resolve(code, emoji, format):
raise ValueError('Cannot resolve %d - no emoji source file defined')
return str(pathlib.Path(emoji['src']).parent)

# (%f) export format (png, webp, jpx, etc.)



# (%f) export format (png-64, webp-128, etc.)
if code == 'f':
return format

# (%z) export size (64, 128, 512, etc.)
# will return 0 (as a string) if it's SVG.
if code == 'z':
if format.split("-")[0] in ["svg", "svgo"]: # if there's no size...
return "0"
else:
return format.split("-")[1]

# (%i) image format, without size (png, webp, avif, etc.)
if code == 'i':
return format.split("-")[0]




# (%s) the emoji's shortcode
if code == 's':
if 'short' not in emoji:
Expand All @@ -48,6 +66,7 @@ def format_resolve(code, emoji, format):
raise FilterException('Cannot resolve %u (unicode codepoint is explicitly undefined )')
return util.uni_to_hex_filename(emoji['code'])


raise ValueError('Cannot resolve format code: ' + code)


Expand Down
39 changes: 39 additions & 0 deletions docs/dzuk/file_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,46 @@ final/something/png-32/hand.png
```
----
## Export format by itself (`%i`)

Inserts the [image format name](image_formats.md) without size. (ie. `png`, `svg`, `flif`, etc.)

```
# manifest example
emoji short = hand src = blah/blah/hand.svg
# out folder
final
# directory format example
final/something/%i/%s
# output (assuming it's a PNG)
final/something/png/hand.png
```
---

## Export size (`%z`)

Inserts the [size declared in the image format](image_formats.md) (ie. `32`, `128`, `512`, etc.)
If it's an SVG (which has no size), it will return '0'.

```
# manifest example
emoji short = hand src = blah/blah/hand.svg
# out folder
final
# directory format example
final/%i/%z/%s
# output (assuming it's a PNG at 128px)
final/png/128/hand.png
```
---
## Shortcode (`%s`)

Inserts the emoji's shortcode.
Expand Down
2 changes: 1 addition & 1 deletion docs/dzuk/image_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ orxporter uses svgcleaner with the following command:
`svgcleaner <in file> <out file> --remove-metadata=no --quiet`

In Mutant Standard tests, optimised SVGs are 30-40% smaller than normal SVGs.
However, svgcleaner is not perfect and can create some unexpected inconsistencies from the original version, so if you use this, you should check your input for flaws.
However, svgcleaner is not perfect and can create some unexpected inconsistencies from the original version, so if you use this, you should check your output for possible inconsistencies.


### Raster
Expand Down
3 changes: 2 additions & 1 deletion docs/kiilas/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Here are the command line options:
current directory (default: **out**)
- **-f PATH_EXPR** -- specifies output filenaming for emoji; the following
formatting codes are supported: **%c** for colormap, **%d** for source
image's directory within input directory, **%f** for export format used,
image's directory within input directory, **%f** for export format used, **%i**
for image format without size, **%z** for image size without format (will return 0 for SVGs),
**%s** for shortcode, **%u** for unicode sequence, **%(property_name)** for
emoji's property; (default: **%f/%s**)
- **-F FORMAT[,FORMAT...]** -- specifies output formats; the following
Expand Down
File renamed without changes.

0 comments on commit 8f2aa67

Please sign in to comment.