ALBANY, N.Y. — A 38-year-old man and his girlfriend have been sentenced to federal prison for making child pornography using a 1-year-old girl.

The US Attorney’s Office says Joshua Carey of Stamford in Delaware County and 28-year-old Ariel Machia of Middleburgh in Schoharie County were sentenced Thursday in Albany’s federal courthouse. They had pleaded guilty to felony counts of sexual exploitation of a child.

Prosecutors say Carey, a previously convicted sex offender, was sentenced to 40 years. Machia was sentenced to 30 years. They admitted that in 2016, they photographed each other engaged in sexual conduct with the child. Carey’s lawyer said his client was “drunk out of his mind” at the time.

Police found the images on a computer while investigating unrelated sex accusations against Machia’s husband. Christopher Machia is currently serving a prison sentence.