I am trying to generate & Export[] Image with the below code, but as shown in the images I get some white border around my rectangle.
How could I export an images that stopes right at the edge of my Rectangle[] edges ?
c0 = {RGBColor[23/85, 29/255, 142/255], RGBColor[244/255, 1, 59/255],
RGBColor[1, 0, 32/85], RGBColor[18/85, 72/85, 197/255]}
Export[FileNameJoin[{Directory[], "DropBox", ToString[#] <> ".jpg"}],
Graphics[{EdgeForm[Thick],
White, Rectangle[{0, 0}, {160, 90}],
Flatten@({Flatten@(Table[
RandomChoice[{GrayLevel[.15], c0[[#]]}], {3}] & /@
Range[2, 4, 1]),
MapThread[
Function[{Xs, Ys},
Rectangle[{Xs, Ys}, {Xs + 16, Ys + 9}]],
{Flatten@Table[Range[0, 32, 16], {3}],
Flatten@(Table[#, {3}] & /@
Range[63, 81, 9])}]}\[Transpose]),
Black, Thick, Line[{{0, 63}, {160, 63}}]}, ImageSize -> 300]] & /@
Range[100]
Answer
There's another, undocumented, approach, although I can't take credit for discovering this one. The solution you're probably looking for (in the sense that Brett Champion's solution seems to clip off a little too much at the edges) is the Method
option for Graphics
:
Method -> {"ShrinkWrap" -> True}
e.g. (graphics example from the documentation for Circle
):
Graphics[
Table[{Hue[t/20], Circle[{Cos[2 Pi t/20], Sin[2 Pi t/20]}, 1]}, {t, 20}],
Method -> {"ShrinkWrap" -> True}
]
Note that this has to be written as Method -> {"ShrinkWrap" -> True}
. The form Method -> "ShrinkWrap" -> True
might be expected to work, but it doesn't.
Comments
Post a Comment