correct writing to database
AA on image scaling