MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Exporting images without white borders


On Monday 23 April 2007 12:25, Jean-Marc Gulliet wrote:
> Steven T. Hatton wrote:
> [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?

The cntr was superfluous to the example.  I neglected to delete it when I took 
out the related code.  The examples /are/ different.  One has 

Graphics[img[[1]],...

The other has 

Graphics[{img[[1]]},...

And, yes, the '{''}' make a difference in the result.  I have now discovered 
that the image size also has a bearing on the result.  Here is the exact file 
I used to produce the results:

SetDirectory[dn = "~/test"];
img = Import[dn <> "/test-in.jpg"];

(*no border*)
Export["test-out-1.jpg"
  ,  Graphics[img[[1]]
    , AspectRatio -> Automatic
    , PlotRange -> {{0, 640}, {0, 480}}
  ]
  ,ImageSize->{640,480}
]

(*1-pixel border at bottom and right*)
Export["test-out-2.jpg"
  ,  Graphics[{img[[1]]}
    , AspectRatio -> Automatic
    , PlotRange -> {{0, 640}, {0, 480}}
  ]
  ,ImageSize->{640,480}
]

If I take out the ,ImageSize->{640,480} the result is that _both_ output 
images have borders on the bottom, right and top edges.


  • Prev by Date: Re: Optimisation of FourierCoefficients
  • Next by Date: Re: question
  • Previous by thread: Exporting images without white borders
  • Next by thread: Re: Exporting images without white borders