Jump to content

Cleanest way to do this...


tibberous

Recommended Posts

I have a table, called images. It has a row that stores the height and width of the initial image.

 

When uploaded, the initial image is resized to 6 different dimensions, keeping aspect. So, if my image was 1000 x 2000, and I select the 200 px version, it would be 100x200.

 

Do you think I should make a stored procedure, that takes in a size, and then returns the right dimensions? Do something like:

 

mysql_query("select height(200) as Height, width(200) as Width from images where id='4'"); ?

 

Is their a better way?

Link to comment
Share on other sites

Not sure what your saying - you mean store it as 123_120_100.jpg, where the name is id, with, height?

 

And here is why I hate stored functions:

CREATE FUNCTION `height`(size int, w int, h int) returns int
begin
if (h >= w) then return size;
else return size * (h / w);
end if;
end ;

 

Be sweet if there was a database that used PHP syntax for stored functions.

Link to comment
Share on other sites

i mean store the actual file name plus the 6 dimensions, maybe a table like this:

 

id INT auto-increment primary key

image_name

dim1_width

dim1_height

dim2_width

dim2_height

etc.

 

when the image is uploaded and resized, add a row with the image name and each of the dimensions, width and height 1 through 6... or maybe i misunderstand.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.