(self, request, pk)
return redirect(reverse('gallery:index'))
Save changes in image.
Save changes in image.
Save changes in image .
def post(self, request, pk):
        """
        Save changes in image.
        """
        x = request.POST.get('x')
        y = request.POST.get('y')
        x2 = request.POST.get('x2')
        y2 = request.POST.get('y2')
        item = get_object_or_404(UserGalleryItem, pk=pk)
        filename = item.picture_name
        filepath = item.get_filepath()
        file = os.path.join(filepath, filename)
        box = (int(x), int(y), int(x2), int(y2))

        img = Image.open(file)
        img.crop(box).save(file)
        create_gallery_thumbnail(request.user.username, filename)

        return redirect(reverse('gallery:index'))
def post ( self , request , pk ) : x = request . POST . get ( 'x' ) y = request . POST . get ( 'y' ) x2 = request . POST . get ( 'x2' ) y2 = request . POST . get ( 'y2' ) item = get_object_or_404 ( UserGalleryItem , pk = pk ) filename = item . picture_name filepath = item . get_filepath ( ) file = os . path . join ( filepath , filename ) box = ( int ( x ) , int ( y ) , int ( x2 ) , int ( y2 ) ) img = Image . open ( file ) img . crop ( box ) . save ( file ) create_gallery_thumbnail ( request . user . username , filename ) return redirect ( reverse ( 'gallery:index' ) )