user499054
user499054

Reputation:

Storing an image dimension with MySQL

What is the optimal way to store an image dimension in a database? Should I just use two SMALLINTs? Or should I use a POINT or a VARCHAR?

Upvotes: 2

Views: 1220

Answers (2)

ludesign
ludesign

Reputation: 1373

Depends on what you need this data for. If you are going to run SELECTs based on image size, then SMALLINT for each (width, height). If you just need image dimensions as meta data to the image, you can use varchar with serialized array (for example returned by getimagesize()) or string.

Hope that helps. :)

Upvotes: 4

Sean Adkinson
Sean Adkinson

Reputation: 8615

Speaking optimally, clearly the least amount of storage required to hold any values you want stored would be best. I don't have a lot to add to what you already know: I think two SMALLINTs would be the best route to go.

Upvotes: 5

Related Questions