Resizing existing images

See all posts Reply

Resizing existing images new!
by Mack, 14 years, 9 months ago
What I am trying to do I know the class wasn't designed for. I want to resize an image that already exist on our server and replace it with no renaming. I tried a lot of different combinations but it just doesn't want to work.

The code below is bad, but as it stands now, it keeps throwing me an error looking for the tmp file to unlink.
while($rowgames = $querygames->fetchRow()){
  $handle = new upload(GAMEPATH.stripslashes($rowgames['gimage']));
  $handle->no_upload_check;
  if($handle->uploaded){
    $handle->file_new_name_body   = str_replace('.png', '', stripslashes($rowgames['gimage']));
    $handle->image_resize         = true;
    $handle->image_x              = GAMESIZEWIDTH;
    $handle->image_ratio_y        = true;
    $handle->image_y              = GAMESIZEHEIGHT;
    $handle->image_ratio_x        = true;
    $handle->image_convert = 'png';
    $handle->process(GAMEPATH);
    if ($handle->processed) {
      $querygames2 = "UPDATE ".TABLE_GAMES." SET gimage = ".$mdb->escape($handle->file_dst_name)." WHERE cgid = '".intval($rowgames['cgid'])."'";
      $mdb->exec($querygames2);
      $handle->clean();
      //unlink(GAMEPATH.stripslashes($rowgames['gimage']));
    }
  } else {
    echo 'error : ' . $handle->error .'';
    echo $rowgames['gimage'];
    die();
  }
  $handle->clean();
}
Reply
Re: Resizing existing images new!
by Mack, 14 years, 9 months ago
I figured it out thanks to the docs page. clean() is what actually does the unlinking. That will not be needed in this case.Reply