2

Tasker doesnt randomly select image

I set up tasker so every 4 minuted it chooses a random folder from a specific director and then randomly chooses an image from that folder and sends it to klwp to set it up as wallpaper. But i noticed that some images get selected waaaaay to often. This should be random but from a folder that contains 1000 images i got 1 image twice already in the last hours. Yesterday i even got an image twice in 8 minutes from a folder that has almost 1500 images in it.

I start to think that tasker doesnt look at all the images in a folder and stops at a point or even just takes the images it once selected. 

Is there something I didnt understand about tasker?   Also i had another issue that wide images dont get send to klwp in full resolution. Is there a way i can make tasker send the image in full resolution or make klwp load it in full resolution maybe?

2 replies

Hi!

Can you please export your task's description (not xml) so I can take a look? Long-click the task in Tasker->export description Thanks in advance

About KLWP, you'll have to ask their developers, sorry 😅

F

    Task: Zufallsbild Effizient

    

    A1: Get Files/Folders Properties [

         Path: Kustom/wallpapers/

         Type: Directories

         Other Filters: NotEmpty ]

    

    A2: Variable Set [

         Name: %ordner_index

         To: %ordner_lfp_number_of_files(#)

         Structure Output (JSON, etc): On ]

    

    A3: Variable Randomize [

         Name: %zufall_ordner

         Min: 1

         Max: %ordner_index ]

    

    A4: Get Files/Folders Properties [

         Path: %ordner_lfp_full_path(%zufall_ordner)

         Type: Files

         Other Filters: Image ]

    

    A5: Variable Set [

         Name: %anzahl

         To: %file_lfp_number_of_files(#)

         Do Maths: On

         Max Rounding Digits: 3

         Structure Output (JSON, etc): On ]

    

    A6: Variable Randomize [

         Name: %rand

         Min: 0

         Max: %anzahl ]

    

    A7: Variable Set [

         Name: %vollerpfad

         To: %file_lfp_full_path(%rand)

         Structure Output (JSON, etc): On ]

    

    A8: Java Function [

         Return: bmap

         Class Or Object: BitmapFactory

         Function: decodeFile

         {Bitmap} (String)

         Param 1 (String): %vollerpfad ]

    

    A9: Variable Set [

         Name: %Bild

         To: %vollerpfad

         Structure Output (JSON, etc): On ]

    

    A10: Variable Search Replace [

          Variable: %Bild

          Search: /storage/emulated/0

          Store Matches In Array: %BildClean

          Replace Matches: On ]

    

    A11: Java Function [

          Return: %height

          Class Or Object: bmap

          Function: getHeight

         {int} () ]

    

    A12: Java Function [

          Return: %width

          Class Or Object: bmap

          Function: getWidth

         {int} () ]

    

    A13: Variable Set [

          Name: %BGScroll

          To: ((((1560*%width/%height)/2)-360)/360)*100

          Do Maths: On

          Max Rounding Digits: 10

          Structure Output (JSON, etc): On ]

    

    A14: Variable Set [

          Name: %BGScroll

          To: 0

          Do Maths: On

          Max Rounding Digits: 3

          Structure Output (JSON, etc): On ]

        If [ %BGScroll < 0 ]

    

    A15: KLWP Send Variable [

          Configuration: Set: BGScroll

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

    A16: KLWP Send Variable [

          Configuration: Set: TaskerBi

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

    A17: KLWP Load Preset [

          Configuration: Set: 'Anime_Zufalls_bild'

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

    

Thank you. Instead of doing actions 1 through 7 can you do just this?

Task: Test

A1: Get Files/Folders Properties [
Path: Kustom/wallpapers/
Type: Files
Recurse: On ]

A2: Flash [
Text: %lfp_full_path(*)
Tasker Layout: On
Dismiss On Click: On ]

%lfp_full_path(*) should return a random file from all subfolders.

Hope this helps!

F

Thank you for your suggestion but one question woundnt that take a lot of time to process? I mean tasker would go through all folders and files first and then choose one file out of all. 

I used to do it like that but at some point tasker took more time to choose an image before a new had to be chosen. 

Thats why i first told tasker to look at all folders and choose one to look more deeply into. 

Ok, you can do it it in 2 steps. But you can still use %list(*) to select a random element in an easier way :)

Task: Test

A1: Get Files/Folders Properties [
Path: DCIM/
Type: Directories ]

A2: Get Files/Folders Properties [

Variable Prefix: files
Path: %lfp_full_path(*)
Type: Files ]

A3: Flash [
Text: %files_lfp_full_path(*)
Continue Task Immediately: On
Dismiss On Click: On ]

F

    Task: Zufallsbild Effizient

    

    A1: Get Files/Folders Properties [

         Path: Kustom/wallpapers/

         Type: Directories

         Other Filters: NotEmpty ]

    

    A2: Variable Set [

         Name: %ordner_index

         To: %ordner_lfp_number_of_files(#)

         Structure Output (JSON, etc): On ]

    

    A3: Variable Randomize [

         Name: %zufall_ordner

         Min: 1

         Max: %ordner_index ]

    

    A4: Get Files/Folders Properties [

         Path: %ordner_lfp_full_path(%zufall_ordner)

         Type: Files

         Other Filters: Image ]

    

    A5: Variable Set [

         Name: %anzahl

         To: %file_lfp_number_of_files(#)

         Do Maths: On

         Max Rounding Digits: 3

         Structure Output (JSON, etc): On ]

    

    A6: Variable Randomize [

         Name: %rand

         Min: 0

         Max: %anzahl ]

    

    A7: Variable Set [

         Name: %vollerpfad

         To: %file_lfp_full_path(%rand)

         Structure Output (JSON, etc): On ]

    

    A8: Java Function [

         Return: bmap

         Class Or Object: BitmapFactory

         Function: decodeFile

         {Bitmap} (String)

         Param 1 (String): %vollerpfad ]

    

    A9: Variable Set [

         Name: %Bild

         To: %vollerpfad

         Structure Output (JSON, etc): On ]

    

    A10: Variable Search Replace [

          Variable: %Bild

          Search: /storage/emulated/0

          Store Matches In Array: %BildClean

          Replace Matches: On ]

    

    A11: Java Function [

          Return: %height

          Class Or Object: bmap

          Function: getHeight

         {int} () ]

    

    A12: Java Function [

          Return: %width

          Class Or Object: bmap

          Function: getWidth

         {int} () ]

    

    A13: Variable Set [

          Name: %BGScroll

          To: ((((1560*%width/%height)/2)-360)/360)*100

          Do Maths: On

          Max Rounding Digits: 10

          Structure Output (JSON, etc): On ]

    

    A14: Variable Set [

          Name: %BGScroll

          To: 0

          Do Maths: On

          Max Rounding Digits: 3

          Structure Output (JSON, etc): On ]

        If [ %BGScroll < 0 ]

    

    A15: KLWP Send Variable [

          Configuration: Set: BGScroll

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

    A16: KLWP Send Variable [

          Configuration: Set: TaskerBi

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

    A17: KLWP Load Preset [

          Configuration: Set: 'Anime_Zufalls_bild'

          Timeout (Seconds): 0

          Structure Output (JSON, etc): On ]

    

   Thank you in advance:)