View source  
  <?php
function imagefield_crop_schema() {
  $schema['imagefield_crop'] = array(
    'fields' => array(
      'fid' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'x' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => FALSE,
      ),
      'y' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => FALSE,
      ),
      'width' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => FALSE,
      ),
      'height' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'fid',
    ),
  );
  return $schema;
}
function imagefield_crop_update_7001() {
  if (!db_table_exists('imagefield_crop')) {
    drupal_install_schema('imagefield_crop');
  }
  
  $crop_info = variable_get('imagefield_crop_info', array());
  if (!empty($crop_info)) {
    $txn = db_transaction();
    
    $chunks = array_chunk($crop_info, 100, TRUE);
    foreach ($chunks as $insert_data) {
      $insert = db_insert('imagefield_crop')
        ->fields(array(
        'fid',
        'x',
        'y',
        'width',
        'height',
      ));
      foreach ($insert_data as $fid => $values) {
        $values['fid'] = $fid;
        $insert
          ->values($values);
      }
      $insert
        ->execute();
    }
  }
  
  variable_del('imagefield_crop_info');
}