I have photos of individual 45 and LP records. In each photo, the record is in the center and is rotated at different angles. The goal is to rotate the image such that the label on the record is upright. Using python, write a program that takes a photo as input and rotates the input photo, then output the correctly rotated photo as a PNG.
Sure, here's a Python code that should do what you described:

from PIL import Image

def rotate_record(image_path):
    image = Image.open(image_path)
    # Convert to grayscale for easier processing
    image = image.convert('L')
    # Rotate the image to all possible angles in increments of 1 degree
    for angle in range(0, 360, 1):
        rotated = image.rotate(angle)
        # Check if the label is at the top of the image
        label_top = rotated.crop((image.width/2-50, 0, image.width/2+50, 50))
        if label_top.getextrema()[0][0] == label_top.getextrema()[1][0]:
            # The label is at the top, so rotate the original image to this angle
            rotated_original = image.rotate(angle, expand=True)
            # Save the rotated image as a PNG file with the same name as the original file
            rotated_original.save(image_path[:-4] + '_rotated.png', 'PNG')
            return
    # If the label was not found, raise an exception
    raise ValueError('Label not found')

Here's how to use the function:
rotate_record('path/to/image.png')

This function uses the Python Imaging Library (PIL) to open and process the image. It rotates the image to all possible angles in increments of 1 degree and checks if the label is at the top of the image. If it finds the label, it rotates the original image to this angle and saves it as a PNG file with the same name as the original file. If it doesn't find the label, it raises a ValueError.

Note that this code assumes that the label is always at the top of the image and that it is a rectangular shape. If this is not the case, you may need to modify the code to check for a different region of the image or to use a different approach altogether.
After aligning the album artwork, can it also be made to crop the image properly?