SyntaxHighlighter

Tuesday 23 July 2013

Day 32: GUIs and exporting, Animation13 web gallery

Batch Photo Processing - sed and imagemagick

Got my CS password reset and now I can successfully get into babbage.

Image magick has a tool called mogrify which is used to batch convert images, but I simply hacked together a shell script or two to get the job done with the renames and everything in tow.

This is the basis:

for infile in *; do
outfile=$(echo $infile | sed -n 's/\./.preview./p');
test -z $outfile && continue;
convert $infile -strip -density 72 -thumbnail 300x300^ -gravity center -extent 300x300 $outfile;
done

Which took all the images called img_xxxx.jpg and made previews according to the required specification. A similar command was run before this to turn the raw images into suitable main images of dpi 72 and resolution 1200 by whatever proportional y value.


And then back to automating ExportJPEGs

Coding and GUIs

So the plan for the GUIs is to have 2 sliders, one to control the vertical height of the model and the other to control its size. There will also be a checkbox to flip the head upside down (because some heads are simply upside down).

All done, and it works nicely!

Easiest to use JPEG exporter on the market!


Now I need to manage loading content into the program, so let's do a bit of thinking..

I know I can build XNB files outside of the program. I can manually press a key (or a button on the GUI) to load the newly built files in and display them in the GUI once they have been built (so the user can export JPEGs). I wonder if this can be automated..

Found that you can watch a directory for file changes using a FileSystemWatcher, details here: http://www.codeproject.com/Articles/26528/C-Application-to-Watch-a-File-or-Directory-using-F

So perhaps I can implement a system that monitors for files and displays them in a drop down list on the GUI? And when a new head model arrives the user can click the head in the drop down list, and the program will build it, load it so the user can export jpegs, and send it to the lowry demo program.

This will completely remove the need for shell scripting to manage and move files about, but we will still use shell scripts to monitor the web server and grab files, and to make and upload gifs after JPEGs have been exported.

Now the final step if I do implement this would be to tell LowryDemo to load the next head once the head is available. Again, this can presumably be done with the FileSystemWatcher - watch the content directory for new .xnb files coming in, when they do come in then load them and add to the head model set.

FileSystemWatcher... what an utterly fantastically useful tool!

The answer has been comprehended

And now I've discovered you can run bash shell scripts from Visual Studio C# applications (actually you can run them from an MS Dos batch file (.bat), and you can run such batch scripts from C# programs). So in other words I can automate the system so that all the user has to do is to run this exportJPEGs program, and the program will automatically do just about everything:
  1. run LowryDemo
  2. run the lftp monitoring client to grab new heads from the central file server
  3. fix the model and texture files, rename them etc
  4. build them
  5. have LowryDemo automatically sense newly built files, load them and add them to the AR program
  6. load the files into this ExportJPEGS program, display them in the GUI for the user to set the view etc
  7. Let the user click the export button, which will and that will not only export JPEGs but also convert them into a gif AND upload the gif to the web server.
So, now let's see if I can get all the parts of this to work together nicely.

Automation tasklist:
  • Get FileSystemWatcher working in ExportJPEGs (return event when file added)
  • Implement ExportJPEGs to do everything up to the uploading of the gif, when user clicks export button
  • Implement ExportJPEGs to automatically run lftp monitor upon starting
  • Implement ExportJPEGs to fix model and rename regex inside fbx files when file is added to watch directory
  • Implement ExportJPEGs to automatically build models after the files are ready
  • Get FileSystemWatcher working in LowryDemo, load new head after content is built, manage model sets etc

No comments:

Post a Comment

Note: only a member of this blog may post a comment.