Re: Exporting images without white borders
- To: mathgroup at smc.vnet.net
- Subject: [mg75292] Re: Exporting images without white borders
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 24 Apr 2007 03:23:17 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f0hunk$a3b$1@smc.vnet.net>
Steven T. Hatton wrote:
[snip]
> This produces a properly saved image file:
> SetDirectory[dn = "~/Documents/test"];
> img = Import[dn <> "/test-in.jpg"];
> cntr = {640/2, 480/2};
> gx = Graphics[
> img[[1]]
> , AspectRatio -> Automatic
> , ImageSize -> {640, 480}
> , PlotRange -> {{0, 640}, {0, 480}}
> ];
> Export["test-out.jpg", gx, ImageSize -> {640, 480}]
>
> This produces an image file with a 1-pixel border on the right and the
> bottom:
> SetDirectory[dn = "~/Documents/test"];
> img = Import[dn <> "/test-in.jpg"];
> cntr = {640/2, 480/2};
> gx = Graphics[
> {img[[1]]}
> , AspectRatio -> Automatic
> , ImageSize -> {640, 480}
> , PlotRange -> {{0, 640}, {0, 480}}
> ];
> Export["test-out.jpg", gx, ImageSize -> {640, 480}]
[snip]
Could you, please post the correct code for each case? It occurs that
both sets of expressions are identical. Also, the variable cntr is not
used. What was its purpose, if any?
Regards,
Jean-Marc
In[1]:=
in1 = {SetDirectory[dn = "~/Documents/test"];
img = Import[StringJoin[dn, "/test-in.jpg"]];
cntr = {640/2, 480/2}; gx = Graphics[img[[1]],
AspectRatio -> Automatic, ImageSize ->
{640, 480}, PlotRange -> {{0, 640},
{0, 480}}]; Export["test-out.jpg", gx,
ImageSize -> {640, 480}]}
In[2]:=
in2 = {SetDirectory[dn = "~/Documents/test"];
img = Import[StringJoin[dn, "/test-in.jpg"]];
cntr = {640/2, 480/2}; gx = Graphics[{img[[1]]},
AspectRatio -> Automatic, ImageSize ->
{640, 480}, PlotRange -> {{0, 640},
{0, 480}}]; Export["test-out.jpg", gx,
ImageSize -> {640, 480}]}
In[3]:=
in1 == in2
Out[3]=
True
In[4]:=
in1 === in2
Out[4]=
True