#' ReVuePro: FITS2JPG
#'
#' A function to convert two-dimensional FITS files to JPG images.
#' @param source The path to a file, or folder of FITS files you wish to convert to JPG images.
#' @param destination The path to a folder you wish to save your JPG output files to.
#' @keywords Thermal Imaging, ReVuePro
#' @import FITSio jpeg
#' @export
#' @examples
#' source="C:/ThermalFITSfiles"
#' destination="C:/MyJPGimages"
#' FITS2JPG(source=source, destination=destination)
FITS2JPG = function(source, destination){
require('FITSio')
require('jpeg')
originalwd=getwd()
is.character0 <- function(x){
is.character(x) && length(x) == 0L
}
rotate <- function(x) t(apply(x, 2, rev))
if(!is.character0(list.files(source))){
for(i in 1:length(list.files(source))){
setwd(source)
toconv=list.files()[i]
fits=readFITS(toconv)
WriteFile=paste(gsub("\\..*", "", source),".jpg",sep="")
setwd(destination)
writeJPEG(rotate(rotate(rotate(fits))), WriteFile)
}
setwd(originalwd)
}
if(is.character0(list.files(source))){
fits=read.fits(source)
WriteFile=paste(gsub("\\..*", "", source),".jpg",sep="")
setwd(destination)
writeJPEG(rotate(rotate(rotate(fits$dat[[1]]))), WriteFile)
setwd(originalwd)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.