Skip to content

Commit

Permalink
Golden Frame 1.0!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Jun 11, 2022
1 parent b60126e commit ed4bcf5
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 25 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish Release

on:
push:
tags:
- "*.*"

jobs:
main:
name: Publish Release
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Publish Release
uses: Leomotors/auto-publish-release@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TITLE: "Golden Frame {VERSION}"
VERSION_MUST_INCREASE: true
TAG: ${{ github.ref }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notables change for Cocoa Discord Utils will be noted here

## [1.0.50] - 2022-06-11

- Initial Release on Main PyPi after many attempts
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include assets/*
include src/*
include src/golden_frame/*
include golden_frame/assets/*
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
# Golden Frame

กรอบทอง Generator
[![](https://img.shields.io/pypi/v/golden-frame)](https://pypi.org/project/golden-frame)
[![](https://img.shields.io/pypi/dm/golden-frame)](https://pypi.org/project/golden-frame)

_work in progress, making a Python Package is so complex just like npm_
"กรอบทอง Generator"

## Example

<img src="assets/golden_frame.png" width=200 /> **+**
<img src="example/zhongxina_before.jpg" width = 200 /> **=**
<img src="example/zhongxina_after.png" width=200 />
<img src="https://github.com/Leomotors/golden-frame/raw/main/golden_frame/assets/golden_frame.png" width=200 /> **+**
<img src="https://github.com/Leomotors/golden-frame/raw/main/example/zhongxina_before.jpg" width = 200 /> **=**
<img src="https://github.com/Leomotors/golden-frame/raw/main/example/zhongxina_after.png" width=200 />

PS. The original picture of golden frame is K-Pop Star (Search: กรอบทอง ทรงพระเจริญ in Google, there are many variant)

### Command for Above Example

```bash
src/cli.py build golden_frame.png example/zhongxina_before.jpg --output=example/zhongxina_after.png
golden-frame build golden_frame.png example/zhongxina_before.jpg --output=example/zhongxina_after.png
```

### Other commands

Use `golden-frame --help`

## Adding Images

Currently, to add images, add them directly in assets folder.

You can get its location with this command

```python
import pkg_resources
pkg_resources.resource_filename("golden_frame", "assets")
```

Note that this is temporary can be overwrite when installing new version.

file_name.json Schema

```json
{
"name": "Golden Frame ทพจร",
"pos": "40,40,205,278"
"pos": "122,122,620,844"
}
```

pos => x1,y1,x2,y2 ; Position to put pictures on, you can get these info using Paint

## TODO

- Upload to PyPi (This is so mucking hard, muck Python)
Binary file removed assets/golden_frame.png
Binary file not shown.
1 change: 1 addition & 0 deletions golden_frame/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from golden_frame.lib import *
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "Golden Frame ทพจร",
"pos": "40,40,206,280"
"pos": "122,122,620,844"
}
Binary file added golden_frame/assets/golden_frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
7 changes: 6 additions & 1 deletion src/cli.py → golden_frame/cli.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env python3

import typer
import os

from lib import PosOptions, buildFromPreset, listFrames
if os.environ.get("DEBUG") is None:
from golden_frame.lib import PosOptions, buildFromPreset, listFrames
else:
print("[DEBUG] Only use this mode for local development")
from lib import PosOptions, buildFromPreset, listFrames

app = typer.Typer()

Expand Down
17 changes: 11 additions & 6 deletions src/lib.py → golden_frame/lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from typing import Dict, List, Tuple, Union
import cv2
import numpy as np
import json
import numpy as np
import os
import pkg_resources

ASSET_PATH = pkg_resources.resource_filename("golden_frame", "assets")

if os.environ.get("DEBUG") is not None:
ASSET_PATH = "./golden_frame/assets"


class CropOptions:
Expand Down Expand Up @@ -73,9 +80,7 @@ def loadConfig(name: str) -> Dict:


def buildFromPreset(frame: str, image: str, out: str, opt=PosOptions.CENTER):
# Temporary Solution
frame = f"./assets/{frame}"
out = f"./{out}"
frame = f"{ASSET_PATH}/{frame}"

try:
frameimg = cv2.imread(frame)
Expand Down Expand Up @@ -108,12 +113,12 @@ def buildFromPreset(frame: str, image: str, out: str, opt=PosOptions.CENTER):
def listFrames() -> str:
import os
items = list(filter(lambda x: not x.endswith(
".json"), os.listdir("./assets")))
".json"), os.listdir(ASSET_PATH)))

text = f"There are {len(items)} frames available.\n"

for item in items:
cfg = loadConfig(f"./assets/{item}")
cfg = loadConfig(f"{ASSET_PATH}/{item}")
text += f"\n{item} : {cfg['name']}"

return text
10 changes: 7 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
[metadata]
name = golden_frame
name = golden-frame
description = Golden Frame Generator, Create Golden Frame for given images, it also supports other frame.
long_description = file: README.md
long_description_content_type = text/markdown
version = 0.1.25
version = 1.0.50
license = MIT
author = Leomotors
author_email = 59821765+Leomotors@users.noreply.github.com
url = https://github.com/Leomotors/golden-frame
install_requires = opencv-python, numpy, typer
keywords = meme, meme-generator

[options]
include_package_data = True
install_requires =
opencv-python
numpy
typer
packages = golden_frame

[options.entry_points]
console_scripts =
Expand Down
Empty file removed src/__init__.py
Empty file.

0 comments on commit ed4bcf5

Please sign in to comment.