Combine Images precise positioning

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Combine Images precise positioning

Post by webtrekker » 15 Jun 2019 10:17

Hi. I find the Combine Images action very useful but would like to be able to position the SRC image with pixel accuracy and not just the 9 pre-defined positions.

Is this feasible, or is there already a way around this (other than to prepare multiple images in Photoshop)?

Thank you.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Combine Images precise positioning

Post by Martin » 16 Jun 2019 14:33

Hi,

There's probably no good workaround available but I can extend the action to incorporate an x/y-offset. I've added it to the todo list.

Regards,
Martin

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Re: Combine Images precise positioning

Post by webtrekker » 16 Jun 2019 15:17

Thanks Martin. You're a star!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Combine Images precise positioning

Post by Desmanto » 16 Jun 2019 17:18

@webtrekker : if you need image processing, widget is actually very versatile for this. You can put your image and arrange them in such a way inside the widget. You can fine tune to the x,y, rotation, size, layer and so many other thing. Then save the widget as image. Next time, you simply need to use script to change the widget image source, and then save the widget as image afterward. I use the same method to collage my screenshot for tutorial purpose.
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.

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Re: Combine Images precise positioning

Post by webtrekker » 17 Jun 2019 17:29

My main reason for asking is that have a flow that changes wallpapers on my phone according to battery level %. The wallpaper is a picture containing a flagpole and the height of the flag on the pole represents the battery level at any given time.

In my flow I have split up the levels into 5 ranges: 0%-20%, 20%-40%, 40%-60%, 60%-80%, 80%-100%. This requires 5 different wallpapers, each with the flag at different positions on the pole ...

battery_flag.png
battery_flag.png (1.25 MiB) Viewed 22373 times

Now, supposing I want the flag to move in smaller steps, like in 10% intervals, or even 1% intervals, then I would need a different wallpaper for every interval, so maybe 10 or even 100 wallpapers! I thought it would be much better if I could use 'Combine Images' to overlay a flag image onto a pole background image requiring only 2 images to be stored on my phone. The trouble with 'Combine Images' though, as I have said in my first post, is that it only allows 9 pre-defined locations for the flag image, whereas I need to be able to position the flag anywhere on the pole with (x,y) pixel accuracy.

I hope that makes things clearer. :D

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Combine Images precise positioning

Post by Desmanto » 17 Jun 2019 17:40

How do you overlay the 2 images? You can do the same also in widget. Simply move the x,y location of the image compared to the background. The anchor for the image is at the top-left. For each percentage of battery, simply move down the image by 1% of your vertical pixel, by adjusting the y. If you 1080x1920 resolution, that means approx 19 pixel added to the y position, for each battery change.

However, keep in mind that if you do it for each percent, you will have a massive write at the /data partition. This will reduce the life expectancy of the nand flash.
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.

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Re: Combine Images precise positioning

Post by webtrekker » 17 Jun 2019 17:48

Yes, but I don't want to use a widget.

I want to alter the wallpaper to depict the battery percentage by the position of the flag, so I need to be able to use the 'Combine Images' feature to overlay a transparent PNG of the flag over a background image of the pole, and I need to be able to position the flag anywhere along the pole. There wouldn't be any great hit on performance, even at 1% intervals, if was simply combining images whenever the battery level changed.

Sorry, but I can't describe it any better than that.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Combine Images precise positioning

Post by Desmanto » 18 Jun 2019 18:27

Sorry, have to rephrase my previous post. I mean the way you change the wallpaper.

From my understanding, you do it this way :
Every % change > Init image 1 > Init Image 2 > Combine Images > Save Image > Set as Wallpaper

If this is the way you do it, you can do the same using widget.
Setup once : Create widget as big as your wallpaper, put Image 2 as the background. Add another Image 1 (the flag) on top of it.
Every % change > Script to change the position of Image 1 in the Widget (move down 19 pixels) > save widget as image > Set As Wallpaper.

In fact, using widget saves you 2 steps, as you don't need to init the image anymore. It is preloaded in the widget.
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.

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Re: Combine Images precise positioning

Post by webtrekker » 18 Jun 2019 19:22

Thank you Desmanto. I will try your suggestion as soon as I get a chance.

User avatar
webtrekker
Posts: 14
Joined: 30 May 2019 23:58

Re: Combine Images precise positioning

Post by webtrekker » 19 Jun 2019 14:01

Well, what an eye-opener! I can't thank you enough for your help Desmanto.

I hadn't realised the depth to which a custom widget could be changed 'on the fly' by script commands. In fact, I've given up on the wallpaper idea and my flow displays the picture in a widget now, which I can resize and place on any of my phone's home screens. I particularly like that I can overlay any number of transparent PNG's with pixel accuracy and turn the visibility of each layer on or off with a script command.

So many possibilities now ..........................! :mrgreen:

Locked