This paper is a study of the electromagnetic radiation at temperature T in a rectangular slab whose walls are made of a perfect conductor. The two large parallel walls of area A are apart by a distance . We take T, A, and d as thermodynamic parameters, obtaining the free energy from a procedure that involves the integration over the slab of the ensemble average of the stress–energy–momentum tensor calculated long ago by Brown and Maclay. Both thermodynamic regimes and are fully addressed. We show that certain thermodynamic quantities that are notoriously ill defined (or trivial) in ordinary blackbody thermodynamics are now well defined (or nontrivial) due to the presence of boundary conditions at the walls of the slab (‘Casimir’s effect’). The relationships among such quantities are fully explored and it is speculated that they may be experimentally checked. Stability is addressed, showing that electromagnetic radiation in the slab is thermally stable; but mechanically unstable. We investigate thermodynamic processes where temperature, internal energy, entropy and enthalpy are each taken to be constant, revealing rather atypical behaviors. For example, in sharp contrast with what one would expect from a gas, when , ‘free expansion’ gives place to ‘free contraction’ in accordance with the second law of thermodynamics. As a check of consistency of the formulae we remark that various Carnot cycles have been examined and verified that they correctly lead to Carnot’s efficiency.