Imagegenerator: configure image size per image

114 views
Skip to first unread message

michael.k...@gmx.at

unread,
Feb 15, 2023, 9:53:43 AM2/15/23
to weewx-user
Hi all,

I wanted to know if it is possible to configure different image sizes per image, something like:

[ImageGenerator]
    image_width = 350
    image_height = 250
    [[day_images]]
        x_label_format = %H:%M
        bottom_label_format = %x %X
        time_length = 97200 # 27 hours

        #will bee 350x250
        [[[daybarometer]]]
           [[[[barometer]]]]

        #will be 700x500
        [[[daytempdew]]]
          [[[[outTemp]]]]
          [[[[dewpoint]]]]
          image_width = 700
          image_height = 500

Tom Keffer

unread,
Feb 15, 2023, 9:59:43 AM2/15/23
to weewx...@googlegroups.com
Yes, it is possible, but you have the options in the wrong spot. You want

        #will be 700x500
        [[[daytempdew]]]
          image_width = 700
          image_height = 500
          [[[[outTemp]]]]
          [[[[dewpoint]]]]

The dimensions must be under the image name "daytempdew", not the observation type "dewpoint".



--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/7543d268-18eb-4abc-b405-ae10e5224d72n%40googlegroups.com.

michael.k...@gmx.at

unread,
Feb 15, 2023, 1:30:12 PM2/15/23
to weewx-user

Thanks Tom! So this is something with the way the config works in general or specific to weewx? Do the "attributes" (or however the correct terminus technicus is in this context) always have to appear before the next [[[]]]]-Level?

Tom Keffer

unread,
Feb 15, 2023, 2:39:14 PM2/15/23
to weewx...@googlegroups.com
This is the way ConfigObj works. An option is a member of the section above it.

Also, see the section Options in the Customizing Guide, in particular the paragraph that starts "Configuration files are read..."

michael.k...@gmx.at

unread,
Feb 16, 2023, 3:34:29 AM2/16/23
to weewx-user

Another Question, regarding this Topic: is it possible to create two different sized images with a minimum of duplicated configuration? Something like this:
[ImageGenerator]

    #... some configs...

    [[day_images]]
       
        # ...a hell lot of special configs...
       
        [[[daybarometer]]]
            [[[[barometer]]]]
            # ...more special configs...
           
        #...really many, many images with much more special configs
   
    [[large-day-images]]

        image_width = 900
        image_height = 600
       
        #the same as [[day images]] but names [[large-{whatever_image_from_day_images}]] without having to copy all the configs

        copy_of = day_image, "large-"

Tom Keffer

unread,
Feb 16, 2023, 8:00:13 AM2/16/23
to weewx...@googlegroups.com
Unfortunately, no.

michael.k...@gmx.at

unread,
Feb 21, 2023, 1:36:09 AM2/21/23
to weewx-user
I ended up coding this: https://github.com/brewster76/fuzzy-archer/blob/lang/bin/user/largeimagegenerator.py to achieve the latter asked question. It probably isn't the most pythonic way to do things, but it seems to work. Since deepcopy took a tremendous amount of time and shallow copying the image configs didn't let me override image_height and image_width, I'm going through the configs manually and adjusting the sizes.

Tom Keffer

unread,
Feb 21, 2023, 6:40:00 AM2/21/23
to weewx...@googlegroups.com
That's pretty clever!

It might have helped you, but weewx has a function that does a deep copy of a ConfigObj, including comments. weeutil.config.deep_copy()

michael.k...@gmx.at

unread,
Feb 21, 2023, 6:56:05 AM2/21/23
to weewx-user
I'll check that deep_copy out, especially what it means in terms of perfomance (probably good enough, or it woldn't exist in weeeutil). My approach is sub 1/100 second on a armv7@1,4GHz for 18 Image configs, the copy.deepcopy() approach  took 2 minutes(!), for whatever reason. Each extra line of code I can avoid, is a potential erroneous line of code, I can avoid :)
Reply all
Reply to author
Forward
0 new messages