/** * Executes RotateImage action * * This action can be used into an ajax action to rotate an image. This function requires * some parameters: * image : The name of the image to resize * imagePath : The full image path * degrees : The angle value for rotation. It can be 90, 180, 270 * imageType : The new image type. This parameter must be 1-GIF 2-JPG 3-PNG. Other * formats will be ignored * imageQuality : The new value for the image quality. Applies only to JPG images * * return A JSon header. */ public function executeRotateImage() { $imageEditor = new ImageEditor($this->getRequestParameter('image'), sfConfig::get('app_images_path')); $imageEditor->rotate($this->getRequestParameter('degrees')); $imageEditor->outputFile($this->getRequestParameter('image'), sfConfig::get('app_images_path'), $this->getRequestParameter('imageType'), $this->getRequestParameter('imageQuality')); // Produces the output header for ajax calling. $output = ''; if ($this->getRequestParameter('previewWidth') != 0 && $this->getRequestParameter('previewHeight') != 0) { $imageAttributes = w3sClassImageManager::getImageAttributes($this->getRequestParameter('image'), $this->getRequestParameter('previewWidth'), $this->getRequestParameter('previewHeight'), $this->getRequestParameter('setCanvas')); $output = '[["w3s_image_size", "' . $imageAttributes["size"] . '"],["w3s_image_width", "' . $imageAttributes["width"] . '"],["w3s_image_height", "' . $imageAttributes["height"] . '"],["w3s_image_preview", "' . $imageAttributes["image"] . '"],["w3s_image_canvas", "' . $imageAttributes["canvas"] . '"],["w3s_start_width", "' . $imageAttributes["width"] . '"],["w3s_start_height", "' . $imageAttributes["height"] . '"]]'; } $this->getResponse()->setHttpHeader("X-JSON", '(' . $output . ')'); return sfView::HEADER_ONLY; }