I know there is a thread that has tiff to jpeg, and I used that in order to base my formatting. I have the jpeg and tiff package installed.
library("jpeg")
library("tiff")
jpeg<- readJPEG("ortho.jpg", native = TRUE)
tiff<- writeTIFF(jpeg,"tiff", bits.per.sample = 16L, compression = "JPEG",
reduce = TRUE)
this works and and it got me a tiff, but with no attributes, therefore no georeference. my current attempt/thought process is to write the jpeg as a raster, and than go from a raster to a tiff. So i am using the raster package and the writeRaster
function. My code at the moment is:
library("jpeg")
library("tiff")
jpeg<- readJPEG("ortho.jpg", native = FALSE)
raster<- as.raster(jpeg)
rf<- writeRaster(raster, filename = "rasterfile.tif" , format="GTiff")
This successfully writes a raster with attributes but i get an error in the writeRaster
portion that reads,
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘writeRaster’ for signature ‘"raster", "character"’
any advice would be appreciated.
Here was my final code that worked.
library(jpeg)
library(tiff)
f <- system.file("ortho.img", package="jpeg")
img <- readJPEG("ortho.jpg", native = FALSE)
writeTIFF(img, "test.tif", bits.per.sample = 8L, compression = "JPEG", reduce = TRUE)
Than I switched the .jgw, that referenced the jpeg to a .tfw, and autocad loaded it right up. Make sure the file names of the tfw and tif are the same.