#NEWLINE# def unset_as_auto_crop( thumb ) : #NEWLINE# #INDENT# '\n    Crop information is normalized on the parent Thumb row so auto-crops do not\n    have crop height/width/x/y associated with them.\n\n    This function takes a Thumb as an argument, generates the best_fit from\n    its reference_thumb, sets the relevant geometry, and clears the original\n    reference_thumb foreign key.\n    ' #NEWLINE# if ( not thumb . reference_thumb ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# reference_thumb_box = thumb . reference_thumb . get_crop_box ( ) #NEWLINE# crop = Crop ( reference_thumb_box , DummyImage ( thumb . image ) ) #NEWLINE# best_fit = crop . best_fit ( thumb . width , thumb . height ) #NEWLINE# thumb . reference_thumb = None #NEWLINE# thumb . crop_w = best_fit . box . w #NEWLINE# thumb . crop_h = best_fit . box . h #NEWLINE# thumb . crop_x = best_fit . box . x1 #NEWLINE# thumb . crop_y = best_fit . box . y1 #NEWLINE# thumb . save ( )