It is currently April 18th, 2024, 10:32 am

Validate if a file exist otherwise set a default file

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Validate if a file exist otherwise set a default file

Post by jsmorley »

Yincognito wrote: November 2nd, 2020, 9:46 pm Thanks for the suggestion, but does one need to use a plugin for every little bit of functionality out there, especially when that functionality exists already? Or, if the plugins are really useful and efficient, why not including them in the standard Rainmeter distribution instead of having to hunt them through the many pages of the forum?

Bottom line, while I very much appreciate both the suggestion and the plugin, it really feels awkward to have to use an image size plugin when there is an image plugin already. It's like having a nice text editor, but using an entirely different program (or some add-on that you have to download, install, etc.) to get the number of lines in an opened text file in that editor. A bit redundant, IMHO, to put it mildly. :confused:
Huh? The entire point of us supporting plugins is to allow users to "extend" the functionality of Rainmeter anyway THEY want or need without us bulking up the distribution for every little thing a user finds useful. It's the very DEFINITION of a "plugin". I don't understand your position on this a single bit. To be perfectly honest, I don't really like this viewpoint. So you really hate the Plugins Administration feature of Notepad++? All the hundred or more plugins available for Notepad++ should just be baked-in?

ImageSize is an example of something that is perfect for a 3rd-party plugin in my view. It's of some value, but not something the majority (or even a large minority) of users will ever need. While I would not be opposed in principle to including the plugin in the distribution, I kinda like that you can get it if you need it, and if you don't, then don't. Sure this plugin, and in fact almost all 3rd-party plugins, are small, and each is not going to add a lot to the distribution. But I personally have probably created a dozen or more little plugins that have a very specific, targeted, or niche purpose, and it would soon add up to stick all of them, and the hundreds of others people have created, into the package. It's why we support and ENCOURAGE people to write their own plugins as they like. It's why we created the Measure=Plugin measure type all those years ago, and I for one am really glad we did.
django933
Posts: 12
Joined: June 18th, 2014, 12:15 am

Re: Validate if a file exist otherwise set a default file

Post by django933 »

Yincognito wrote: November 2nd, 2020, 9:09 pm Ok, first I will post the code that checks for the image meter dimensions to see if the image exists or not, i.e. the one using negative coordinates like I explained earlier. This code should work, but it doesn't, despite being logically correct, at least the way I see it:
Yes, i tried the first variant and didn't work. I was looking for info of the ImageSize plugin in the Rainmeter manual and i though it was not supported anymore because it's not listed there :( .
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Validate if a file exist otherwise set a default file

Post by jsmorley »

django933 wrote: November 2nd, 2020, 10:06 pm
https://forum.rainmeter.net/viewtopic.php?f=127&t=18822#p101884

I will say that if someone is going to recommend a 3rd-party plugin, they should always provide a link to where it can be found. I know that Balala did, just saying in general.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Validate if a file exist otherwise set a default file

Post by Yincognito »

jsmorley wrote: November 2nd, 2020, 9:51 pm Huh? The entire point of us supporting plugins is to allow users to "extend" the functionality of Rainmeter anyway THEY want or need without us bulking up the distribution for every little thing a user finds useful. I don't understand your position on this a single bit. To be perfectly honest, I don't really like this viewpoint.
To be specific: while it's useful for bangs to be "modular" in nature (i.e. having an update bang, an redraw bang, and so on), would you - hypothetically - make a plugin for both the update action AND the redraw action, or would you include them both in the same package? Apply this to the topic we just discuss and maybe you'll understand what I meant better. As for liking my viewpoint, I don't want or mean to create antagonism, really - I said this in the most calm and logical way possible. I'm NOT against plugins, to be clear - I just see the redundancy in this case since the plugin deals with something the Image meter already deals with, not to mention the existence of :W or :H parameters for a section variable. It's not that you created this plugin, it's the fact that the functionality is (or should have been, depending on what we're talking about) there in the first place, potentially in the standard distribution.

It's like the OS or another software releasing a patch for each of the colors Red, Green and Blue theme, when it could just release a patch to change the color of the theme to any color in the RGB spectrum, or just include the feature in the standard distribution (since it already has options to change colors in the related settings).

I really don't know how to explain this better than that. Sorry if you don't like the view or don't understand what I mean with this. To me it just seems the most natural thing to do, like not scratching your left ear with your right hand. I'm just not going to talk about this further, I said what I thought, and I really don't want to make such a fuss over it. Eventually I guess I'll have to keep my opinions to myself. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Validate if a file exist otherwise set a default file

Post by jsmorley »

Yincognito wrote: November 2nd, 2020, 10:27 pm To be specific: while it's useful for bangs to be "modular" in nature (i.e. having an update bang, an redraw bang, and so on), would you - hypothetically - make a plugin for both the update action AND the redraw action, or would you include them both in the same package? Apply this to the topic we just discuss and maybe you'll understand what I meant better. As for liking my viewpoint, I don't want or mean to create antagonism, really - I said this in the most calm and logical way possible. I'm NOT against plugins, to be clear - I just see the redundancy in this case since the plugin deals with something the Image meter already deals with, not to mention the existence of :W or :H parameters for a section variable. It's not that you created this plugin, it's the fact that the functionality is (or should have been, depending on what we're talking about) there in the first place, potentially in the standard distribution.

It's like the OS or another software releasing a patch for each of the colors Red, Green and Blue theme, when it could just release a patch to change the color of the theme to any color in the RGB spectrum, or just include the feature in the standard distribution (since it already has options to change colors in the related settings).

I really don't know how to explain this better than that. Sorry if you don't like the view or don't understand what I mean with this. To me it just seems the most natural thing to do, like not scratching your left ear with your right hand. I'm just not going to talk about this further, I said what I thought, and I really don't want to make such a fuss over it. Eventually I guess I'll have to keep my opinions to myself. :confused:
Your opinions are always welcome of course. The problem with returning the size of an Image is the question of how/where? An Image meter is, well, a meter, it displays something, it's not a measure that returns a value. So the logical way to do what you want is to create an Image measure, which I personally see of limited value. The :W and :H parameters on a meter section variable return the size of the "meter", which isn't necessarily the physical size of the image.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Validate if a file exist otherwise set a default file

Post by Yincognito »

jsmorley wrote: November 2nd, 2020, 10:31 pm Your opinions are always welcome of course. The problem with returning the size of an Image is the question of how/where? An Image meter is, well, a meter, it displays something, it's not a measure that returns a value. So the logical way to do what you want is to create an Image measure, which I personally see of limited value.
Ok, but I still don't follow. Shouldn't the W and H parameters return the size of the image contained in the associated meter in the first place (you know, since they're one and the same in the case of the Image meter)? :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Validate if a file exist otherwise set a default file

Post by Yincognito »

jsmorley wrote: November 2nd, 2020, 10:31 pmThe :W and :H parameters on a meter section variable return the size of the "meter", which isn't necessarily the physical size of the image.
Sorry, what?! :jawdrop For sure I'm missing something here, I just don't know what...
I mean, even if there is transparency involved, you can't add more than that image or less than that image to an Image meter, can you?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Validate if a file exist otherwise set a default file

Post by jsmorley »

Yincognito wrote: November 2nd, 2020, 10:37 pm Sorry, what?! :jawdrop For sure I'm missing something here, I just don't know what...
I mean, even if there is transparency involved, you can't add more than that image or less than that image to an Image meter, can you?
Sorry, I should have been clear. What I mean is that if you have an Image meter with a defined W and / or H value on it, that becomes the size of the "meter". It no longer has anything to do with the size of the image.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Validate if a file exist otherwise set a default file

Post by jsmorley »

As long as you don't use W or H on an image meter, then yes.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeterImage]
Meter=Image
ImageName=#@#Images\laughing.jpg

[MeterSize]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[MeterImage:W] by [MeterImage:H]
DynamicVariables=1

1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Validate if a file exist otherwise set a default file

Post by Yincognito »

jsmorley wrote: November 2nd, 2020, 10:39 pm Sorry, I should have been clear. What I mean is that if you have an Image meter with a defined W and / or H value on it, that becomes the size of the "meter". It no longer has anything to do with the size of the image.
Aaaah... now it makes sense, of course. But if one wants to find the dimensions of an image, he could / should be able to do that by not constraining the W and H of the meter, right? Which is precisely what I did in the above code. This is the main reason why I didn't understand the need to use a plugin for that, to be honest - when the result should have come naturally, as a consequence of the code...
Last edited by Yincognito on November 2nd, 2020, 10:45 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth