Blog 07-15-23

For DoIt theme:

twemoji: if true, the content will enable the twemoji.

1
twemoji: true

Example:

Twemoji Description
🤣 (Rolling On The Floor Laughing)
🙂 (Slightly Smiling Face)
😇 (Smiling Face With Halo)
👻 (ghost)
🥶 (cold face)
❤️ (red heart)
👆️ (backhand index pointing up)
😵‍💫 (face with spiral eyes)
💬 (speech balloon)
🙀 (weary cat)
💦 (sweat droplets)

Finding Emojis:

 Twemoji Cheatsheet

 Official Emoji list

Emojis are represented by Unicode characters, which are standardized codes used to represent text in various writing systems, including emojis. Unicode ensures that emojis can be rendered and interpreted consistently across different devices, operating systems, and web browsers. In the case of twemoji, it is a JavaScript library that replaces Unicode emoji characters with images provided by Twitter’s Twemoji project. The library detects Unicode emoji characters in your web page and dynamically replaces them with <img> tags that link to the appropriate twemoji image hosted on a CDN (Content Delivery Network). This allows for consistent rendering of emojis across different platforms and ensures that even devices or browsers without native emoji support can display them as images.


Description: Automate the process of running the cwebp command with a Python script that prompts the user for input and generates the output filename based on the user’s input

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import subprocess

# Get the path to the input file or folder
input_path = input("Enter the path to the input file or folder: ")

# Get the quality parameter for cwebp
quality = input("Enter the quality parameter for cwebp (0-100): ")

# Get the path to the output folder
output_folder = input("Enter the path to the output folder (default is the input folder): ")
if output_folder == "":
    output_folder = os.path.dirname(input_path)

# Get the prefix for the output filename
prefix = input("Enter the prefix for the output filename (default is 'output'): ")
if prefix == "":
    prefix = "output"

# Define a dictionary mapping file extensions to quality parameters
quality_params = {
    ".png": "80",
    ".jpg": "90",
    ".jpeg": "90",
    ".gif": "80"
}

# Check if the input path is a file or a folder, and convert accordingly
if os.path.isfile(input_path):
    # Convert the specified file
    _, ext = os.path.splitext(input_path)
    if ext.lower() in quality_params:
        quality = quality_params[ext.lower()]
    input_file = os.path.basename(input_path)
    output_file = prefix + "_" + os.path.splitext(input_file)[0] + ".webp"
    output_path = os.path.join(output_folder, output_file)
    cmd = ["cwebp", input_path, "-q", quality, "-o", output_path]
    subprocess.run(cmd)
else:
    # Convert all files in the specified folder
    for input_file in os.listdir(input_path):
        _, ext = os.path.splitext(input_file)
        if ext.lower() in quality_params:
            quality = quality_params[ext.lower()]
            input_path = os.path.join(input_path, input_file)
            output_file = prefix + "_" + os.path.splitext(input_file)[0] + ".webp"
            output_path = os.path.join(output_folder, output_file)
            cmd = ["cwebp", input_path, "-q", quality, "-o", output_path]
            subprocess.run(cmd)

# Print a message to indicate that the task is complete
print("Task complete. The output files are located at: " + output_folder)

This script first prompts for input and stores the input path in a variable (input_path). It then checks if the input path is a file or a folder using the os.path.isfile() function.

If the input path is a file, it extracts the file extension and uses the quality_params dictionary to look up the corresponding quality parameter. It then generates the output filename and path, and runs the cwebp command as before.

If the input path is a folder, it loops through all files in the folder, extracts the file extension, and uses the quality_params dictionary to look up the corresponding quality parameter. It then generates the output filename and path for each file, and runs the cwebp command as before.

The quality_params dictionary and the other input parameters can be modified as needed, and the script will automatically switch between converting a folder and a single file depending on the user input.


 [Arknights] [FC-8] Eunectes + Healers