ciril Posted August 17, 2008 Share Posted August 17, 2008 Hello everyone, This is my first post in here What a great forum. I'v been looking online everywhere for any tips or help, basically I have a script which will scan given location (folder or drive). And makes listing, just like regular "index of" type. Is there any command or way to detect "image sequence/order" within files?! To detect if given files have any mathematical formation/order in filenames. Say I have directory: flower001.jpg flower002.jpg flower003.jpg house1.jpg house2.jpg house5.jpg house6.jpg house7.jpg footage__000100.jpg footage__000101.jpg footage__000102.jpg footage__000103.jpg footage2___000432.jpg footage2___000433.jpg footage2___000434.jpg footage2___000435.jpg footage2___000436.jpg What function/command would you use to be listed/detected as following (sample format could be anything different): Image Sequences flower001-003 ----- 3 images house1-2 ---- 2 images house5-7 ---- 3 images footage__000100-footage__000103 ---- 4 images footage2___000432-footage2___000436 ----- 5 images Is this has to do with NATURAL order and sorting?! Thank you for any tips or help. take care, ciril Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/ Share on other sites More sharing options...
ratcateme Posted August 17, 2008 Share Posted August 17, 2008 to my knowledge you would have to write tour own function. have a look at glob() and readdir() Scott. Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618284 Share on other sites More sharing options...
Fadion Posted August 17, 2008 Share Posted August 17, 2008 I gave this a try, but couldn't find a way of organizing the data. Surely one can get the files in an array with glob(), parse the data in a new array to remove numbers (to let only flower, flower, house, house, ...) and find the unique values with array_unique. But that's as far as I can reach. Basically, if the files are of the format "image_1, image_2, flower_1, flower_2", i have this: <?php $files = array(); $unique = array(); foreach(glob("*.jpg") as $file){ $files[] = $file; $unique[] = substr($file, 0, strrpos($file, '_')); } $unique = array_unique($unique); print_r($unique); ?> The $unique array hold the unique values with their keys (ie. [ 0 ]=>"flower", [ 3 ]=>"house") but I can't find a way go through all $files values, from a $unique key to another. Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618291 Share on other sites More sharing options...
ratcateme Posted August 17, 2008 Share Posted August 17, 2008 you could go through $unique and run another glob() but i don't know how to get it to output the numbers of each file Scott. Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618296 Share on other sites More sharing options...
ciril Posted August 17, 2008 Author Share Posted August 17, 2008 Thank you guys for such QUICK response and sharing your experience scott, ratcateme & GuiltyGear, I already love this forum. I'm building software which is for visual effects (free for all package) and in most vfx applications (such as Fusion, Shake, Nuke), we have what they call "File Sequence". PHP will be the main backbone engine for all SQLite (great advantage here - single file etc. no install) operations. You gather image sequence, and it loads onto timeline. If there is any "missing frame" say you have order: 143,144,145,146,152,153,154 - it will know that 152 is new sequence since next higher number is missing from 146 (as last frame). Readir it's already in use and others like scanf, and fopen. Binary EXE (PHP is the heart) --- gives extreme performance. Thank you for writing sample code - GuiltyGear. I will look more into it, when solution come I will post code here. best, c Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618297 Share on other sites More sharing options...
Fadion Posted August 17, 2008 Share Posted August 17, 2008 you could go through $unique and run another glob() but i don't know how to get it to output the numbers of each file It can work and I though about that, but me neither don't know how to group the files. @ciril. I understand what you want to achieve. Flash (and many similar apps) have the option of sequence importing by selecting one file of the sequence. If thats your case, you can use the code i provided in a reduced form. I'm not sure how are you going to let the user select the file sequence (by uploading all the files and selecting one, by giving them a predefined library?) so this may not work in your case, but let give this a try: <?php $initial = 'flower_001'; $initial = substr($initial, 0, strrpos($initial, '_')); $files = array(); foreach(glob($initial , "*.jpg") as $file){ $files[] = $file; } print_r($files); //should give you: flower_001, flower_002, flower_003 ?> Surely you can improve the code by adding a regex to get the common filename without numbers, but that shouldn't be difficult. This will work if you let the user specify an initial file foor the sequence ($initial) and sort them even if a sequence file is missing. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618307 Share on other sites More sharing options...
ciril Posted August 17, 2008 Author Share Posted August 17, 2008 Hey GuiltyGear, Thanks your involvement into this. Users/Artists will do regular Windows base "Browse..." for TARGET either hard drive (as entire C:, D: Z: etc) or specified folder(s). PHP code will search and list image sequences from entire source/TARGET for their shots/image sequences. Read curcial info, resoltuion, bit depth, format info, uncompressed data etc. (tiff, dpx, tga, JPG is not really used in effects). Will also make thumbs from from, say split sequence into 3 frame grabs etc. Best, c Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618313 Share on other sites More sharing options...
ciril Posted August 17, 2008 Author Share Posted August 17, 2008 check your email GuiltyGear Link to comment https://forums.phpfreaks.com/topic/120016-image-sequences-detecting-scanning-file-orderpatterns/#findComment-618317 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.