In the class which handles the events,
in mousePressed event,
check which vertex of the bounded rectangle (of the image or component) has been clicked,
and in mouseDragged event,
draw the image setting the initial point of the bounded rectangle of the image or component as the diagonally opposite vertex of the currentvertex.
Until u release the mouse button, repaint the image with the changing dimensions.