title: Scaling an Image - Maintaining the position - Pillow
body: <p>Folks, I'm trying to scale an image both Shrink it and expand it, but maintain it's position in the image. Let me explain. Given an image below:
  <img src="https://i.imgur.com/YDcJMA1.png" alt="Image">, I need to scale it but maintain the position.</p>
  
  <p>I'm using the below code to do it, but it's not preserving the position. Any ideas?</p>
  
  <pre><code>from PIL import Image, ImageChops, ImageOps,ImageStat, ImageFilter
  def scaling_thumbline(image1):
      scale = Image.new("1", image1.size, "white");
      image1.show()
      x = image1.size[0]
      y = image1.size[1]
      print (x,y)
      image2 = image1.resize((x/2,y/2),Image.ANTIALIAS);
      image2.show()
      print image2.size
      for x in range(0,image2.size[0]):
          for y in range(0,image2.size[1]):
              scale.putpixel((x,y),image2.getpixel((x,y)));
  
     scale.show()
     print scale.size
  
  
  
  image1 = Image.open("Problems/Basic Problems C/Basic Problem C-02/A.png").convert("1");
  scaling_thumbline(image1)
  </code></pre>
  
  <p>And I get, 
  <img src="https://i.imgur.com/EFyaDEs.png" alt="Image">, I need to scale it but maintain the position. Notice how instead of in the middle, the image has moved to the top.</p>
  
  <p>Any ideas? Help?</p>