diff options
author | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-08-14 18:04:25 +0200 |
---|---|---|
committer | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-08-14 18:04:25 +0200 |
commit | 755f49e71564ef7e1d2240c7ea0358adecb2f174 (patch) | |
tree | b97b6bbbdf529ff51efec661354ec6868d90d382 | |
parent | e9176554b0a357ba254ac64f6efafcfba0734009 (diff) | |
download | desktop-skin-755f49e71564ef7e1d2240c7ea0358adecb2f174.tar.gz desktop-skin-755f49e71564ef7e1d2240c7ea0358adecb2f174.tar.bz2 desktop-skin-755f49e71564ef7e1d2240c7ea0358adecb2f174.zip |
Add "mark_image.py" toolsubmit/tizen_common/20140814.161215accepted/tizen/common/20140814.161757
mark_image.py is a Python script able to write colored text
on any selected position of a .png image.
Change-Id: Ib3b616707bc43d1fd493878cc3e1061dac19ebd1
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
-rwxr-xr-x | Script/mark_image.py | 52 | ||||
-rw-r--r-- | packaging/desktop-skin.spec | 3 |
2 files changed, 55 insertions, 0 deletions
diff --git a/Script/mark_image.py b/Script/mark_image.py new file mode 100755 index 0000000..bc84163 --- /dev/null +++ b/Script/mark_image.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import sys +import cairo + + +if len(sys.argv) < 8: + print "Usage: mark_image.py <file>.png <text> <color> <X1> <Y1> <X2> <Y2> (000000 < color < ffffff) (0 < X/Y < 100)" + sys.exit (0) + + +file = str(sys.argv[1]) +text = str(sys.argv[2]) +c_red = (int(sys.argv[3], 16) >> 16) & 0xff; +c_green = (int(sys.argv[3], 16) >> 8) & 0xff; +c_blue = int(sys.argv[3], 16) & 0xff; +x1 = int(sys.argv[4]) +y1 = int(sys.argv[5]) +x2 = int(sys.argv[6]) +y2 = int(sys.argv[7]) + +if x1 >= x2: + print "<X2> has to be bigger than <X1> !" + sys.exit (1) + +if y1 >= y2: + print "<Y2> has to be bigger than <Y1> !" + sys.exit (1) + + +surface = cairo.ImageSurface.create_from_png (file) +context = cairo.Context (surface) + + +width = surface.get_width () +height = surface.get_height () + +size = 6 +context.set_font_size (size) +xext,yext,wext,hext,xaext,yaext = context.text_extents (text) + +while ((x2-x1)*width)/100 > wext: + size += 1 + context.set_font_size (size) + xext,yext,wext,hext,xaext,yaext = context.text_extents (text) + + +context.move_to ((x1*width)/100, (y1*height)/100) +context.set_source_rgb (c_red/255, c_green/255, c_blue/255) +context.show_text (text) + +surface.write_to_png (file) diff --git a/packaging/desktop-skin.spec b/packaging/desktop-skin.spec index bfd7686..831428a 100644 --- a/packaging/desktop-skin.spec +++ b/packaging/desktop-skin.spec @@ -6,6 +6,8 @@ License: GPL-2.0+ Release: 1 Source0: %{name}-%{version}.tar.gz +Requires: python-cairo + %description Provides desktop visuals and test programs - desktop background @@ -22,6 +24,7 @@ Provides desktop visuals and test programs mkdir -p %{buildroot}%{_bindir} install -m 755 Script/launch_cam.sh %{buildroot}%{_bindir} install -m 755 Script/launch_video.sh %{buildroot}%{_bindir} +install -m 755 Script/mark_image.py %{buildroot}%{_bindir} install -m 755 Script/wifi %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_datadir}/media/videos |