Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
18 changes: 12 additions & 6 deletions androidframer/framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -104,23 +104,29 @@ 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 + "_"

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