MathGroup Archive 2002

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

Search the Archive

Re: Resizing Graphics

  • To: mathgroup at
  • Subject: [mg36414] Re: [mg36302] Resizing Graphics
  • From: Dale Horton <daleh at>
  • Date: Fri, 6 Sep 2002 03:16:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

At 12:19 AM 8/30/2002, Aaron wrote:
>I was wondering if there is a method for resizing Raster graphics
>(resizing the actual matrix of pixels, not just the display size).  I
>am processing a large number of JPEG images, and we sometimes need to
>reduce the image size to allow data processing algorithms to function
>without running out of memory.  In the past we simply used a program
>such as Photoshop to resize them before importing them into
>Mathematica.  Due to the number of images we are processing now this
>is very inconvenient and it would be very useful if there was a method
>for accomplishing it in Mathematica, but I can't find one.  I also
>thought about doing something simple like sampling every few pixels or
>averaging, but I thought there might be a method with more efficacy
>than this. I also tried exporting the graphics with the Export command
>as new JPEGs and manipulating the ImageResolution and ImageSize
>options but this seemed to have no effect.  Any help would be much
>Aaron Urbas

In 4.2, the following should work (as long as you define newsize).

in = Import["file.jpg"];
Export["newfile.jpg", in, ImageSize->newsize]

In 4.1 and earlier, this will not work because an optimization interferes 
with the ImageSize and rasters are written out with the raster size, not 
the ImageSize. There is a ConversionOption to force the behavior you want.

in = Import["file.jpg"];
Export["newfile.jpg", Show[in, ImageSize->newsize],


  • Prev by Date: Re: Generating Two Unit Orthogonal Vectors
  • Next by Date: Re: Generating Two Unit Orthogonal Vectors (correction)
  • Previous by thread: Re: Resizing Graphics
  • Next by thread: How to define new function using the previous output?