[VERY LONG TRAIN OF THOUGHTS... TUUUT TUUUT... GOING ON A SIDETRACK]
quote:
Originally posted by Matti
@CookieRevised: Okay, I understand that you don't need a complete script file with a fully functional class to just read the dimensions of the image.
But heck, as a script developer I prefer a clear overall structure so I know where I can easily find my functions. And when I group related methods in a single library file, it's much easier to extend that with extra methods since you'll probably already have a decent base to built on.
I have to admit I didn't know about how to read the size of the PNG binary - thanks for that! Still, I think it's more of a hassle when you need different functions for different image formats (PNG, JPG, GIF) when you can use a universal image library which does just the same.
If you need to read several formats, and if you are going to use several functions, then yes, absolutely. But in this case you only going to read the size of a PNG, nothing else.
quote:
Ah well, it appears to be a matter of your own taste... Maybe I'm spoiled by all the OOP goodness the most recent frameworks and programming languages offer (.NET, PHP, jQuery,...). Maybe I don't want to dive into dealing with bytes and binaries any more. Well, then so be it!
a matter of taste, absolutely... but...
I'm all for libraries myself, but only if you're going to use several functions of that library. Otherwise it is a complete and utter waste of space if you only need 1 function, especially in a language like JScript where nothing is compiled and every unused function stays in. Unlike compiled programs where it doesn't matter if you add a 50MB big library of code, only the used code is going to be compiled and included (in most languages) anyways.
But if you only need one function (like here) and you write in a language like JScript then I would rather export that one function to the script instead of adding a 20Kb big library (so to speak) which would simply sit there doing nothing.
I'm 100% certain that if you compare the GDI+ version of the readsize function with the GDI library in Screenshot Sender, that the code would be almost 100% the same (since there is no other way to do it/program it with GDI). And that single function can be use for any image format GDI+ supports.
And most importantly in this case here (IMHO) is that exporting, and also revising, functions from libraries can be an extremely big learning tool. Otherwise you'll keep on using functions without knowing what they actually do or how they do it. A lot of problems and questions arise from the fact that if you (too) often use libraries (even if you only need 1 thing) and if you get too dependant on them, you don't learn anything new or don't have a clue what to improve or bugfix... That's one of the major reasons why I like to include only the 1 or 2 functions from a library in my snippets/examples to people, instead of simply suggesting to use lib x or y with 50 functions. Especially if the OP shows that he/she is more than happy to learn new things and how to do stuff... Other people might even benefit too (like you just said that you now learned how to use the ReadFile APIs to read binary data).
But in the end, a matter of taste, absolutely, since I personaly like to know what wrapper X does or what functions wrapper Y actually use (in case I come across a similar but slightly different problem which I can't fix with out-of-the-box-functions). And hence, I reflect that to the people I try to help too... As it is more satisfying (too me at least) that people learn something new from your examples, than that they are 'helped' with a already written stuff which they need to copy (without even looking at it).
[/ARRIVED AT STATION
]