// ========================================================================== // http://www.tjgalda.com // // Copyright (C) 2007 TJ Galda. All rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to TJ Galda which is protected by U.S. and // Canadian federal copyright law and by international treaties. // // The Data is provided for use exclusively by You. You have the right // to use, modify, and incorporate this Data into other products for // purposes authorized by TJ Galda, without fee. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the // following disclaimer, must be included in all copies of the // Software, in whole or in part, and all derivative works of // the Software, unless such copies or derivative works are solely // in the form of machine-executable object code generated by a // source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // TJ GALDA DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR // PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR // TRADE PRACTICE. IN NO EVENT WILL TJ GALDA AND/OR ITS LICENSORS // BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF TJ GALDA // AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY // OR PROBABILITY OF SUCH DAMAGES. // // http://www.tjgalda.com // ========================================================================== // // TJ Galda Script File // MODIFY THIS AT YOUR OWN RISK // // Creation Date: tj, May 15, 2007 // // Procedure Name: // tj_imageViewer.mel // // Good stuff: // *****- launches fcheck regardless of padding // *****- can change frame rates // - can shrink/magnify images // - full fcheck interface // - built for windows // - type in path for pictures // - takes start frame", "end frame", "stepping and file extension // - deduces the number of frames in sequence, assuming the sequence starts on frame 1 // // // Input Arguments: // None // // Return Value: // None. // // http://www.tjgalda.com // ========================================================================== // Good stuff: // *****- launches fcheck regardless of padding // *****- can change frame rates // - can shrink/magnify images // - full fcheck interface // - built for windows // - type in path for pictures // - takes start frame", "end frame", "stepping and file extension // - deduces the number of frames in sequence, assuming the sequence starts on frame 1 //////////////////////////////////////// global proc tj_imageViewer() { //default locations string $label_default_fcheck_dir = "C:\\aw\\maya8.5\\bin\\"; string $label_default_images_dir = "P:\\test\\images\\"; ////////////////// // start window ////////////////// if ( `window -exists TJ_ImageViewer` ) deleteUI -window TJ_ImageViewer; window -widthHeight 400 100 -title "TJ_ImageViewer" -in "TJ_ImageViewer" -rtf true -mxb false -s true TJ_ImageViewer; ////////////////// // window interface ////////////////// columnLayout; text -label " Written to support .####. naming conventions, handling any number of padding"; text -label ""; textFieldGrp -label "Explicit Fcheck Directory" -fileName $label_default_fcheck_dir tj_fcheck_dir; textFieldGrp -label "Explicit Images Directory" -fileName $label_default_images_dir -cc "tj_img_UpdateWindow" tj_images_dir; text -label "Directories must have trailing slash (e.g. P:\\images\\)"; textFieldGrp -label "Image Name" -text "head_test" -cc "tj_img_UpdateWindow" tj_image_name; //pull down for image type //Supports: yuv", "als", "gif", "bw", "pic", "tga", "tif", "tiff", "vst", "rla // "jpg", "cin", "iff", "pxb", "scn", "ppm,", "pri", "qtl", "rgb", "sgi", string $ext_supported[] = {"als", "cin", "gif", "iff", "jpg", "pic", "ppm", "pri", "pxb", "qtl", "rgb", "rla", "scn", "sgi", "tga", "tif", "tiff", "vst", "yuv", "bw"}; string $tj_imageTypeOptionM = `optionMenu -label "File Type" -cc "tj_img_UpdateWindow" tj_imageTypeOptionM`; for ($itemSupported in $ext_supported) { menuItem -label $itemSupported $tj_imageTypeOptionM; } optionMenu -e -v "rgb" $tj_imageTypeOptionM; intFieldGrp -label "Frame Padding" -v1 4 -cc "tj_img_UpdateWindow" tj_frame_padding; string $label_tj_images_dir = `textFieldGrp -q -tx tj_images_dir`; text -label ""; string $button_text = "Browse " + $label_tj_images_dir + " Directory"; button -label $button_text -command "tj_img_viewDirectoryory" view_dir_button; text -label ("") view_dir_text; text -label ""; textFieldGrp -label "Start Frame" -text "1" tj_start_frame; textFieldGrp -label "End Frame" -text "180" tj_end_frame; textFieldGrp -label "Stepping" -text "1" tj_stepping; floatFieldGrp -label "Image Shrinkage Factor" -v1 1 -cc "tj_img_UpdateWindow" tj_shrink; floatFieldGrp -label "Image Magnification Factor" -v1 1 -cc "tj_img_UpdateWindow" tj_mag; text -label "Factor values is forced to be 1 or more, 1 will leave image size alone."; textFieldGrp -label "Frames Per Second" -text "30" tj_fps; button -label "View Images" -command "tj_img_viewImages" fcheck_button; ////////////////// // Show window ////////////////// showWindow TJ_ImageViewer; } //-------Window.Done----------------------------------------------------------- global proc tj_img_UpdateWindow() { print "\n"; //////////////// // Get UI values //////////////// string $label_tj_fcheck_dir = `textFieldGrp -q -tx tj_fcheck_dir`; string $label_tj_images_dir = `textFieldGrp -q -tx tj_images_dir`; string $label_tj_image_name = `textFieldGrp -q -tx tj_image_name`; string $label_tj_extension = `optionMenu -q -v "tj_imageTypeOptionM"`; string $label_start_frame = `textFieldGrp -q -tx tj_start_frame`; string $label_end_frame = `textFieldGrp -q -tx tj_end_frame`; string $label_stepping = `textFieldGrp -q -tx tj_stepping`; string $label_tj_fps = `textFieldGrp -q -tx tj_fps`; string $label_tj_images_dir = `textFieldGrp -q -tx tj_images_dir`; string $button_text = "Browse " + $label_tj_images_dir + " Directory"; button -edit -label $button_text view_dir_button; string $fcheck_button_text = ("View " + $label_tj_images_dir + $label_tj_image_name + ".#." + $label_tj_extension); button -edit -label $fcheck_button_text fcheck_button; string $label_tj_shrink = ""; string $label_tj_mag = ""; float $shrink_check[] = `floatFieldGrp -q -v tj_shrink`; if ($shrink_check[0] < 1) { $shrink_check[0] = 1; floatFieldGrp -e -v1 1 tj_shrink; $label_tj_shrink = 1; } else { $label_tj_shrink = $shrink_check[0]; } float $mag_check[] = `floatFieldGrp -q -v tj_mag`; if ($mag_check[0] < 1) { $mag_check[0] = 1; floatFieldGrp -e -v1 1 tj_mag; $label_tj_mag = 1; } else { $label_tj_mag = $mag_check[0]; } int $pad_check = `intFieldGrp -q -v1 tj_frame_padding`; if ($pad_check < 1 || $pad_check > 4) { warning "Frame padding must be between 1 and 4, resetting to 4 as default"; intFieldGrp -e -v1 4 tj_frame_padding; } } //-------Update.Done----------------------------------------------------------- ////////////////// // View Directory ////////////////// global proc tj_img_viewDirectoryory() { //////////////// // Get UI values //////////////// string $label_tj_images_dir = `textFieldGrp -q -tx tj_images_dir`; string $label_tj_extension = `optionMenu -q -v "tj_imageTypeOptionM"`; string $label_tj_image_name = `textFieldGrp -q -tx tj_image_name`; //////////////// // open file dialog //////////////// string $file_dialog_return = ""; string $file_dialog_return = `fileDialog -directoryMask ($label_tj_images_dir + "*." + $label_tj_extension)`; //////////////// // get just directory //////////////// //gives full path and filename string $ntPath = $file_dialog_return; print "\nUser browsed for and chose this file: "; print $ntPath; //comes back without trailing slash string $returned_directory_string = `dirname( $ntPath )`; //////////////// // strip off numbers and extension //////////////// //check for cancel,if canceled out, ignore update proc if (`size($file_dialog_return)` != 0) { string $directory_and_image_name; $imageDir = $ntPath; for ( $i = size($file_dialog_return); $i > 0 ; $i -= 1 ) { if ( "." == `substring $file_dialog_return $i $i` ) { $directory_and_image_name = `substring $file_dialog_return 1 ($i - 1)`; } } ///////////////// // get just image name using directory name's length ///////////////// int $directory_length = 0; int $dir_length = 0; int $dir_and_image_length = 0; int $dir_and_image_length = `size($directory_and_image_name)`; int $dir_length = `size($returned_directory_string)`; string $returned_image_name = `substring $directory_and_image_name ($dir_length + 2) $dir_and_image_length`; ///////////////// //get image extension and check if supported ///////////////// string $buffer[]; int $numTokens = `tokenize $ntPath "." $buffer`; string $returned_extension = $buffer[2]; string $ext_supported[] = { "yuv", "als", "gif", "jpg", "cin", "iff", "pxb", "scn", "ppm", "pri", "qtl", "rgb", "sgi", "bw", "pic", "tga", "tif", "tiff", "vst", "rla"}; int $flag_extGood = 0; for ($itemSupported in $ext_supported) { if ($itemSupported == $returned_extension) { $flag_extGood = 1; } } //if the extension is supported by fcheck, update the window, otherwise return a warning if ($flag_extGood == 1) { $label_tj_extension = $returned_extension; optionMenu -e -v $returned_extension "tj_imageTypeOptionM"; } else { warning ("Browsed File extension is not supported by FCheck: ["+$returned_extension+"] type is not supported"); } //use tokens to find padding int $found_padding = 4; string $frame_number_returned = $buffer[1]; int $length_pad_returned = `size ($frame_number_returned)`; //default is 4, so avoid if already 4 if ($length_pad_returned != 4) { string $check_for_zero_start = `substring $frame_number_returned 1 1`; if ($check_for_zero_start == "0" && $length_pad_returned == 3) { //3 padding $found_padding = 3; } if ($check_for_zero_start == "0" && $length_pad_returned == 2) { //2 padding $found_padding = 2; } else { //must be 1 pad $found_padding = 1; } } ///////////////// // get number of images ///////////////// //must convert pathing for system call for dir // from P:/example/example/file.0001.sgi // to P:\example\example\file.0001.sgi string $buffer[]; int $numTokens = `tokenize $ntPath "/" $buffer`; string $rebuilt_path = $buffer[0]; $numTokens = $numTokens - 2; for ($i = 1; $i <= $numTokens; $i++) { $rebuilt_path = ($rebuilt_path+"\\"+$buffer[$i]); } string $returned_image_list = ""; $returned_image_list = `system("dir "+$rebuilt_path+"\\"+$returned_image_name+".*."+$label_tj_extension+" /B /ON")`; //size will be image name+.+####+.+ext+ // or directory and image - $dir_length + 1 int $ntPath_length = `size($ntPath)`; int $dos_feedback_size = `size($returned_image_list)`; int $number_of_files_found = ($ntPath_length - $dir_length + 1); $number_of_files_found = $dos_feedback_size / $number_of_files_found ; if ($number_of_files_found != 0) { ////////feedback print "\n\n\n Call to windows, found the following files:\n======================\n"; print ("dir "+$rebuilt_path+"\\"+$returned_image_name+".*."+$label_tj_extension+" /B /ON"); print "\n======= start list ===============\n"; print $returned_image_list; print "\n========end of list ==============\n"; print "\nNumber of frames found: = "; print $number_of_files_found; textFieldGrp -edit -text $number_of_files_found tj_end_frame; } //////////////// // use returned values //////////////// string $button_text = ("Browse " + $returned_directory_string + "/ Directory"); string $fcheck_button_text = ("VIEW " + $returned_directory_string + "/" + $returned_image_name + ".#." + $label_tj_extension); //make big and green button -edit -label $fcheck_button_text -h 30 -bgc 0.5 0.8 0.5 fcheck_button; button -edit -label $button_text view_dir_button; text -edit -label ("NOTE: Double check directory and image names, type in manually if incorrect.") view_dir_text ; string $tj_images_dir = ($returned_directory_string + "/"); textFieldGrp -edit -fileName $tj_images_dir tj_images_dir; textFieldGrp -edit -fileName $returned_image_name tj_image_name; intFieldGrp -e -v1 $found_padding tj_frame_padding; } } //-------View.Directory.Done----------------------------------------------------- //////////////// // Start Fcheck //////////////// global proc tj_img_viewImages(){ //////////////// // Get UI values //////////////// string $label_tj_fcheck_dir = `textFieldGrp -q -tx tj_fcheck_dir`; string $label_tj_images_dir = `textFieldGrp -q -tx tj_images_dir`; string $label_tj_image_name = `textFieldGrp -q -tx tj_image_name`; string $label_tj_extension = `optionMenu -q -v "tj_imageTypeOptionM"`; string $label_start_frame = `textFieldGrp -q -tx tj_start_frame`; string $label_end_frame = `textFieldGrp -q -tx tj_end_frame`; string $label_stepping = `textFieldGrp -q -tx tj_stepping`; int $label_frame_padding = `intFieldGrp -q -v1 tj_frame_padding`; string $label_tj_shrink = ""; string $label_tj_mag = ""; float $shrink_check[] = `floatFieldGrp -q -v tj_shrink`; if ($shrink_check[0] < 1) { $shrink_check[0] = 1; floatFieldGrp -e -v1 1 tj_shrink; $label_tj_shrink = 1; } else { $label_tj_shrink = $shrink_check[0]; } float $mag_check[] = `floatFieldGrp -q -v tj_mag`; if ($mag_check[0] < 1) { $mag_check[0] = 1; floatFieldGrp -e -v1 1 tj_mag; $label_tj_mag = 1; } else { $label_tj_mag = $mag_check[0]; } string $label_tj_fps = `textFieldGrp -q -tx tj_fps`; ///////////////// //build padding call for fcheck naming convention ///////////////// string $frame_padd_system = "#"; if ($label_frame_padding == 1) { $frame_padd_system = "@"; } else if ($label_frame_padding == 2) { $frame_padd_system = "@@"; } else { $frame_padd_system = "@@@"; } ///////////////// //execute command ///////////////// system("start " + $label_tj_fcheck_dir + "fcheck.exe " + "-s " + $label_tj_shrink + " -m " + $label_tj_mag + " -r " + $label_tj_fps + " -n " + $label_start_frame + " " + $label_end_frame + " " + $label_stepping + " " + $label_tj_images_dir + $label_tj_image_name + "."+$frame_padd_system+"." + $label_tj_extension); } //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------