-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/atomic-exports' into upstream
- Loading branch information
Showing
13 changed files
with
457 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import os | ||
|
||
from dest_paths import format_path, format_resolve | ||
from exception import FilterException | ||
import svg | ||
|
||
def emoji(m, filtered_emoji, input_path, formats, path, src_size, | ||
num_threads, renderer, max_batch, verbose): | ||
""" | ||
Checks all emoji in a very light validation as well as checking if emoji | ||
aren't filtered out by user choices. | ||
It only checks: | ||
- If the emoji has been filtered out by user exporting options. | ||
- If the source SVG file exists. | ||
(Will throw an Exception if not the case.) | ||
- If the shortcode ('short') attribute exists. | ||
(Will throw an Exception if not the case.) | ||
- If the svg size is consistent (if a -q flag is used). | ||
(Will throw an Exception if not the case.) | ||
It this doesn't result in an Exception, it returns dict containing | ||
a list of emoji that aren't filtered out, as well as a count | ||
of emoji that were skipped. | ||
""" | ||
|
||
exporting_emoji = [] | ||
skipped_emoji_count = 0 | ||
|
||
for i, e in enumerate(filtered_emoji): | ||
|
||
short = e.get("code", "<UNNAMED>") # to provide info on possible error printouts | ||
|
||
try: | ||
format_path(path, e, 'svg') | ||
except FilterException as ex: | ||
if verbose: | ||
log.out(f"- - Skipped emoji: {short} - {ex}", 34) | ||
skipped_emoji_count += 1 | ||
continue # skip if filtered out | ||
|
||
if 'src' not in e: | ||
raise ValueError(f"The emoji '{short}' is missing an 'src' attribute. It needs to have one.") | ||
|
||
|
||
|
||
# try to see if the source SVG file exists | ||
srcpath = os.path.join(m.homedir, input_path, e['src']) | ||
try: | ||
emoji_svg = open(srcpath, 'r').read() | ||
except Exception: | ||
raise ValueError(f"This source image for emoji '{short}' could not be loaded: {srcpath}") | ||
|
||
|
||
|
||
# the SVG size check (-q) | ||
if src_size is not None: | ||
img_size = svg.get_viewbox_size(emoji_svg) | ||
|
||
if img_size != src_size: | ||
raise ValueError("""The source image size for emoji '{}' is not what | ||
was expected. It's supposed to be {}, but it's actually | ||
{}.""".format( | ||
short, | ||
str(src_size[0]) + 'x' + str(src_size[1]), | ||
str(img_size[0]) + 'x' + str(img_size[1]) | ||
)) | ||
|
||
# add the emoji to exporting_emoji if it's passed all the tests. | ||
exporting_emoji.append(e) | ||
|
||
return { "exporting_emoji" : exporting_emoji | ||
, "skipped_emoji_count" : skipped_emoji_count | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Metadata (Licenses) | ||
|
||
Orxporter can embed metadata into your resulting emoji. This is useful if you want to put author or license information into your work for public distribution. | ||
|
||
You add metadata to your manifests using the orx keyword `license`, as shown below: | ||
|
||
``` | ||
license svg = license/svg.xml exif = license/exif.json | ||
``` | ||
|
||
Metadata is automatically embedded in your resulting images, but if you want to leave it out... | ||
|
||
- Use the flag `-l` if you're using the [simple exporting method](image_easy,md). | ||
- Use `license = no` in your Parameters file if you're using the [advanced exporting method](image_advanced), | ||
|
||
Metadata embedding is only done with certain formats: | ||
|
||
- EXIF metadata can be embedded in PNG and AVIF files. | ||
- SVG metadata can be embedded in SVG files. | ||
|
||
--- | ||
|
||
## `svg`: SVG Metadata | ||
|
||
SVG Metadata is an XML file you create that contains stuff that gets inserted in the `<metadata>` tag of your resulting SVGs. | ||
|
||
Below is an example XML file with Mutant Standard's SVG metadata: | ||
|
||
``` | ||
<rdf:RDF xmlns:cc="http://web.resource.org/cc/" | ||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
xmlns:dc = "http://purl.org/dc/elements/1.1/" | ||
> | ||
<rdf:Description rdf:about=""> | ||
<dc:title>Mutant Standard emoji v0.4.1</dc:title> | ||
</rdf:Description> | ||
<cc:work rdf:about=""> | ||
<cc:license rdf:resource="http://creativecommons.org/licenses/by-nc-sa/4.0/"/> | ||
<cc:attributionName>Dzuk</cc:attributionName> | ||
<cc:attributionURL>http://mutant.tech/</cc:attributionURL> | ||
</cc:work> | ||
</rdf:RDF> | ||
``` | ||
|
||
--- | ||
|
||
## `exif`: EXIF Metadata | ||
|
||
EXIF Metadata is a JSON file you create that contains stuff that gets inserted in the EXIF metadata of your resulting raster images. | ||
|
||
Below is an example JSON file with Mutant Standard's EXIF metadata: | ||
|
||
``` | ||
{ | ||
"XMP-dc:title": "Mutant Standard emoji v0.4.1", | ||
"XMP-dc:rights": "This work is licensed to the public under the Attribution-NonCommercial-ShareAlike 4.0 International license https://creativecommons.org/licenses/by-nc-sa/4.0/", | ||
"XMP-xmpRights:UsageTerms": "This work is licensed to the public under the Attribution-NonCommercial-ShareAlike 4.0 International license https://creativecommons.org/licenses/by-nc-sa/4.0/", | ||
"XMP-cc:AttributionName": "Dzuk", | ||
"XMP-cc:AttributionURL": "mutant.tech", | ||
"XMP-cc:License": "https://creativecommons.org/licenses/by-nc-sa/4.0/" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.