• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 12
  •   
Release script.colorbox
#1
Blurb, I will try support here when I can.
The script will change as more users use it.
I have to say a big 'THANK YOU' to all the guys who share code, it saves me a lot of time having to code from scratch!!
Please see my GitHub repo for sources and check out the people who write them!

2.0.4 (version kodi repo)
  • Own multiple containers can be defined (cannot be changed after init atm)
  • Ability to ask for a set of window propertys and then set them randomly
  • Three containers (7972 7973 7974) to strip various formatting codes from strings ([CR] /r /t etc.)
  • RunScript support improved
  • LUMAImageColor* and BWImageColor* will give value 0-256 based on main color (luminosity and contrast)

Currently included:
  • Various effects including pixelate, posterize, blur, pixelshifts, distortions, two tone and more (see default.py 'ColorBox_function_map')
  • Episodes watched percentage for tvshows (Show_Percentage)
  • Auto transition between colors for daemon types
  • ListItem.Art(fanart) auto processed if set (cfa_daemon_set)
  • Change various settings via NINE_manual_set, ie, pixelsize, quality (see default.py 'ColorBox_settings_map')
  • Manual types eg. 'RunScript(script.colorbox,info=blur,id=PICTURE_NAME,prefix=mypic1,blursize=1,quality=8)'

See skin.adonic for implementations (in Kodi Repo)
My repo has latest versions [adonic for Leia only due to DialogAddonSettings.xml] https://github.com/BADMS/repository.BADM...-1.0.0.zip

Image
https://github.com/BADMS/script.colorbox

- colorbox 2.0.4 adds 'dataglitch' just a simple rgb band shifter for now
- colorbox 2.0.3 is on my repo with a little (crucial) bugfix
Reply
#2
@badass

I'm wondering if you could tell me how to grab the poster colour. I know how to get the fanart with cfa daemon and ImageColorcfa property, but how would I get the main poster colour. I can't quite figure it out. Also, I'm wondering if there is a way to run a daemon that blurs fanart from a variable?

So far my startup is (I focus a button on startup thats why its onfocus rather than onload)
Code:
<onfocus>Skin.SetString(colorbox_quality,8)</onfocus>
<onfocus>Skin.SetString(colorbox_blursize,2)</onfocus>
<onfocus>Skin.SetString(colorbox_bitsize,1)</onfocus>
<onfocus>Skin.SetString(colorbox_pixelsize,12)</onfocus>
<onfocus>Skin.SetString(colorbox_black,000000)</onfocus>
<onfocus>Skin.SetString(colorbox_white,ffffff)</onfocus>
<onfocus condition="System.HasAddon(script.colorbox) + Skin.HasSetting(EnableColorbox)">RunScript(script.colorbox,daemon=True)</onfocus>
<onfocus>SetProperty(cfa_daemon_set,blur,home)</onfocus>

And then I can get the fanart color with this, but how would I get the poster color?
Code:
<value condition="!String.IsEmpty(Window(Home).Property(ImageColorcfa))">$INFO[Window(Home).Property(ImageColorcfa)]</value>
Reply
#3
Ok, hopefully this is it (though I just noticed even my startup is wrong! hehe).

startup.xml:

Code:
<onfocus condition="System.HasAddon(script.colorbox) + Skin.HasSetting(EnableColorbox)">RunScript(script.colorbox,daemon=True)</onfocus>
<onfocus>SetProperty(FIVE_daemon_fallback,adonic.jpg,home)</onfocus>
<onfocus>Skin.SetString(colorbox_quality,8)</onfocus>
<onfocus>Skin.SetString(colorbox_blursize,2)</onfocus>
<onfocus>Skin.SetString(colorbox_bitsize,1)</onfocus>
<onfocus>Skin.SetString(colorbox_pixelsize,12)</onfocus>
<onfocus>Skin.SetString(colorbox_black,000000)</onfocus>
<onfocus>Skin.SetString(colorbox_white,ffffff)</onfocus>
<onfocus>SetProperty(cfa_daemon_set,blur,home)</onfocus>
<onfocus>SetProperty(FIVE_daemon_set,blur,home)</onfocus>
<onfocus condition="System.HasAddon(script.colorbox)">AlarmClock(nms1,SetProperty(NINE_manual_set,"var=quality,set=$INFO[Skin.String(colorbox_quality)]|var=blursize,set=$INFO[Skin.String(colorbox_blursize)]|var=bitsize,set=$INFO[Skin.String(colorbox_bitsize)]|var=pixelsize,set=$INFO[Skin.String(colorbox_pixelsize)]|var=black,set=$INFO[Skin.String(colorbox_black)]|var=white,set=$INFO[Skin.String(colorbox_white)]",home),00:05,true)</onfocus>

then in the page you want to use it, say myvideonav:

Code:
<control type="multiimage" id="7975">
    <left>-2160</left>
    <imagepath background="true">$VAR[ThumbVar]</imagepath>
</control>

then hopefully you have:

Code:
$INFO[Window(home).Property(ImageColorFIVE)]
$INFO[Window(home).Property(ImageCColorFIVE)]
$INFO[Window(home).Property(ImageFilterFIVE)]
$INFO[Window(home).Property(ImageFIVE)]
$INFO[Window(home).Property(BWImageColorFIVE)]
$INFO[Window(home).Property(LUMAImageColorFIVE)]

I think that's all propertys, early here Wink

You can use 7977 and that will just give you colors, nothing else, set same as above, just set 'SetProperty(SEVEN_daemon_set,True,home)' to enable, then replace FIVE with SEVEN in color props above.
Reply
#4
Thanks heaps. This works great. -- Although my actual idea that I wanted it for didn't turn out so great. But that doesn't matter because this actually really helped me understand how the script works. Finally can get it working with skinhelper supplied art which is fantastic! Thanks again! Big Grin
Reply
#5
Phew, it worked!! Wink You're welcome Big Grin
Reply
#6
- colorbox 2.0.3 is on my repo with a little (crucial) bugfix
Reply
#7
I can't seem to change the blur size (radius). This is my startup.xml:
Code:
    <onload condition="System.HasAddon(script.colorbox)">RunScript(script.colorbox,daemon=True)</onload>
    <onload>Skin.SetString(colorbox_blursize,5)</onload>
    <onload>SetProperty(cfa_daemon_set,blur,home)</onload>
Then
Code:
$INFO[Window(home).Property(ImageFiltercfa)]
to show the fanart.
But I can't see any change from the defaults, even if set to much higher.
Reply
#8
(2017-07-31, 09:55)BigNoid Wrote: I can't seem to change the blur size (radius). This is my startup.xml:
Code:
    <onload condition="System.HasAddon(script.colorbox)">RunScript(script.colorbox,daemon=True)</onload>
    <onload>Skin.SetString(colorbox_blursize,5)</onload>
    <onload>SetProperty(cfa_daemon_set,blur,home)</onload>
Then
Code:
$INFO[Window(home).Property(ImageFiltercfa)]
to show the fanart.
But I can't see any change from the defaults, even if set to much higher.

You need to set via NINE property (I just use Skin.String(colorbox_blursize) to save it for future use). I dont check that string as afaik it would induce much disk checking, as skin.strings are constantly read/write to disk. And I use alarmclock just to ensure i'm clear of anything the daemon is setting up.

Code:
<onfocus condition="System.HasAddon(script.colorbox)">AlarmClock(nms1,SetProperty(NINE_manual_set,"var=quality,set=$INFO[Skin.String(colorbox_quality)]|var=blursize,set=$INFO[Skin.String(colorbox_blursize)]|var=bitsize,set=$INFO[Skin.String(colorbox_bitsize)]|var=pixelsize,set=$INFO[Skin.String(colorbox_pixelsize)]|var=black,set=$INFO[Skin.String(colorbox_black)]|var=white,set=$INFO[Skin.String(colorbox_white)]",home),00:05,true)</onfocus>

or in your case just:

Code:
<onfocus condition="System.HasAddon(script.colorbox)">AlarmClock(nms1,SetProperty(NINE_manual_set,"var=blursize,set=$INFO[Skin.String(colorbox_blursize)]",home),00:05,true)</onfocus>
Reply
#9
Working now, thx!
Reply
#10
Halftone & Dither in next release (on git now)

Image
Image
Image
Image
Image
Image
Reply
#11
Is there any way to influence the colors picked for ImageCColor and ImageColor? I would like to grab the ImageCColor and use it to color a background texture and use ImageColor for text that is displayed over that texture. Often though the colors are not contrasting enough even though there are definitely colors in the image that could provide such colors. I am assuming the script only picks colors that make up a certain minimum part of the image. Maybe we could use a sensitivity setting in the onload property that decreases or increases this tolerance? Again, purely assumption on how the script works.
Reply
#12
The image colour is the overall average colour of the image, the other is it's opposite.
What happens is if grey or midrange colour the opposite is the same.
There are two property's that return a number between 0-256 depending on something called luminosity and contrast, think they are in first post, BW & LUMA.
You could set colors based on these, will try explain more later, at work atm.
Reply
#13
@Jeroen
If you look at script.colorbox/resources/lib/Utils.py, search 'def Get_Colors(img, md5):', there is a block I commented out that checked for similar colours. I ran out of time to tweak it just right, but if uncomment it and have a play you might find a sweet spot, then i'll add it source. You will have to delete script.colorbox/ dir in userdata/addons_data. And maybe all your Kodi\userdata\Thumbnails\ and Kodi\userdata\Database\textures.db too just to ensure clean start.

This picture describes the problem, where the colors x-over in the middle portions:
Image

Try tweak this line, like I have below, it 'seems' to work ok'ish.

Code:
if abs(int(contrast)-int(ccontrast)) < 20:
            cimagecolor = RGB_to_hex("{:.0f}".format(clamp(int(comp[0]) + 20) + clamp(int(comp[1]) + 20) + clamp(int(comp[2]) + 20)))

or play with the values

Code:
contrast = "{:.0f}".format((int(color[0]) * 0.299) + (int(color[1]) * 0.587) + (int(color[2]) * 0.144))

It's quite a ballache thing to master, as I haven't found a 'win all' equation yet! Wink
(and you will have to delete userdata/addon_data/script.colorbox/colors.txt each time!).

To carry on, there is Frequent_Color', but this mainly black or white, so you could try:

Code:
if md5 not in colors_dict:
        imagecolor = Get_Frequent_Color(img)
        cimagecolor = Complementary_Color(imagecolor)
        color = hex_to_RGB(imagecolor)
        comp = hex_to_RGB(cimagecolor)
        contrast = "{:.0f}".format((int(color[0]) * 0.299) + (int(color[1]) * 0.587) + (int(color[2]) * 0.144))
        ccontrast = "{:.0f}".format((int(comp[0]) * 0.299) + (int(comp[1]) * 0.587) + (int(comp[2]) * 0.144))
        if abs(int(contrast)-int(ccontrast)) < 20:
            cimagecolor = RGB_to_hex((clamp(int(comp[0]) + 20) + clamp(int(comp[1]) + 20) + clamp(int(comp[2]) + 20)))
        Write_Colors_Dict(md5,imagecolor,cimagecolor)

or make the complimentary color the frequent
Code:
if md5 not in colors_dict:
        colour_tuple = [None, None, None]
        for channel in range(3):
            # Get data for one channel at a time
            pixels = img.getdata(band=channel)
            values = []
            for pixel in pixels:
                values.append(pixel)
            colour_tuple[channel] = clamp(sum(values) / len(values))
        imagecolor = 'ff%02x%02x%02x' % tuple(colour_tuple)
        cimagecolor = Get_Frequent_Color(img)
        Write_Colors_Dict(md5,imagecolor,cimagecolor)

Or, simpler if you find a slice of code on the web that deals with this conundrum I can look at it to add in.
I haven't yet found something simple unfortunately Smile

edit: there's an error in some of this code, will post the fixes shortly
Reply
#14
@badaas - I was wondering if it was possible to have a way for ImageColor and ImageCColor to have a fixed brightness and saturation set by the skin so that only the overall hue of the image is used to determine the color returned. This would be really useful for setting a highlight color based upon the image color. I think this might also help with what Jeroen wants to do. If this is too difficult, would it be possible to return HUEImageColor as the hue value from 0-255 similar to LUMAImageColor. Then I can just define a bunch of preset colours and pick them depending on the hue value.

EDIT: Also, looking at the image you linked, am I right in assuming that to pick the complimentary colour you invert the colour spectrum and pick the colour with the same value on the other side. If it is a scale of 0 to 1 in 0.1 intervals, then why not instead of inverting, just add 0.5 to the original value and use that value. If the value is over 1 then just subtract 1 from it. That way the Hue is thought of in terms of a wheel which is how complimentary colours are picked in design any way.
Reply
#15
(2017-08-12, 07:16)jurialmunkey Wrote: @badaas - I was wondering if it was possible to have a way for ImageColor and ImageCColor to have a fixed brightness and saturation set by the skin so that only the overall hue of the image is used to determine the color returned. This would be really useful for setting a highlight color based upon the image color. I think this might also help with what Jeroen wants to do. If this is too difficult, would it be possible to return HUEImageColor as the hue value from 0-255 similar to LUMAImageColor. Then I can just define a bunch of preset colours and pick them depending on the hue value.

EDIT: Also, looking at the image you linked, am I right in assuming that to pick the complimentary colour you invert the colour spectrum and pick the colour with the same value on the other side. If it is a scale of 0 to 1 in 0.1 intervals, then why not instead of inverting, just add 0.5 to the original value and use that value. If the value is over 1 then just subtract 1 from it. That way the Hue is thought of in terms of a wheel which is how complimentary colours are picked in design any way.

1. I can look at this yes Smile So you would have same color but different shade (hue)?
2. I am looking at other ways to get the color, I kind of abandoned it as had to work on other sides of things with script, but now I can concentrate on it. BUT! It seems the genius smitchell6879 has done it, but he's licensed it to himself.
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 12
  •   



Logout Mark Read Team Forum Stats Members Help
script.colorbox1
This forum uses Lukasz Tkacz MyBB addons.