Scaling images on upload
There's no need to scale your images when you upload them, the usual method is to serve a cached version of the scaled image when it's displayed. This is usually accomplished by setting up an image style in the Drupal admin UI that has the effects you need, and then using theme_image_style() to output that image:

$file = file_load($fid);
$options = array(
  'style_name' =&gt; 'image-style-machine-name',
  'alt' =&gt; 'Alternative Text',
  'path' =&gt; $file-&gt;uri
);

$image_output = theme('image_style', $options);


Doing it this way gives the added benefit of your having the original uploaded file available at any time (for example to link through to as a full-sized version of an image, or in a lightbox, etc.)