I dug into the book (ePub version, thankfully) and found this excerpt:
And next, Snape was kneeling in Sirius’s old bedroom. Tears were
dripping from the end of his hooked nose as he read the old letter
from Lily. The second page carried only a few words:
could ever have been friends with Gellert Grindelwald. I think her mind’s going, personally!
Lots of love, Lily
Snape took the page bearing Lily’s signature, and her love, and tucked it inside his robes. Then he ripped in two the photograph he was also holding, so that he kept the part from which Lily laughed, throwing the portion showing James and Harry back on to the floor, under the chest of drawers...
Harry Potter and the Deathly Hallows, Chapter 33: The Price's Tale
The chapter is told linearly (unlike the scene in the motion picture), so we know that this happens sometime between Harry leaves Privet Drive and Severus helps Harry into finding Gryffindor's Sword.
As it can be noticed, the scene is completely different and even happens 17 years later (in the book). I believe this was a needed change for the following reasons:
- The whole Lily's letter plot is left behind in the films.
- The scene was a vindication of Severus Snape's character; showing him ripping the photograph would have had a negative impact on the public.
- The scene is truly powerful; we see Snape bursting into tears upon seeing the lifeless body of his beloved.
Canonically, due to Fidelius Charm's nature, Severus should not have even been able to be there, unless Peter Pettigrew personally told him the location of the Potter's residence.
As @Deltharis has pointed out, this can only be explained through speculation.
Update: Fidelius Charm is inconsistently presented throughout the books, so anything is possible.
Personally, I'm gonna go with "Severus couldn't stay for too long without blowing up his cover".