The inflatable boat was found Monday off a beach at the popular resort of Costa Teguise in Lanzarote in Spain's Canary Islands with five bodies inside. Two others were found dead outside the boat.
"Judicial authorities have confirmed that the seven victims were all adults and two died drowning and five from hypothermia, exhaustion and hunger," the Canaries' high court said in a statement.
Two men "thought to be of Moroccan nationality" were sent to jail over the incident, a court spokesman told AFP, adding that the pair had no ID on them.
One of them is only 19 years old, according to a bone test done to determine his age.
He was identified by other passengers on the boat as one of the two bosses," the statement said.
Some 20 other migrants survived the crossing.
The Canary Islands archipelago off the coast of Morocco were once a prized destination for migrants hoping to reach Spain's shores and access Europe to begin new lives.
But migrants are increasingly favouring the so-called western Mediterranean trail, which sees migrants making the sea crossing between north Africa and southern mainland Spain.
A total of 1,916 migrants have reached Europe by sea since the beginning of the year, according to the International Organization for Migration, and a further 194 died or disappeared during the crossings.