transform: Image Transform

Description Usage Arguments Details See Also Examples

Description

Basic transformations like rotate, resize, crop and flip. The geometry syntax is used to specify sizes and areas.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Arguments

image

magick image object returned by image_read() or image_graph()

fuzz

Fuzz percentage: value between 0 and 100. Relative distance between colors to be considered similar in the filling algorithm.

geometry

a geometry string specifying area (for cropping) or size (for resizing).

degrees

value between 0 and 360 for how many degrees to rotate

filter

string with filter type from: filter_types

repage

resize the canvas to the cropped area

threshold

straightens an image. A threshold of 40 works for most images.

pagesize

geometry string with preferred size and location of an image canvas

density

geometry string with vertical and horizontal resolution in pixels of the image. Specifies an image density when decoding a Postscript or PDF.

orientation

string to set image orientation one of the orientation_types. If NULL it applies auto-orientation which tries to infer the correct orientation from the Exif data.

Details

For details see Magick++ STL documentation. Short descriptions:

The most powerful resize function is image_resize which allows for setting a custom resize filter. Output 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.

See Also

Other image: _index_, analysis, animation, attributes, color, composite, device, edges, editing, effects, fx, geometry, morphology, ocr, options, painting, segmentation, video

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 <- image_read("logo:")
 <- image_scale(, "400")
image_trim()
image_chop(, "100x20")
image_rotate(, 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(, "400x400+200+200")
image_flip()
image_flop()
if(magick_config()$version > "6.8.6")
  image_orient()

ropensci/magick documentation built on Jan. 15, 2019, 3:27 a.m.