code: def resize_compute_width_height(fullfile,_megapixels):
      
  
      img = Image.open(fullfile)
      width,height=img.size
  
      current_megapixels=width*height/(2.0**20)
      scale=sqrt(_megapixels/float(current_megapixels))
  
      logger.debug('A resize scale would be %f'%(scale))
      # Can't make bigger, return original
      if scale>= 1.0:
          logger.warning('Image is %0.1f MP, trying to scale to %0.1f MP - just using original!',
                  current_megapixels,_megapixels);
          return width,height
  
      new_width=int(width*scale)
      new_height=int(height*scale)
  
      return new_width,new_height
docs: Given image file and desired megapixels,
      computes the new width and height