ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello there. I need a method of finding out how large (memory-wise) an image is - it doesn't mastter when this is found out (ie. before or after the image is sent), but the size does need to be recorded in a MySQL database.
It loads the image resource directly from the site. It has to do this due to oddities in my hosting, where I only get a tiny amount of 'smart' CGI-enabled space and a huge amount of 'dumb' space for keeping images and the like.
I could have it download the image to a temporary file, but this way is much more efficient - if I can measure the image's size. It is in memory, after all - surely there's a way of finding out how much it's using?
The result has to be stored in a MySQL database. (I guess it could be stored in a file instead, but I don't really see the point...)
No, I looked at that - as far as I can tell, it takes the path to a saved file as input and gives you it's physical sizes (ie. width x height) rather than its data size.
I've decided to do it the inefficient way now - it saves the file to disk using the copy() function, then gets its size before loading it in as an image.
Thanks for all your help though, it's greatly appreciated.
Hmm, would this constitute a possible feature request?
Thanks, but I've realised that the way I've used is actually better now.
It measures the exact filesize transferred from the storage space, which is what I need to know - if the script re-encodes the image itself, its ouput might be a different length.
Thanks for the method, though - I'll refer back to this next time I'm confronted with a similar problem!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.