diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..24ec92a
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -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
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..522f2f9
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -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 }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..dd82c0b
--- /dev/null
+++ b/CHANGELOG.md
@@ -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
diff --git a/MANIFEST.in b/MANIFEST.in
index e3b5e22..fb30fc5 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,3 +1 @@
-include assets/*
-include src/*
-include src/golden_frame/*
+include golden_frame/assets/*
diff --git a/README.md b/README.md
index 9bcda2b..b709699 100644
--- a/README.md
+++ b/README.md
@@ -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
- **+**
- **=**
-
+ **+**
+ **=**
+
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)
diff --git a/assets/golden_frame.png b/assets/golden_frame.png
deleted file mode 100644
index 2585b74..0000000
Binary files a/assets/golden_frame.png and /dev/null differ
diff --git a/golden_frame/__init__.py b/golden_frame/__init__.py
new file mode 100644
index 0000000..6df5671
--- /dev/null
+++ b/golden_frame/__init__.py
@@ -0,0 +1 @@
+from golden_frame.lib import *
diff --git a/assets/golden_frame.json b/golden_frame/assets/golden_frame.json
similarity index 60%
rename from assets/golden_frame.json
rename to golden_frame/assets/golden_frame.json
index 97e8061..5135360 100644
--- a/assets/golden_frame.json
+++ b/golden_frame/assets/golden_frame.json
@@ -1,4 +1,4 @@
{
"name": "Golden Frame ทพจร",
- "pos": "40,40,206,280"
+ "pos": "122,122,620,844"
}
\ No newline at end of file
diff --git a/golden_frame/assets/golden_frame.png b/golden_frame/assets/golden_frame.png
new file mode 100644
index 0000000..353e680
Binary files /dev/null and b/golden_frame/assets/golden_frame.png differ
diff --git a/assets/obamium_portrait.jpg b/golden_frame/assets/obamium_portrait.jpg
similarity index 100%
rename from assets/obamium_portrait.jpg
rename to golden_frame/assets/obamium_portrait.jpg
diff --git a/assets/obamium_portrait.json b/golden_frame/assets/obamium_portrait.json
similarity index 100%
rename from assets/obamium_portrait.json
rename to golden_frame/assets/obamium_portrait.json
diff --git a/assets/vladdy_daddy.jpg b/golden_frame/assets/vladdy_daddy.jpg
similarity index 100%
rename from assets/vladdy_daddy.jpg
rename to golden_frame/assets/vladdy_daddy.jpg
diff --git a/assets/vladdy_daddy.json b/golden_frame/assets/vladdy_daddy.json
similarity index 100%
rename from assets/vladdy_daddy.json
rename to golden_frame/assets/vladdy_daddy.json
diff --git a/assets/wessuwan.json b/golden_frame/assets/wessuwan.json
similarity index 100%
rename from assets/wessuwan.json
rename to golden_frame/assets/wessuwan.json
diff --git a/assets/wessuwan.png b/golden_frame/assets/wessuwan.png
similarity index 100%
rename from assets/wessuwan.png
rename to golden_frame/assets/wessuwan.png
diff --git a/src/cli.py b/golden_frame/cli.py
old mode 100755
new mode 100644
similarity index 73%
rename from src/cli.py
rename to golden_frame/cli.py
index 08e5fdf..5e6d9d3
--- a/src/cli.py
+++ b/golden_frame/cli.py
@@ -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()
diff --git a/src/lib.py b/golden_frame/lib.py
similarity index 89%
rename from src/lib.py
rename to golden_frame/lib.py
index d162438..0d9ff32 100644
--- a/src/lib.py
+++ b/golden_frame/lib.py
@@ -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:
@@ -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)
@@ -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
diff --git a/setup.cfg b/setup.cfg
index 6850bac..540f876 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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 =
diff --git a/src/__init__.py b/src/__init__.py
deleted file mode 100644
index e69de29..0000000