Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Image file dimension reader

Author
Message
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Nov 2007 14:50 Edited at: 22nd Nov 2007 14:53
Here's a function to read the dimensions of image files (supports BMP, PNG, and DDS) without having to actually load the image into memory. I'm not sure of what use this has, but someone asked for a way to do this and as I thought it would be interesting to code, I did it.

Function(s) and example code:



Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 22nd Nov 2007 19:56
Someone could check before actually loading the image perhaps? If it's not of a certain size like 256x256 then it won't be loaded.... Something! Some use...... Somewhere.......... cupcakes............


Cheers,

-naota

"I choose to believe, what I was programmed to believe!"
Aex.Uni forums
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 22nd Nov 2007 20:26
I thought perhaps it might be useful if you want to make sure a ridiculously large image isn't loaded, although then again you could just deduce this from the large file size.

But yes, your suggestion of checking that the image is a specific size for some purpose makes sense.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Alsan
19
Years of Service
User Offline
Joined: 20th May 2005
Location: Germany - Nähe Kassel
Posted: 23rd Nov 2007 21:22 Edited at: 23rd Nov 2007 21:24
Well, I could have used it some time ago when I wanted to delete all images of a certain size out of several thousand images. It was sooo slow to load every file and use the Image Width()/Image Height() functions.

I think I asked for something like this in a German DB forum, but noone came up with your solution. Nice work!

Login to post a reply

Server time is: 2024-11-22 13:16:06
Your offset time is: 2024-11-22 13:16:06