In wireless sensor networks (WSNs), sensor nodes have limited resources with regard to computation, storage, communication bandwidth, and the most important of all, energy supply. In addition, in many applications of sensor networks, we need to send images to a sink node. Therefore, we have to use methods for sending images in which the number and volume of packets are optimized to save energy. Data compression is one of the optimization methods in energy consumption. In this paper, an effective compression algorithm is proposed to reduces computational and energy consumption and eventually, increases the overall network lifetime. Here in, we use a combination of three DCT, DWT and SWT wavelet transforms to achieve our goals.Simulation results show that the proposed algorithm achieves its goals with regard to data compression and reduction of energy consumption, and improves the network lifetime.