I have to resize an image and upload it to server using django, currently i am using fileSystem storage for uploading file, but and my code is
def create_new_event(request, steps=None):
if request.method == 'POST':
stepFirstForm = CreateEventStepFirstForm(request.POST, request.FILES)
if stepFirstForm.is_valid():
if request.FILES['artist_image']:
randomArtistImage = ''.join(random.choice('0123456789ABCDEFabcdefghijklmn') for i in range(8));
myfile = request.FILES['artist_image']
fs = FileSystemStorage()
fileName, fileExtension = os.path.splitext(myfile.name)
artistImageName = randomArtistImage+'-'+str(request.user.id)+str(fileExtension)
filename = fs.save('event_artists_images/'+artistImageName, myfile)
uploaded_artist_image_url = fs.url(filename)
Using this code i can move image to event_artists_images folder, but i want to also resize this image upto 300*300 pixels. How can i do this. If i can use PIL Image class then on server how can i upload and resize file.