diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1cba798..ec04275 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -21,8 +21,8 @@ jobs: python-version: 3.6 - name: Install imagemagick run: | - git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.0.10 - cd ImageMagick-7.0.10 + git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.1.0-32 + cd ImageMagick-7.1.0-32 ./configure --prefix=${HOME}/opt make sudo make install diff --git a/README.md b/README.md index 5e921de..0e13741 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,9 @@ For each language set strings for title keys specified in framer.json } } ``` +### ImageMagick commands +```bash +magick input.png -resize 50% out.png +magick composite -compose atop -geometry +x+y 1.png 2.png out.png +magick input.png -gravity North -font font.ttf -fill white -pointsize 150 -draw 'text 0,100 "some text"' out.png +``` \ No newline at end of file diff --git a/androidframer/framer.py b/androidframer/framer.py index f601efe..0326084 100755 --- a/androidframer/framer.py +++ b/androidframer/framer.py @@ -18,7 +18,7 @@ def __init__(self, config, strings, images): self.folder = images #Read self.config = json.loads(open(self.configFile).read()) - self.titles = json.loads(open(self.stringsFile).read()) + self.titles = json.loads(open(self.stringsFile, encoding='utf-8').read()) #Config file self.bg = self.config["background"] self.font = self.config["font"] @@ -104,7 +104,7 @@ def resize(self, imgFolder, file, ext): """ img = os.path.join(imgFolder, (file + ext)) out = os.path.join(imgFolder, (file + '_' + ext)) - command = f"convert {img} -resize %{str(self.resizeRatio)} {out}" + command = f"magick {img} -resize {str(100)}% {out}" self.cmd(command) return file + "_" @@ -112,15 +112,21 @@ def frame(self, imgFolder, file, ext): '''Put the file.ext in a frame''' img = os.path.join(imgFolder, (file + ext)) out = os.path.join(imgFolder, (file + 'framed' + ext)) - command = f"convert {self.bg} {img} -geometry +{self.xPos}+{self.yPos} -composite {out}" + command = f"magick composite -compose atop -geometry +{self.xPos}+{self.yPos} {img} {self.bg} {out}" self.cmd(command) return out def label(self, img, title1, title2): '''Label img with title1 and title2''' out = img.replace('_framed', '_out') - command = f"convert {img} -font {self.font} -gravity North -fill white -pointsize {self.fontSize} -draw \"text 0,100 '{title1}'\" -draw \"text 0,220 '{title2}'\" {out}" + command = f"magick {img} -font {self.font} -gravity North -fill white -pointsize {self.fontSize} -draw \"text 0,190 '{title1}'\" -draw \"text 0,220 '{title2}'\" {out}" self.cmd(command) - os.remove(img) - os.remove(img.replace('_framed', '_')) + try: + os.remove(img) + except: + print("") + try: + os.remove(img.replace('_framed', '_')) + except: + print("") return out \ No newline at end of file