Index: audio_getid3.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_getid3.module,v
retrieving revision 1.33
diff -u -p -u -r1.33 audio_getid3.module
--- audio_getid3.module	5 Aug 2007 23:57:40 -0000	1.33
+++ audio_getid3.module	22 Aug 2007 00:01:38 -0000
@@ -399,7 +399,7 @@ function audio_write_id3tags($filepath, 
       'data' => file_get_contents($image['filepath']),
       'picturetypeid' => $image['pictype'],
       'description' => audio_image_type_dirty_array($image['pictype']),
-      'mime' => $image['filemime'],
+      'mime' => $image['mime_type'],
     );
   }
 
Index: audio_image.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_image.inc,v
retrieving revision 1.8
diff -u -p -u -r1.8 audio_image.inc
--- audio_image.inc	22 Aug 2007 02:53:53 -0000	1.8
+++ audio_image.inc	22 Aug 2007 02:54:11 -0000
@@ -92,32 +92,30 @@ function audio_image_type_dirty_array($i
  */
 function audio_image_from_file($filepath, $pictype) {
   if ($image = image_get_info($filepath)) {
+    $changed = FALSE;
+
     // Crop to a square.
     $size = min($image['width'], $image['height']);
     if ($image['width'] != $image['height']) {
-      image_crop($filepath, $filepath, 0, 0, $size, $size);
+      $changed |= image_crop($filepath, $filepath, 0, 0, $size, $size);
     }
 
     // Resize to the maximum dimension.
     $maxsize = variable_get('audio_image_size', 170);
     if ($size > $maxsize) {
-      image_resize($filepath, $filepath, $maxsize, $maxsize);
-      $size = $maxsize;
+      $changed |= image_resize($filepath, $filepath, $maxsize, $maxsize);
+    }
+
+    if ($changed) {
+      // Changing the image dimensions will affect the file size. Clear out
+      // PHP's cached value so we can find the new size.
+      clearstatcache();
+      $image = image_get_info($filepath);
     }
 
-    // Changing the image dimensions will affect the file size. Clear out
-    // PHP's cached value so we can find the new size.
-    clearstatcache();
-
-    return array(
-      'pictype'   => $pictype,
-      'filepath'  => $filepath,
-      'filemime'  => $image['mime_type'],
-      'filesize'  => filesize($filepath),
-      'extension' => $image['extension'],
-      'width'     => $size,
-      'height'    => $size,
-    );
+    // Add in our addition information.
+    $additions = array('pictype' => $pictype, 'filepath' => $filepath);
+    return array_merge($image, $additions);
   }
   return FALSE;
 }
Index: audio_images.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_images.install,v
retrieving revision 1.6
diff -u -p -u -r1.6 audio_images.install
--- audio_images.install	7 Mar 2007 23:52:01 -0000	1.6
+++ audio_images.install	21 Aug 2007 23:29:03 -0000
@@ -8,38 +8,30 @@ function audio_images_install() {
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-      db_query("
-        CREATE TABLE {audio_image} (
+      db_query("CREATE TABLE {audio_image} (
           `pid` int(10) NOT NULL default '0',
           `nid` int(10) unsigned NOT NULL default '0',
           `vid` int(10) unsigned NOT NULL default '0',
           `pictype` tinyint(2) unsigned NOT NULL default '0',
-          `width` smallint(6) unsigned NOT NULL default '0',
-          `height` smallint(6) unsigned NOT NULL default '0',
-          `filemime` varchar(20) NOT NULL default '',
           `filepath` varchar(255) NOT NULL default '',
-          `filesize` int(10) unsigned NOT NULL default '0',
           PRIMARY KEY  (`pid`),
+          KEY `audio_image_nid` (`nid`),
           KEY `audio_image_vid_pictype` (`vid`,`pictype`)
         ) /*!40100 DEFAULT CHARACTER SET utf8 */;
       ");
       break;
     case 'pgsql':
-      db_query("
-        CREATE TABLE {audio_image} (
+      db_query("CREATE TABLE {audio_image} (
           pid INTEGER PRIMARY KEY,
           nid INTEGER NOT NULL DEFAULT 0,
           vid INTEGER NOT NULL DEFAULT 0,
           pictype INTEGER NOT NULL DEFAULT 0,
-          width INTEGER NOT NULL DEFAULT 0,
-          height INTEGER NOT NULL DEFAULT 0,
-          filemime VARCHAR(20) NOT NULL DEFAULT '',
-          filepath VARCHAR(255) NOT NULL DEFAULT '',
-          filesize INTEGER NOT NULL DEFAULT 0
-        );
-        CREATE INDEX audio_image_vid_pictype_index ON {audio_image} (vid, pictype);
-        CREATE SEQUENCE audio_image_pid_seq;
-      ");
+          filepath VARCHAR(255) NOT NULL DEFAULT ''
+        );"
+      );
+      db_query("CREATE INDEX {audio_image}_nid_index ON {audio_image} (nid);");
+      db_query("CREATE INDEX {audio_image}_vid_pictype_index ON {audio_image} (vid, pictype);");
+      db_query("CREATE SEQUENCE {audio_image}_pid_seq;");
   }
 }
 
@@ -86,4 +78,27 @@ function audio_images_update_2() {
       break;
   }
   return $ret;
-}
\ No newline at end of file
+}
+
+/**
+ * Simplify the {audio_image} table.
+ */
+function audio_images_update_5200() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("ALTER TABLE {audio_image}
+        DROP COLUMN `width`,
+        DROP COLUMN `height`,
+        DROP COLUMN `filemime`,
+        DROP COLUMN `filesize`;
+      ");
+      $ret[] = update_sql("ALTER TABLE {audio_image}
+        ADD KEY audio_image_nid (`nid`);
+      ");
+      break;
+  }
+  return $ret;
+}
+
Index: audio_images.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/audio_images.module,v
retrieving revision 1.21
diff -u -p -u -r1.21 audio_images.module
--- audio_images.module	21 Aug 2007 23:17:58 -0000	1.21
+++ audio_images.module	22 Aug 2007 00:19:34 -0000
@@ -59,16 +59,16 @@ function audio_images_form_alter($form_i
       '#description' => t('Cover art or other images.'),
       '#weight' => 0,
       '#tree' => TRUE,
+      '#theme' => 'audio_images_form',
     );
 
     if ($node->audio_images) {
-      $form['audio_images']['#theme'] = 'audio_images_form';
       foreach ((array)$node->audio_images as $pid => $image) {
         $form['audio_images'][$pid]['pid'] = array('#type' => 'value', '#value' => $pid);
         $form['audio_images'][$pid]['pictype'] = array('#type' => 'value', '#value' => $image['pictype']);
         $form['audio_images'][$pid]['filepath'] = array('#type' => 'value', '#value' => $image['filepath']);
-        $form['audio_images'][$pid]['filemime'] = array('#type' => 'value', '#value' => $image['filemime']);
-        $form['audio_images'][$pid]['filesize'] = array('#type' => 'value', '#value' => $image['filesize']);
+        $form['audio_images'][$pid]['mime_type'] = array('#type' => 'value', '#value' => $image['mime_type']);
+        $form['audio_images'][$pid]['file_size'] = array('#type' => 'value', '#value' => $image['file_size']);
         $form['audio_images'][$pid]['height'] = array('#type' => 'value', '#value' => $image['height']);
         $form['audio_images'][$pid]['width'] = array('#type' => 'value', '#value' => $image['width']);
         $form['audio_images'][$pid]['delete'] = array('#type' => 'checkbox', '#default_value' => $image['delete']);
@@ -95,19 +95,21 @@ function audio_images_form_alter($form_i
  */
 function theme_audio_images_form(&$form) {
   $pictypes = audio_image_type_dirty_array();
+
+  $header = array(t('Type'), t('MIME Type'), t('Dimensions'), t('Size'), t('Delete'));
   $rows = array();
   foreach (element_children($form) as $pid) {
     if ($pid != 'new') {
       $rows[] = array(
         l($pictypes[$form[$pid]['pictype']['#value']], $form[$pid]['filepath']['#value']),
-        $form[$pid]['filemime']['#value'],
+        $form[$pid]['mime_type']['#value'],
         $form[$pid]['height']['#value'] .'x'. $form[$pid]['width']['#value'],
-        $form[$pid]['filesize']['#value'],
+        $form[$pid]['file_size']['#value'],
         drupal_render($form[$pid]['delete']),
       );
     }
   }
-  $header = array(t('Type'), t('MIME Type'), t('Dimensions'), t('Size'), t('Delete'));
+
   return theme('table', $header, $rows) . drupal_render($form);
 }
 
@@ -118,9 +120,11 @@ function audio_images_audio($op, &$node)
   switch ($op) {
     case 'load':
       $ret['audio_images'] = array();
-      $result = db_query("SELECT pid, pictype, filemime, width, height, filepath, filesize FROM {audio_image} WHERE vid=%d", $node->vid);
-      while ($img = db_fetch_array($result)) {
-        $ret['audio_images'][$img['pid']] = $img;
+      $result = db_query("SELECT pid, pictype, filepath FROM {audio_image} WHERE vid = %d", $node->vid);
+      while ($row = db_fetch_array($result)) {
+        if ($info = image_get_info($row['filepath'])) {
+          $ret['audio_images'][$row['pid']] = array_merge($info, $row);
+        }
       }
       return $ret;
 
@@ -139,6 +143,7 @@ function audio_images_audio($op, &$node)
         $imagepath = _audio_image_filename(basename($node->audio_file->filename), $upload->filemime, $pictype, TRUE);
         if ($file = file_save_upload($upload, $imagepath, FILE_EXISTS_REPLACE)) {
           if ($image = audio_image_from_file($file->filepath, $pictype)) {
+var_dump($image);
             $pid = 'new_'. count($_SESSION['audio_images']);
             $image['pid'] = $pid;
             $node->audio_images[$pid] = $image;
@@ -260,17 +265,16 @@ function _audio_images_save_new(&$node, 
 /**
  * Save an image to the audio_image table and copies it to the audio/images
  * directory.
- * 
+ *
  * The caller needs to delete original image file if it was a temporary.
  */
 function _audio_images_save_copy(&$node, $image) {
-  $newpath = _audio_image_filename($node->vid, $image['filemime'], $image['pictype'], FALSE);
+  $newpath = _audio_image_filename($node->vid, $image['file_mime'], $image['pictype'], FALSE);
   if (file_copy($image['filepath'], $newpath, FILE_EXISTS_REPLACE)) {
     $pid = db_next_id('{audio_image}_pid');
-    db_query("INSERT INTO {audio_image} (pid, nid, vid, pictype, filemime, width, height, filepath, filesize)
-      VALUES (%d, %d, %d, %d, '%s', %d, %d, '%s', %d)",
-      $pid, $node->nid, $node->vid, $image['pictype'], $image['filemime'],
-      $image['width'], $image['height'], $newpath, filesize($newpath));
+    db_query("INSERT INTO {audio_image} (pid, nid, vid, pictype, filepath)
+      VALUES (%d, %d, %d, %d, '%s')",
+      $pid, $node->nid, $node->vid, $image['pictype'], $newpath);
 
     $image['filepath'] = $newpath;
     $image['pid'] = $pid;

