Added the validate image function and resize function