def crop(self, im, new_width, new_height):
        """
        Crop the input image to the specified dimensions.
        """
        width, height = im.size
        left = (width - new_width) / 2
        top = (height - new_height) / 2
        right = (width + new_width) / 2
        bottom = (height + new_height) / 2
        return im.crop((left, top, right, bottom))

        Crop the input image to the specified dimensions.
        
src/diffusers/pipelines/stable_diffusion_gligen/pipeline_stable_diffusion_gligen_text_image.py