Added beforeProcessImage callback