tkimageRead {tkImgR} | R Documentation |
Tk commands to deal with images
Description
These commands create, read, copy, write, and delete images using the 'tcltk' package.
Usage
tkimageRead(imageName = NULL, fileName, ...)
tkimageCreate(imageName = NULL, ...)
tkimageCopy(imageName, sourceImage, ...)
tkimageWrite(imageName, fileName, ...)
tkimageDelete(imageName)
Arguments
imageName |
Specifies the name for the image; if is NULL then Tk picks a name of the form image#, where # is an integer. |
fileName |
The path for the image file. |
... |
Further arguments. |
sourceImage |
The name (or the tcl object) of the image to be copied. |
Value
tclObj with the image if the function is tkimageCreate
, tkimageRead
, and tkimageCopy
or no value for tkimageWrite
or tkimageDelete
Examples
#tkimageRead
file_path <- system.file("img", "example.png", package = "tkImgR")
im01 <- tkimageRead("tkImage01", file_path)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im01)
#tkimageCreate
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01")
tkimage.height(im1) #0
im1 <- tkimageCreate("tkImage01", file_path)
tkimage.height(im1) #2824
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
#tkimageCopy
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
im3 <- tkimageCreate("tkImage03")
tkimageCopy(im3, "tkImage01")
c("tkImage01","tkImage03") %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
tkimageDelete(im3)
#tkimageWrite
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
file_path_crop_image <- file.path(tempdir(check = TRUE), "crop.png")
#if is possible to write the file
if (file.access(file_path_crop_image)==0){
tkimageWrite(im1, file_path_crop_image, from=c(0,1500))
im1_crop <- tkimageRead("tkImage01_crop", file_path_crop_image)
print(tkimage.height(im1)) #2824
print(tkimage.height(im1_crop)) #1324 = 2824 - 1500
tkimageDelete(im1_crop)
}
#tkimageDelete
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
[Package tkImgR version 0.0.5 Index]