Anisotropic lattice compression and pressure-induced electronic phase transitions in Sr2IrO4