Mobile app version of vmapp.org
Login or Join
Merenda212

: Storing image order without a database The classic question is whether to store images in a database or on the file system. In my case I feel it is probably best to store it on the file

@Merenda212

Posted in: #Database #Datastorage #Images

The classic question is whether to store images in a database or on the file system. In my case I feel it is probably best to store it on the file system.

However the specific order of the albums and images is very important. Originally I thought that I could do this by displaying images in the order of their last modified date and then artificially change that value to modify the order. However that method is flawed as adding new images to an album will reorder all the images as the modified time is changed unwillingly.

Can anyone give me advice on how I can keep track of the order without using a database?

(Not 100% sure if this question belongs here or maybe on stackoverflow, but I'm taking my chances and if I'm wrong feel free to correct it.)

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Merenda212

2 Comments

Sorted by latest first Latest Oldest Best

 

@Kimberly868

A programming option would be to store the image order in the EXIF data of the jpg files.

There's a UserComment or ImageDescription property you could use - assuming that these weren't already used in the image of course.

This will be slower than using an external file/database or changing the names or timestamps of the files, but it is self contained.

10% popularity Vote Up Vote Down


 

@Cody1181609

You can use simple text file to simulate real database. If folder = album, then store order of images in text file in each folder (same file name, for example: order.txt.db).

Possible file format:


single line of text that you need to parse after reading from file (for example: file1.jpg|file2.jpg|file5.jpg|file3.jpg) -- it is easy to parse if you select right delimiter that is not part of the actual file name;
one line per file (each file on new line) -- maybe even better, as new line is definitely unique delimiter that will not be part of the file name;
scripting language-specific format (for example: serialized array for PHP -- using serialize() function) -- can easily be un-serialized and ready to use with no additional parsing (as un-serializing routine will do all parsing job for you).




If your hosting plan does not allow/support MySQL or similar database engine .. then it may support SQLite -- it is fast and one database = one file which can be stored as any other file on your site (just need read-write access).



Another approach would be renaming file names to include sorting order number (e.g. 001-file1.jpg, 002-file5.jpg etc), but this is more complicated to manage (kind of similar problems to using file modification time).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme