I completed to pray namaz magrib and isha and then I noticed there was a book with a picture in the direction. I did not do it intentionaly

Is my namaz valid?

Your namaz is valid. Only it is Makrooh to offer namaz in front of any living animal’s picture. Doesn’t matter it is in front of you or back of you or it’s left or right of you.