Creating image from text
Moderator: Martin
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Creating image from text
Loving automagic more every day, good morning.
I wonder if there is a way to create an image starting with a certain text, with that text into the image.
On a mac, or Linux, you can use imagemagick from the command line.
I could then use dropbox, hazel, a bash script with imagemagick, then dropbox again to get my image on the phone, but I wonder wether there is a quicker and simpler way with automagic and / or an android app one can automate with automagic.
Thank you.
Tiziano
I wonder if there is a way to create an image starting with a certain text, with that text into the image.
On a mac, or Linux, you can use imagemagick from the command line.
I could then use dropbox, hazel, a bash script with imagemagick, then dropbox again to get my image on the phone, but I wonder wether there is a quicker and simpler way with automagic and / or an android app one can automate with automagic.
Thank you.
Tiziano
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Creating image from text
Thank you, I tried it. I guess I should edit it but Java is beyond me. Maybe some day. Thank you.
Re: Creating image from text
Creating image is simple, you can use action Save Widget to Image File. That java is for image in notification. You can design the image in the widget. Put the necessary element text there. This is the example of mine, which I design to show on my ticwatch.
You can then use setWidget function to change anything, including the text, color, font size and basically any element. Just go to any script/expression/control UI, tap the function, search setWidget, choose it. You can then choose the widget, and modify any element you want.
After that, you can use the action Save Widget to Image File. Choose png or jpg, depends on your content. If mostly text, just use png for better result.
You can then use setWidget function to change anything, including the text, color, font size and basically any element. Just go to any script/expression/control UI, tap the function, search setWidget, choose it. You can then choose the widget, and modify any element you want.
Code: Select all
setWidgetElementProperty("Wear Note", "Text_1", "text", "Your Text here");
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Creating image from text
Very interesting, I'll give it a try. Would you please post an example flow so that I can work on that? That would be simpler for me. Thank you.
Re: Creating image from text
Here is the sample flow.
You can add any element to the widget and later change it from the setWidget(). Just use the function button inside script, for easier access to any widget element you need.
It contains the widget. The script is to change the text and textsize. Save it to image, then create toast message.You can add any element to the widget and later change it from the setWidget(). Just use the function button inside script, for easier access to any widget element you need.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Creating image from text
Magic! Thank you.
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Creating image from text
This is hot. Now I just have to write some code to change text dimension according to text length, since I am going to use it with variuos length texts. Thanks again, that did the trick, I could not imagine widget were so powerful.
Re: Creating image from text
I have done that already too. When the text is too many, I shrink the text size. Delete the last line for the textsize, and replace it with this.
This use a map to put multiple stepping. Change the key and value based on your try and error. The reading start from 0 to the next 200, the font size is 24.0. So if your text length is less than 200, it default to 24.0 (the biggest). As it grows, the font size started to get smaller and smaller.
The code above is longer than if you just use multiple if to check it. But I prefer this way to make it tidy and seems organized. Adding new level of fontsize is also much easier.
Code: Select all
//set font size depends on note length
fontsize = newMapFromValues(
0, 24.0,
200, 22.0,
300, 20.0,
400, 18.0,
500, 16.0,
600, 14.0);
len = length(note);
for(i in getMapKeys(fontsize))
if(len >= i) j = i else break;
setWidgetElementProperty("Wear Note", "Text_1", "textsize", fontsize[j]);
The code above is longer than if you just use multiple if to check it. But I prefer this way to make it tidy and seems organized. Adding new level of fontsize is also much easier.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.