0

For a data science project, I have to crop hundreds of images. I have found multiple ways to do this, for example with Photoshop or other editors, but i dont have those.

The images I have are sized 6663 x 8192, but I need to crop them to 512 x 512. This cropping needs to be done in the center of the image. So the image needs to be cropped to a 512 x 512 square cut out from the center of the image.

Does anyone know how to do this? I found some solutions using PIL, but i am unsure on how to do this exactly. Any help is greatly appreciated.

Barco
  • 79
  • 6
  • 1
    take a look at this https://stackoverflow.com/a/16648197/12036671 – Sandil Ranasinghe Nov 24 '22 at 13:32
  • 1
    Does this answer your question? [Crop an image in the centre using PIL](https://stackoverflow.com/questions/16646183/crop-an-image-in-the-centre-using-pil) – Sandil Ranasinghe Nov 24 '22 at 13:34
  • use imagemagick. this doesn't require programming. -- you've "found some solutions"? then just use them? what's to be unsure about? please go into detail. -- asking for recommendations is off-topic. please review [help/on-topic]. also take the [tour] and review [ask] and [mre]. – Christoph Rackwitz Nov 24 '22 at 13:37
  • 1
    The technique is in the answer to the duplicate question... just use `512x512+0+0` instead of `95%`. – Mark Setchell Nov 24 '22 at 15:29

0 Answers0