Digital forensic specialist Darren Collins, who is said to have acted out of "morbid curiosity", admitted misconduct in a public office last month after being sacked by Staffordshire Police for gross misconduct.
Birmingham Crown Court heard 56-year-old Collins "thought he might just get a telling off" if colleagues found he had been storing and viewing images without authorisation.
Opening the case against Collins, of Pinewood Drive, Little Haywood, near Stafford, prosecutor Simon Davis said the defendant had first appeared in court in 2019 and had since seen various proceedings delayed by the Covid-19 pandemic.
Mr Davis told the court Collins had admitted a charge relating to illegal access to and storage of images of deceased persons between January 2014 and December 2018.
Collins, the court heard, had used a "back door" method to access images of murder scenes, including a deposition site, pictures taken at post-mortem examinations, and others relating to road traffic collisions.
After his arrest, Collins, who had worked for Staffordshire Police for 18 years, claimed he had looked at the images because digital forensics was a "stepping stone" and he wanted to become a scenes of crime officer.
Addressing Friday's hearing, defence barrister Kelly Cyples said Collins suffered from post-traumatic stress disorder as a result of legitimate work on investigations into child abuse.
She told Judge Roderick Henderson: "The crux of this case is that, at the time, Mr Collins certainly did not realise that what he was doing was criminal.
"He accepts and understands, with the benefit of hindsight, he should not have and was not permitted to look at other images beyond the parameters he had been given for his actual role.
"There was no malicious intent and the images have never been shown to anyone else."
Passing sentence, Judge Henderson said relatives of victims pictured in some of the images had been informed that they had been looked at by Collins.
"These people of course suffered dreadfully with the loss of their loved ones," the judge said.
"To discover now that you were looking (at the images) for nothing but gratuitous curiosity is a further grievous insult to them, their memory and their families.
"The behaviour of this defendant is utterly exceptional in my experience. This is a case which calls out for immediate custody."
In a statement issued after Collins pleaded guilty, Staffordshire Police said a rigorous and extensive investigation had found no evidence that the images had been shared.
A comprehensive review of current security and access systems and processes had also been carried out, the force said.