BetaRide gave you some good links and generic suggestions already, here's some code to help you get a quicker start:
function mymodule_node_presave($node) {
//drupal_set_message('<pre>'.var_export($node, TRUE).'</pre>');
if (!isset($node->field_pic['und'][0]) && isset($node->field_file['und'][0]['fid'])) {
$result = db_query("SELECT filename, uri, filemime FROM {file_managed} WHERE fid = :fid",
array(':fid' => $node->field_file['und'][0]['fid']));
$record = $result->fetchObject();
if ($record->filemime == 'audio/mpeg' && pathinfo($record->filename, PATHINFO_EXTENSION) == 'mp3') {
// TODO - create the picture, save in the temporary files folder and return the filename.
$filename = 'created_image.png';
$image = file_get_contents('sites/default/files/tmp/'.$filename);
// public://pics/ -> sites/default/files/pics
$file = file_save_data($image, 'public://pics/'.$filename, FILE_EXISTS_RENAME);
drupal_unlink('sites/default/files/tmp/'.$filename);
$node->field_pic['und'][0] = (array) $file;
}
}
}
This script should work when you have created a content type with 'field_file' and 'field_pic' that both allow 1 entry. First one should accept at least mp3 files and the second png images your linked script will create. The function/hook gets called before saving a node. If there is no image present in the image field and a mp3 file is present in the other you should use the script to create the image and return it's filename. After that a copy of the file from 'sites/default/files/tmp/' gets created into 'sites/default/files/pics' (possible name conflicts are taken care of). Then the temporary file gets deleted and the image info attached to the node. As you might have guessed 'sites/default/files' and it's subfolders should be used to store public files on Drupal sites. You should also make sure 'field_pic' file directory (set up via the GUI) matches with the one used in the code.