So, I figured it out by myself. The problem was the anchorpoint. My images were on even pixels but the anchorpoint was odd.
So the solution is to use following expressions:
// Position
newX = Math.round(transform.position[0]);
newY = Math.round(transform.position[1]);
[newX, newY]
// Anchorpoint
newX = Math.round(transform.anchorpoint[0]);
newY = Math.round(transform.anchorpoint[1]);
[newX, newY]
UPDATE 2
Since I use this expression everytime now I am animating motion graphics, I thought it would be cool to make an actual after effects script of it. You can purchase it here:
FIXL -Snap Layers to Pixel
UPDATE
When you try to animate layers with these expressions, it comes to rough animations. That's why I wrote a new expression that only applies if a keyframe is set. So its safe that whenever an image or layer is resting on the same position for a longer time, it will stay on even pixels.
Add this Expression to the position property of your layer:
n = transform.position.numKeys
t = time;
timeOfKeyframe = null;
for(i=1; i <= n; i++){
if ( t == transform.position.key(i).time ){
timeOfKeyframe = transform.position.key(i).time;
}
else{
value;
}
}
if (t == timeOfKeyframe) {
keyValue = transform.position.valueAtTime(timeOfKeyframe);
roundedValue = [Math.round(keyValue[0]),Math.round(keyValue[1])];
}
else{
value;
}