
Basic transformations like rotate, resize, crop and flip. Details below.
image_trim(image)image_chop(image, geometry)
image_rotate(image, degrees)
image_resize(image, geometry = NULL, filter = NULL)
image_scale(image, geometry = NULL)
image_sample(image, geometry = NULL)
image_crop(image, geometry = NULL)
image_flip(image)
image_flop(image)
image_deskew(image, treshold = 40)
image_page(image, pagesize = NULL, density = NULL)
magick image object returned by image_read()
or image_graph()
a string with geometry syntax specifying width+height and/or position offset.
value between 0 and 360 for how many degrees to rotate
string with a filtertype.
straightens an image. A threshold of 40 works for most images.
geometry string with preferred size and location of an image canvas
geometry string with vertical and horizontal resolution in pixels of the image. Specifies an image density when decoding a Postscript or PDF.
For details see Magick++ STL documentation. Short descriptions:
image_trim removes edges that are the background color from the image.
image_chop removes vertical or horizontal subregion of image.
image_crop cuts out a subregion of original image
image_rotate rotates and increases size of canvas to fit rotated image.
image_deskew auto rotate to correct skewed images
image_resize resizes using custom filterType
image_scale and image_sample resize using simple ratio and pixel sampling algorithm.
image_flip and image_flop invert image vertically and horizontally
The most powerful resize function is image_resize which allows for setting
a custom resize filter. Outut of image_scale is similar to image_resize(img, filter = "point")
.
For resize operations it holds that if no geometry
is specified, all frames
are rescaled to match the top frame.
Other image: analysis
,
animation
, attributes
,
color
, composite
,
device
, editing
,
effects
, index
,
ocr
, painting
# NOT RUN {
logo <- image_read("logo:")
logo <- image_scale(logo, "400")
image_trim(logo)
image_chop(logo, "100x20")
image_rotate(logo, 45)
# Small image
rose <- image_convert(image_read("rose:"), "png")
# Resize to 400 width or height:
image_resize(rose, "400x")
image_resize(rose, "x400")
# Resize keeping ratio
image_resize(rose, "400x400")
# Resize, force size losing ratio
image_resize(rose, "400x400!")
# Different filters
image_resize(rose, "400x", filter = "Triangle")
image_resize(rose, "400x", filter = "Point")
# simple pixel resize
image_scale(rose, "400x")
image_sample(rose, "400x")
image_crop(logo, "400x400+200+200")
image_flip(logo)
image_flop(logo)
# }
Run the code above in your browser using DataLab