All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.global.media.RotateImageFileCommand Maven / Gradle / Ivy

Go to download

Nyla Solutions Global Java API provides support for basic application utilities (application configuration, data encryption, debugger and text processing).

The newest version!
/**
 * 
 */
package nyla.solutions.global.media;

import java.io.File;



import nyla.solutions.global.exception.SystemException;
import nyla.solutions.global.io.IO;
import nyla.solutions.global.patterns.command.file.FileCommand;
import nyla.solutions.global.util.Config;
import nyla.solutions.global.util.Debugger;


/**
 * Rotate an image file a given number of degrees
 * @author Gregory Green
 *
 */
public class RotateImageFileCommand implements FileCommand
{
	/**
	 * Rotate the file image
	 */
	public Void execute(File file)
	{	
		try 
		{
			//make output directory if it does not exist
			if(!IO.exists(this.outputPath))
				IO.mkdir(new File(this.outputPath));
			
			Graphics.rotateImage(file, new File(this.outputPath+Config.getFileSeparator()+file.getName()), format, degrees);
			return null;
		} 
		catch (Exception e) 
		{
			throw new SystemException(Debugger.stackTrace(e));
		}
	}//---------------------------------------------
	
	/**
	 * @return the outputPath
	 */
	public String getOutputPath()
	{
		return outputPath;
	}
	/**
	 * @param outputPath the outputPath to set
	 */
	public void setOutputPath(String outputPath)
	{
		this.outputPath = outputPath;
	}
	/**
	 * @return the degrees
	 */
	public int getDegrees()
	{
		return degrees;
	}
	/**
	 * @param degrees the degrees to set
	 */
	public void setDegrees(int degrees)
	{
		this.degrees = degrees;
	}
	/**
	 * @return the format
	 */
	public String getFormat()
	{
		return format;
	}
	/**
	 * @param format the format to set
	 */
	public void setFormat(String format)
	{
		this.format = format;
	}

	private String outputPath = Config.getProperty(getClass(),"outputPath",".");
	private int  degrees = Config.getPropertyInteger(this.getClass(),"degrees",0).intValue();
	private String format = Config.getProperty(this.getClass(),"format","png");
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy