diff --git a/Magick++/demo/gravity.cpp b/Magick++/demo/gravity.cpp
index d2468ad..c262515 100644
--- a/Magick++/demo/gravity.cpp
+++ b/Magick++/demo/gravity.cpp
@@ -3,7 +3,7 @@
 // Copyright Bob Friesenhahn, 2000, 2001, 2003
 //
 // Demo of text annotation with gravity.  Produces an animation showing
-// the effect of rotated text along with various gravity specifications.
+// the effect of rotated text assize_t with various gravity specifications.
 //
 // After running demo program, run 'animate gravity_out.miff' if you
 // are using X-Windows to see an animated result.
diff --git a/Magick++/lib/Drawable.cpp b/Magick++/lib/Drawable.cpp
index 5d08084..56552a6 100644
--- a/Magick++/lib/Drawable.cpp
+++ b/Magick++/lib/Drawable.cpp
@@ -276,7 +276,7 @@
 }
 void Magick::DrawableBezier::operator()( MagickCore::DrawingWand * context_ ) const
 {
-  unsigned long num_coords = (unsigned long) _coordinates.size();
+  size_t num_coords = (size_t) _coordinates.size();
   PointInfo *coordinates = new PointInfo[num_coords];
 
   PointInfo *q = coordinates;
@@ -633,7 +633,7 @@
 }
 Magick::DrawableFont::DrawableFont ( const std::string &family_,
                                      Magick::StyleType style_,
-                                     const unsigned long weight_,
+                                     const size_t weight_,
                                      Magick::StretchType stretch_ )
   : _font(),
     _family(family_),
@@ -794,7 +794,7 @@
 void Magick::DrawablePolygon::operator()
   ( MagickCore::DrawingWand * context_ ) const
 {
-  unsigned long num_coords = (unsigned long) _coordinates.size();
+  size_t num_coords = (size_t) _coordinates.size();
   PointInfo *coordinates = new PointInfo[num_coords];
 
   PointInfo *q = coordinates;
@@ -834,7 +834,7 @@
 void Magick::DrawablePolyline::operator()
   ( MagickCore::DrawingWand * context_ ) const
 {
-  unsigned long num_coords = (unsigned long) _coordinates.size();
+  size_t num_coords = (size_t) _coordinates.size();
   PointInfo *coordinates = new PointInfo[num_coords];
 
   PointInfo *q = coordinates;
@@ -900,8 +900,8 @@
 
 // Push Pattern definition
 Magick::DrawablePushPattern::DrawablePushPattern
-( const std::string &id_, long x_, long y_,
-  long width_, long height_ )
+( const std::string &id_, ssize_t x_, ssize_t y_,
+  ssize_t width_, ssize_t height_ )
   : _id(id_),
     _x(x_),
     _y(y_),
@@ -1058,7 +1058,7 @@
 void Magick::DrawableDashArray::operator()
   ( MagickCore::DrawingWand * context_ ) const
 {
-  (void) DrawSetStrokeDashArray( context_, (unsigned long) _size, _dasharray );
+  (void) DrawSetStrokeDashArray( context_, (size_t) _size, _dasharray );
 }
 Magick::DrawableBase* Magick::DrawableDashArray::copy() const
 {
diff --git a/Magick++/lib/Geometry.cpp b/Magick++/lib/Geometry.cpp
index 85cede7..dc104fb 100644
--- a/Magick++/lib/Geometry.cpp
+++ b/Magick++/lib/Geometry.cpp
@@ -206,10 +206,10 @@
         }
     }
 
-  long x = 0;
-  long y = 0;
-  unsigned long width_val = 0;
-  unsigned long height_val = 0;
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width_val = 0;
+  size_t height_val = 0;
   int flags = GetGeometry (geom, &x, &y, &width_val, &height_val );
 
   if (flags == NoValue)
@@ -353,7 +353,7 @@
   RectangleInfo rectangle;
   rectangle.width = _width;
   rectangle.height = _height;
-  _xNegative ? rectangle.x = static_cast<long>(0-_xOff) : rectangle.x = static_cast<long>(_xOff);
-  _yNegative ? rectangle.y = static_cast<long>(0-_yOff) : rectangle.y = static_cast<long>(_yOff);
+  _xNegative ? rectangle.x = static_cast<ssize_t>(0-_xOff) : rectangle.x = static_cast<ssize_t>(_xOff);
+  _yNegative ? rectangle.y = static_cast<ssize_t>(0-_yOff) : rectangle.y = static_cast<ssize_t>(_yOff);
   return rectangle;
 }
diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp
index 9c3e72e..f58968d 100644
--- a/Magick++/lib/Image.cpp
+++ b/Magick++/lib/Image.cpp
@@ -667,10 +667,10 @@
 {
   modifyImage();
 
-  long x = offset_.xOff();
-  long y = offset_.yOff();
-  unsigned long width = columns();
-  unsigned long height = rows();
+  ssize_t x = offset_.xOff();
+  ssize_t y = offset_.yOff();
+  size_t width = columns();
+  size_t height = rows();
 
   ParseMetaGeometry (static_cast<std::string>(offset_).c_str(),
 		      &x, &y,
@@ -770,7 +770,7 @@
 // usally of the same size as the source image, unless 'bestfit' is set to
 // true.
 void Magick::Image::distort ( const DistortImageMethod method_,
-                              const unsigned long number_arguments_,
+                              const size_t number_arguments_,
                               const double *arguments_,
                               const bool bestfit_ )
 {
@@ -978,7 +978,7 @@
                         DefaultChannels,
                         options()->drawInfo(), // const DrawInfo *draw_info
                         &target,
-                  			static_cast<long>(x_), static_cast<long>(y_),
+                  			static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
                         method_  == FloodfillMethod ? MagickFalse : MagickTrue);
   throwImageException();
 }
@@ -1009,8 +1009,8 @@
                           DefaultChannels,
                           options()->drawInfo(), // const DrawInfo *draw_info
                           &target, // const MagickPacket target
-                          static_cast<long>(x_), // const long x_offset
-                          static_cast<long>(y_), // const long y_offset
+                          static_cast<ssize_t>(x_), // const ssize_t x_offset
+                          static_cast<ssize_t>(y_), // const ssize_t y_offset
                           MagickFalse // const PaintMethod method
       );
 
@@ -1044,8 +1044,8 @@
                         DefaultChannels,
                         options()->drawInfo(),
                         &target,
-                        static_cast<long>(x_),
-                        static_cast<long>(y_),
+                        static_cast<ssize_t>(x_),
+                        static_cast<ssize_t>(y_),
                         MagickTrue);
 
   throwImageException();
@@ -1097,10 +1097,10 @@
 {
   FrameInfo info;
 
-  info.x           = static_cast<long>(geometry_.width());
-  info.y           = static_cast<long>(geometry_.height());
-  info.width       = columns() + ( static_cast<unsigned long>(info.x) << 1 );
-  info.height      = rows() + ( static_cast<unsigned long>(info.y) << 1 );
+  info.x           = static_cast<ssize_t>(geometry_.width());
+  info.y           = static_cast<ssize_t>(geometry_.height());
+  info.width       = columns() + ( static_cast<size_t>(info.x) << 1 );
+  info.height      = rows() + ( static_cast<size_t>(info.y) << 1 );
   info.outer_bevel = geometry_.xOff();
   info.inner_bevel = geometry_.yOff();
 
@@ -1117,12 +1117,12 @@
 			    const int outerBevel_, const int innerBevel_ )
 {
   FrameInfo info;
-  info.x           = static_cast<long>(width_);
-  info.y           = static_cast<long>(height_);
-  info.width       = columns() + ( static_cast<unsigned long>(info.x) << 1 );
-  info.height      = rows() + ( static_cast<unsigned long>(info.y) << 1 );
-  info.outer_bevel = static_cast<long>(outerBevel_);
-  info.inner_bevel = static_cast<long>(innerBevel_);
+  info.x           = static_cast<ssize_t>(width_);
+  info.y           = static_cast<ssize_t>(height_);
+  info.width       = columns() + ( static_cast<size_t>(info.x) << 1 );
+  info.height      = rows() + ( static_cast<size_t>(info.y) << 1 );
+  info.outer_bevel = static_cast<ssize_t>(outerBevel_);
+  info.inner_bevel = static_cast<ssize_t>(innerBevel_);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1743,10 +1743,10 @@
 {
   // Calculate new size.  This code should be supported using binary arguments
   // in the ImageMagick library.
-  long x = 0;
-  long y = 0;
-  unsigned long width = columns();
-  unsigned long height = rows();
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
 
   ParseMetaGeometry (static_cast<std::string>(geometry_).c_str(),
                      &x, &y,
@@ -1769,10 +1769,10 @@
 // Roll image
 void Magick::Image::roll ( const Geometry &roll_ )
 {
-  long xOff = roll_.xOff();
+  ssize_t xOff = roll_.xOff();
   if ( roll_.xNegative() )
     xOff = 0 - xOff;
-  long yOff = roll_.yOff();
+  ssize_t yOff = roll_.yOff();
   if ( roll_.yNegative() )
     yOff = 0 - yOff;
 
@@ -1791,8 +1791,8 @@
   GetExceptionInfo( &exceptionInfo );
   MagickCore::Image* newImage =
     RollImage( image(),
-               static_cast<long>(columns_),
-               static_cast<long>(rows_), &exceptionInfo );
+               static_cast<ssize_t>(columns_),
+               static_cast<ssize_t>(rows_), &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
@@ -1813,10 +1813,10 @@
 // Sample image
 void Magick::Image::sample ( const Geometry &geometry_ )
 {
-  long x = 0;
-  long y = 0;
-  unsigned long width = columns();
-  unsigned long height = rows();
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
 
   ParseMetaGeometry (static_cast<std::string>(geometry_).c_str(),
 		      &x, &y,
@@ -1834,10 +1834,10 @@
 // Scale image
 void Magick::Image::scale ( const Geometry &geometry_ )
 {
-  long x = 0;
-  long y = 0;
-  unsigned long width = columns();
-  unsigned long height = rows();
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
 
   ParseMetaGeometry (static_cast<std::string>(geometry_).c_str(),
 		      &x, &y,
@@ -1971,7 +1971,7 @@
 //
 void Magick::Image::sparseColor ( const ChannelType channel,
                                   const SparseColorMethod method,
-                                  const unsigned long number_arguments,
+                                  const size_t number_arguments,
                                   const double *arguments )
 {
   ExceptionInfo exceptionInfo;
@@ -2282,10 +2282,10 @@
 {
   // Calculate new size.  This code should be supported using binary arguments
   // in the ImageMagick library.
-  long x = 0;
-  long y = 0;
-  unsigned long width = columns();
-  unsigned long height = rows();
+  ssize_t x = 0;
+  ssize_t y = 0;
+  size_t width = columns();
+  size_t height = rows();
 
   ParseMetaGeometry (static_cast<std::string>(geometry_).c_str(),
                      &x, &y,
@@ -3430,7 +3430,7 @@
     {
       const IndexPacket* indexes = getConstIndexes();
       if ( indexes )
-        return colorMap( (unsigned long) *indexes );
+        return colorMap( (size_t) *indexes );
     }
 
   return Color(); // invalid
@@ -3837,11 +3837,11 @@
   return constOptions()->tileName( );
 }
 
-unsigned long Magick::Image::totalColors ( void )
+size_t Magick::Image::totalColors ( void )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
-  unsigned long colors = GetNumberColors( image(), 0, &exceptionInfo);
+  size_t colors = GetNumberColors( image(), 0, &exceptionInfo);
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
   return colors;
@@ -4264,7 +4264,7 @@
 }
 
 // Register image with image registry or obtain registration id
-long Magick::Image::registerId( void )
+ssize_t Magick::Image::registerId( void )
 {
   Lock( &_imgRef->_mutexLock );
   if( _imgRef->id() < 0 )
diff --git a/Magick++/lib/ImageRef.cpp b/Magick++/lib/ImageRef.cpp
index 8dab259..3397150 100644
--- a/Magick++/lib/ImageRef.cpp
+++ b/Magick++/lib/ImageRef.cpp
@@ -92,7 +92,7 @@
 }
 
 // Assign registration id to reference
-void Magick::ImageRef::id ( const long id_ )
+void Magick::ImageRef::id ( const ssize_t id_ )
 {
   if( _id > -1 )
     {
diff --git a/Magick++/lib/Magick++/Drawable.h b/Magick++/lib/Magick++/Drawable.h
index c5d5cd5..acebf3e 100644
--- a/Magick++/lib/Magick++/Drawable.h
+++ b/Magick++/lib/Magick++/Drawable.h
@@ -934,7 +934,7 @@
 
   DrawableFont ( const std::string &family_,
                  StyleType style_,
-                 const unsigned long weight_,
+                 const size_t weight_,
                  StretchType stretch_ );
   DrawableFont ( const DrawableFont& original_ );
 
@@ -959,7 +959,7 @@
   std::string   _font;
   std::string   _family;
   StyleType     _style;
-  unsigned long _weight;
+  size_t _weight;
   StretchType   _stretch;
 };
 
@@ -1304,8 +1304,8 @@
 class MagickDLLDecl DrawablePushPattern : public DrawableBase
 {
 public:
-  DrawablePushPattern ( const std::string &id_, long x_, long y_,
-                        long width_, long height_ );
+  DrawablePushPattern ( const std::string &id_, ssize_t x_, ssize_t y_,
+                        ssize_t width_, ssize_t height_ );
 
   DrawablePushPattern ( const DrawablePushPattern& original_ );
 
@@ -1319,10 +1319,10 @@
 
 private:
   std::string         _id;
-  long		_x;
-  long		_y;
-  long		_width;
-  long		_height;
+  ssize_t		_x;
+  ssize_t		_y;
+  ssize_t		_width;
+  ssize_t		_height;
 };
 
 // Rectangle
@@ -2055,8 +2055,8 @@
 class MagickDLLDecl DrawableViewbox : public DrawableBase
 {
 public:
-  DrawableViewbox(unsigned long x1_, unsigned long y1_,
-                  unsigned long x2_, unsigned long y2_)
+  DrawableViewbox(size_t x1_, size_t y1_,
+                  size_t x2_, size_t y2_)
     : _x1(x1_),
       _y1(y1_),
       _x2(x2_),
@@ -2071,47 +2071,47 @@
   /*virtual*/
   DrawableBase* copy() const;
 
-  void x1( unsigned long x1_ )
+  void x1( size_t x1_ )
     {
       _x1 = x1_;
     }
-  unsigned long x1( void ) const
+  size_t x1( void ) const
     {
       return _x1;
     }
 
-  void y1( unsigned long y1_ )
+  void y1( size_t y1_ )
     {
       _y1 = y1_;
     }
-  unsigned long y1( void ) const
+  size_t y1( void ) const
     {
       return _y1;
     }
 
-  void x2( unsigned long x2_ )
+  void x2( size_t x2_ )
     {
       _x2 = x2_;
     }
-  unsigned long x2( void ) const
+  size_t x2( void ) const
     {
       return _x2;
     }
 
-  void y2( unsigned long y2_ )
+  void y2( size_t y2_ )
     {
       _y2 = y2_;
     }
-  unsigned long y2( void ) const
+  size_t y2( void ) const
     {
       return _y2;
     }
 
 private:
-  unsigned long _x1;
-  unsigned long _y1;
-  unsigned long _x2;
-  unsigned long _y2;
+  size_t _x1;
+  size_t _y1;
+  size_t _x2;
+  size_t _y2;
 };
 
 //
@@ -2197,7 +2197,7 @@
   double	_radiusX;	// X radius
   double	_radiusY;	// Y radius
   double	_xAxisRotation;	// Rotation relative to X axis
-  bool        _largeArcFlag;	// Draw longer of the two matching arcs
+  bool        _largeArcFlag;	// Draw ssize_ter of the two matching arcs
   bool        _sweepFlag;	// Draw arc matching clock-wise rotation
   double	_x;		// End-point X
   double	_y;		// End-point Y
diff --git a/Magick++/lib/Magick++/Image.h b/Magick++/lib/Magick++/Image.h
index 559244d..3151d27 100644
--- a/Magick++/lib/Magick++/Image.h
+++ b/Magick++/lib/Magick++/Image.h
@@ -273,7 +273,7 @@
     // usally of the same size as the source image, unless 'bestfit' is set to
     // true.
     void            distort ( const DistortImageMethod method_,
-                              const unsigned long number_arguments_,
+                              const size_t number_arguments_,
                               const double *arguments_,
                               const bool bestfit_ = false );
 
@@ -663,7 +663,7 @@
     // methods.
     void            sparseColor ( const ChannelType channel,
                               const SparseColorMethod method,
-                              const unsigned long number_arguments,
+                              const size_t number_arguments,
                               const double *arguments );
 
     // Add a digital watermark to the image (based on second image)
@@ -1216,7 +1216,7 @@
     std::string     tileName ( void ) const;
 
     // Number of colors in the image
-    unsigned long   totalColors ( void );
+    size_t   totalColors ( void );
 
     // Origin of coordinate system to use when annotating with text or drawing
     void            transformOrigin ( const double x_,const  double y_ );
@@ -1354,7 +1354,7 @@
     void            throwImageException( void ) const;
 
     // Register image with image registry or obtain registration id
-    long            registerId( void );
+    ssize_t            registerId( void );
 
     // Unregister image from image registry
     void            unregisterId( void) ;
diff --git a/Magick++/lib/Magick++/ImageRef.h b/Magick++/lib/Magick++/ImageRef.h
index c1a0881..14350b0 100644
--- a/Magick++/lib/Magick++/ImageRef.h
+++ b/Magick++/lib/Magick++/ImageRef.h
@@ -43,12 +43,12 @@
     void                 options ( Options * options_ );
     Options *            options ( void );
 
-    void                 id ( const long id_ );
-    long                 id ( void ) const;
+    void                 id ( const ssize_t id_ );
+    ssize_t                 id ( void ) const;
     
     MagickCore::Image *   _image;    // ImageMagick Image
     Options *            _options;  // User-specified options
-    long                 _id;       // Registry ID (-1 if not registered)
+    ssize_t                 _id;       // Registry ID (-1 if not registered)
     int                  _refCount; // Reference count
     MutexLock            _mutexLock;// Mutex lock
   };
@@ -72,7 +72,7 @@
 }
 
 // Retrieve registration id from reference
-inline long Magick::ImageRef::id ( void ) const
+inline ssize_t Magick::ImageRef::id ( void ) const
 {
   return _id;
 }
diff --git a/Magick++/lib/Magick++/STL.h b/Magick++/lib/Magick++/STL.h
index b526b16..2374442 100644
--- a/Magick++/lib/Magick++/STL.h
+++ b/Magick++/lib/Magick++/STL.h
@@ -351,19 +351,19 @@
   {
   public:
     distortImage( const Magick::DistortImageMethod method_,
-      const unsigned long number_arguments_,
+      const size_t number_arguments_,
       const double *arguments_,
       const bool bestfit_ );
           
     distortImage( const Magick::DistortImageMethod method_,
-      const unsigned long number_arguments_,
+      const size_t number_arguments_,
       const double *arguments_ );
 
     void operator()( Image &image_ ) const;
 
   private:
     DistortImageMethod _method;
-    unsigned long _number_arguments;
+    size_t _number_arguments;
     const double *_arguments;
     bool _bestfit;
   };
@@ -2010,7 +2010,7 @@
                       CoderInfo::MatchType isMultiFrame_ = CoderInfo::AnyMatch
                       ) {
     // Obtain first entry in MagickInfo list
-    unsigned long number_formats;
+    size_t number_formats;
     MagickCore::ExceptionInfo exceptionInfo;
     MagickCore::GetExceptionInfo( &exceptionInfo );
     char **coder_list =
@@ -2025,7 +2025,7 @@
     // Clear out container
     container_->clear();
 
-    for ( int i=0; i < (long) number_formats; i++)
+    for ( int i=0; i < (ssize_t) number_formats; i++)
       {
         const MagickCore::MagickInfo *magick_info =
           MagickCore::GetMagickInfo( coder_list[i], &exceptionInfo );
@@ -2073,7 +2073,7 @@
 
   //
   // Fill container with color histogram.
-  // Entries are of type "std::pair<Color,unsigned long>".  Use the pair
+  // Entries are of type "std::pair<Color,size_t>".  Use the pair
   // "first" member to access the Color and the "second" member to access
   // the number of times the color occurs in the image.
   //
@@ -2082,9 +2082,9 @@
   //  Using <map>:
   //
   //  Image image("image.miff");
-  //  map<Color,unsigned long> histogram;
+  //  map<Color,size_t> histogram;
   //  colorHistogram( &histogram, image );
-  //  std::map<Color,unsigned long>::const_iterator p=histogram.begin();
+  //  std::map<Color,size_t>::const_iterator p=histogram.begin();
   //  while (p != histogram.end())
   //    {
   //      cout << setw(10) << (int)p->second << ": ("
@@ -2098,9 +2098,9 @@
   //  Using <vector>:
   //
   //  Image image("image.miff");
-  //  std::vector<std::pair<Color,unsigned long> > histogram;
+  //  std::vector<std::pair<Color,size_t> > histogram;
   //  colorHistogram( &histogram, image );
-  //  std::vector<std::pair<Color,unsigned long> >::const_iterator p=histogram.begin();
+  //  std::vector<std::pair<Color,size_t> >::const_iterator p=histogram.begin();
   //  while (p != histogram.end())
   //    {
   //      cout << setw(10) << (int)p->second << ": ("
@@ -2118,7 +2118,7 @@
     MagickCore::GetExceptionInfo( &exceptionInfo );
 
     // Obtain histogram array
-    unsigned long colors;
+    size_t colors;
     MagickCore::ColorPacket *histogram_array = 
       MagickCore::GetImageHistogram( image.constImage(), &colors, &exceptionInfo );
     throwException( exceptionInfo );
@@ -2128,13 +2128,13 @@
     histogram_->clear();
 
     // Transfer histogram array to container
-    for ( unsigned long i=0; i < colors; i++)
+    for ( size_t i=0; i < colors; i++)
       {
-        histogram_->insert(histogram_->end(),std::pair<const Color,unsigned long>
+        histogram_->insert(histogram_->end(),std::pair<const Color,size_t>
                            ( Color(histogram_array[i].pixel.red,
                                    histogram_array[i].pixel.green,
                                    histogram_array[i].pixel.blue),
-                                   (unsigned long) histogram_array[i].count) );
+                                   (size_t) histogram_array[i].count) );
       }
     
     // Deallocate histogram array
diff --git a/Magick++/lib/Pixels.cpp b/Magick++/lib/Pixels.cpp
index d9e8328..a88433f 100644
--- a/Magick++/lib/Pixels.cpp
+++ b/Magick++/lib/Pixels.cpp
@@ -105,7 +105,7 @@
   _columns = columns_;
   _rows = rows_;
 
-  PixelPacket* pixels = QueueCacheViewAuthenticPixels( _view, static_cast<long>(x_), static_cast<long>(y_),
+  PixelPacket* pixels = QueueCacheViewAuthenticPixels( _view, static_cast<ssize_t>(x_), static_cast<ssize_t>(y_),
                                       columns_, rows_,  &_exception );
   if ( !pixels )
     throwException( _exception );
diff --git a/Magick++/lib/STL.cpp b/Magick++/lib/STL.cpp
index 6a7a8a1..5f416c1 100644
--- a/Magick++/lib/STL.cpp
+++ b/Magick++/lib/STL.cpp
@@ -296,7 +296,7 @@
 // usally of the same size as the source image, unless 'bestfit' is set to
 // true.
 Magick::distortImage::distortImage( const Magick::DistortImageMethod method_,
-                                    const unsigned long number_arguments_,
+                                    const size_t number_arguments_,
                                     const double *arguments_,
                                     const bool bestfit_ )
   : _method ( method_ ),
@@ -306,7 +306,7 @@
 {
 }
 Magick::distortImage::distortImage( const Magick::DistortImageMethod method_,
-                                    const unsigned long number_arguments_,
+                                    const size_t number_arguments_,
                                     const double *arguments_ )
   : _method ( method_ ),
     _number_arguments ( number_arguments_ ),
diff --git a/Magick++/tests/attributes.cpp b/Magick++/tests/attributes.cpp
index 7da08df..8e3dde4 100644
--- a/Magick++/tests/attributes.cpp
+++ b/Magick++/tests/attributes.cpp
@@ -691,7 +691,7 @@
       {
 	++failures;
 	cout << "Line: " << __LINE__ << ", fileSize ("
-	     << static_cast<long>(image.fileSize())
+	     << static_cast<ssize_t>(image.fileSize())
 	     << ") is not zero as expected" << endl;
       }
 
diff --git a/Magick++/tests/colorHistogram.cpp b/Magick++/tests/colorHistogram.cpp
index 1600148..4418eac 100644
--- a/Magick++/tests/colorHistogram.cpp
+++ b/Magick++/tests/colorHistogram.cpp
@@ -44,9 +44,9 @@
 
     // Create histogram vector
 #if defined(USE_MAP)
-    std::map<Color,unsigned long> histogram;
+    std::map<Color,size_t> histogram;
 #elif defined(USE_VECTOR)
-    std::vector<std::pair<Color,unsigned long> > histogram;
+    std::vector<std::pair<Color,size_t> > histogram;
 #endif
 
     colorHistogram( &histogram, image );
@@ -64,9 +64,9 @@
          << histogram.size() << " entries:" << endl;
 
 #if defined(USE_MAP)
-    std::map<Color,unsigned long>::const_iterator p=histogram.begin();
+    std::map<Color,size_t>::const_iterator p=histogram.begin();
 #elif defined(USE_VECTOR)
-    std::vector<std::pair<Color,unsigned long> >::const_iterator p=histogram.begin();
+    std::vector<std::pair<Color,size_t> >::const_iterator p=histogram.begin();
 #endif
     while (p != histogram.end())
       {
diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs
index dd4060a..20813f4 100644
--- a/PerlMagick/Magick.xs
+++ b/PerlMagick/Magick.xs
@@ -159,14 +159,14 @@
   const char
     *method;
 
-  long
+  ssize_t
     type;
 } Arguments;
 
 struct ArgumentList
 {
-  long
-    long_reference;
+  ssize_t
+    integer_reference;
 
   MagickRealType
     real_reference;
@@ -543,7 +543,7 @@
 static Image
   *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
 
-static long
+static ssize_t
   strEQcase(const char *,const char *);
 
 /*
@@ -610,7 +610,7 @@
 %
 %  The format of the constant routine is:
 %
-%      double constant(char *name,long sans)
+%      double constant(char *name,ssize_t sans)
 %
 %  A description of each parameter follows:
 %
@@ -621,7 +621,7 @@
 %    o sans: This integer value is not used.
 %
 */
-static double constant(char *name,long sans)
+static double constant(char *name,ssize_t sans)
 {
   (void) sans;
   errno=0;
@@ -833,8 +833,8 @@
 %    o info: a structure of type info.
 %
 */
-static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,long *current,
-  long *last,ExceptionInfo *exception)
+static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,ssize_t *current,
+  ssize_t *last,ExceptionInfo *exception)
 {
   Image
     *image;
@@ -852,10 +852,10 @@
         *head,
         *previous;
 
-      long
+      ssize_t
         n;
 
-      register long
+      register ssize_t
         i;
 
       /*
@@ -927,7 +927,7 @@
       break;
   }
   (void) fprintf(stderr,"GetList: UnrecognizedType %ld\n",
-    (long) SvTYPE(reference));
+    (ssize_t) SvTYPE(reference));
   return((Image *) NULL);
 }
 
@@ -971,7 +971,7 @@
     *sv;
 
   (void) FormatMagickString(message,MaxTextExtent,"%s::package%s%lx",
-    PackageName,XS_VERSION,(long) reference);
+    PackageName,XS_VERSION,(ssize_t) reference);
   sv=perl_get_sv(message,(TRUE | 0x02));
   if (sv == (SV *) NULL)
     {
@@ -1049,7 +1049,7 @@
   return(strtod(value,(char **) NULL));
 }
 
-static inline long StringToLong(const char *value)
+static inline ssize_t StringToLong(const char *value)
 {
   return(strtol(value,(char **) NULL,10));
 }
@@ -1060,10 +1060,10 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     sp;
 
-  long
+  ssize_t
     x,
     y;
 
@@ -1229,14 +1229,14 @@
             int
               items;
 
-            long
+            ssize_t
               i;
 
             if (image->storage_class == DirectClass)
               continue;
             i=0;
             items=sscanf(attribute,"%*[^[][%ld",&i);
-            if (i > (long) image->colors)
+            if (i > (ssize_t) image->colors)
               i%=image->colors;
             if ((strchr(SvPV(sval,na),',') == 0) ||
                 (strchr(SvPV(sval,na),')') != 0))
@@ -1315,9 +1315,9 @@
           flags=ParseGeometry(SvPV(sval,na),&geometry_info);
           for ( ; image; image=image->next)
           {
-            image->delay=(unsigned long) floor(geometry_info.rho+0.5);
+            image->delay=(size_t) floor(geometry_info.rho+0.5);
             if ((flags & SigmaValue) != 0)
-              image->ticks_per_second=(unsigned long)
+              image->ticks_per_second=(size_t)
                 floor(geometry_info.sigma+0.5);
           }
           break;
@@ -1558,7 +1558,7 @@
           int
             items;
 
-          long
+          ssize_t
             index;
 
           register PixelPacket
@@ -1580,7 +1580,7 @@
               {
                 indexes=GetCacheViewAuthenticIndexQueue(image_view);
                 items=sscanf(SvPV(sval,na),"%ld",&index);
-                if ((index >= 0) && (index < (long) image->colors))
+                if ((index >= 0) && (index < (ssize_t) image->colors))
                   *indexes=(IndexPacket) index;
                 (void) SyncCacheViewAuthenticPixels(image_view,exception);
               }
@@ -2265,7 +2265,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     current,
     last;
 
@@ -2299,7 +2299,7 @@
 %
 %  The format of the strEQcase routine is:
 %
-%      long strEQcase(const char *p,const char *q)
+%      ssize_t strEQcase(const char *p,const char *q)
 %
 %  A description of each parameter follows:
 %
@@ -2309,12 +2309,12 @@
 %
 %
 */
-static long strEQcase(const char *p,const char *q)
+static ssize_t strEQcase(const char *p,const char *q)
 {
   char
     c;
 
-  register long
+  register ssize_t
     i;
 
   for (i=0 ; (c=(*q)) != 0; i++)
@@ -2364,7 +2364,7 @@
 double
 constant(name,argument)
   char *name
-  long argument
+  ssize_t argument
 
 #
 ###############################################################################
@@ -2393,7 +2393,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -2480,10 +2480,10 @@
     Image
       *image;
 
-    long
+    ssize_t
       stack;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -2711,7 +2711,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       ac,
       n,
       number_images;
@@ -2719,7 +2719,7 @@
     register char
       **p;
 
-    register long
+    register ssize_t
       i;
 
     STRLEN
@@ -3083,13 +3083,13 @@
       *image,
       *reconstruct_image;
 
-    long
+    ssize_t
       option;
 
     MetricType
       metric;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -3141,7 +3141,7 @@
         {
           if (LocaleCompare(attribute,"channel") == 0)
             {
-              long
+              ssize_t
                 option;
 
               option=ParseChannelOption(SvPV(ST(i),na));
@@ -3270,13 +3270,13 @@
     Image
       *image;
 
-    long
+    ssize_t
       option;
 
     ImageLayerMethod
       method;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -3413,7 +3413,7 @@
           Array (AV *) reference
         */
         (void) FormatMagickString(message,MaxTextExtent,"package%s%lx",
-          XS_VERSION,(long) reference);
+          XS_VERSION,(ssize_t) reference);
         hv=gv_stashpv(PackageName, FALSE);
         if (!hv)
           break;
@@ -3474,7 +3474,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -3564,7 +3564,7 @@
     MagickEvaluateOperator
       op;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -3596,7 +3596,7 @@
     op=MeanEvaluateOperator;
     if (items == 2)
       {
-        long
+        ssize_t
           in;
 
         in=ParseMagickOption(MagickEvaluateOptions,MagickFalse,(char *)
@@ -3620,7 +3620,7 @@
           {
             if (LocaleCompare(attribute,"operator") == 0)
               {
-                long
+                ssize_t
                   in;
 
                 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
@@ -3768,7 +3768,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     ssize_t
@@ -3899,7 +3899,7 @@
     PixelPacket
       background_color;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -4033,7 +4033,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -4087,7 +4087,7 @@
           {
             if (LocaleCompare(attribute,"channel") == 0)
               {
-                long
+                ssize_t
                   option;
 
                 option=ParseChannelOption(SvPV(ST(i),na));
@@ -4185,10 +4185,10 @@
     Image
       *image;
 
-    long
+    ssize_t
       j;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -4224,14 +4224,14 @@
           if (LocaleCompare(attribute,"adjoin") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->adjoin);
+                s=newSViv((ssize_t) info->image_info->adjoin);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"antialias") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->antialias);
+                s=newSViv((ssize_t) info->image_info->antialias);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4281,7 +4281,7 @@
           if (LocaleCompare(attribute,"base-columns") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->magick_columns);
+                s=newSViv((ssize_t) image->magick_columns);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4295,21 +4295,21 @@
           if (LocaleCompare(attribute,"base-height") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->magick_rows);
+                s=newSViv((ssize_t) image->magick_rows);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"base-rows") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->magick_rows);
+                s=newSViv((ssize_t) image->magick_rows);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"base-width") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->magick_columns);
+                s=newSViv((ssize_t) image->magick_columns);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4440,7 +4440,7 @@
           if (LocaleCompare(attribute,"colors") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) GetNumberColors(image,(FILE *) NULL,
+                s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
                   &image->exception));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4454,7 +4454,7 @@
                 break;
               j=0;
               items=sscanf(attribute,"%*[^[][%ld",&j);
-              if (j > (long) image->colors)
+              if (j > (ssize_t) image->colors)
                 j%=image->colors;
               (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
                 QuantumFormat "," QuantumFormat "," QuantumFormat,
@@ -4467,7 +4467,7 @@
           if (LocaleCompare(attribute,"columns") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->columns);
+                s=newSViv((ssize_t) image->columns);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4511,7 +4511,7 @@
           if (LocaleCompare(attribute,"delay") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->delay);
+                s=newSViv((ssize_t) image->delay);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4519,7 +4519,7 @@
             {
               s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
               if (image != (Image *) NULL)
-                s=newSViv((long) GetImageDepth(image,&image->exception));
+                s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4551,7 +4551,7 @@
           if (LocaleCompare(attribute,"dither") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->dither);
+                s=newSViv((ssize_t) info->image_info->dither);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4602,7 +4602,7 @@
           if (LocaleCompare(attribute,"filesize") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) GetBlobSize(image));
+                s=newSViv((ssize_t) GetBlobSize(image));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4710,7 +4710,7 @@
           if (LocaleCompare(attribute,"height") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->rows);
+                s=newSViv((ssize_t) image->rows);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4761,7 +4761,7 @@
                   MagickBooleanType
                     status;
 
-                  static long
+                  static ssize_t
                     id = 0;
 
                   (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
@@ -4780,7 +4780,7 @@
               int
                 items;
 
-              long
+              ssize_t
                 x,
                 y;
 
@@ -4831,7 +4831,7 @@
           if (LocaleCompare(attribute,"iterations") == 0)  /* same as loop */
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->iterations);
+                s=newSViv((ssize_t) image->iterations);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4868,7 +4868,7 @@
           if (LocaleCompare(attribute,"loop") == 0)  /* same as iterations */
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->iterations);
+                s=newSViv((ssize_t) image->iterations);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -4938,7 +4938,7 @@
           if (LocaleCompare(attribute,"matte") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->matte);
+                s=newSViv((ssize_t) image->matte);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5025,14 +5025,14 @@
           if (LocaleCompare(attribute,"page.x") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->page.x);
+                s=newSViv((ssize_t) image->page.x);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"page.y") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->page.y);
+                s=newSViv((ssize_t) image->page.y);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5044,7 +5044,7 @@
               int
                 items;
 
-              long
+              ssize_t
                 x,
                 y;
 
@@ -5076,7 +5076,7 @@
           if (LocaleCompare(attribute,"pointsize") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->pointsize);
+                s=newSViv((ssize_t) info->image_info->pointsize);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5099,16 +5099,16 @@
           if (LocaleCompare(attribute,"quality") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->quality);
+                s=newSViv((ssize_t) info->image_info->quality);
               if (image != (Image *) NULL)
-                s=newSViv((long) image->quality);
+                s=newSViv((ssize_t) image->quality);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"quantum") == 0)
             {
               if (info)
-                s=newSViv((long) MAGICKCORE_QUANTUM_DEPTH);
+                s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5142,7 +5142,7 @@
           if (LocaleCompare(attribute,"rows") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->rows);
+                s=newSViv((ssize_t) image->rows);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5163,14 +5163,14 @@
           if (LocaleCompare(attribute,"subimage") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->subimage);
+                s=newSViv((ssize_t) info->image_info->subimage);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"subrange") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->subrange);
+                s=newSViv((ssize_t) info->image_info->subrange);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5191,14 +5191,14 @@
           if (LocaleCompare(attribute,"scene") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->scene);
+                s=newSViv((ssize_t) image->scene);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"scenes") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) info->image_info->number_scenes);
+                s=newSViv((ssize_t) info->image_info->number_scenes);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5226,7 +5226,7 @@
           if (LocaleCompare(attribute,"taint") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) IsTaintImage(image));
+                s=newSViv((ssize_t) IsTaintImage(image));
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5268,7 +5268,7 @@
             {
               if (image == (Image *) NULL)
                 break;
-              j=(long) GetImageType(image,&image->exception);
+              j=(ssize_t) GetImageType(image,&image->exception);
               s=newSViv(j);
               (void) sv_setpv(s,MagickOptionToMnemonic(MagickTypeOptions,j));
               SvIOK_on(s);
@@ -5315,13 +5315,13 @@
           if (LocaleCompare(attribute,"verbose") == 0)
             {
               if (info)
-                s=newSViv((long) info->image_info->verbose);
+                s=newSViv((ssize_t) info->image_info->verbose);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
           if (LocaleCompare(attribute,"version") == 0)
             {
-              s=newSVpv(GetMagickVersion((unsigned long *) NULL),0);
+              s=newSVpv(GetMagickVersion((size_t *) NULL),0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5336,7 +5336,7 @@
             {
               if (image == (Image *) NULL)
                 break;
-              j=(long) GetImageVirtualPixelMethod(image);
+              j=(ssize_t) GetImageVirtualPixelMethod(image);
               s=newSViv(j);
               (void) sv_setpv(s,MagickOptionToMnemonic(
                 MagickVirtualPixelOptions,j));
@@ -5365,7 +5365,7 @@
           if (LocaleCompare(attribute,"width") == 0)
             {
               if (image != (Image *) NULL)
-                s=newSViv((long) image->columns);
+                s=newSViv((ssize_t) image->columns);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
             }
@@ -5466,7 +5466,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       i;
 
     RectangleInfo
@@ -5622,7 +5622,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       i;
 
     RectangleInfo
@@ -5919,7 +5919,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     ssize_t
@@ -5933,7 +5933,7 @@
       *perl_exception,
       *reference;
 
-    unsigned long
+    size_t
       number_colors;
 
     exception=AcquireExceptionInfo();
@@ -5966,7 +5966,7 @@
         continue;
       count+=number_colors;
       EXTEND(sp,6*count);
-      for (i=0; i < (long) number_colors; i++)
+      for (i=0; i < (ssize_t) number_colors; i++)
       {
         (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
           histogram[i].pixel.red);
@@ -5987,7 +5987,7 @@
           histogram[i].pixel.opacity);
         PUSHs(sv_2mortal(newSVpv(message,0)));
         (void) FormatMagickString(message,MaxTextExtent,"%lu",
-           (unsigned long) histogram[i].count);
+           (size_t) histogram[i].count);
         PUSHs(sv_2mortal(newSVpv(message,0)));
       }
       histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
@@ -6034,7 +6034,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       option;
 
     MagickBooleanType
@@ -6049,7 +6049,7 @@
     register const PixelPacket
       *p;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -6090,7 +6090,7 @@
         {
           if (LocaleCompare(attribute,"channel") == 0)
             {
-              long
+              ssize_t
                 option;
 
               option=ParseChannelOption(SvPV(ST(i),na));
@@ -6237,7 +6237,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       option;
 
     MagickBooleanType
@@ -6247,7 +6247,7 @@
     RectangleInfo
       region;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -6411,7 +6411,7 @@
         else
           {
             EXTEND(sp,strlen(map)*region.width*region.height);
-            for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
+            for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
               PUSHs(sv_2mortal(newSVnv(pixels[i])));
           }
         pixels=(float *) RelinquishMagickMemory(pixels);
@@ -6436,7 +6436,7 @@
         else
           {
             EXTEND(sp,strlen(map)*region.width*region.height);
-            for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
+            for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
               PUSHs(sv_2mortal(newSViv(pixels[i])));
           }
         pixels=(Quantum *) RelinquishMagickMemory(pixels);
@@ -6480,10 +6480,10 @@
       *image,
       *next;
 
-    long
+    ssize_t
       scene;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -6530,7 +6530,7 @@
     }
     SetImageInfo(package_info->image_info,(unsigned int)
       GetImageListLength(image),&image->exception);
-    EXTEND(sp,(long) GetImageListLength(image));
+    EXTEND(sp,(ssize_t) GetImageListLength(image));
     for ( ; image; image=image->next)
     {
       length=0;
@@ -6594,7 +6594,7 @@
       *image,
       *layers;
 
-    long
+    ssize_t
       option,
       sp;
 
@@ -6604,7 +6604,7 @@
     ImageLayerMethod
       method;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -7225,7 +7225,7 @@
       *next,
       *region_image;
 
-    long
+    ssize_t
       base,
       j,
       number_images;
@@ -7243,7 +7243,7 @@
       geometry,
       region_info;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -7324,8 +7324,8 @@
     Zero(&attribute_flag,NumberOf(attribute_flag),char);
     for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
     {
-      long
-        longest;
+      ssize_t
+        ssize_test;
 
       Arguments
         *pp,
@@ -7337,7 +7337,7 @@
       SV
         *sv;
 
-      longest=0;
+      ssize_test=0;
       pp=(Arguments *) NULL;
       qq=rp->arguments;
       if (i == items)
@@ -7350,10 +7350,10 @@
         {
           if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
             break;
-          if (strEQcase(attribute,qq->method) > longest)
+          if (strEQcase(attribute,qq->method) > ssize_test)
             {
               pp=qq;
-              longest=strEQcase(attribute,qq->method);
+              ssize_test=strEQcase(attribute,qq->method);
             }
         }
       if (pp == (Arguments *) NULL)
@@ -7401,7 +7401,7 @@
         }
         case IntegerReference:
         {
-          al->long_reference=SvIV(sv);
+          al->integer_reference=SvIV(sv);
           break;
         }
         case StringReference:
@@ -7420,14 +7420,14 @@
           if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
             {
               al->string_reference=(char *) SvPV(sv,al->length);
-              al->long_reference=(-1);
+              al->integer_reference=(-1);
               break;
             }
-          al->long_reference=ParseMagickOption((MagickOption) pp->type,
+          al->integer_reference=ParseMagickOption((MagickOption) pp->type,
             MagickFalse,SvPV(sv,na));
           if (pp->type == MagickChannelOptions)
-            al->long_reference=ParseChannelOption(SvPV(sv,na));
-          if ((al->long_reference < 0) && ((al->long_reference=SvIV(sv)) <= 0))
+            al->integer_reference=ParseChannelOption(SvPV(sv,na));
+          if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
             {
               (void) FormatMagickString(message,MaxTextExtent,
                 "invalid %.60s value",pp->method);
@@ -7457,7 +7457,7 @@
       {
         default:
         {
-          (void) FormatMagickString(message,MaxTextExtent,"%ld",(long) ix);
+          (void) FormatMagickString(message,MaxTextExtent,"%ld",(ssize_t) ix);
           ThrowPerlException(exception,OptionError,
             "UnrecognizedPerlMagickMethod",message);
           goto PerlException;
@@ -7483,11 +7483,11 @@
         case 3:  /* AddNoise */
         {
           if (attribute_flag[0] == 0)
-            argument_list[0].long_reference=UniformNoise;
+            argument_list[0].integer_reference=UniformNoise;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           image=AddNoiseImageChannel(image,channel,(NoiseType)
-            argument_list[0].long_reference,exception);
+            argument_list[0].integer_reference,exception);
           break;
         }
         case 4:  /* Colorize */
@@ -7517,9 +7517,9 @@
                 geometry.height=geometry.width;
             }
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
             QueryColorDatabase(argument_list[3].string_reference,
               &image->border_color,exception);
@@ -7530,7 +7530,7 @@
             QueryColorDatabase(argument_list[5].string_reference,
               &image->border_color,exception);
           if (attribute_flag[6] != 0)
-            image->compose=(CompositeOperator) argument_list[6].long_reference;
+            image->compose=(CompositeOperator) argument_list[6].integer_reference;
           image=BorderImage(image,&geometry,exception);
           break;
         }
@@ -7548,7 +7548,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=BlurImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,exception);
           break;
@@ -7559,31 +7559,31 @@
             flags=ParseGravityGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            geometry.x=argument_list[3].long_reference;
+            geometry.x=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry.y=argument_list[4].long_reference;
+            geometry.y=argument_list[4].integer_reference;
           image=ChopImage(image,&geometry,exception);
           break;
         }
         case 8:  /* Crop */
         {
           if (attribute_flag[6] != 0)
-            image->gravity=(GravityType) argument_list[6].long_reference;
+            image->gravity=(GravityType) argument_list[6].integer_reference;
           if (attribute_flag[0] != 0)
             flags=ParseGravityGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            geometry.x=argument_list[3].long_reference;
+            geometry.x=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry.y=argument_list[4].long_reference;
+            geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             image->fuzz=
               SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
@@ -7651,27 +7651,27 @@
               frame_info.inner_bevel=geometry.y;
             }
           if (attribute_flag[1] != 0)
-            frame_info.width=argument_list[1].long_reference;
+            frame_info.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            frame_info.height=argument_list[2].long_reference;
+            frame_info.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            frame_info.inner_bevel=argument_list[3].long_reference;
+            frame_info.inner_bevel=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            frame_info.outer_bevel=argument_list[4].long_reference;
+            frame_info.outer_bevel=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             QueryColorDatabase(argument_list[5].string_reference,&fill_color,
               exception);
           if (attribute_flag[6] != 0)
             QueryColorDatabase(argument_list[6].string_reference,&fill_color,
               exception);
-          frame_info.x=(long) frame_info.width;
-          frame_info.y=(long) frame_info.height;
+          frame_info.x=(ssize_t) frame_info.width;
+          frame_info.y=(ssize_t) frame_info.height;
           frame_info.width=image->columns+2*frame_info.x;
           frame_info.height=image->rows+2*frame_info.y;
           if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
             image->matte_color=fill_color;
           if (attribute_flag[7] != 0)
-            image->compose=(CompositeOperator) argument_list[7].long_reference;
+            image->compose=(CompositeOperator) argument_list[7].integer_reference;
           image=FrameImage(image,&frame_info,exception);
           break;
         }
@@ -7681,7 +7681,7 @@
             argument_list[0].real_reference=0.5;
           if (attribute_flag[1] != 0)
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[1].long_reference;
+              argument_list[1].integer_reference;
           image=ImplodeImage(image,argument_list[0].real_reference,
             exception);
           break;
@@ -7726,9 +7726,9 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.x=argument_list[1].long_reference;
+            geometry.x=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.y=argument_list[2].long_reference;
+            geometry.y=argument_list[2].integer_reference;
           image=RollImage(image,geometry.x,geometry.y,exception);
           break;
         }
@@ -7754,9 +7754,9 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           image=SampleImage(image,geometry.width,geometry.height,exception);
           break;
         }
@@ -7766,9 +7766,9 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           image=ScaleImage(image,geometry.width,geometry.height,exception);
           break;
         }
@@ -7786,7 +7786,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           image=ShadeImage(image,
-            argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
+            argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
             geometry_info.rho,geometry_info.sigma,exception);
           break;
         }
@@ -7804,7 +7804,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=SharpenImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,exception);
           break;
@@ -7845,7 +7845,7 @@
             argument_list[0].real_reference=50.0;
           if (attribute_flag[1] != 0)
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[1].long_reference;
+              argument_list[1].integer_reference;
           image=SwirlImage(image,argument_list[0].real_reference,exception);
           break;
         }
@@ -7856,18 +7856,18 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] == 0)
-            argument_list[3].long_reference=(long) UndefinedFilter;
+            argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
           if (attribute_flag[4] != 0)
             SetImageArtifact(image,"filter:support",
               argument_list[4].string_reference);
           if (attribute_flag[5] == 0)
             argument_list[5].real_reference=1.0;
           image=ResizeImage(image,geometry.width,geometry.height,
-            (FilterTypes) argument_list[3].long_reference,
+            (FilterTypes) argument_list[3].integer_reference,
             argument_list[5].real_reference,exception);
           break;
         }
@@ -7928,7 +7928,7 @@
             (void) QueryColorDatabase(argument_list[8].string_reference,
               &draw_info->fill,exception);
           if (attribute_flag[11] != 0)
-            draw_info->gravity=(GravityType) argument_list[11].long_reference;
+            draw_info->gravity=(GravityType) argument_list[11].integer_reference;
           if (attribute_flag[25] != 0)
             {
               AV
@@ -8049,7 +8049,7 @@
             draw_info->stroke_width=argument_list[17].real_reference;
           if (attribute_flag[18] != 0)
             {
-              draw_info->text_antialias=argument_list[18].long_reference != 0 ?
+              draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
                 MagickTrue : MagickFalse;
               draw_info->stroke_antialias=draw_info->text_antialias;
             }
@@ -8057,13 +8057,13 @@
             (void) CloneString(&draw_info->family,
               argument_list[19].string_reference);
           if (attribute_flag[20] != 0)
-            draw_info->style=(StyleType) argument_list[20].long_reference;
+            draw_info->style=(StyleType) argument_list[20].integer_reference;
           if (attribute_flag[21] != 0)
-            draw_info->stretch=(StretchType) argument_list[21].long_reference;
+            draw_info->stretch=(StretchType) argument_list[21].integer_reference;
           if (attribute_flag[22] != 0)
-            draw_info->weight=argument_list[22].long_reference;
+            draw_info->weight=argument_list[22].integer_reference;
           if (attribute_flag[23] != 0)
-            draw_info->align=(AlignType) argument_list[23].long_reference;
+            draw_info->align=(AlignType) argument_list[23].integer_reference;
           if (attribute_flag[24] != 0)
             (void) CloneString(&draw_info->encoding,
               argument_list[24].string_reference);
@@ -8084,7 +8084,7 @@
             draw_info->interword_spacing=argument_list[31].real_reference;
           if (attribute_flag[32] != 0)
             draw_info->direction=(DirectionType)
-              argument_list[32].long_reference;
+              argument_list[32].integer_reference;
           (void) AnnotateImage(image,draw_info);
           draw_info=DestroyDrawInfo(draw_info);
           break;
@@ -8106,9 +8106,9 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.x=argument_list[1].long_reference;
+            geometry.x=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.y=argument_list[2].long_reference;
+            geometry.y=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
             (void) QueryColorDatabase(argument_list[3].string_reference,
               &draw_info->fill,exception);
@@ -8125,7 +8125,7 @@
             image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
               QuantumRange);
           if (attribute_flag[6] != 0)
-            invert=(MagickBooleanType) argument_list[6].long_reference;
+            invert=(MagickBooleanType) argument_list[6].integer_reference;
           (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
             geometry.x,geometry.y,invert);
           draw_info=DestroyDrawInfo(draw_info);
@@ -8153,7 +8153,7 @@
             Parameter Handling used for BOTH normal and tiled composition.
           */
           if (attribute_flag[1] != 0) /* compose */
-            compose=(CompositeOperator) argument_list[1].long_reference;
+            compose=(CompositeOperator) argument_list[1].integer_reference;
           if (attribute_flag[6] != 0) /* opacity  */
             {
               if (compose != DissolveCompositeOp)
@@ -8165,13 +8165,13 @@
                   double
                     opacity;
 
-                  long
+                  ssize_t
                     y;
 
                   MagickBooleanType
                     sync;
 
-                  register long
+                  register ssize_t
                     x;
 
                   register PixelPacket
@@ -8191,11 +8191,11 @@
                   if (composite_image->matte != MagickTrue)
                     (void) SetImageOpacity(composite_image,OpaqueOpacity);
                   composite_view=AcquireCacheView(composite_image);
-                  for (y=0; y < (long) composite_image->rows ; y++)
+                  for (y=0; y < (ssize_t) composite_image->rows ; y++)
                   {
-                    q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
+                    q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
                       composite_image->columns,1,exception);
-                    for (x=0; x < (long) composite_image->columns; x++)
+                    for (x=0; x < (ssize_t) composite_image->columns; x++)
                     {
                       if (q->opacity == OpaqueOpacity)
                         q->opacity=ClampToQuantum(opacity);
@@ -8213,7 +8213,7 @@
               &composite_image->background_color,exception);
           if (attribute_flag[12] != 0) /* "interpolate=>" */
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[12].long_reference;
+              argument_list[12].integer_reference;
           if (attribute_flag[13] != 0)   /* "args=>" */
             (void) SetImageArtifact(composite_image,"compose:args",
               argument_list[13].string_reference);
@@ -8234,9 +8234,9 @@
                if (rotate_image == (Image *) NULL)
                  break;
             }
-          if (attribute_flag[7] && argument_list[7].long_reference) /* tile */
+          if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
             {
-              long
+              ssize_t
                 x,
                 y;
 
@@ -8249,8 +8249,8 @@
              else
                (void) SetImageArtifact(composite_image,
                  "compose:outside-overlay","false");
-             for (y=0; y < (long) image->rows; y+=composite_image->rows)
-                for (x=0; x < (long) image->columns; x+=composite_image->columns)
+             for (y=0; y < (ssize_t) image->rows; y+=composite_image->rows)
+                for (x=0; x < (ssize_t) image->columns; x+=composite_image->columns)
                 {
                   if (attribute_flag[8] != 0) /* rotate */
                     (void) CompositeImage(image,compose,rotate_image,x,y);
@@ -8265,7 +8265,7 @@
             Parameter Handling used used ONLY for normal composition.
           */
           if (attribute_flag[5] != 0) /* gravity */
-            image->gravity=(GravityType) argument_list[5].long_reference;
+            image->gravity=(GravityType) argument_list[5].integer_reference;
           if (attribute_flag[2] != 0) /* geometry offset */
             {
               SetGeometry(image,&geometry);
@@ -8275,9 +8275,9 @@
                 &geometry);
             }
           if (attribute_flag[3] != 0) /* x offset */
-            geometry.x=argument_list[3].long_reference;
+            geometry.x=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0) /* y offset */
-            geometry.y=argument_list[4].long_reference;
+            geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[10] != 0) /* mask */
             {
               if ((image->compose == DisplaceCompositeOp) ||
@@ -8302,7 +8302,7 @@
                 }
             }
           if (attribute_flag[11] != 0) /* channel */
-            channel=(ChannelType) argument_list[11].long_reference;
+            channel=(ChannelType) argument_list[11].integer_reference;
           /*
             Composite two images (normal composition).
           */
@@ -8319,9 +8319,9 @@
               /*
                 Position adjust rotated image then composite.
               */
-              geometry.x-=(long) (rotate_image->columns-
+              geometry.x-=(ssize_t) (rotate_image->columns-
                 composite_image->columns)/2;
-              geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
+              geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
               CompositeImageChannel(image,channel,compose,rotate_image,
                 geometry.x,geometry.y);
               rotate_image=DestroyImage(rotate_image);
@@ -8339,16 +8339,16 @@
         case 36:  /* Contrast */
         {
           if (attribute_flag[0] == 0)
-            argument_list[0].long_reference=0;
-          (void) ContrastImage(image,argument_list[0].long_reference != 0 ?
+            argument_list[0].integer_reference=0;
+          (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
             MagickTrue : MagickFalse);
           break;
         }
         case 37:  /* CycleColormap */
         {
           if (attribute_flag[0] == 0)
-            argument_list[0].long_reference=6;
-          (void) CycleColormapImage(image,argument_list[0].long_reference);
+            argument_list[0].integer_reference=6;
+          (void) CycleColormapImage(image,argument_list[0].integer_reference);
           break;
         }
         case 38:  /* Draw */
@@ -8361,12 +8361,12 @@
           (void) CloneString(&draw_info->primitive,"point");
           if (attribute_flag[0] != 0)
             {
-              if (argument_list[0].long_reference < 0)
+              if (argument_list[0].integer_reference < 0)
                 (void) CloneString(&draw_info->primitive,
                   argument_list[0].string_reference);
               else
                 (void) CloneString(&draw_info->primitive,MagickOptionToMnemonic(
-                  MagickPrimitiveOptions,argument_list[0].long_reference));
+                  MagickPrimitiveOptions,argument_list[0].integer_reference));
             }
           if (attribute_flag[1] != 0)
             {
@@ -8389,7 +8389,7 @@
               (void) ConcatenateString(&draw_info->primitive," ");
               (void) ConcatenateString(&draw_info->primitive,
                 MagickOptionToMnemonic(MagickMethodOptions,
-                argument_list[2].long_reference));
+                argument_list[2].integer_reference));
             }
           if (attribute_flag[3] != 0)
             {
@@ -8528,7 +8528,7 @@
             draw_info->pointsize=argument_list[16].real_reference;
           if (attribute_flag[17] != 0)
             {
-              draw_info->stroke_antialias=argument_list[17].long_reference != 0
+              draw_info->stroke_antialias=argument_list[17].integer_reference != 0
                 ? MagickTrue : MagickFalse;
               draw_info->text_antialias=draw_info->stroke_antialias;
             }
@@ -8557,7 +8557,7 @@
             }
           if (attribute_flag[23] != 0)
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[23].long_reference;
+              argument_list[23].integer_reference;
           if ((attribute_flag[24] != 0) &&
               (draw_info->fill_pattern != (Image *) NULL))
             flags=ParsePageGeometry(draw_info->fill_pattern,
@@ -8587,7 +8587,7 @@
             draw_info->interword_spacing=argument_list[31].real_reference;
           if (attribute_flag[32] != 0)
             draw_info->direction=(DirectionType)
-              argument_list[32].long_reference;
+              argument_list[32].integer_reference;
           DrawImage(image,draw_info);
           draw_info=DestroyDrawInfo(draw_info);
           break;
@@ -8595,14 +8595,14 @@
         case 39:  /* Equalize */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           EqualizeImageChannel(image,channel);
           break;
         }
         case 40:  /* Gamma */
         {
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           if (attribute_flag[2] == 0)
             argument_list[2].real_reference=1.0;
           if (attribute_flag[3] == 0)
@@ -8638,10 +8638,10 @@
           quantize_info=AcquireQuantizeInfo(info->image_info);
           if (attribute_flag[1] != 0)
             quantize_info->dither=(MagickBooleanType)
-              argument_list[1].long_reference;
+              argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
             quantize_info->dither_method=(DitherMethod)
-              argument_list[2].long_reference;
+              argument_list[2].integer_reference;
           (void) RemapImages(quantize_info,image,
             argument_list[0].image_reference);
           quantize_info=DestroyQuantizeInfo(quantize_info);
@@ -8665,9 +8665,9 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.x=argument_list[1].long_reference;
+            geometry.x=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.y=argument_list[2].long_reference;
+            geometry.y=argument_list[2].integer_reference;
           if (image->matte == MagickFalse)
             (void) SetImageOpacity(image,OpaqueOpacity);
           (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
@@ -8683,7 +8683,7 @@
               QuantumRange);
           invert=MagickFalse;
           if (attribute_flag[6] != 0)
-            invert=(MagickBooleanType) argument_list[6].long_reference;
+            invert=(MagickBooleanType) argument_list[6].integer_reference;
           (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
             geometry.x,geometry.y,invert);
           draw_info=DestroyDrawInfo(draw_info);
@@ -8734,17 +8734,17 @@
         case 44:  /* Negate */
         {
           if (attribute_flag[0] == 0)
-            argument_list[0].long_reference=0;
+            argument_list[0].integer_reference=0;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           (void) NegateImageChannel(image,channel,
-            argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse);
+            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
           break;
         }
         case 45:  /* Normalize */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           NormalizeImageChannel(image,channel);
           break;
         }
@@ -8771,10 +8771,10 @@
             image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
               QuantumRange);
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           invert=MagickFalse;
           if (attribute_flag[4] != 0)
-            invert=(MagickBooleanType) argument_list[4].long_reference;
+            invert=(MagickBooleanType) argument_list[4].integer_reference;
           (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
             invert);
           break;
@@ -8786,31 +8786,31 @@
 
           quantize_info=AcquireQuantizeInfo(info->image_info);
           if (attribute_flag[0] != 0)
-            quantize_info->number_colors=(unsigned long)
-              argument_list[0].long_reference;
+            quantize_info->number_colors=(size_t)
+              argument_list[0].integer_reference;
           if (attribute_flag[1] != 0)
-            quantize_info->tree_depth=(unsigned long)
-              argument_list[1].long_reference;
+            quantize_info->tree_depth=(size_t)
+              argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
             quantize_info->colorspace=(ColorspaceType)
-              argument_list[2].long_reference;
+              argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            quantize_info->dither=argument_list[3].long_reference != 0 ?
+            quantize_info->dither=argument_list[3].integer_reference != 0 ?
               MagickTrue : MagickFalse;
           if (attribute_flag[4] != 0)
             quantize_info->measure_error=
-              argument_list[4].long_reference != 0 ? MagickTrue : MagickFalse;
+              argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
           if (attribute_flag[5] != 0)
             (void) QueryColorDatabase(argument_list[5].string_reference,
               &image->transparent_color,exception);
-          if (attribute_flag[5] && argument_list[5].long_reference)
+          if (attribute_flag[5] && argument_list[5].integer_reference)
             {
               (void) QuantizeImages(quantize_info,image);
               goto PerlException;
             }
           if (attribute_flag[6] != 0)
             quantize_info->dither_method=(DitherMethod)
-              argument_list[6].long_reference;
+              argument_list[6].integer_reference;
           if ((image->storage_class == DirectClass) ||
               (image->colors > quantize_info->number_colors) ||
               (quantize_info->colorspace == GRAYColorspace))
@@ -8826,12 +8826,12 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] == 0)
-            argument_list[3].long_reference=1;
-          (void) RaiseImage(image,&geometry,argument_list[3].long_reference !=
+            argument_list[3].integer_reference=1;
+          (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
             0 ? MagickTrue : MagickFalse);
           break;
         }
@@ -8864,9 +8864,9 @@
           if (attribute_flag[2] != 0)
             smoothing_threshold=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            colorspace=(ColorspaceType) argument_list[3].long_reference;
+            colorspace=(ColorspaceType) argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            verbose=argument_list[4].long_reference != 0 ?
+            verbose=argument_list[4].integer_reference != 0 ?
               MagickTrue : MagickFalse;
           (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
             smoothing_threshold);
@@ -8910,9 +8910,9 @@
           if (attribute_flag[0] == MagickFalse)
             argument_list[0].real_reference=0.0;
           if (attribute_flag[1] != MagickFalse)
-            op=(MagickEvaluateOperator) argument_list[1].long_reference;
+            op=(MagickEvaluateOperator) argument_list[1].integer_reference;
           if (attribute_flag[2] != MagickFalse)
-            channel=(ChannelType) argument_list[2].long_reference;
+            channel=(ChannelType) argument_list[2].integer_reference;
           (void) EvaluateImageChannel(image,channel,op,
             argument_list[0].real_reference,exception);
           break;
@@ -8940,10 +8940,10 @@
             image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
               QuantumRange);
           if (attribute_flag[3] == 0)
-            argument_list[3].long_reference=0;
+            argument_list[3].integer_reference=0;
           invert=MagickFalse;
           if (attribute_flag[3] != 0)
-            invert=(MagickBooleanType) argument_list[3].long_reference;
+            invert=(MagickBooleanType) argument_list[3].integer_reference;
           (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
             invert);
           break;
@@ -8956,7 +8956,7 @@
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference="50%";
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           threshold=SiPrefixToDouble(argument_list[0].string_reference,
             QuantumRange);
           (void) BilevelImageChannel(image,channel,threshold);
@@ -9002,7 +9002,7 @@
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[3].long_reference;
+              argument_list[3].integer_reference;
           image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
             exception);
           break;
@@ -9010,7 +9010,7 @@
         case 61:  /* Separate */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           (void) SeparateImageChannel(image,channel);
           break;
         }
@@ -9023,9 +9023,9 @@
               goto PerlException;
             }
           if (attribute_flag[1] != 0)
-            geometry.x=argument_list[1].long_reference;
+            geometry.x=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.y=argument_list[2].long_reference;
+            geometry.y=argument_list[2].integer_reference;
           image=StereoAnaglyphImage(image,argument_list[0].image_reference,
             geometry.x,geometry.y,exception);
           break;
@@ -9039,8 +9039,8 @@
               goto PerlException;
             }
           if (attribute_flag[1] == 0)
-            argument_list[1].long_reference=0;
-          image->offset=argument_list[1].long_reference;
+            argument_list[1].integer_reference=0;
+          image->offset=argument_list[1].integer_reference;
           image=SteganoImage(image,argument_list[0].image_reference,exception);
           break;
         }
@@ -9063,7 +9063,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,exception);
           break;
@@ -9076,18 +9076,18 @@
           double
             *kernel;
 
-          unsigned long
+          size_t
             order;
 
           if (attribute_flag[0] == 0)
             break;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
             image->bias=SiPrefixToDouble(argument_list[2].string_reference,
               QuantumRange);
           av=(AV *) argument_list[0].array_reference;
-          order=(unsigned long) sqrt(av_len(av)+1);
+          order=(size_t) sqrt(av_len(av)+1);
           kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
           if (kernel == (double *) NULL)
             {
@@ -9095,9 +9095,9 @@
                 "MemoryAllocationFailed",PackageName);
               goto PerlException;
             }
-          for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
+          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
             kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
-          for ( ; j < (long) (order*order); j++)
+          for ( ; j < (ssize_t) (order*order); j++)
             kernel[j]=0.0;
           image=ConvolveImageChannel(image,channel,order,kernel,exception);
           kernel=(double *) RelinquishMagickMemory(kernel);
@@ -9122,10 +9122,10 @@
             name=argument_list[0].string_reference;
           if (attribute_flag[2] != 0)
             image->rendering_intent=(RenderingIntent)
-              argument_list[2].long_reference;
+              argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
             image->black_point_compensation=
-              argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse;
+              argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
           if (attribute_flag[1] != 0)
             {
               if (argument_list[1].length == 0)
@@ -9144,7 +9144,7 @@
               SetStringInfoDatum(profile,(const unsigned char *)
                 argument_list[1].string_reference);
               (void) ProfileImage(image,name,GetStringInfoDatum(profile),
-                (unsigned long) GetStringInfoLength(profile),MagickFalse);
+                (size_t) GetStringInfoLength(profile),MagickFalse);
               profile=DestroyStringInfo(profile);
               break;
             }
@@ -9167,7 +9167,7 @@
             profile=GetImageProfile(profile_image,name);
             if (profile != (const StringInfo *) NULL)
               (void) ProfileImage(image,name,GetStringInfoDatum(profile),
-                (unsigned long) GetStringInfoLength(profile),MagickFalse);
+                (size_t) GetStringInfoLength(profile),MagickFalse);
             name=GetNextImageProfile(profile_image);
           }
           profile_image=DestroyImage(profile_image);
@@ -9196,7 +9196,7 @@
           if (attribute_flag[4] != 0)
             geometry_info.psi=argument_list[4].real_reference;
           if (attribute_flag[5] != 0)
-            channel=(ChannelType) argument_list[5].long_reference;
+            channel=(ChannelType) argument_list[5].integer_reference;
           image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
           break;
@@ -9219,7 +9219,7 @@
           if (attribute_flag[3] != 0)
             geometry_info.xi=argument_list[3].real_reference;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].long_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           image=MotionBlurImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,geometry_info.xi,exception);
           break;
@@ -9229,7 +9229,7 @@
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference="o8x8";
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           (void) OrderedPosterizeImageChannel(image,channel,
             argument_list[0].string_reference,exception);
           break;
@@ -9240,9 +9240,9 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           image=ShaveImage(image,&geometry,exception);
           break;
         }
@@ -9280,7 +9280,7 @@
           if (attribute_flag[3] != 0)
             gamma=argument_list[3].real_reference;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].long_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             {
               argument_list[0].real_reference=argument_list[5].real_reference;
@@ -9294,9 +9294,9 @@
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference="#1";
           if (attribute_flag[1] == 0)
-            argument_list[1].long_reference=MagickTrue;
+            argument_list[1].integer_reference=MagickTrue;
           (void) ClipImagePath(image,argument_list[0].string_reference,
-            argument_list[1].long_reference != 0 ? MagickTrue : MagickFalse);
+            argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
           break;
         }
         case 75:  /* AffineTransform */
@@ -9410,7 +9410,7 @@
           }
           if (attribute_flag[6] != 0)
             image->interpolate=(InterpolatePixelMethod)
-              argument_list[6].long_reference;
+              argument_list[6].integer_reference;
           if (attribute_flag[7] != 0)
             QueryColorDatabase(argument_list[7].string_reference,
               &image->background_color,exception);
@@ -9442,19 +9442,19 @@
                 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
             }
           if (attribute_flag[1] != 0)
-            geometry_info.rho=argument_list[1].long_reference;
+            geometry_info.rho=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry_info.sigma=argument_list[2].long_reference;
+            geometry_info.sigma=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            geometry_info.xi=argument_list[3].long_reference;;
-          image=AdaptiveThresholdImage(image,(unsigned long) geometry_info.rho,
-            (unsigned long) geometry_info.sigma,(long) geometry_info.xi,
+            geometry_info.xi=argument_list[3].integer_reference;;
+          image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
+            (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
             exception);
           break;
         }
         case 78:  /* Resample */
         {
-          unsigned long
+          size_t
             height,
             width;
 
@@ -9470,18 +9470,18 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] == 0)
-            argument_list[3].long_reference=(long) UndefinedFilter;
+            argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
           if (attribute_flag[4] == 0)
             SetImageArtifact(image,"filter:support",
               argument_list[4].string_reference);
           if (attribute_flag[5] != 0)
             argument_list[5].real_reference=1.0;
-          width=(unsigned long) (geometry_info.rho*image->columns/
+          width=(size_t) (geometry_info.rho*image->columns/
             (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
-          height=(unsigned long) (geometry_info.sigma*image->rows/
+          height=(size_t) (geometry_info.sigma*image->rows/
             (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
           image=ResizeImage(image,width,height,(FilterTypes)
-            argument_list[3].long_reference,argument_list[5].real_reference,
+            argument_list[3].integer_reference,argument_list[5].real_reference,
             exception);
           if (image != (Image *) NULL)
             {
@@ -9506,7 +9506,7 @@
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference="50%";
           if (attribute_flag[2] != 0)
-            channel=(ChannelType) argument_list[2].long_reference;
+            channel=(ChannelType) argument_list[2].integer_reference;
           BlackThresholdImageChannel(image,channel,
             argument_list[0].string_reference,exception);
           break;
@@ -9516,7 +9516,7 @@
           if (attribute_flag[0] == 0)
             argument_list[0].string_reference="50%";
           if (attribute_flag[2] != 0)
-            channel=(ChannelType) argument_list[2].long_reference;
+            channel=(ChannelType) argument_list[2].integer_reference;
           WhiteThresholdImageChannel(image,channel,
             argument_list[0].string_reference,exception);
           break;
@@ -9533,7 +9533,7 @@
           if (attribute_flag[1] != 0)
             geometry_info.rho=argument_list[1].real_reference;
           if (attribute_flag[2] != 0)
-            channel=(ChannelType) argument_list[2].long_reference;
+            channel=(ChannelType) argument_list[2].integer_reference;
           image=RadialBlurImageChannel(image,channel,geometry_info.rho,
             exception);
           break;
@@ -9544,9 +9544,9 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           image=ThumbnailImage(image,geometry.width,geometry.height,exception);
           break;
         }
@@ -9573,7 +9573,7 @@
         case 86:  /* Channel */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           (void) SeparateImageChannel(image,channel);
           break;
         }
@@ -9583,13 +9583,13 @@
             flags=ParseGravityGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            geometry.x=argument_list[3].long_reference;
+            geometry.x=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry.y=argument_list[4].long_reference;
+            geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
               QuantumRange);
@@ -9597,18 +9597,18 @@
             (void) QueryColorDatabase(argument_list[6].string_reference,
               &image->background_color,exception);
           if (attribute_flag[7] != 0)
-            image->gravity=(GravityType) argument_list[7].long_reference;
+            image->gravity=(GravityType) argument_list[7].integer_reference;
           image=SpliceImage(image,&geometry,exception);
           break;
         }
         case 88:  /* Posterize */
         {
           if (attribute_flag[0] == 0)
-            argument_list[0].long_reference=3;
+            argument_list[0].integer_reference=3;
           if (attribute_flag[1] == 0)
-            argument_list[1].long_reference=0;
-          (void) PosterizeImage(image,argument_list[0].long_reference,
-            argument_list[1].long_reference ? MagickTrue : MagickFalse);
+            argument_list[1].integer_reference=0;
+          (void) PosterizeImage(image,argument_list[0].integer_reference,
+            argument_list[1].integer_reference ? MagickTrue : MagickFalse);
           break;
         }
         case 89:  /* Shadow */
@@ -9629,11 +9629,11 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            geometry_info.xi=argument_list[3].long_reference;
+            geometry_info.xi=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry_info.psi=argument_list[4].long_reference;
+            geometry_info.psi=argument_list[4].integer_reference;
           image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
-            (long) ceil(geometry_info.xi-0.5),(long) ceil(geometry_info.psi-
+            (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
             0.5),exception);
           break;
         }
@@ -9645,7 +9645,7 @@
             (void) SetImageArtifact(image,"identify:features",
               argument_list[1].string_reference);
           if ((attribute_flag[2] != 0) &&
-              (argument_list[2].long_reference != 0))
+              (argument_list[2].integer_reference != 0))
             (void) SetImageArtifact(image,"identify:unique","true");
           (void) IdentifyImage(image,argument_list[0].file_reference,
             MagickTrue);
@@ -9678,10 +9678,10 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           sharpen=MagickTrue;
           if (attribute_flag[4] != 0)
-            sharpen=argument_list[4].long_reference != 0 ? MagickTrue :
+            sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
               MagickFalse;
           (void) SigmoidalContrastImageChannel(image,channel,sharpen,
             geometry_info.rho,geometry_info.sigma);
@@ -9690,7 +9690,7 @@
         case 93:  /* Extent */
         {
           if (attribute_flag[7] != 0)
-            image->gravity=(GravityType) argument_list[7].long_reference;
+            image->gravity=(GravityType) argument_list[7].integer_reference;
           if (attribute_flag[0] != 0)
             {
               int
@@ -9706,13 +9706,13 @@
               geometry.y=(-geometry.y);
             }
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            geometry.x=argument_list[3].long_reference;
+            geometry.x=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry.y=argument_list[4].long_reference;
+            geometry.y=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
               QuantumRange);
@@ -9740,14 +9740,14 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            geometry_info.xi=argument_list[3].long_reference;
+            geometry_info.xi=argument_list[3].integer_reference;
           if (attribute_flag[4] != 0)
-            geometry_info.psi=argument_list[4].long_reference;
+            geometry_info.psi=argument_list[4].integer_reference;
           if (attribute_flag[5] != 0)
             (void) QueryColorDatabase(argument_list[5].string_reference,
               &image->background_color,exception);
           image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
-            (long) ceil(geometry_info.xi-0.5),(long) ceil(geometry_info.psi-
+            (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
             0.5),exception);
           break;
         }
@@ -9779,7 +9779,7 @@
           if (attribute_flag[2] != 0)
             white_point=argument_list[2].real_reference;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].long_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           (void) ContrastStretchImageChannel(image,channel,black_point,
             white_point);
           break;
@@ -9806,7 +9806,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,exception);
           break;
@@ -9879,7 +9879,7 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,exception);
           break;
@@ -9916,11 +9916,11 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
-            image->filter=(FilterTypes) argument_list[4].long_reference;
+            image->filter=(FilterTypes) argument_list[4].integer_reference;
           if (attribute_flag[4] != 0)
             SetImageArtifact(image,"filter:support",
               argument_list[4].string_reference);
@@ -10016,7 +10016,7 @@
           if (attribute_flag[6] != 0)
             draw_info->pointsize=argument_list[6].real_reference;
           if (attribute_flag[7] != 0)
-            draw_info->gravity=(GravityType) argument_list[7].long_reference;
+            draw_info->gravity=(GravityType) argument_list[7].integer_reference;
           if (attribute_flag[8] != 0)
             (void) QueryColorDatabase(argument_list[8].string_reference,
               &image->background_color,exception);
@@ -10041,9 +10041,9 @@
             flags=ParsePageGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.x=argument_list[1].long_reference;
+            geometry.x=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.y=argument_list[2].long_reference;
+            geometry.y=argument_list[2].integer_reference;
           if (attribute_flag[3] != 0)
             (void) QueryColorDatabase(argument_list[3].string_reference,
               &draw_info->fill,exception);
@@ -10056,10 +10056,10 @@
             image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
               QuantumRange);
           if (attribute_flag[6] != 0)
-            channel=(ChannelType) argument_list[6].long_reference;
+            channel=(ChannelType) argument_list[6].integer_reference;
           invert=MagickFalse;
           if (attribute_flag[7] != 0)
-            invert=(MagickBooleanType) argument_list[7].long_reference;
+            invert=(MagickBooleanType) argument_list[7].integer_reference;
           (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
             geometry.y,invert);
           draw_info=DestroyDrawInfo(draw_info);
@@ -10076,7 +10076,7 @@
           DistortImageMethod
             method;
 
-          unsigned long
+          size_t
             number_coordinates;
 
           VirtualPixelMethod
@@ -10086,9 +10086,9 @@
             break;
           method=UndefinedDistortion;
           if (attribute_flag[1] != 0)
-            method=(DistortImageMethod) argument_list[1].long_reference;
+            method=(DistortImageMethod) argument_list[1].integer_reference;
           av=(AV *) argument_list[0].array_reference;
-          number_coordinates=(unsigned long) av_len(av)+1;
+          number_coordinates=(size_t) av_len(av)+1;
           coordinates=(double *) AcquireQuantumMemory(number_coordinates,
             sizeof(*coordinates));
           if (coordinates == (double *) NULL)
@@ -10097,14 +10097,14 @@
                 "MemoryAllocationFailed",PackageName);
               goto PerlException;
             }
-          for (j=0; j < (long) number_coordinates; j++)
+          for (j=0; j < (ssize_t) number_coordinates; j++)
             coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
           virtual_pixel=UndefinedVirtualPixelMethod;
           if (attribute_flag[2] != 0)
             virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
-              argument_list[2].long_reference);
+              argument_list[2].integer_reference);
           image=DistortImage(image,method,number_coordinates,coordinates,
-            argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
+            argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
             exception);
           if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
             virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
@@ -10120,7 +10120,7 @@
               goto PerlException;
             }
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           (void) ClutImageChannel(image,channel,
             argument_list[0].image_reference);
           break;
@@ -10131,9 +10131,9 @@
             flags=ParseRegionGeometry(image,argument_list[0].string_reference,
               &geometry,exception);
           if (attribute_flag[1] != 0)
-            geometry.width=argument_list[1].long_reference;
+            geometry.width=argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
-            geometry.height=argument_list[2].long_reference;
+            geometry.height=argument_list[2].integer_reference;
           if (attribute_flag[3] == 0)
             argument_list[3].real_reference=1.0;
           if (attribute_flag[4] == 0)
@@ -10181,10 +10181,10 @@
           quantize_info=AcquireQuantizeInfo(info->image_info);
           if (attribute_flag[1] != 0)
             quantize_info->dither=(MagickBooleanType)
-              argument_list[1].long_reference;
+              argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
             quantize_info->dither_method=(DitherMethod)
-              argument_list[2].long_reference;
+              argument_list[2].integer_reference;
           (void) RemapImages(quantize_info,image,
             argument_list[0].image_reference);
           quantize_info=DestroyQuantizeInfo(quantize_info);
@@ -10201,7 +10201,7 @@
           SparseColorMethod
             method;
 
-          unsigned long
+          size_t
             number_coordinates;
 
           VirtualPixelMethod
@@ -10211,9 +10211,9 @@
             break;
           method=UndefinedColorInterpolate;
           if (attribute_flag[1] != 0)
-            method=(SparseColorMethod) argument_list[1].long_reference;
+            method=(SparseColorMethod) argument_list[1].integer_reference;
           av=(AV *) argument_list[0].array_reference;
-          number_coordinates=(unsigned long) av_len(av)+1;
+          number_coordinates=(size_t) av_len(av)+1;
           coordinates=(double *) AcquireQuantumMemory(number_coordinates,
             sizeof(*coordinates));
           if (coordinates == (double *) NULL)
@@ -10222,14 +10222,14 @@
                 "MemoryAllocationFailed",PackageName);
               goto PerlException;
             }
-          for (j=0; j < (long) number_coordinates; j++)
+          for (j=0; j < (ssize_t) number_coordinates; j++)
             coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
           virtual_pixel=UndefinedVirtualPixelMethod;
           if (attribute_flag[2] != 0)
             virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
-              argument_list[2].long_reference);
+              argument_list[2].integer_reference);
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           image=SparseColorImage(image,channel,method,number_coordinates,
             coordinates,exception);
           if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
@@ -10248,7 +10248,7 @@
           MagickFunction
             function;
 
-          unsigned long
+          size_t
             number_parameters;
 
           VirtualPixelMethod
@@ -10258,9 +10258,9 @@
             break;
           function=UndefinedFunction;
           if (attribute_flag[1] != 0)
-            function=(MagickFunction) argument_list[1].long_reference;
+            function=(MagickFunction) argument_list[1].integer_reference;
           av=(AV *) argument_list[0].array_reference;
-          number_parameters=(unsigned long) av_len(av)+1;
+          number_parameters=(size_t) av_len(av)+1;
           parameters=(double *) AcquireQuantumMemory(number_parameters,
             sizeof(*parameters));
           if (parameters == (double *) NULL)
@@ -10269,12 +10269,12 @@
                 "MemoryAllocationFailed",PackageName);
               goto PerlException;
             }
-          for (j=0; j < (long) number_parameters; j++)
+          for (j=0; j < (ssize_t) number_parameters; j++)
             parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
           virtual_pixel=UndefinedVirtualPixelMethod;
           if (attribute_flag[2] != 0)
             virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
-              argument_list[2].long_reference);
+              argument_list[2].integer_reference);
           (void) FunctionImage(image,function,number_parameters,parameters,
             exception);
           if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
@@ -10298,9 +10298,9 @@
           if (attribute_flag[2] != 0)
             geometry_info.sigma=argument_list[2].real_reference;
           if (attribute_flag[3] != 0)
-            geometry_info.xi=argument_list[3].long_reference;;
+            geometry_info.xi=argument_list[3].integer_reference;;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].long_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
             geometry_info.sigma,geometry_info.xi,exception);
           break;
@@ -10314,7 +10314,7 @@
               goto PerlException;
             }
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           (void) HaldClutImageChannel(image,channel,
             argument_list[0].image_reference);
           break;
@@ -10330,14 +10330,14 @@
         case 124:  /* ForwardFourierTransformImage */
         {
           image=ForwardFourierTransformImage(image,
-            argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
+            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
             exception);
           break;
         }
         case 125:  /* InverseFourierTransformImage */
         {
           image=InverseFourierTransformImage(image,image->next,
-            argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
+            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
             exception);
           break;
         }
@@ -10352,14 +10352,14 @@
         case 127:  /* AutoGamma */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           (void) AutoGammaImageChannel(image,channel);
           break;
         }
         case 128:  /* AutoLevel */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           (void) AutoLevelImageChannel(image,channel);
           break;
         }
@@ -10378,16 +10378,16 @@
              (void) QueryMagickColor(argument_list[2].string_reference,
                &white_point,exception);
           if (attribute_flag[3] != 0)
-            channel=(ChannelType) argument_list[3].long_reference;
+            channel=(ChannelType) argument_list[3].integer_reference;
           (void) LevelColorsImageChannel(image,channel,&black_point,
-            &white_point,argument_list[0].long_reference != 0 ? MagickTrue :
+            &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
             MagickFalse);
           break;
         }
         case 130:  /* Clamp */
         {
           if (attribute_flag[0] != 0)
-            channel=(ChannelType) argument_list[0].long_reference;
+            channel=(ChannelType) argument_list[0].integer_reference;
           (void) ClampImageChannel(image,channel);
           break;
         }
@@ -10402,7 +10402,7 @@
           if (kernel == (KernelInfo *) NULL)
             break;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           if (attribute_flag[2] != 0)
             image->bias=SiPrefixToDouble(argument_list[2].string_reference,
               QuantumRange);
@@ -10431,7 +10431,7 @@
           if (attribute_flag[2] != 0)
             contrast=argument_list[2].real_reference;
           if (attribute_flag[4] != 0)
-            channel=(ChannelType) argument_list[4].long_reference;
+            channel=(ChannelType) argument_list[4].integer_reference;
           (void) BrightnessContrastImageChannel(image,channel,brightness,
             contrast);
           break;
@@ -10444,7 +10444,7 @@
           MorphologyMethod
             method;
 
-          long
+          ssize_t
             iterations;
 
           if (attribute_flag[0] == 0)
@@ -10453,13 +10453,13 @@
           if (kernel == (KernelInfo *) NULL)
             break;
           if (attribute_flag[1] != 0)
-            channel=(ChannelType) argument_list[1].long_reference;
+            channel=(ChannelType) argument_list[1].integer_reference;
           method=UndefinedMorphology;
           if (attribute_flag[2] != 0)
-            method=argument_list[2].long_reference;
+            method=argument_list[2].integer_reference;
           iterations=1;
           if (attribute_flag[3] != 0)
-            iterations=argument_list[4].long_reference;
+            iterations=argument_list[4].integer_reference;
           image=MorphologyImageChannel(image,channel,method,iterations,kernel,
             exception);
           kernel=DestroyKernelInfo(kernel);
@@ -10477,13 +10477,13 @@
           KernelInfo
             *kernel_info;
 
-          unsigned long
+          size_t
             order;
 
           if (attribute_flag[0] == 0)
             break;
           av=(AV *) argument_list[0].array_reference;
-          order=(unsigned long) sqrt(av_len(av)+1);
+          order=(size_t) sqrt(av_len(av)+1);
           color_matrix=(double *) AcquireQuantumMemory(order,order*
             sizeof(*color_matrix));
           if (color_matrix == (double *) NULL)
@@ -10492,9 +10492,9 @@
                 "MemoryAllocationFailed",PackageName);
               goto PerlException;
            }
-          for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
+          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
             color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
-          for ( ; j < (long) (order*order); j++)
+          for ( ; j < (ssize_t) (order*order); j++)
             color_matrix[j]=0.0;
           kernel_info=AcquireKernelInfo("1");
           if (kernel_info == (KernelInfo *) NULL)
@@ -10597,7 +10597,7 @@
       *image,
       *next;
 
-    long
+    ssize_t
       sp;
 
     MagickPixelPacket
@@ -10606,7 +10606,7 @@
     MontageInfo
       *montage_info;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -10762,7 +10762,7 @@
            }
          if (LocaleCompare(attribute,"gravity") == 0)
            {
-             long
+             ssize_t
                in;
 
              in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
@@ -10810,7 +10810,7 @@
             }
           if (LocaleCompare(attribute,"mode") == 0)
             {
-              long
+              ssize_t
                 in;
 
               in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
@@ -11003,10 +11003,10 @@
     Image
       *image;
 
-    long
+    ssize_t
       number_frames;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -11223,7 +11223,7 @@
     int
       n;
 
-    long
+    ssize_t
       ac;
 
     MagickBooleanType
@@ -11232,7 +11232,7 @@
     register char
       **p;
 
-    register long
+    register ssize_t
       i;
 
     STRLEN
@@ -11246,7 +11246,7 @@
       *perl_exception,
       *reference;
 
-    unsigned long
+    size_t
       count;
 
     exception=AcquireExceptionInfo();
@@ -11362,7 +11362,7 @@
       {
         PUSHs(sv_2mortal(newSViv(next->columns)));
         PUSHs(sv_2mortal(newSViv(next->rows)));
-        PUSHs(sv_2mortal(newSViv((unsigned long) GetBlobSize(next))));
+        PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
         PUSHs(sv_2mortal(newSVpv(next->magick,0)));
       }
       image=DestroyImageList(image);
@@ -11518,7 +11518,7 @@
     MagickPixelPacket
       color;
 
-    register long
+    register ssize_t
       i;
 
     SV
@@ -11531,12 +11531,12 @@
         const ColorInfo
           **colorlist;
 
-        unsigned long
+        size_t
           colors;
 
         colorlist=GetColorInfoList("*",&colors,exception);
         EXTEND(sp,colors);
-        for (i=0; i < (long) colors; i++)
+        for (i=0; i < (ssize_t) colors; i++)
         {
           PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
         }
@@ -11553,13 +11553,13 @@
           PUSHs(&sv_undef);
           continue;
         }
-      PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.red+0.5))));
-      PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.green+0.5))));
-      PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.blue+0.5))));
+      PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
+      PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
+      PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
       if (color.matte != MagickFalse)
-        PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.opacity+0.5))));
+        PUSHs(sv_2mortal(newSViv((size_t) floor(color.opacity+0.5))));
       if (color.colorspace == CMYKColorspace)
-        PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.index+0.5))));
+        PUSHs(sv_2mortal(newSViv((size_t) floor(color.index+0.5))));
     }
 
   PerlException:
@@ -11602,7 +11602,7 @@
     PixelPacket
       target_color;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -11666,7 +11666,7 @@
     ExceptionInfo
       *exception;
 
-    register long
+    register ssize_t
       i;
 
     SV
@@ -11682,12 +11682,12 @@
         const TypeInfo
           **typelist;
 
-        unsigned long
+        size_t
           types;
 
         typelist=GetTypeInfoList("*",&types,exception);
         EXTEND(sp,types);
-        for (i=0; i < (long) types; i++)
+        for (i=0; i < (ssize_t) types; i++)
         {
           PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
         }
@@ -11802,7 +11802,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       type;
 
     MagickBooleanType
@@ -11811,7 +11811,7 @@
     MagickStatusType
       flags;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -12083,7 +12083,7 @@
           if (LocaleCompare(attribute,"weight") == 0)
             {
               flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
-              draw_info->weight=(unsigned long) geometry_info.rho;
+              draw_info->weight=(size_t) geometry_info.rho;
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -12211,7 +12211,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       type;
 
     MagickBooleanType
@@ -12220,7 +12220,7 @@
     MagickStatusType
       flags;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -12454,7 +12454,7 @@
           if (LocaleCompare(attribute,"weight") == 0)
             {
               flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
-              draw_info->weight=(unsigned long) geometry_info.rho;
+              draw_info->weight=(size_t) geometry_info.rho;
               break;
             }
           ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
@@ -12562,7 +12562,7 @@
     ExceptionInfo
       *exception;
 
-    register long
+    register ssize_t
       i;
 
     SV
@@ -12581,12 +12581,12 @@
         const MagickInfo
           **format_list;
 
-        unsigned long
+        size_t
           types;
 
         format_list=GetMagickInfoList("*",&types,exception);
         EXTEND(sp,types);
-        for (i=0; i < (long) types; i++)
+        for (i=0; i < (ssize_t) types; i++)
         {
           (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
           LocaleLower(format);
@@ -12609,8 +12609,8 @@
       PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
       PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
       PUSHs(sv_2mortal(newSViv(magick_info->raw)));
-      PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
-      PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
+      PUSHs(sv_2mortal(newSViv((ssize_t) magick_info->decoder)));
+      PUSHs(sv_2mortal(newSViv((ssize_t) magick_info->encoder)));
       if (magick_info->description == (char *) NULL)
         PUSHs(&sv_undef);
       else
@@ -12652,11 +12652,11 @@
     ExceptionInfo
       *exception;
 
-    long
+    ssize_t
       j,
       option;
 
-    register long
+    register ssize_t
       i;
 
     SV
@@ -12726,7 +12726,7 @@
     int
       n;
 
-    long
+    ssize_t
       ac,
       number_images;
 
@@ -12736,7 +12736,7 @@
     register char
       **p;
 
-    register long
+    register ssize_t
       i;
 
     STRLEN
@@ -12931,7 +12931,7 @@
     ExceptionInfo
       *exception;
 
-    register long
+    register ssize_t
       i;
 
     SV
@@ -12984,7 +12984,7 @@
     Image
       *image;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -13054,7 +13054,7 @@
     Image
       *image;
 
-    long
+    ssize_t
       option;
 
     MagickBooleanType
@@ -13066,7 +13066,7 @@
     register IndexPacket
       *indexes;
 
-    register long
+    register ssize_t
       i;
 
     register PixelPacket
@@ -13111,7 +13111,7 @@
         {
           if (LocaleCompare(attribute,"channel") == 0)
             {
-              long
+              ssize_t
                 option;
 
               option=ParseChannelOption(SvPV(ST(i),na));
@@ -13216,7 +13216,7 @@
         double
           scale;
 
-        register long
+        register ssize_t
           i;
 
         i=0;
@@ -13491,7 +13491,7 @@
       *clone,
       *image;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
@@ -13562,7 +13562,7 @@
              Image
                *next;
 
-             long
+             ssize_t
                in;
 
              in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
@@ -13648,11 +13648,11 @@
       *image,
       *next;
 
-    long
+    ssize_t
       number_images,
       scene;
 
-    register long
+    register ssize_t
       i;
 
     struct PackageInfo
diff --git a/coders/art.c b/coders/art.c
index cff9dec..060a23b 100644
--- a/coders/art.c
+++ b/coders/art.c
@@ -98,7 +98,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   QuantumInfo
@@ -139,9 +139,9 @@
   image->depth=1;
   image->endian=MSBEndian;
   (void) ReadBlobLSBShort(image);
-  image->columns=(unsigned long) ReadBlobLSBShort(image);
+  image->columns=(size_t) ReadBlobLSBShort(image);
   (void) ReadBlobLSBShort(image);
-  image->rows=(unsigned long) ReadBlobLSBShort(image);
+  image->rows=(size_t) ReadBlobLSBShort(image);
   /*
     Initialize image colormap.
   */
@@ -161,7 +161,7 @@
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   pixels=GetQuantumPixels(quantum_info);
   length=GetQuantumExtent(image,quantum_info,quantum_type);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register PixelPacket
       *restrict q;
@@ -209,10 +209,10 @@
 %
 %  The format of the RegisterARTImage method is:
 %
-%      unsigned long RegisterARTImage(void)
+%      size_t RegisterARTImage(void)
 %
 */
-ModuleExport unsigned long RegisterARTImage(void)
+ModuleExport size_t RegisterARTImage(void)
 {
   MagickInfo
     *entry;
@@ -278,7 +278,7 @@
 */
 static MagickBooleanType WriteARTImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -330,7 +330,7 @@
   */
   (void) SetImageType(image,BilevelType);
   quantum_info=AcquireQuantumInfo(image_info,image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/avs.c b/coders/avs.c
index f79a230..db04a9e 100644
--- a/coders/avs.c
+++ b/coders/avs.c
@@ -95,13 +95,13 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -119,7 +119,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -165,7 +165,7 @@
     if (pixels == (unsigned char *) NULL) 
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     length=(size_t) 4*image->columns;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       count=ReadBlob(image,length,pixels);
       if ((size_t) count != length)
@@ -174,7 +174,7 @@
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*p++));
         q->red=ScaleCharToQuantum(*p++);
@@ -246,10 +246,10 @@
 %
 %  The format of the RegisterAVSImage method is:
 %
-%      unsigned long RegisterAVSImage(void)
+%      size_t RegisterAVSImage(void)
 %
 */
-ModuleExport unsigned long RegisterAVSImage(void)
+ModuleExport size_t RegisterAVSImage(void)
 {
   MagickInfo
     *entry;
@@ -313,7 +313,7 @@
 */
 static MagickBooleanType WriteAVSImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -325,7 +325,7 @@
   register const PixelPacket
     *restrict p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -369,13 +369,13 @@
     /*
       Convert MIFF to AVS raster pixels.
     */
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (PixelPacket *) NULL)
         break;
       q=pixels;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar((Quantum) (QuantumRange-
           (image->matte != MagickFalse ? p->opacity : OpaqueOpacity)));
diff --git a/coders/bmp.c b/coders/bmp.c
index a547103..ac4f53b 100644
--- a/coders/bmp.c
+++ b/coders/bmp.c
@@ -101,7 +101,7 @@
     offset_bits,
     size;
 
-  long
+  ssize_t
     width,
     height;
 
@@ -154,7 +154,7 @@
 %  The format of the DecodeImage method is:
 %
 %      MagickBooleanType DecodeImage(Image *image,
-%        const unsigned long compression,unsigned char *pixels)
+%        const size_t compression,unsigned char *pixels)
 %
 %  A description of each parameter follows:
 %
@@ -170,7 +170,7 @@
 %
 */
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -184,7 +184,7 @@
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -192,15 +192,15 @@
 }
 
 static MagickBooleanType DecodeImage(Image *image,
-  const unsigned long compression,unsigned char *pixels)
+  const size_t compression,unsigned char *pixels)
 {
   int
     count;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -222,7 +222,7 @@
   x=0;
   p=pixels;
   q=pixels+(size_t) image->columns*image->rows;
-  for (y=0; y < (long) image->rows; )
+  for (y=0; y < (ssize_t) image->rows; )
   {
     if ((p < pixels) || (p >= q))
       break;
@@ -336,7 +336,7 @@
 %  The format of the EncodeImage method is:
 %
 %    static MagickBooleanType EncodeImage(Image *image,
-%      const unsigned long bytes_per_line,const unsigned char *pixels,
+%      const size_t bytes_per_line,const unsigned char *pixels,
 %      unsigned char *compressed_pixels)
 %
 %  A description of each parameter follows:
@@ -352,10 +352,10 @@
 %      pixel data.
 %
 */
-static size_t EncodeImage(Image *image,const unsigned long bytes_per_line,
+static size_t EncodeImage(Image *image,const size_t bytes_per_line,
   const unsigned char *pixels,unsigned char *compressed_pixels)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -364,7 +364,7 @@
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -383,14 +383,14 @@
   p=pixels;
   q=compressed_pixels;
   i=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    for (x=0; x < (long) bytes_per_line; x+=i)
+    for (x=0; x < (ssize_t) bytes_per_line; x+=i)
     {
       /*
         Determine runlength.
       */
-      for (i=1; ((x+i) < (long) bytes_per_line); i++)
+      for (i=1; ((x+i) < (ssize_t) bytes_per_line); i++)
         if ((i == 255) || (*(p+i) != *p))
           break;
       *q++=(unsigned char) i;
@@ -492,7 +492,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -505,13 +505,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -527,7 +527,7 @@
     magick[12],
     *pixels;
 
-  unsigned long
+  size_t
     bit,
     blue,
     bytes_per_line,
@@ -567,7 +567,7 @@
     PixelPacket
       quantum_bits;
 
-    unsigned long
+    size_t
       profile_data,
       profile_size;
 
@@ -708,7 +708,7 @@
               Read color management information.
             */
             bmp_info.alpha_mask=ReadBlobLSBLong(image);
-            bmp_info.colorspace=(long) ReadBlobLSBLong(image);
+            bmp_info.colorspace=(ssize_t) ReadBlobLSBLong(image);
             /*
               Decode 2^30 fixed point formatted CIE primaries.
             */
@@ -747,7 +747,7 @@
           }
         if (bmp_info.size > 108)
           {
-            unsigned long
+            size_t
               intent;
 
             /*
@@ -824,8 +824,8 @@
       default:
         ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression");
     }
-    image->columns=(unsigned long) MagickAbsoluteValue(bmp_info.width);
-    image->rows=(unsigned long) MagickAbsoluteValue(bmp_info.height);
+    image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);
+    image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);
     image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;
     if ((bmp_info.bits_per_pixel == 16) ||
         (bmp_info.bits_per_pixel == 32))
@@ -868,7 +868,7 @@
         if (count != (ssize_t) (packet_size*image->colors))
           ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
         p=bmp_colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].blue=ScaleCharToQuantum(*p++);
           image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -900,7 +900,7 @@
       {
         if (image->debug != MagickFalse)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-            "  Reading pixels (%ld bytes)",(long) length);
+            "  Reading pixels (%ld bytes)",(ssize_t) length);
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
           ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
@@ -942,7 +942,7 @@
       }
     if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))
       {
-        register unsigned long
+        register size_t
           sample;
 
         /*
@@ -986,20 +986,20 @@
         /*
           Convert bitmap scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < ((long) image->columns-7); x+=8)
+          for (x=0; x < ((ssize_t) image->columns-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
             {
               index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
               indexes[x+bit]=index;
-              *q++=image->colormap[(long) index];
+              *q++=image->colormap[(ssize_t) index];
             }
             p++;
           }
@@ -1009,7 +1009,7 @@
               {
                 index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
                 indexes[x+bit]=index;
-                *q++=image->colormap[(long) index];
+                *q++=image->colormap[(ssize_t) index];
               }
               p++;
             }
@@ -1029,28 +1029,28 @@
         /*
           Convert PseudoColor scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < ((long) image->columns-1); x+=2)
+          for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
             index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,*p & 0x0f);
             indexes[x+1]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
           if ((image->columns % 2) != 0)
             {
               index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
               indexes[x]=index;
-              *q++=image->colormap[(long) index];
+              *q++=image->colormap[(ssize_t) index];
               p++;
             }
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -1072,18 +1072,18 @@
         if ((bmp_info.compression == BI_RLE8) ||
             (bmp_info.compression == BI_RLE4))
           bytes_per_line=image->columns;
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x = (long)image->columns; x != 0; --x)
+          for (x = (ssize_t)image->columns; x != 0; --x)
           {
             index=ConstrainColormapIndex(image,*p);
             *indexes++=index;
-            *q=image->colormap[(long) index];
+            *q=image->colormap[(ssize_t) index];
             p++;
             q++;
           }
@@ -1101,7 +1101,7 @@
       }
       case 16:
       {
-        unsigned long
+        size_t
           pixel;
 
         /*
@@ -1113,15 +1113,15 @@
             "UnrecognizedImageCompression");
         bytes_per_line=2*(image->columns+image->columns % 2);
         image->storage_class=DirectClass;
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
-            pixel=(unsigned long) (*p++);
+            pixel=(size_t) (*p++);
             pixel|=(*p++) << 8;
             red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
             if (quantum_bits.red == 5)
@@ -1169,13 +1169,13 @@
           Convert DirectColor scanline.
         */
         bytes_per_line=4*((image->columns*24+31)/32);
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->blue=ScaleCharToQuantum(*p++);
             q->green=ScaleCharToQuantum(*p++);
@@ -1205,18 +1205,18 @@
           ThrowReaderException(CorruptImageError,
             "UnrecognizedImageCompression");
         bytes_per_line=4*(image->columns);
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
-          unsigned long
+          size_t
             pixel;
 
           p=pixels+(image->rows-y-1)*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
-            pixel=(unsigned long) (*p++);
+            pixel=(size_t) (*p++);
             pixel|=(*p++ << 8);
             pixel|=(*p++ << 16);
             pixel|=(*p++ << 24);
@@ -1334,10 +1334,10 @@
 %
 %  The format of the RegisterBMPImage method is:
 %
-%      unsigned long RegisterBMPImage(void)
+%      size_t RegisterBMPImage(void)
 %
 */
-ModuleExport unsigned long RegisterBMPImage(void)
+ModuleExport size_t RegisterBMPImage(void)
 {
   MagickInfo
     *entry;
@@ -1430,7 +1430,7 @@
   const StringInfo
     *profile;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1446,7 +1446,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1457,7 +1457,7 @@
     *bmp_data,
     *pixels;
 
-  unsigned long
+  size_t
     bytes_per_line,
     type;
 
@@ -1515,7 +1515,7 @@
         if (image->matte != MagickFalse)
           (void) SetImageStorageClass(image,DirectClass);
         else
-          if ((unsigned long) bmp_info.number_colors < image->colors)
+          if ((size_t) bmp_info.number_colors < image->colors)
             (void) SetImageStorageClass(image,DirectClass);
           else
             {
@@ -1570,8 +1570,8 @@
           bmp_info.file_size+=extra_size;
           bmp_info.offset_bits+=extra_size;
         }
-    bmp_info.width=(long) image->columns;
-    bmp_info.height=(long) image->rows;
+    bmp_info.width=(ssize_t) image->columns;
+    bmp_info.height=(ssize_t) image->rows;
     bmp_info.planes=1;
     bmp_info.image_size=(unsigned int) (bytes_per_line*image->rows);
     bmp_info.file_size+=bmp_info.image_size;
@@ -1606,14 +1606,14 @@
     {
       case 1:
       {
-        unsigned long
+        size_t
           bit,
           byte;
 
         /*
           Convert PseudoClass image to a BMP monochrome image.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1622,7 +1622,7 @@
           q=pixels+(image->rows-y-1)*bytes_per_line;
           bit=0;
           byte=0;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             byte<<=1;
             byte|=indexes[x] != 0 ? 0x01 : 0x00;
@@ -1639,7 +1639,7 @@
                *q++=(unsigned char) (byte << (8-bit));
                x++;
              }
-          for (x=(long) (image->columns+7)/8; x < (long) bytes_per_line; x++)
+          for (x=(ssize_t) (image->columns+7)/8; x < (ssize_t) bytes_per_line; x++)
             *q++=0x00;
           if (image->previous == (Image *) NULL)
             {
@@ -1652,14 +1652,14 @@
       }
       case 4:
       {
-        unsigned long
+        size_t
           nibble,
           byte;
 
         /*
           Convert PseudoClass image to a BMP monochrome image.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1668,10 +1668,10 @@
           q=pixels+(image->rows-y-1)*bytes_per_line;
           nibble=0;
           byte=0;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             byte<<=4;
-            byte|=((unsigned long) indexes[x] & 0x0f);
+            byte|=((size_t) indexes[x] & 0x0f);
             nibble++;
             if (nibble == 2)
               {
@@ -1685,7 +1685,7 @@
              *q++=(unsigned char) (byte << 4);
              x++;
            }
-          for (x=(long) (image->columns+1)/2; x < (long) bytes_per_line; x++)
+          for (x=(ssize_t) (image->columns+1)/2; x < (ssize_t) bytes_per_line; x++)
             *q++=0x00;
           if (image->previous == (Image *) NULL)
             {
@@ -1701,16 +1701,16 @@
         /*
           Convert PseudoClass packet to BMP pixel.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           indexes=GetVirtualIndexQueue(image);
           q=pixels+(image->rows-y-1)*bytes_per_line;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             *q++=(unsigned char) indexes[x];
-          for ( ; x < (long) bytes_per_line; x++)
+          for ( ; x < (ssize_t) bytes_per_line; x++)
             *q++=0x00;
           if (image->previous == (Image *) NULL)
             {
@@ -1726,20 +1726,20 @@
         /*
           Convert DirectClass packet to BMP BGR888.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           q=pixels+(image->rows-y-1)*bytes_per_line;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
             *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
             p++;
           }
-          for (x=3L*(long) image->columns; x < (long) bytes_per_line; x++)
+          for (x=3L*(ssize_t) image->columns; x < (ssize_t) bytes_per_line; x++)
             *q++=0x00;
           if (image->previous == (Image *) NULL)
             {
@@ -1755,13 +1755,13 @@
         /*
           Convert DirectClass packet to ARGB8888 pixel.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           q=pixels+(image->rows-y-1)*bytes_per_line;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1936,7 +1936,7 @@
         if ((image->rendering_intent != UndefinedIntent) ||
             (profile != (StringInfo *) NULL))
           {
-            long
+            ssize_t
               intent;
 
             switch ((int) image->rendering_intent)
@@ -1989,7 +1989,7 @@
         if (bmp_colormap == (unsigned char *) NULL)
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
         q=bmp_colormap;
-        for (i=0; i < (long) MagickMin((long) image->colors,(long) bmp_info.number_colors); i++)
+        for (i=0; i < (ssize_t) MagickMin((ssize_t) image->colors,(ssize_t) bmp_info.number_colors); i++)
         {
           *q++=ScaleQuantumToChar(image->colormap[i].blue);
           *q++=ScaleQuantumToChar(image->colormap[i].green);
@@ -1997,7 +1997,7 @@
           if (type > 2)
             *q++=(unsigned char) 0x0;
         }
-        for ( ; i < (long) (1UL << bmp_info.bits_per_pixel); i++)
+        for ( ; i < (ssize_t) (1UL << bmp_info.bits_per_pixel); i++)
         {
           *q++=(unsigned char) 0x00;
           *q++=(unsigned char) 0x00;
diff --git a/coders/braille.c b/coders/braille.c
index 3d308f1..49b1993 100644
--- a/coders/braille.c
+++ b/coders/braille.c
@@ -86,10 +86,10 @@
 %
 %  The format of the RegisterBRAILLEImage method is:
 %
-%      unsigned long RegisterBRAILLEImage(void)
+%      size_t RegisterBRAILLEImage(void)
 %
 */
-ModuleExport unsigned long RegisterBRAILLEImage(void)
+ModuleExport size_t RegisterBRAILLEImage(void)
 {
   MagickInfo
     *entry;
@@ -179,7 +179,7 @@
     unicode = 0,
     iso_11548_1 = 0;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -194,10 +194,10 @@
   IndexPacket
     polarity;
 
-  register long
+  register ssize_t
     x;
 
-  unsigned long
+  size_t
     cell_height = 4;
 
   /*
@@ -256,19 +256,19 @@
         (PixelIntensityToQuantum(&image->colormap[0]) >=
          PixelIntensityToQuantum(&image->colormap[1]));
   }
-  for (y=0; y < (long) image->rows; y+=cell_height)
+  for (y=0; y < (ssize_t) image->rows; y+=cell_height)
   {
     if ((y+cell_height) > image->rows)
-      cell_height = (unsigned long) (image->rows-y);
+      cell_height = (size_t) (image->rows-y);
 
     p=GetVirtualPixels(image,0,y,image->columns,cell_height,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x+=2)
+    for (x=0; x < (ssize_t) image->columns; x+=2)
     {
       unsigned char cell = 0;
-      int two_columns = x+1 < (long) image->columns;
+      int two_columns = x+1 < (ssize_t) image->columns;
 
       do
       {
diff --git a/coders/cals.c b/coders/cals.c
index 91c7219..75d3f97 100644
--- a/coders/cals.c
+++ b/coders/cals.c
@@ -163,10 +163,10 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     density,
     direction,
     height,
@@ -303,10 +303,10 @@
 %
 %  The format of the RegisterCALSImage method is:
 %
-%      unsigned long RegisterCALSImage(void)
+%      size_t RegisterCALSImage(void)
 %
 */
-ModuleExport unsigned long RegisterCALSImage(void)
+ModuleExport size_t RegisterCALSImage(void)
 {
   MagickInfo
     *entry;
@@ -410,7 +410,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   i=0;
@@ -444,7 +444,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -456,7 +456,7 @@
   unsigned char
     *group4;
 
-  unsigned long
+  size_t
     density,
     orient_x,
     orient_y;
@@ -544,7 +544,7 @@
         geometry_info;
 
       (void) ParseGeometry(image_info->density,&geometry_info);
-      density=(unsigned long) floor(geometry_info.rho+0.5);
+      density=(size_t) floor(geometry_info.rho+0.5);
     }
   (void) FormatMagickString(header,MaxTextExtent,"rdensty: %04lu",density);
   count=WriteCALSRecord(image,header);
diff --git a/coders/caption.c b/coders/caption.c
index b7242cb..91313eb 100644
--- a/coders/caption.c
+++ b/coders/caption.c
@@ -105,13 +105,13 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   TypeMetric
     metrics;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -162,8 +162,8 @@
         if (draw_info->gravity == UndefinedGravity)
           (void) CloneString(&draw_info->geometry,geometry);
         status=GetMultilineTypeMetrics(image,draw_info,&metrics);
-        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+        width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(size_t) floor(metrics.height+draw_info->stroke_width+
           0.5);
         if ((width > (image->columns+1)) || (height > (image->rows+1)))
           break;
@@ -181,8 +181,8 @@
         if (draw_info->gravity == UndefinedGravity)
           (void) CloneString(&draw_info->geometry,geometry);
         status=GetMultilineTypeMetrics(image,draw_info,&metrics);
-        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+        width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(size_t) floor(metrics.height+draw_info->stroke_width+
           0.5);
         if ((width > (image->columns+1)) || (height > (image->rows+1)))
           break;
@@ -192,10 +192,10 @@
     }
   i=FormatMagickCaption(image,draw_info,&metrics,&caption);
   if (image->rows == 0)
-    image->rows=(unsigned long) ((i+1)*(metrics.ascent-metrics.descent+
+    image->rows=(size_t) ((i+1)*(metrics.ascent-metrics.descent+
       draw_info->stroke_width)+0.5);
   if (image->rows == 0)
-    image->rows=(unsigned long) ((i+1)*draw_info->pointsize+
+    image->rows=(size_t) ((i+1)*draw_info->pointsize+
       draw_info->stroke_width+0.5);
   if (SetImageBackgroundColor(image) == MagickFalse)
     {
@@ -209,7 +209,7 @@
   (void) CloneString(&draw_info->text,caption);
   status=GetMultilineTypeMetrics(image,draw_info,&metrics);
   if (draw_info->gravity != UndefinedGravity)
-    image->page.x=(long) (metrics.bounds.x1-draw_info->stroke_width/2.0);
+    image->page.x=(ssize_t) (metrics.bounds.x1-draw_info->stroke_width/2.0);
   else
     {
       (void) FormatMagickString(geometry,MaxTextExtent,"%+g%+g",
@@ -243,10 +243,10 @@
 %
 %  The format of the RegisterCAPTIONImage method is:
 %
-%      unsigned long RegisterCAPTIONImage(void)
+%      size_t RegisterCAPTIONImage(void)
 %
 */
-ModuleExport unsigned long RegisterCAPTIONImage(void)
+ModuleExport size_t RegisterCAPTIONImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/cin.c b/coders/cin.c
index 227f5f8..94407b7 100644
--- a/coders/cin.c
+++ b/coders/cin.c
@@ -81,7 +81,7 @@
     sign,
     sense;
 
-  unsigned long
+  size_t
     line_pad,
     channel_pad;
 
@@ -91,7 +91,7 @@
 
 typedef struct _CINFileInfo
 {
-  unsigned long
+  size_t
     magic,
     image_offset,
     generic_length,
@@ -115,14 +115,14 @@
     offset,
     reserve1;
 
-  unsigned long
+  size_t
     prefix,
     count;
 
   char
     format[32];
 
-  unsigned long
+  size_t
     frame_position;
 
   float
@@ -141,7 +141,7 @@
     bits_per_pixel,
     reserve;
 
-  unsigned long
+  size_t
     pixels_per_line,
     lines_per_image;
 
@@ -175,7 +175,7 @@
 
 typedef struct _CINOriginationInfo
 {
-  long
+  ssize_t
     x_offset,
     y_offset;
 
@@ -291,8 +291,8 @@
 %
 */
 
-static size_t GetBytesPerRow(unsigned long columns,
-  unsigned long samples_per_pixel,unsigned long bits_per_pixel,
+static size_t GetBytesPerRow(size_t columns,
+  size_t samples_per_pixel,size_t bits_per_pixel,
   MagickBooleanType pad)
 {
   size_t
@@ -361,7 +361,7 @@
 {
   union
   {
-    unsigned long
+    size_t
       unsigned_value;
 
     double
@@ -390,7 +390,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -405,7 +405,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   register PixelPacket
@@ -420,7 +420,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     lsb_first;
 
   /*
@@ -581,14 +581,14 @@
   /*
     Image origination information.
   */
-  cin.origination.x_offset=(long) ReadBlobLong(image);
+  cin.origination.x_offset=(ssize_t) ReadBlobLong(image);
   offset+=4;
-  if ((unsigned long) cin.origination.x_offset != ~0UL)
+  if ((size_t) cin.origination.x_offset != ~0UL)
     (void) FormatImageProperty(image,"cin:origination.x_offset","%ld",
       cin.origination.x_offset);
-  cin.origination.y_offset=(long) ReadBlobLong(image);
+  cin.origination.y_offset=(ssize_t) ReadBlobLong(image);
   offset+=4;
-  if ((unsigned long) cin.origination.y_offset != ~0UL)
+  if ((size_t) cin.origination.y_offset != ~0UL)
     (void) FormatImageProperty(image,"cin:origination.y_offset","%ld",
       cin.origination.y_offset);
   offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *)
@@ -631,15 +631,15 @@
       */
       cin.film.id=ReadBlobByte(image);
       offset++;
-      if (((unsigned long) cin.film.id) != ~0UL)
+      if (((size_t) cin.film.id) != ~0UL)
         (void) FormatImageProperty(image,"cin:film.id","%d",cin.film.id);
       cin.film.type=ReadBlobByte(image);
       offset++;
-      if (((unsigned long) cin.film.type) != ~0UL)
+      if (((size_t) cin.film.type) != ~0UL)
         (void) FormatImageProperty(image,"cin:film.type","%d",cin.film.type);
       cin.film.offset=ReadBlobByte(image);
       offset++;
-      if (((unsigned long) cin.film.offset) != ~0UL)
+      if (((size_t) cin.film.offset) != ~0UL)
         (void) FormatImageProperty(image,"cin:film.offset","%d",
           cin.film.offset);
       cin.film.reserve1=ReadBlobByte(image);
@@ -687,7 +687,7 @@
       (void) SetImageProfile(image,"cin:user.data",profile);
       profile=DestroyStringInfo(profile);
     }
-  for ( ; offset < (long) cin.file.image_offset; offset++)
+  for ( ; offset < (ssize_t) cin.file.image_offset; offset++)
     (void) ReadBlobByte(image);
   image->depth=cin.image.channel[0].bits_per_pixel;
   image->columns=cin.image.channel[0].pixels_per_line;
@@ -714,7 +714,7 @@
       quantum_type=GrayQuantum;
       length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue);
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -762,10 +762,10 @@
 %
 %  The format of the RegisterCINImage method is:
 %
-%      unsigned long RegisterCINImage(void)
+%      size_t RegisterCINImage(void)
 %
 */
-ModuleExport unsigned long RegisterCINImage(void)
+ModuleExport size_t RegisterCINImage(void)
 {
   MagickInfo
     *entry;
@@ -852,7 +852,7 @@
   const StringInfo
     *profile;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -870,7 +870,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -913,7 +913,7 @@
   profile=GetImageProfile(image,"cin:user.data");
   if (profile != (StringInfo *) NULL)
     {
-      cin.file.image_offset+=(unsigned long) GetStringInfoLength(profile);
+      cin.file.image_offset+=(size_t) GetStringInfoLength(profile);
       cin.file.image_offset=(((cin.file.image_offset+0x2000-1)/0x2000)*0x2000);
     }
   offset+=WriteBlobLong(image,cin.file.image_offset);
@@ -924,7 +924,7 @@
   cin.file.user_length=0x00;
   if (profile != (StringInfo *) NULL)
     {
-      cin.file.user_length+=(unsigned long) GetStringInfoLength(profile);
+      cin.file.user_length+=(size_t) GetStringInfoLength(profile);
       cin.file.user_length=(((cin.file.user_length+0x2000-1)/0x2000)*0x2000);
     }
   offset+=WriteBlobLong(image,cin.file.user_length);
@@ -1006,7 +1006,7 @@
   */
   cin.data_format.interleave=0; /* pixel interleave (rgbrgbr...) */
   offset+=WriteBlobByte(image,cin.data_format.interleave);
-  cin.data_format.packing=5; /* packing longword (32bit) boundaries */
+  cin.data_format.packing=5; /* packing ssize_tword (32bit) boundaries */
   offset+=WriteBlobByte(image,cin.data_format.packing);
   cin.data_format.sign=0; /* unsigned data */
   offset+=WriteBlobByte(image,cin.data_format.sign);
@@ -1025,12 +1025,12 @@
   value=GetCINProperty(image_info,image,"cin:origination.x_offset");
   if (value != (const char *) NULL)
     cin.origination.x_offset=StringToLong(value);
-  offset+=WriteBlobLong(image,(unsigned long) cin.origination.x_offset);
+  offset+=WriteBlobLong(image,(size_t) cin.origination.x_offset);
   cin.origination.y_offset=0UL;
   value=GetCINProperty(image_info,image,"cin:origination.y_offset");
   if (value != (const char *) NULL)
     cin.origination.y_offset=StringToLong(value);
-  offset+=WriteBlobLong(image,(unsigned long) cin.origination.y_offset);
+  offset+=WriteBlobLong(image,(size_t) cin.origination.y_offset);
   value=GetCINProperty(image_info,image,"cin:origination.filename");
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.origination.filename,value,
@@ -1159,7 +1159,7 @@
       quantum_type=GrayQuantum;
       length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue);
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/cip.c b/coders/cip.c
index 0ed42c6..40a1582 100644
--- a/coders/cip.c
+++ b/coders/cip.c
@@ -88,10 +88,10 @@
 %
 %  The format of the RegisterCIPImage method is:
 %
-%      unsigned long RegisterCIPImage(void)
+%      size_t RegisterCIPImage(void)
 %
 */
-ModuleExport unsigned long RegisterCIPImage(void)
+ModuleExport size_t RegisterCIPImage(void)
 {
   MagickInfo
     *entry;
@@ -155,7 +155,7 @@
 %
 */
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -170,7 +170,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -179,7 +179,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -229,30 +229,30 @@
   (void) WriteBlobString(image,"<Data>");
   if (image->colorspace != RGBColorspace)
     (void) TransformImageColorspace(image,RGBColorspace);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < ((long) image->columns-3); x+=4)
+    for (x=0; x < ((ssize_t) image->columns-3); x+=4)
     {
       byte=(unsigned char)
-        ((((unsigned long) (4*PixelIntensityToQuantum(p+3)/QuantumRange) & 0x03) << 6) |
-         (((unsigned long) (4*PixelIntensityToQuantum(p+2)/QuantumRange) & 0x03) << 4) |
-         (((unsigned long) (4*PixelIntensityToQuantum(p+1)/QuantumRange) & 0x03) << 2) |
-         (((unsigned long) (4*PixelIntensityToQuantum(p+0)/QuantumRange) & 0x03) << 0));
+        ((((size_t) (4*PixelIntensityToQuantum(p+3)/QuantumRange) & 0x03) << 6) |
+         (((size_t) (4*PixelIntensityToQuantum(p+2)/QuantumRange) & 0x03) << 4) |
+         (((size_t) (4*PixelIntensityToQuantum(p+1)/QuantumRange) & 0x03) << 2) |
+         (((size_t) (4*PixelIntensityToQuantum(p+0)/QuantumRange) & 0x03) << 0));
       (void) FormatMagickString(buffer,MaxTextExtent,"%02x",byte);
       (void) WriteBlobString(image,buffer);
       p+=4;
     }
     if ((image->columns % 4) != 0)
       {
-        i=(long) image->columns % 4;
+        i=(ssize_t) image->columns % 4;
         byte=(unsigned char)
-          ((((unsigned long) (4*PixelIntensityToQuantum(p+MagickMin(i,3))/QuantumRange) & 0x03) << 6) |
-           (((unsigned long) (4*PixelIntensityToQuantum(p+MagickMin(i,2))/QuantumRange) & 0x03) << 4) |
-           (((unsigned long) (4*PixelIntensityToQuantum(p+MagickMin(i,1))/QuantumRange) & 0x03) << 2) |
-           (((unsigned long) (4*PixelIntensityToQuantum(p+MagickMin(i,0))/QuantumRange) & 0x03) << 0));
+          ((((size_t) (4*PixelIntensityToQuantum(p+MagickMin(i,3))/QuantumRange) & 0x03) << 6) |
+           (((size_t) (4*PixelIntensityToQuantum(p+MagickMin(i,2))/QuantumRange) & 0x03) << 4) |
+           (((size_t) (4*PixelIntensityToQuantum(p+MagickMin(i,1))/QuantumRange) & 0x03) << 2) |
+           (((size_t) (4*PixelIntensityToQuantum(p+MagickMin(i,0))/QuantumRange) & 0x03) << 0));
         (void) FormatMagickString(buffer,MaxTextExtent,"%02x",~byte);
         (void) WriteBlobString(image,buffer);
       }
diff --git a/coders/clip.c b/coders/clip.c
index 42ef3d2..3c8723e 100644
--- a/coders/clip.c
+++ b/coders/clip.c
@@ -80,10 +80,10 @@
 %
 %  The format of the RegisterCLIPImage method is:
 %
-%      unsigned long RegisterCLIPImage(void)
+%      size_t RegisterCLIPImage(void)
 %
 */
-ModuleExport unsigned long RegisterCLIPImage(void)
+ModuleExport size_t RegisterCLIPImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/clipboard.c b/coders/clipboard.c
index d55fe89..c0a0b51 100644
--- a/coders/clipboard.c
+++ b/coders/clipboard.c
@@ -101,10 +101,10 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -201,12 +201,12 @@
       BitBlt(hDC,0,0,image->columns,image->rows,hMemDC,0,0,SRCCOPY);
       /* finally copy the pixels! */
       pBits=ppBits;
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=ScaleCharToQuantum(pBits->rgbRed);
           q->green=ScaleCharToQuantum(pBits->rgbGreen);
@@ -247,10 +247,10 @@
 %
 %  The format of the RegisterCLIPBOARDImage method is:
 %
-%      unsigned long RegisterCLIPBOARDImage(void)
+%      size_t RegisterCLIPBOARDImage(void)
 %
 */
-ModuleExport unsigned long RegisterCLIPBOARDImage(void)
+ModuleExport size_t RegisterCLIPBOARDImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/cmyk.c b/coders/cmyk.c
index 91ad393..da309e4 100644
--- a/coders/cmyk.c
+++ b/coders/cmyk.c
@@ -102,7 +102,7 @@
     *canvas_image,
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -117,7 +117,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -183,7 +183,7 @@
       */
       image->scene++;
       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
@@ -215,7 +215,7 @@
             length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const IndexPacket
             *restrict canvas_indexes;
@@ -226,7 +226,7 @@
           register IndexPacket
             *restrict indexes;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -247,7 +247,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -258,7 +258,7 @@
                 break;
               canvas_indexes=GetVirtualIndexQueue(canvas_image);
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -303,7 +303,7 @@
             length=GetQuantumExtent(canvas_image,quantum_info,CyanQuantum);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const IndexPacket
             *restrict canvas_indexes;
@@ -314,7 +314,7 @@
           register IndexPacket
             *restrict indexes;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -338,7 +338,7 @@
             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
               break;
             if (((y-image->extract_info.y) >= 0) && 
-                ((y-image->extract_info.y) < (long) image->rows))
+                ((y-image->extract_info.y) < (ssize_t) image->rows))
               {
                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
                   0,canvas_image->columns,1,exception);
@@ -349,7 +349,7 @@
                   break;
                 canvas_indexes=GetVirtualIndexQueue(canvas_image);
                 indexes=GetAuthenticIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   switch (quantum_type)
                   {
@@ -388,12 +388,12 @@
             length=GetQuantumExtent(canvas_image,quantum_info,CyanQuantum);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -414,7 +414,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -423,7 +423,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 p++;
@@ -440,12 +440,12 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -466,7 +466,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -475,7 +475,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
                 p++;
@@ -492,12 +492,12 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -518,7 +518,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -527,7 +527,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetBluePixelComponent(q,GetBluePixelComponent(p));
                 p++;
@@ -544,7 +544,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const IndexPacket
             *restrict canvas_indexes;
@@ -555,7 +555,7 @@
           register IndexPacket
             *restrict indexes;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -576,7 +576,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -587,7 +587,7 @@
                 break;
               canvas_indexes=GetVirtualIndexQueue(canvas_image);
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 indexes[x]=canvas_indexes[image->extract_info.x+x];
                 p++;
@@ -606,12 +606,12 @@
           }
         if (image->matte != MagickFalse)
           {
-            for (y=0; y < (long) image->extract_info.height; y++)
+            for (y=0; y < (ssize_t) image->extract_info.height; y++)
             {
               register const PixelPacket
                 *restrict p;
 
-              register long
+              register ssize_t
                 x;
 
               register PixelPacket
@@ -632,7 +632,7 @@
               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
                 break;
               if (((y-image->extract_info.y) >= 0) && 
-                  ((y-image->extract_info.y) < (long) image->rows))
+                  ((y-image->extract_info.y) < (ssize_t) image->rows))
                 {
                   p=GetVirtualPixels(canvas_image,
                     canvas_image->extract_info.x,0,canvas_image->columns,1,
@@ -642,7 +642,7 @@
                   if ((p == (const PixelPacket *) NULL) ||
                       (q == (PixelPacket *) NULL))
                     break;
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
                     p++;
@@ -689,8 +689,8 @@
               break;
             }
         length=GetQuantumExtent(canvas_image,quantum_info,CyanQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -698,12 +698,12 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -724,7 +724,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -733,7 +733,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 p++;
@@ -760,8 +760,8 @@
             return((Image *) NULL);
           }
         length=GetQuantumExtent(canvas_image,quantum_info,MagentaQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -769,12 +769,12 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -795,7 +795,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -804,7 +804,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
                 p++;
@@ -831,8 +831,8 @@
             return((Image *) NULL);
           }
         length=GetQuantumExtent(canvas_image,quantum_info,YellowQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -840,12 +840,12 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -866,7 +866,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -875,7 +875,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetBluePixelComponent(q,GetBluePixelComponent(p));
                 p++;
@@ -902,8 +902,8 @@
             return((Image *) NULL);
           }
         length=GetQuantumExtent(canvas_image,quantum_info,BlackQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -911,7 +911,7 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const IndexPacket
             *restrict canvas_indexes;
@@ -922,7 +922,7 @@
           register IndexPacket
             *restrict indexes;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -943,7 +943,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -954,7 +954,7 @@
                 break;
               canvas_indexes=GetVirtualIndexQueue(canvas_image);
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 indexes[x]=canvas_indexes[image->extract_info.x+x];
                 p++;
@@ -983,8 +983,8 @@
                 return((Image *) NULL);
               }
             length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
-            for (i=0; i < (long) scene; i++)
-              for (y=0; y < (long) image->extract_info.height; y++)
+            for (i=0; i < (ssize_t) scene; i++)
+              for (y=0; y < (ssize_t) image->extract_info.height; y++)
                 if (ReadBlob(image,length,pixels) != (ssize_t) length)
                   {
                     ThrowFileException(exception,CorruptImageError,
@@ -992,12 +992,12 @@
                     break;
                   }
             count=ReadBlob(image,length,pixels);
-            for (y=0; y < (long) image->extract_info.height; y++)
+            for (y=0; y < (ssize_t) image->extract_info.height; y++)
             {
               register const PixelPacket
                 *restrict p;
 
-              register long
+              register ssize_t
                 x;
 
               register PixelPacket
@@ -1018,7 +1018,7 @@
               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
                 break;
               if (((y-image->extract_info.y) >= 0) && 
-                  ((y-image->extract_info.y) < (long) image->rows))
+                  ((y-image->extract_info.y) < (ssize_t) image->rows))
                 {
                   p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
                     0,canvas_image->columns,1,exception);
@@ -1027,7 +1027,7 @@
                   if ((p == (const PixelPacket *) NULL) ||
                       (q == (PixelPacket *) NULL))
                     break;
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
                     p++;
@@ -1107,10 +1107,10 @@
 %
 %  The format of the RegisterCMYKImage method is:
 %
-%      unsigned long RegisterCMYKImage(void)
+%      size_t RegisterCMYKImage(void)
 %
 */
-ModuleExport unsigned long RegisterCMYKImage(void)
+ModuleExport size_t RegisterCMYKImage(void)
 {
   MagickInfo
     *entry;
@@ -1192,7 +1192,7 @@
 static MagickBooleanType WriteCMYKImage(const ImageInfo *image_info,
   Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1263,7 +1263,7 @@
         /*
           No interlacing:  CMYKCMYKCMYKCMYKCMYKCMYK...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1290,7 +1290,7 @@
         /*
           Line interlacing:  CCC...MMM...YYY...KKK...CCC...MMM...YYY...KKK...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1340,7 +1340,7 @@
         /*
           Plane interlacing:  CCCCCC...MMMMMM...YYYYYY...KKKKKK...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1360,7 +1360,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1380,7 +1380,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1400,7 +1400,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1422,7 +1422,7 @@
           }
         if (quantum_type == CMYKAQuantum)
           {
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
@@ -1465,7 +1465,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1491,7 +1491,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1517,7 +1517,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1543,7 +1543,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1571,7 +1571,7 @@
               AppendBinaryBlobMode,&image->exception);
             if (status == MagickFalse)
               return(status);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
diff --git a/coders/cut.c b/coders/cut.c
index 29be38c..a5358a5 100644
--- a/coders/cut.c
+++ b/coders/cut.c
@@ -92,12 +92,12 @@
 } CUTPalHeader;
 
 
-static void InsertRow(long depth,unsigned char *p,long y,Image *image)
+static void InsertRow(ssize_t depth,unsigned char *p,ssize_t y,Image *image)
 {
   ExceptionInfo
     *exception;
 
-  unsigned long bit; long x;
+  size_t bit; ssize_t x;
   register PixelPacket *q;
   IndexPacket index;
   register IndexPacket *indexes;
@@ -113,13 +113,13 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        for (x=0; x < ((ssize_t) image->columns-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
               {
                 index=(IndexPacket) ((((*p) & (0x80 >> bit)) != 0) ? 0x01 : 0x00);
                 indexes[x+bit]=index;
-                *q++=image->colormap[(long) index];
+                *q++=image->colormap[(ssize_t) index];
               }
             p++;
           }
@@ -129,7 +129,7 @@
               {
                 index=(IndexPacket) ((((*p) & (0x80 >> bit)) != 0) ? 0x01 : 0x00);
                 indexes[x+bit]=index;
-                *q++=image->colormap[(long) index];
+                *q++=image->colormap[(ssize_t) index];
               }
             p++;
           }
@@ -143,39 +143,39 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-1); x+=2)
+        for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
             index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p) & 0x3);
             indexes[x+1]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if ((image->columns % 4) != 0)
           {
             index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             if ((image->columns % 4) >= 1)
 
               {
                 index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
                 indexes[x]=index;
-                *q++=image->colormap[(long) index];
+                *q++=image->colormap[(ssize_t) index];
                 if ((image->columns % 4) >= 2)
 
                   {
                     index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
                     indexes[x]=index;
-                    *q++=image->colormap[(long) index];
+                    *q++=image->colormap[(ssize_t) index];
                   }
               }
             p++;
@@ -191,21 +191,21 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-1); x+=2)
+        for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
             index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p) & 0xf);
             indexes[x+1]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if ((image->columns % 2) != 0)
           {
             index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -218,11 +218,11 @@
         if (q == (PixelPacket *) NULL) break;
         indexes=GetAuthenticIndexQueue(image);
 
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           {
             index=ConstrainColormapIndex(image,*p);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -241,7 +241,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     x,
     y;
 
@@ -255,10 +255,10 @@
   exception=(&image->exception);
   intensity=0;
   scale_intensity=ScaleCharToQuantum(16);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (intensity < q->red)
         intensity=q->red;
@@ -309,13 +309,13 @@
   MagickOffsetType
     offset;
 
-  unsigned long EncodedByte;
+  size_t EncodedByte;
   unsigned char RunCount,RunValue,RunCountMasked;
   CUTHeader  Header;
   CUTPalHeader PalHeader;
-  long depth;
-  long i,j;
-  long ldblk;
+  ssize_t depth;
+  ssize_t i,j;
+  ssize_t ldblk;
   unsigned char *BImgBuff=NULL,*ptrB;
   PixelPacket *q;
 
@@ -359,13 +359,13 @@
   while((int) RunCountMasked!=0)  /*end of line?*/
     {
       i=1;
-      if((int) RunCount<0x80) i=(long) RunCountMasked;
+      if((int) RunCount<0x80) i=(ssize_t) RunCountMasked;
       offset=SeekBlob(image,TellBlob(image)+i,SEEK_SET);
       if (offset < 0)
         ThrowReaderException(CorruptImageError,"ImproperImageHeader");
       if(EOFBlob(image) != MagickFalse) goto CUT_KO;  /*wrong data*/
       EncodedByte-=i+1;
-      ldblk+=(long) RunCountMasked;
+      ldblk+=(ssize_t) RunCountMasked;
 
       RunCount=(unsigned char) ReadBlobByte(image);
       if(EOFBlob(image) != MagickFalse)  goto CUT_KO;  /*wrong data: unexpected eof in line*/
@@ -382,7 +382,7 @@
   image->columns=Header.Width;
   image->rows=Header.Height;
   image->depth=8;
-  image->colors=(unsigned long) (GetQuantumRange(1UL*i)+1);
+  image->colors=(size_t) (GetQuantumRange(1UL*i)+1);
 
   if (image_info->ping) goto Finish;
 
@@ -390,7 +390,7 @@
   if ((clone_info=CloneImageInfo(image_info)) == NULL) goto NoPalette;
 
 
-  i=(long) strlen(clone_info->filename);
+  i=(ssize_t) strlen(clone_info->filename);
   j=i;
   while(--i>0)
     {
@@ -461,7 +461,7 @@
 
       for(i=0;i<=(int) PalHeader.MaxIndex;i++)
         {      /*this may be wrong- I don't know why is palette such strange*/
-          j=(long) TellBlob(palette);
+          j=(ssize_t) TellBlob(palette);
           if((j % 512)>512-6)
             {
               j=((j / 512)+1)*512;
@@ -505,7 +505,7 @@
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
             }
 
-      for (i=0; i < (long)image->colors; i++)
+      for (i=0; i < (ssize_t)image->colors; i++)
         {
           image->colormap[i].red=ScaleCharToQuantum((unsigned char) i);
           image->colormap[i].green=ScaleCharToQuantum((unsigned char) i);
@@ -534,7 +534,7 @@
 
       while((int) RunCountMasked!=0)
         {
-          if((long) RunCountMasked>j)
+          if((ssize_t) RunCountMasked>j)
             {    /*Wrong Data*/
               RunCountMasked=(unsigned char) j;
               if(j==0)
@@ -573,7 +573,7 @@
         {
           if(GetCutColors(image)==2)
             {
-              for (i=0; i < (long)image->colors; i++)
+              for (i=0; i < (ssize_t)image->colors; i++)
                 {
                   register Quantum
                     sample;
@@ -584,10 +584,10 @@
                 }
 
               image->colormap[1].red=image->colormap[1].green=image->colormap[1].blue=(Quantum) QuantumRange;
-              for (i=0; i < (long)image->rows; i++)
+              for (i=0; i < (ssize_t)image->rows; i++)
                 {
                   q=QueueAuthenticPixels(image,0,i,image->columns,1,exception);
-                  for (j=0; j < (long)image->columns; j++)
+                  for (j=0; j < (ssize_t)image->columns; j++)
                     {
                       if(q->red==ScaleCharToQuantum(1))
                         {
@@ -635,10 +635,10 @@
 %
 %  The format of the RegisterCUTImage method is:
 %
-%      unsigned long RegisterCUTImage(void)
+%      size_t RegisterCUTImage(void)
 %
 */
-ModuleExport unsigned long RegisterCUTImage(void)
+ModuleExport size_t RegisterCUTImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dcm.c b/coders/dcm.c
index a5c8e6d..518a38f 100644
--- a/coders/dcm.c
+++ b/coders/dcm.c
@@ -2803,7 +2803,7 @@
     index,
     *redmap;
 
-  long
+  ssize_t
     element,
     group,
     scene,
@@ -2825,7 +2825,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -2844,7 +2844,7 @@
   unsigned char
     *data;
 
-  unsigned long
+  size_t
     bits_allocated,
     bytes_per_pixel,
     colors,
@@ -2931,16 +2931,16 @@
     /*
       Read a group.
     */
-    image->offset=(long) TellBlob(image);
-    group=(long) ReadBlobLSBShort(image);
-    element=(long) ReadBlobLSBShort(image);
+    image->offset=(ssize_t) TellBlob(image);
+    group=(ssize_t) ReadBlobLSBShort(image);
+    element=(ssize_t) ReadBlobLSBShort(image);
     quantum=0;
     /*
       Find corresponding VR for this group and element.
     */
     for (i=0; dicom_info[i].group < 0xffff; i++)
-      if ((group == (long) dicom_info[i].group) &&
-          (element == (long) dicom_info[i].element))
+      if ((group == (ssize_t) dicom_info[i].group) &&
+          (element == (ssize_t) dicom_info[i].element))
         break;
     (void) CopyMagickString(implicit_vr,dicom_info[i].vr,MaxTextExtent);
     count=ReadBlob(image,2,(unsigned char *) explicit_vr);
@@ -3018,12 +3018,12 @@
         if (use_explicit == MagickFalse)
           explicit_vr[0]='\0';
         for (i=0; dicom_info[i].description != (char *) NULL; i++)
-          if ((group == (long) dicom_info[i].group) &&
-              (element == (long) dicom_info[i].element))
+          if ((group == (ssize_t) dicom_info[i].group) &&
+              (element == (ssize_t) dicom_info[i].element))
             break;
         (void) fprintf(stdout,"0x%04lX %4ld %s-%s (0x%04lx,0x%04lx)",
-          (unsigned long) image->offset,(long) length,implicit_vr,
-          explicit_vr,(unsigned long) group,(unsigned long) element);
+          (size_t) image->offset,(ssize_t) length,implicit_vr,
+          explicit_vr,(size_t) group,(size_t) element);
         if (dicom_info[i].description != (char *) NULL)
           (void) fprintf(stdout," %s",dicom_info[i].description);
         (void) fprintf(stdout,": ");
@@ -3162,7 +3162,7 @@
             /*
               Photometric interpretation.
             */
-            for (i=0; i < (long) MagickMin(length,MaxTextExtent-1); i++)
+            for (i=0; i < (ssize_t) MagickMin(length,MaxTextExtent-1); i++)
               photometric[i]=(char) data[i];
             photometric[i]='\0';
             polarity=LocaleCompare(photometric,"MONOCHROME1 ") == 0 ?
@@ -3230,7 +3230,7 @@
             if (image->depth > 32)
               ThrowReaderException(CorruptImageError,"ImproperImageHeader");
             max_value=(1UL << significant_bits)-1;
-            mask=(unsigned long) GetQuantumRange(significant_bits);
+            mask=(size_t) GetQuantumRange(significant_bits);
             break;
           }
           case 0x0102:
@@ -3272,13 +3272,13 @@
             */
             if (data == (unsigned char *) NULL)
               break;
-            colors=(unsigned long) (length/bytes_per_pixel);
+            colors=(size_t) (length/bytes_per_pixel);
             datum=colors;
             graymap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*graymap));
             if (graymap == (int *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-            for (i=0; i < (long) colors; i++)
+            for (i=0; i < (ssize_t) colors; i++)
               if (bytes_per_pixel == 1)
                 graymap[i]=(int) data[i];
               else
@@ -3295,14 +3295,14 @@
             */
             if (data == (unsigned char *) NULL)
               break;
-            colors=(unsigned long) (length/2);
+            colors=(size_t) (length/2);
             datum=colors;
             redmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*redmap));
             if (redmap == (int *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
-            for (i=0; i < (long) colors; i++)
+            for (i=0; i < (ssize_t) colors; i++)
             {
               if (image->endian != LSBEndian)
                 index=(unsigned short) ((*p << 8) | *(p+1));
@@ -3323,14 +3323,14 @@
             */
             if (data == (unsigned char *) NULL)
               break;
-            colors=(unsigned long) (length/2);
+            colors=(size_t) (length/2);
             datum=colors;
             greenmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*greenmap));
             if (greenmap == (int *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
-            for (i=0; i < (long) colors; i++)
+            for (i=0; i < (ssize_t) colors; i++)
             {
               if (image->endian != LSBEndian)
                 index=(unsigned short) ((*p << 8) | *(p+1));
@@ -3351,14 +3351,14 @@
             */
             if (data == (unsigned char *) NULL)
               break;
-            colors=(unsigned long) (length/2);
+            colors=(size_t) (length/2);
             datum=colors;
             bluemap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*bluemap));
             if (bluemap == (int *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
-            for (i=0; i < (long) colors; i++)
+            for (i=0; i < (ssize_t) colors; i++)
             {
               if (image->endian != LSBEndian)
                 index=(unsigned short) ((*p << 8) | *(p+1));
@@ -3397,15 +3397,15 @@
           *attribute;
 
         for (i=0; dicom_info[i].description != (char *) NULL; i++)
-          if ((group == (long) dicom_info[i].group) &&
-              (element == (long) dicom_info[i].element))
+          if ((group == (ssize_t) dicom_info[i].group) &&
+              (element == (ssize_t) dicom_info[i].element))
             break;
         attribute=AcquireString("dcm:");
         (void) ConcatenateString(&attribute,dicom_info[i].description);
-        for (i=0; i < (long) MagickMax(length,4); i++)
+        for (i=0; i < (ssize_t) MagickMax(length,4); i++)
           if (isprint((int) data[i]) == MagickFalse)
             break;
-        if ((i == (long) length) || (length > 4))
+        if ((i == (ssize_t) length) || (length > 4))
           {
             (void) SubstituteString(&attribute," ","");
             (void) SetImageProperty(image,attribute,(char *) data);
@@ -3421,21 +3421,21 @@
             /*
               Display group data.
             */
-            for (i=0; i < (long) MagickMax(length,4); i++)
+            for (i=0; i < (ssize_t) MagickMax(length,4); i++)
               if (isprint((int) data[i]) == MagickFalse)
                 break;
-            if ((i != (long) length) && (length <= 4))
+            if ((i != (ssize_t) length) && (length <= 4))
               {
-                long
+                ssize_t
                   j;
 
                 datum=0;
-                for (j=(long) length-1; j >= 0; j--)
+                for (j=(ssize_t) length-1; j >= 0; j--)
                   datum=(256*datum+data[j]);
                 (void) fprintf(stdout,"%d",datum);
               }
             else
-              for (i=0; i < (long) length; i++)
+              for (i=0; i < (ssize_t) length; i++)
                 if (isprint((int) data[i]) != MagickFalse)
                   (void) fprintf(stdout,"%c",data[i]);
                 else
@@ -3454,10 +3454,10 @@
   }
   if ((width == 0) || (height == 0))
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-  image->columns=(unsigned long) width;
-  image->rows=(unsigned long) height;
+  image->columns=(size_t) width;
+  image->rows=(size_t) height;
   if (signed_data == 0xffff)
-    signed_data=(unsigned long) (significant_bits == 16 ? 1 : 0);
+    signed_data=(size_t) (significant_bits == 16 ? 1 : 0);
   if ((image->compression == JPEGCompression) ||
       (image->compression == JPEG2000Compression))
     {
@@ -3479,7 +3479,7 @@
       /*
         Read offset table.
       */
-      for (i=0; i < (long) stream_info->remaining; i++)
+      for (i=0; i < (ssize_t) stream_info->remaining; i++)
         (void) ReadBlobByte(image);
       tag=(ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image);
       length=(size_t) ReadBlobLSBLong(image);
@@ -3493,10 +3493,10 @@
             stream_info->offset_count,sizeof(*stream_info->offsets));
           if (stream_info->offsets == (ssize_t *) NULL)
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          for (i=0; i < (long) stream_info->offset_count; i++)
+          for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]=(ssize_t) ReadBlobLSBLong(image);
           offset=TellBlob(image);
-          for (i=0; i < (long) stream_info->offset_count; i++)
+          for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]+=offset;
         }
       /*
@@ -3505,7 +3505,7 @@
       read_info=CloneImageInfo(image_info);
       SetImageInfoBlob(read_info,(void *) NULL,0);
       images=NewImageList();
-      for (scene=0; scene < (long) number_scenes; scene++)
+      for (scene=0; scene < (ssize_t) number_scenes; scene++)
       {
         char
           filename[MaxTextExtent];
@@ -3590,8 +3590,8 @@
       if (scale == (Quantum *) NULL)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
       range=GetQuantumRange(image->depth);
-      for (i=0; i < (long) (GetQuantumRange(image->depth)+1); i++)
-        scale[i]=ScaleAnyToQuantum((unsigned long) i,range);
+      for (i=0; i < (ssize_t) (GetQuantumRange(image->depth)+1); i++)
+        scale[i]=ScaleAnyToQuantum((size_t) i,range);
     }
   if (image->compression == RLECompression)
     {
@@ -3604,7 +3604,7 @@
       /*
         Read RLE offset table.
       */
-      for (i=0; i < (long) stream_info->remaining; i++)
+      for (i=0; i < (ssize_t) stream_info->remaining; i++)
         (void) ReadBlobByte(image);
       tag=(ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image);
       length=(size_t) ReadBlobLSBLong(image);
@@ -3618,14 +3618,14 @@
             stream_info->offset_count,sizeof(*stream_info->offsets));
           if (stream_info->offsets == (ssize_t *) NULL)
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          for (i=0; i < (long) stream_info->offset_count; i++)
+          for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]=(ssize_t) ReadBlobLSBLong(image);
           offset=TellBlob(image);
-          for (i=0; i < (long) stream_info->offset_count; i++)
+          for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]+=offset;
         }
     }
-  for (scene=0; scene < (long) number_scenes; scene++)
+  for (scene=0; scene < (ssize_t) number_scenes; scene++)
   {
     if (image_info->ping != MagickFalse)
       break;
@@ -3637,7 +3637,7 @@
         /*
           Read RLE segment table.
         */
-        for (i=0; i < (long) stream_info->remaining; i++)
+        for (i=0; i < (ssize_t) stream_info->remaining; i++)
           (void) ReadBlobByte(image);
         tag=(ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image);
         stream_info->remaining=(size_t) ReadBlobLSBLong(image);
@@ -3650,8 +3650,8 @@
            stream_info->segments[i]=(ssize_t) ReadBlobLSBLong(image);
         stream_info->remaining-=64;
       }
-    image->columns=(unsigned long) width;
-    image->rows=(unsigned long) height;
+    image->columns=(size_t) width;
+    image->rows=(size_t) height;
     if ((image->colormap == (PixelPacket *) NULL) && (samples_per_pixel == 1))
       {
         if (colors == 0)
@@ -3659,7 +3659,7 @@
         if (AcquireImageColormap(image,colors) == MagickFalse)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         if (redmap != (int *) NULL)
-          for (i=0; i < (long) colors; i++)
+          for (i=0; i < (ssize_t) colors; i++)
           {
             index=redmap[i];
             if ((scale != (Quantum *) NULL) && (index <= (int) max_value))
@@ -3667,7 +3667,7 @@
             image->colormap[i].red=index;
           }
         if (greenmap != (int *) NULL)
-          for (i=0; i < (long) colors; i++)
+          for (i=0; i < (ssize_t) colors; i++)
           {
             index=greenmap[i];
             if ((scale != (Quantum *) NULL) && (index <= (int) max_value))
@@ -3675,7 +3675,7 @@
             image->colormap[i].green=index;
           }
         if (bluemap != (int *) NULL)
-          for (i=0; i < (long) colors; i++)
+          for (i=0; i < (ssize_t) colors; i++)
           {
             index=bluemap[i];
             if ((scale != (Quantum *) NULL) && (index <= (int) max_value))
@@ -3683,7 +3683,7 @@
             image->colormap[i].blue=index;
           }
         if (graymap != (int *) NULL)
-          for (i=0; i < (long) colors; i++)
+          for (i=0; i < (ssize_t) colors; i++)
           {
             index=graymap[i];
             if ((scale != (Quantum *) NULL) && (index <= (int) max_value))
@@ -3698,14 +3698,14 @@
         /*
           Convert Planar RGB DCM Medical image to pixel packets.
         */
-        for (i=0; i < (long) samples_per_pixel; i++)
+        for (i=0; i < (ssize_t) samples_per_pixel; i++)
         {
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               switch ((int) i)
               {
@@ -3766,7 +3766,7 @@
         byte=0;
         i=0;
         if ((window_center != 0) && (window_width == 0))
-          window_width=(unsigned long) window_center;
+          window_width=(size_t) window_center;
         option=GetImageOption(image_info,"dcm:display-range");
         if (option != (const char *) NULL)
           {
@@ -3774,13 +3774,13 @@
               window_width=0;
           }
         (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             if (samples_per_pixel == 1)
               {
@@ -3831,25 +3831,25 @@
                   }
                 else
                   {
-                    long
+                    ssize_t
                       window_max,
                       window_min;
 
-                    window_min=(long) ceil(window_center-(window_width-1)/2.0-
+                    window_min=(ssize_t) ceil(window_center-(window_width-1)/2.0-
                       0.5);
-                    window_max=(long) floor(window_center+(window_width-1)/2.0+
+                    window_max=(ssize_t) floor(window_center+(window_width-1)/2.0+
                       0.5);
-                    if ((long) pixel_value <= window_min)
+                    if ((ssize_t) pixel_value <= window_min)
                       index=0;
                     else
-                      if ((long) pixel_value > window_max)
+                      if ((ssize_t) pixel_value > window_max)
                         index=(int) max_value;
                       else
                         index=(int) (max_value*(((pixel_value-window_center-
                           0.5)/(window_width-1))+0.5));
                   }
                 index&=mask;
-                index=(int) ConstrainColormapIndex(image,(unsigned long) index);
+                index=(int) ConstrainColormapIndex(image,(size_t) index);
                 indexes[x]=(IndexPacket) index;
                 pixel.red=1UL*image->colormap[index].red;
                 pixel.green=1UL*image->colormap[index].green;
@@ -3859,9 +3859,9 @@
               {
                 if (bytes_per_pixel == 1)
                   {
-                    pixel.red=(unsigned long) ReadDCMByte(stream_info,image);
-                    pixel.green=(unsigned long) ReadDCMByte(stream_info,image);
-                    pixel.blue=(unsigned long) ReadDCMByte(stream_info,image);
+                    pixel.red=(size_t) ReadDCMByte(stream_info,image);
+                    pixel.green=(size_t) ReadDCMByte(stream_info,image);
+                    pixel.blue=(size_t) ReadDCMByte(stream_info,image);
                   }
                 else
                   {
@@ -3915,7 +3915,7 @@
     if (image_info->number_scenes != 0)
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
         break;
-    if (scene < (long) (number_scenes-1))
+    if (scene < (ssize_t) (number_scenes-1))
       {
         /*
           Allocate next image structure.
@@ -3974,10 +3974,10 @@
 %
 %  The format of the RegisterDCMImage method is:
 %
-%      unsigned long RegisterDCMImage(void)
+%      size_t RegisterDCMImage(void)
 %
 */
-ModuleExport unsigned long RegisterDCMImage(void)
+ModuleExport size_t RegisterDCMImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dds.c b/coders/dds.c
index c186650..1908764 100644
--- a/coders/dds.c
+++ b/coders/dds.c
@@ -116,7 +116,7 @@
 */
 typedef struct _DDSPixelFormat
 {
-  unsigned long
+  size_t
     flags,
     fourcc,
     rgb_bitcount,
@@ -128,7 +128,7 @@
 
 typedef struct _DDSInfo
 {
-  unsigned long
+  size_t
     flags,
     height,
     width,
@@ -225,7 +225,7 @@
 %
 */
 
-static inline unsigned long Min(unsigned long one, unsigned long two)
+static inline size_t Min(size_t one, size_t two)
 {
   if (one < two)
     return one;
@@ -252,7 +252,7 @@
   DDSDecoder
     *decoder;
   
-  unsigned long
+  size_t
     n, num_images;
   
   /*
@@ -408,7 +408,7 @@
 
 static MagickBooleanType ReadDDSInfo(Image *image, DDSInfo *dds_info)
 {
-  unsigned long
+  size_t
     hdr_size,
     required;
   
@@ -424,7 +424,7 @@
   dds_info->flags = ReadBlobLSBLong(image);
   
   /* Check required flags */
-  required=(unsigned long) (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT);
+  required=(size_t) (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT);
   if ((dds_info->flags & required) != required)
     return MagickFalse;
   
@@ -498,14 +498,14 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     j,
     y;
   
   PixelPacket
     *q;
   
-  register long
+  register ssize_t
     i,
     x;
   
@@ -516,13 +516,13 @@
     c0,
     c1;
   
-  unsigned long
+  size_t
     bits;
 
   exception=(&image->exception);
-  for (y = 0; y < (long) dds_info->height; y += 4)
+  for (y = 0; y < (ssize_t) dds_info->height; y += 4)
   {
-    for (x = 0; x < (long) dds_info->width; x += 4)
+    for (x = 0; x < (ssize_t) dds_info->width; x += 4)
     {
       /* Get 4x4 patch of pixels to write on */
       q = QueueAuthenticPixels(image, x, y, Min(4, dds_info->width - x),
@@ -543,7 +543,7 @@
       {
         for (i = 0; i < 4; i++)
         {
-          if ((x + i) < (long) dds_info->width && (y + j) < (long) dds_info->height)
+          if ((x + i) < (ssize_t) dds_info->width && (y + j) < (ssize_t) dds_info->height)
             {
               code = (unsigned char) ((bits >> ((j*4+i)*2)) & 0x3);
               q->red     = ScaleCharToQuantum( colors.r[code] );
@@ -576,21 +576,21 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     j,
     y;
 
   PixelPacket
     *q;
   
-  register long
+  register ssize_t
     i,
     x;
   
   unsigned char
     alpha;
   
-  unsigned long
+  size_t
     a0,
     a1,
     bits,
@@ -601,9 +601,9 @@
     c1;
   
   exception=(&image->exception);
-  for (y = 0; y < (long) dds_info->height; y += 4)
+  for (y = 0; y < (ssize_t) dds_info->height; y += 4)
   {
-    for (x = 0; x < (long) dds_info->width; x += 4)
+    for (x = 0; x < (ssize_t) dds_info->width; x += 4)
     {
       /* Get 4x4 patch of pixels to write on */
       q = QueueAuthenticPixels(image, x, y, Min(4, dds_info->width - x),
@@ -628,7 +628,7 @@
       {
         for (i = 0; i < 4; i++)
         {
-          if ((x + i) < (long) dds_info->width && (y + j) < (long) dds_info->height)
+          if ((x + i) < (ssize_t) dds_info->width && (y + j) < (ssize_t) dds_info->height)
             {
               code = (bits >> ((4*j+i)*2)) & 0x3;
               q->red   = ScaleCharToQuantum( colors.r[code] );
@@ -668,7 +668,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -678,7 +678,7 @@
   PixelPacket
     *q;
   
-  register long
+  register ssize_t
     i,
     x;
 
@@ -686,7 +686,7 @@
     a0,
     a1;
   
-  unsigned long
+  size_t
     alpha,
     bits,
     code,
@@ -697,9 +697,9 @@
     c1;
   
   exception=(&image->exception);
-  for (y = 0; y < (long) dds_info->height; y += 4)
+  for (y = 0; y < (ssize_t) dds_info->height; y += 4)
   {
-    for (x = 0; x < (long) dds_info->width; x += 4)
+    for (x = 0; x < (ssize_t) dds_info->width; x += 4)
     {
       /* Get 4x4 patch of pixels to write on */
       q = QueueAuthenticPixels(image, x, y, Min(4, dds_info->width - x),
@@ -727,7 +727,7 @@
       {
         for (i = 0; i < 4; i++)
         {
-          if ((x + i) < (long) dds_info->width && (y + j) < (long) dds_info->height)
+          if ((x + i) < (ssize_t) dds_info->width && (y + j) < (ssize_t) dds_info->height)
             {
               code = (bits >> ((4*j+i)*2)) & 0x3;
               q->red   = ScaleCharToQuantum( colors.r[code] );
@@ -735,7 +735,7 @@
               q->blue  = ScaleCharToQuantum( colors.b[code] );
               
               /* Extract alpha value */
-              alpha_code = (unsigned long) (alpha_bits >> (3*(4*j+i))) & 0x7;
+              alpha_code = (size_t) (alpha_bits >> (3*(4*j+i))) & 0x7;
               if (alpha_code == 0)
                 alpha = a0;
               else if (alpha_code == 1)
@@ -771,21 +771,21 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     x, y;
   
   PixelPacket
     *q;
   
   exception=(&image->exception);
-  for (y = 0; y < (long) dds_info->height; y++)
+  for (y = 0; y < (ssize_t) dds_info->height; y++)
   {
     q = QueueAuthenticPixels(image, 0, y, dds_info->width, 1,exception);
     
     if (q == (PixelPacket *) NULL)
       return MagickFalse;
     
-    for (x = 0; x < (long) dds_info->width; x++)
+    for (x = 0; x < (ssize_t) dds_info->width; x++)
     {
       q->blue  = ScaleCharToQuantum( (unsigned char) ReadBlobByte(image) );
       q->green = ScaleCharToQuantum( (unsigned char) ReadBlobByte(image) );
@@ -807,21 +807,21 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     x, y;
   
   PixelPacket
     *q;
   
   exception=(&image->exception);
-  for (y = 0; y < (long) dds_info->height; y++)
+  for (y = 0; y < (ssize_t) dds_info->height; y++)
   {
     q = QueueAuthenticPixels(image, 0, y, dds_info->width, 1,exception);
     
     if (q == (PixelPacket *) NULL)
       return MagickFalse;
     
-    for (x = 0; x < (long) dds_info->width; x++)
+    for (x = 0; x < (ssize_t) dds_info->width; x++)
     {
       q->blue    = ScaleCharToQuantum( (unsigned char) ReadBlobByte(image) );
       q->green   = ScaleCharToQuantum( (unsigned char) ReadBlobByte(image) );
@@ -844,13 +844,13 @@
 */
 static void SkipDXTMipmaps(Image *image, DDSInfo *dds_info, int texel_size)
 {
-  register long
+  register ssize_t
     i;
 
   MagickOffsetType
     offset;
 
-  unsigned long
+  size_t
     h,
     w;
   
@@ -867,7 +867,7 @@
       /*
         Mipmapcount includes the main image, so start from one
       */
-      for (i = 1; (i < (long) dds_info->mipmapcount) && w && h; i++)
+      for (i = 1; (i < (ssize_t) dds_info->mipmapcount) && w && h; i++)
       {
         offset = (MagickOffsetType) ((w + 3) / 4) * ((h + 3) / 4) * texel_size;
         (void) SeekBlob(image, offset, SEEK_CUR);
@@ -886,10 +886,10 @@
   MagickOffsetType
     offset;
   
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     h,
     w;
 
@@ -906,7 +906,7 @@
       /*
         Mipmapcount includes the main image, so start from one
       */
-      for (i=1; (i < (long) dds_info->mipmapcount) && w && h; i++)
+      for (i=1; (i < (ssize_t) dds_info->mipmapcount) && w && h; i++)
       {
         offset = (MagickOffsetType) w * h * pixel_size;
         (void) SeekBlob(image, offset, SEEK_CUR);
@@ -974,7 +974,7 @@
 %      RegisterDDSImage(void)
 %
 */
-ModuleExport unsigned long RegisterDDSImage(void)
+ModuleExport size_t RegisterDDSImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dib.c b/coders/dib.c
index a08279b..485ac05 100644
--- a/coders/dib.c
+++ b/coders/dib.c
@@ -71,10 +71,10 @@
 */
 typedef struct _DIBInfo
 {
-  unsigned long
+  size_t
     size;
 
-  long
+  ssize_t
     width,
     height;
 
@@ -82,7 +82,7 @@
     planes,
     bits_per_pixel;
 
-  unsigned long
+  size_t
     compression,
     image_size,
     x_pixels,
@@ -94,7 +94,7 @@
     alpha_mask,
     colors_important;
 
-  long
+  ssize_t
     colorspace;
 
   PointInfo
@@ -161,10 +161,10 @@
   int
     count;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -186,7 +186,7 @@
   x=0;
   p=pixels;
   q=pixels+(size_t) image->columns*image->rows;
-  for (y=0; y < (long) image->rows; )
+  for (y=0; y < (ssize_t) image->rows; )
   {
     if ((p < pixels) || (p >= q))
       break;
@@ -300,7 +300,7 @@
 %  The format of the EncodeImage method is:
 %
 %    static MagickBooleanType EncodeImage(Image *image,
-%      const unsigned long bytes_per_line,const unsigned char *pixels,
+%      const size_t bytes_per_line,const unsigned char *pixels,
 %      unsigned char *compressed_pixels)
 %
 %  A description of each parameter follows:
@@ -316,16 +316,16 @@
 %      pixel data.
 %
 */
-static size_t EncodeImage(Image *image,const unsigned long bytes_per_line,
+static size_t EncodeImage(Image *image,const size_t bytes_per_line,
   const unsigned char *pixels,unsigned char *compressed_pixels)
 {
-  long
+  ssize_t
     y;
 
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -344,14 +344,14 @@
   p=pixels;
   q=compressed_pixels;
   i=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    for (x=0; x < (long) bytes_per_line; x+=i)
+    for (x=0; x < (ssize_t) bytes_per_line; x+=i)
     {
       /*
         Determine runlength.
       */
-      for (i=1; ((x+i) < (long) bytes_per_line); i++)
+      for (i=1; ((x+i) < (ssize_t) bytes_per_line); i++)
         if ((*(p+i) != *p) || (i == 255))
           break;
       *q++=(unsigned char) i;
@@ -435,7 +435,7 @@
 %
 */
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -460,7 +460,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     bit,
     y;
 
@@ -470,13 +470,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -491,7 +491,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     bytes_per_line;
 
   /*
@@ -539,8 +539,8 @@
       dib_info.blue_mask=ReadBlobLSBLong(image);
     }
   image->matte=dib_info.bits_per_pixel == 32 ? MagickTrue : MagickFalse;
-  image->columns=(unsigned long) MagickAbsoluteValue(dib_info.width);
-  image->rows=(unsigned long) MagickAbsoluteValue(dib_info.height);
+  image->columns=(size_t) MagickAbsoluteValue(dib_info.width);
+  image->rows=(size_t) MagickAbsoluteValue(dib_info.height);
   image->depth=8;
   if ((dib_info.number_colors != 0) || (dib_info.bits_per_pixel < 16))
     {
@@ -589,7 +589,7 @@
       if (count != (ssize_t) (packet_size*image->colors))
         ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
       p=dib_colormap;
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         image->colormap[i].blue=ScaleCharToQuantum(*p++);
         image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -643,30 +643,30 @@
       /*
         Convert bitmap scanline.
       */
-      for (y=(long) image->rows-1; y >= 0; y--)
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
       {
         p=pixels+(image->rows-y-1)*bytes_per_line;
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        for (x=0; x < ((ssize_t) image->columns-7); x+=8)
         {
           for (bit=0; bit < 8; bit++)
           {
             index=(IndexPacket) ((*p) & (0x80 >> bit) ? 0x01 : 0x00);
             indexes[x+bit]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
           }
           p++;
         }
         if ((image->columns % 8) != 0)
           {
-            for (bit=0; bit < (long) (image->columns % 8); bit++)
+            for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
             {
               index=(IndexPacket) ((*p) & (0x80 >> bit) ? 0x01 : 0x00);
               indexes[x+bit]=index;
-              *q++=image->colormap[(long) index];
+              *q++=image->colormap[(ssize_t) index];
             }
             p++;
           }
@@ -687,28 +687,28 @@
       /*
         Convert PseudoColor scanline.
       */
-      for (y=(long) image->rows-1; y >= 0; y--)
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
       {
         p=pixels+(image->rows-y-1)*bytes_per_line;
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-1); x+=2)
+        for (x=0; x < ((ssize_t) image->columns-1); x+=2)
         {
           index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
           indexes[x]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           index=ConstrainColormapIndex(image,*p & 0xf);
           indexes[x+1]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           p++;
         }
         if ((image->columns % 2) != 0)
           {
             index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -731,18 +731,18 @@
       if ((dib_info.compression == BI_RLE8) ||
           (dib_info.compression == BI_RLE4))
         bytes_per_line=image->columns;
-      for (y=(long) image->rows-1; y >= 0; y--)
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
       {
         p=pixels+(image->rows-y-1)*bytes_per_line;
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           index=ConstrainColormapIndex(image,*p);
           indexes[x]=index;
-          *q=image->colormap[(long) index];
+          *q=image->colormap[(ssize_t) index];
           p++;
           q++;
         }
@@ -769,13 +769,13 @@
       image->storage_class=DirectClass;
       if (dib_info.compression == BI_RLE8)
         bytes_per_line=2*image->columns;
-      for (y=(long) image->rows-1; y >= 0; y--)
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
       {
         p=pixels+(image->rows-y-1)*bytes_per_line;
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           word=(*p++);
           word|=(*p++ << 8);
@@ -817,13 +817,13 @@
       /*
         Convert DirectColor scanline.
       */
-      for (y=(long) image->rows-1; y >= 0; y--)
+      for (y=(ssize_t) image->rows-1; y >= 0; y--)
       {
         p=pixels+(image->rows-y-1)*bytes_per_line;
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->blue=ScaleCharToQuantum(*p++);
           q->green=ScaleCharToQuantum(*p++);
@@ -891,10 +891,10 @@
 %
 %  The format of the RegisterDIBImage method is:
 %
-%      unsigned long RegisterDIBImage(void)
+%      size_t RegisterDIBImage(void)
 %
 */
-ModuleExport unsigned long RegisterDIBImage(void)
+ModuleExport size_t RegisterDIBImage(void)
 {
   MagickInfo
     *entry;
@@ -966,7 +966,7 @@
   DIBInfo
     dib_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -978,7 +978,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -989,7 +989,7 @@
     *dib_data,
     *pixels;
 
-  unsigned long
+  size_t
     bytes_per_line;
 
   /*
@@ -1032,10 +1032,10 @@
     }
   bytes_per_line=4*((image->columns*dib_info.bits_per_pixel+31)/32);
   dib_info.size=40;
-  dib_info.width=(long) image->columns;
-  dib_info.height=(long) image->rows;
+  dib_info.width=(ssize_t) image->columns;
+  dib_info.height=(ssize_t) image->rows;
   dib_info.planes=1;
-  dib_info.compression=(unsigned long) (dib_info.bits_per_pixel == 16 ?
+  dib_info.compression=(size_t) (dib_info.bits_per_pixel == 16 ?
     BI_BITFIELDS : BI_RGB);
   dib_info.image_size=bytes_per_line*image->rows;
   dib_info.x_pixels=75*39;
@@ -1045,14 +1045,14 @@
     case UndefinedResolution:
     case PixelsPerInchResolution:
     {
-      dib_info.x_pixels=(unsigned long) (100.0*image->x_resolution/2.54);
-      dib_info.y_pixels=(unsigned long) (100.0*image->y_resolution/2.54);
+      dib_info.x_pixels=(size_t) (100.0*image->x_resolution/2.54);
+      dib_info.y_pixels=(size_t) (100.0*image->y_resolution/2.54);
       break;
     }
     case PixelsPerCentimeterResolution:
     {
-      dib_info.x_pixels=(unsigned long) (100.0*image->x_resolution);
-      dib_info.y_pixels=(unsigned long) (100.0*image->y_resolution);
+      dib_info.x_pixels=(size_t) (100.0*image->x_resolution);
+      dib_info.y_pixels=(size_t) (100.0*image->y_resolution);
       break;
     }
   }
@@ -1076,7 +1076,7 @@
       /*
         Convert PseudoClass image to a DIB monochrome image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
@@ -1085,7 +1085,7 @@
         q=pixels+(image->rows-y-1)*bytes_per_line;
         bit=0;
         byte=0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           byte<<=1;
           byte|=indexes[x] != 0 ? 0x01 : 0x00;
@@ -1103,7 +1103,7 @@
              *q++=(unsigned char) (byte << (8-bit));
              x++;
            }
-        for (x=(long) (image->columns+7)/8; x < (long) bytes_per_line; x++)
+        for (x=(ssize_t) (image->columns+7)/8; x < (ssize_t) bytes_per_line; x++)
           *q++=0x00;
         status=SetImageProgress(image,SaveImageTag,y,image->rows);
         if (status == MagickFalse)
@@ -1116,16 +1116,16 @@
       /*
         Convert PseudoClass packet to DIB pixel.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
         q=pixels+(image->rows-y-1)*bytes_per_line;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           *q++=(unsigned char) indexes[x];
-        for ( ; x < (long) bytes_per_line; x++)
+        for ( ; x < (ssize_t) bytes_per_line; x++)
           *q++=0x00;
         status=SetImageProgress(image,SaveImageTag,y,image->rows);
         if (status == MagickFalse)
@@ -1140,13 +1140,13 @@
       /*
         Convert PseudoClass packet to DIB pixel. 
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
         q=pixels+(image->rows-y-1)*bytes_per_line;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           word=(unsigned short) ((ScaleColor8to5((unsigned char)
             ScaleQuantumToChar(GetRedPixelComponent(p))) << 11) | (ScaleColor8to6((unsigned char)
@@ -1156,7 +1156,7 @@
           *q++=(unsigned char)(word >> 8);
           p++;
         }
-        for (x=2L*image->columns; x < (long) bytes_per_line; x++)
+        for (x=2L*image->columns; x < (ssize_t) bytes_per_line; x++)
           *q++=0x00;
         status=SetImageProgress(image,SaveImageTag,y,image->rows);
         if (status == MagickFalse)
@@ -1170,13 +1170,13 @@
       /*
         Convert DirectClass packet to DIB RGB pixel.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
         q=pixels+(image->rows-y-1)*bytes_per_line;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
           *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1186,7 +1186,7 @@
           p++;
         }
         if (dib_info.bits_per_pixel == 24)
-          for (x=3L*image->columns; x < (long) bytes_per_line; x++)
+          for (x=3L*image->columns; x < (ssize_t) bytes_per_line; x++)
             *q++=0x00;
         status=SetImageProgress(image,SaveImageTag,y,image->rows);
         if (status == MagickFalse)
@@ -1212,7 +1212,7 @@
             pixels=(unsigned char *) RelinquishMagickMemory(pixels);
             ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
           }
-        dib_info.image_size=(unsigned long) EncodeImage(image,bytes_per_line,
+        dib_info.image_size=(size_t) EncodeImage(image,bytes_per_line,
           pixels,dib_data);
         pixels=(unsigned char *) RelinquishMagickMemory(pixels);
         pixels=dib_data;
@@ -1222,7 +1222,7 @@
     Write DIB header.
   */
   (void) WriteBlobLSBLong(image,dib_info.size);
-  (void) WriteBlobLSBLong(image,(unsigned long) dib_info.width);
+  (void) WriteBlobLSBLong(image,(size_t) dib_info.width);
   (void) WriteBlobLSBLong(image,(unsigned short) dib_info.height);
   (void) WriteBlobLSBShort(image,(unsigned short) dib_info.planes);
   (void) WriteBlobLSBShort(image,dib_info.bits_per_pixel);
@@ -1247,14 +1247,14 @@
           if (dib_colormap == (unsigned char *) NULL)
             ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
           q=dib_colormap;
-          for (i=0; i < (long) MagickMin(image->colors,dib_info.number_colors); i++)
+          for (i=0; i < (ssize_t) MagickMin(image->colors,dib_info.number_colors); i++)
           {
             *q++=ScaleQuantumToChar(image->colormap[i].blue);
             *q++=ScaleQuantumToChar(image->colormap[i].green);
             *q++=ScaleQuantumToChar(image->colormap[i].red);
             *q++=(Quantum) 0x0;
           }
-          for ( ; i < (long) (1L << dib_info.bits_per_pixel); i++)
+          for ( ; i < (ssize_t) (1L << dib_info.bits_per_pixel); i++)
           {
             *q++=(Quantum) 0x0;
             *q++=(Quantum) 0x0;
diff --git a/coders/djvu.c b/coders/djvu.c
index 9d383d5..2ff2e07 100644
--- a/coders/djvu.c
+++ b/coders/djvu.c
@@ -163,14 +163,14 @@
 static ddjvu_message_t*
 pump_data_until_message(LoadContext *lc,Image *image) /* ddjvu_context_t *context, type ddjvu_document_type_t */
 {
-        unsigned long blocksize = BLOCKSIZE;
+        size_t blocksize = BLOCKSIZE;
         unsigned char data[BLOCKSIZE];
-        unsigned long size;
+        size_t size;
         ddjvu_message_t *message;
 
         /* i might check for a condition! */
         while (!(message = ddjvu_message_peek(lc->context))
-               && (size = (unsigned long) ReadBlob(image,(size_t) blocksize,data)) == blocksize) {
+               && (size = (size_t) ReadBlob(image,(size_t) blocksize,data)) == blocksize) {
                 ddjvu_stream_write(lc->document, lc->streamid, (char *) data, size);
         }
         if (message)
@@ -390,9 +390,9 @@
                 printf("%s: expanding BITONAL page/image\n", __FUNCTION__);
 #endif
                 register IndexPacket *indexes;
-                unsigned long bit, byte;
+                size_t bit, byte;
 
-                for (y=0; y < (long) image->rows; y++)
+                for (y=0; y < (ssize_t) image->rows; y++)
                         {
                                 PixelPacket * o = QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
                                 if (o == (PixelPacket *) NULL)
@@ -402,9 +402,9 @@
                                 byte=0;
 
                                 /* fixme:  the non-aligned, last =<7 bits ! that's ok!!!*/
-                                for (x= 0; x < (long) image->columns; x++)
+                                for (x= 0; x < (ssize_t) image->columns; x++)
                                         {
-                                                if (bit == 0) byte= (unsigned long) q[(y * stride) + (x / 8)];
+                                                if (bit == 0) byte= (size_t) q[(y * stride) + (x / 8)];
 
                                                 indexes[x]=(IndexPacket) (((byte & 0x01) != 0) ? 0x00 : 0x01);
                                                 bit++;
@@ -421,7 +421,7 @@
                 printf("%s: expanding PHOTO page/image\n", __FUNCTION__);
 #endif
                 /* now transfer line-wise: */
-                long i;
+                ssize_t i;
 #if 0
                 /* old: */
                 char* r;
@@ -429,7 +429,7 @@
                 register PixelPacket *r;
 #endif
 
-                for (i = 0;i< (long) lc->image->rows; i++)
+                for (i = 0;i< (ssize_t) lc->image->rows; i++)
                         {
 #if DEBUG
                                if (i % 1000 == 0) printf("%d\n",i);
@@ -627,7 +627,7 @@
               image->y_resolution=image->x_resolution;
             info.width*=image->x_resolution/info.dpi;
             info.height*=image->y_resolution/info.dpi;
-            info.dpi=(long) MagickMax(image->x_resolution,image->y_resolution);
+            info.dpi=(ssize_t) MagickMax(image->x_resolution,image->y_resolution);
           }
         type = ddjvu_page_get_type(lc->page);
 
@@ -637,8 +637,8 @@
         /* mmc:  set  image->depth  */
         /* mmc:  This from the type */
 
-        image->columns=(unsigned long) info.width;
-        image->rows=(unsigned long) info.height;
+        image->columns=(size_t) info.width;
+        image->rows=(size_t) info.height;
 
         /* mmc: bitonal should be palettized, and compressed! */
         if (type == DDJVU_PAGETYPE_BITONAL){
@@ -756,7 +756,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -858,7 +858,7 @@
   i=0;
   if (image_info->number_scenes != 0)
     i=image_info->scene;
-  for ( ; i < (long) lc->pages; i++)
+  for ( ; i < (ssize_t) lc->pages; i++)
   {
     image=ReadOneDJVUImage(lc,i,image_info,exception);
     if (image == (Image *) NULL)
@@ -916,10 +916,10 @@
 %
 %  The format of the RegisterDJVUImage method is:
 %
-%      unsigned long RegisterDJVUImage(void)
+%      size_t RegisterDJVUImage(void)
 %
 */
-ModuleExport unsigned long RegisterDJVUImage(void)
+ModuleExport size_t RegisterDJVUImage(void)
 {
   char
     version[MaxTextExtent];
diff --git a/coders/dng.c b/coders/dng.c
index d0193f1..41b3bc4 100644
--- a/coders/dng.c
+++ b/coders/dng.c
@@ -230,10 +230,10 @@
 %
 %  The format of the RegisterDNGImage method is:
 %
-%      unsigned long RegisterDNGImage(void)
+%      size_t RegisterDNGImage(void)
 %
 */
-ModuleExport unsigned long RegisterDNGImage(void)
+ModuleExport size_t RegisterDNGImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dot.c b/coders/dot.c
index c92d7c1..5337b11 100644
--- a/coders/dot.c
+++ b/coders/dot.c
@@ -176,10 +176,10 @@
 %
 %  The format of the RegisterDOTImage method is:
 %
-%      unsigned long RegisterDOTImage(void)
+%      size_t RegisterDOTImage(void)
 %
 */
-ModuleExport unsigned long RegisterDOTImage(void)
+ModuleExport size_t RegisterDOTImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dps.c b/coders/dps.c
index 0e0826a..a638c99 100644
--- a/coders/dps.c
+++ b/coders/dps.c
@@ -117,7 +117,7 @@
     sans,
     status;
 
-  long
+  ssize_t
     x,
     y;
 
@@ -127,13 +127,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i;
 
   register PixelPacket
     *q;
 
-  register unsigned long
+  register size_t
     pixel;
 
   Screen
@@ -276,12 +276,12 @@
   if ((visual_info->klass != DirectColor) && (visual_info->klass != TrueColor))
     for (i=0; i < visual_info->colormap_size; i++)
     {
-      colors[i].pixel=(unsigned long) i;
+      colors[i].pixel=(size_t) i;
       colors[i].pad=0;
     }
   else
     {
-      unsigned long
+      size_t
         blue,
         blue_bit,
         green,
@@ -320,8 +320,8 @@
   */
   if ((visual_info->klass != TrueColor) && (visual_info->klass != DirectColor))
     image->storage_class=PseudoClass;
-  image->columns=(unsigned long) dps_image->width;
-  image->rows=(unsigned long) dps_image->height;
+  image->columns=(size_t) dps_image->width;
+  image->rows=(size_t) dps_image->height;
   if (image_info->ping != MagickFalse)
     {
       (void) CloseBlob(image);
@@ -332,11 +332,11 @@
     case DirectClass:
     default:
     {
-      register unsigned long
+      register size_t
         color,
         index;
 
-      unsigned long
+      size_t
         blue_mask,
         blue_shift,
         green_mask,
@@ -373,12 +373,12 @@
       */
       if ((visual_info->colormap_size > 0) &&
           (visual_info->klass == DirectColor))
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             pixel=XGetPixel(dps_image,x,y);
             index=(pixel >> red_shift) & red_mask;
@@ -395,12 +395,12 @@
             break;
         }
       else
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             pixel=XGetPixel(dps_image,x,y);
             color=(pixel >> red_shift) & red_mask;
@@ -426,7 +426,7 @@
       /*
         Create colormap.
       */
-      if (AcquireImageColormap(image,(unsigned long) visual_info->colormap_size) == MagickFalse)
+      if (AcquireImageColormap(image,(size_t) visual_info->colormap_size) == MagickFalse)
         {
           image=DestroyImage(image);
           colors=(XColor *) RelinquishMagickMemory(colors);
@@ -435,7 +435,7 @@
             (XFontStruct *) NULL,&resource_info,(XWindowInfo *) NULL);
           return((Image *) NULL);
         }
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         image->colormap[colors[i].pixel].red=ScaleShortToQuantum(colors[i].red);
         image->colormap[colors[i].pixel].green=
@@ -446,13 +446,13 @@
       /*
         Convert X image to PseudoClass packets.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           indexes[x]=(unsigned short) XGetPixel(dps_image,x,y);
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
@@ -491,12 +491,12 @@
             {
               image->storage_class=DirectClass;
               image->matte=MagickTrue;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
                 if (q == (PixelPacket *) NULL)
                   break;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   SetOpacityPixelComponent(q,OpaqueOpacity);
                   if (XGetPixel(matte_image,x,y) == 0)
@@ -540,10 +540,10 @@
 %
 %  The format of the RegisterDPSImage method is:
 %
-%      unsigned long RegisterDPSImage(void)
+%      size_t RegisterDPSImage(void)
 %
 */
-ModuleExport unsigned long RegisterDPSImage(void)
+ModuleExport size_t RegisterDPSImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/dpx.c b/coders/dpx.c
index 49cf443..ce374bb 100644
--- a/coders/dpx.c
+++ b/coders/dpx.c
@@ -370,8 +370,8 @@
 %
 */
 
-static size_t GetBytesPerRow(unsigned long columns,
-  unsigned long samples_per_pixel,unsigned long bits_per_pixel,
+static size_t GetBytesPerRow(size_t columns,
+  size_t samples_per_pixel,size_t bits_per_pixel,
   MagickBooleanType pad)
 {
   size_t
@@ -513,14 +513,14 @@
   }
 }
 
-static void TimeCodeToString(const unsigned long timestamp,char *code)
+static void TimeCodeToString(const size_t timestamp,char *code)
 {
 #define TimeFields  7
 
   unsigned int
     shift;
 
-  register long
+  register ssize_t
     i;
 
   *code='\0';
@@ -549,7 +549,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     row,
     y;
 
@@ -565,7 +565,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -577,7 +577,7 @@
   unsigned char
     component_type;
 
-  unsigned long
+  size_t
     samples_per_pixel;
 
   /*
@@ -900,18 +900,18 @@
       dpx.television.interlace=(unsigned char) ReadBlobByte(image);
       offset++;
       if (dpx.television.interlace != 0)
-        (void) FormatImageProperty(image,"dpx:television.interlace","%ld",(long)
+        (void) FormatImageProperty(image,"dpx:television.interlace","%ld",(ssize_t)
           dpx.television.interlace);
       dpx.television.field_number=(unsigned char) ReadBlobByte(image);
       offset++;
       if (dpx.television.field_number != 0)
         (void) FormatImageProperty(image,"dpx:television.field_number","%ld",
-          (long) dpx.television.field_number);
+          (ssize_t) dpx.television.field_number);
       dpx.television.video_signal=(unsigned char) ReadBlobByte(image);
       offset++;
       if (dpx.television.video_signal != 0)
         (void) FormatImageProperty(image,"dpx:television.video_signal","%ld",
-          (long) dpx.television.video_signal);
+          (ssize_t) dpx.television.video_signal);
       dpx.television.padding=(unsigned char) ReadBlobByte(image);
       offset++;
       if (dpx.television.padding != 0)
@@ -992,7 +992,7 @@
            profile=DestroyStringInfo(profile);
         }
     }
-  for ( ; offset < (long) dpx.file.image_offset; offset++)
+  for ( ; offset < (ssize_t) dpx.file.image_offset; offset++)
     (void) ReadBlobByte(image);
   /*
     Read DPX image header.
@@ -1076,9 +1076,9 @@
   SetQuantumQuantum(quantum_info,32);
   SetQuantumPack(quantum_info,dpx.image.image_element[0].packing == 0 ?
     MagickTrue : MagickFalse);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    long
+    ssize_t
       offset;
 
     MagickBooleanType
@@ -1158,10 +1158,10 @@
 %
 %  The format of the RegisterDPXImage method is:
 %
-%      unsigned long RegisterDPXImage(void)
+%      size_t RegisterDPXImage(void)
 %
 */
-ModuleExport unsigned long RegisterDPXImage(void)
+ModuleExport size_t RegisterDPXImage(void)
 {
   MagickInfo
     *entry;
@@ -1251,7 +1251,7 @@
   char
     buffer[2];
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
@@ -1286,7 +1286,7 @@
   DPXInfo
     dpx;
 
-  long
+  ssize_t
     horizontal_factor,
     vertical_factor,
     y;
@@ -1312,7 +1312,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1347,8 +1347,8 @@
         flags;
 
       flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
-      horizontal_factor=(long) geometry_info.rho;
-      vertical_factor=(long) geometry_info.sigma;
+      horizontal_factor=(ssize_t) geometry_info.rho;
+      vertical_factor=(ssize_t) geometry_info.sigma;
       if ((flags & SigmaValue) == 0)
         vertical_factor=horizontal_factor;
       if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
@@ -1408,7 +1408,7 @@
     dpx.file.timestamp);
   offset+=WriteBlob(image,sizeof(dpx.file.timestamp),(unsigned char *)
     dpx.file.timestamp);
-  (void) strncpy(dpx.file.creator,GetMagickVersion((unsigned long *) NULL),
+  (void) strncpy(dpx.file.creator,GetMagickVersion((size_t *) NULL),
     sizeof(dpx.file.creator));
   value=GetDPXProperty(image_info,image,"dpx:file.creator");
   if (value != (const char *) NULL)
@@ -1809,7 +1809,7 @@
       extent=GetBytesPerRow(image->columns,1UL,image->depth,MagickTrue);
     }
   pixels=GetQuantumPixels(quantum_info);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/emf.c b/coders/emf.c
index 0004003..53c7b8e 100644
--- a/coders/emf.c
+++ b/coders/emf.c
@@ -257,7 +257,7 @@
   length=UTF8ToUTF16(source,(wchar_t *) NULL);
   if (length == 0)
     {
-      register long
+      register ssize_t
         i;
 
       /*
@@ -267,7 +267,7 @@
       utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
       if (utf16 == (wchar_t *) NULL)
         return((wchar_t *) NULL);
-      for (i=0; i <= (long) length; i++)
+      for (i=0; i <= (ssize_t) length; i++)
         utf16[i]=source[i];
       return(utf16);
     }
@@ -285,8 +285,8 @@
   metafile.  Width and height are returned in .01mm units.
 */
 #if defined(MAGICKCORE_WINGDI32_DELEGATE)
-static HENHMETAFILE ReadEnhMetaFile(const char *path,long *width,
-  long *height)
+static HENHMETAFILE ReadEnhMetaFile(const char *path,ssize_t *width,
+  ssize_t *height)
 {
 #pragma pack( push, 2 )
   typedef struct
@@ -447,7 +447,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     height,
     width,
     y;
@@ -455,7 +455,7 @@
   RECT
     rect;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -489,14 +489,14 @@
           if (image->units == PixelsPerCentimeterResolution)
             x_resolution*=CENTIMETERS_INCH;
         }
-      image->rows=(unsigned long) ((height/1000.0/CENTIMETERS_INCH)*
+      image->rows=(size_t) ((height/1000.0/CENTIMETERS_INCH)*
         y_resolution+0.5);
-      image->columns=(unsigned long) ((width/1000.0/CENTIMETERS_INCH)*
+      image->columns=(size_t) ((width/1000.0/CENTIMETERS_INCH)*
         x_resolution+0.5);
     }
   if (image_info->size != (char *) NULL)
     {
-      long
+      ssize_t
         x;
 
       image->columns=width;
@@ -510,7 +510,7 @@
       char
         *geometry;
 
-      long
+      ssize_t
         sans;
 
       register char
@@ -526,10 +526,10 @@
           flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
             &image->rows);
           if (image->x_resolution != 0.0)
-            image->columns=(unsigned long) floor((image->columns*
+            image->columns=(size_t) floor((image->columns*
               image->x_resolution)+0.5);
           if (image->y_resolution != 0.0)
-            image->rows=(unsigned long) floor((image->rows*image->y_resolution)+
+            image->rows=(size_t) floor((image->rows*image->y_resolution)+
               0.5);
         }
       else
@@ -538,10 +538,10 @@
           flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
             &image->rows);
           if (image->x_resolution != 0.0)
-            image->columns=(unsigned long) floor(((image->columns*
+            image->columns=(size_t) floor(((image->columns*
               image->x_resolution)/DefaultResolution)+0.5);
           if (image->y_resolution != 0.0)
-            image->rows=(unsigned long) floor(((image->rows*
+            image->rows=(size_t) floor(((image->rows*
               image->y_resolution)/DefaultResolution)+0.5);
         }
       geometry=DestroyString(geometry);
@@ -589,9 +589,9 @@
     Initialize the bitmap to the image background color.
   */
   pBits=ppBits;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       pBits->rgbRed=ScaleQuantumToChar(image->background_color.red);
       pBits->rgbGreen=ScaleQuantumToChar(image->background_color.green);
@@ -608,12 +608,12 @@
   */
   PlayEnhMetaFile(hDC,hemf,&rect);
   pBits=ppBits;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=ScaleCharToQuantum(pBits->rgbRed);
       q->green=ScaleCharToQuantum(pBits->rgbGreen);
@@ -653,10 +653,10 @@
 %
 %  The format of the RegisterEMFImage method is:
 %
-%      unsigned long RegisterEMFImage(void)
+%      size_t RegisterEMFImage(void)
 %
 */
-ModuleExport unsigned long RegisterEMFImage(void)
+ModuleExport size_t RegisterEMFImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/ept.c b/coders/ept.c
index 493dc0b..9b86ac9 100644
--- a/coders/ept.c
+++ b/coders/ept.c
@@ -71,7 +71,7 @@
 */
 typedef struct _EPTInfo
 {
-  unsigned long
+  size_t
     magick;
 
   MagickOffsetType
@@ -267,10 +267,10 @@
 %
 %  The format of the RegisterEPTImage method is:
 %
-%      unsigned long RegisterEPTImage(void)
+%      size_t RegisterEPTImage(void)
 %
 */
-ModuleExport unsigned long RegisterEPTImage(void)
+ModuleExport size_t RegisterEPTImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/exr.c b/coders/exr.c
index 60ef9ed..9d4c4a2 100644
--- a/coders/exr.c
+++ b/coders/exr.c
@@ -151,10 +151,10 @@
     min_x,
     min_y;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -214,7 +214,7 @@
       (void) ImfCloseInputFile(file);
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -222,7 +222,7 @@
     ImfInputSetFrameBuffer(file,scanline-min_x-image->columns*(min_y+y),1,
       image->columns);
     ImfInputReadPixels(file,min_y+y,min_y+y);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=HDRIClampToQuantum((MagickRealType) QuantumRange*ImfHalfToFloat(
         scanline[x].r));
@@ -267,10 +267,10 @@
 %
 %  The format of the RegisterEXRImage method is:
 %
-%      unsigned long RegisterEXRImage(void)
+%      size_t RegisterEXRImage(void)
 %
 */
-ModuleExport unsigned long RegisterEXRImage(void)
+ModuleExport size_t RegisterEXRImage(void)
 {
   MagickInfo
     *entry;
@@ -359,7 +359,7 @@
   int
     compression;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -368,7 +368,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -424,12 +424,12 @@
       (void) ImfCloseOutputFile(file);
       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       ImfFloatToHalf(QuantumScale*p->red,&half_quantum);
       scanline[x].r=half_quantum;
diff --git a/coders/fax.c b/coders/fax.c
index 1f179ed..ea8753d 100644
--- a/coders/fax.c
+++ b/coders/fax.c
@@ -206,10 +206,10 @@
 %
 %  The format of the RegisterFAXImage method is:
 %
-%      unsigned long RegisterFAXImage(void)
+%      size_t RegisterFAXImage(void)
 %
 */
-ModuleExport unsigned long RegisterFAXImage(void)
+ModuleExport size_t RegisterFAXImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/fits.c b/coders/fits.c
index 8f7829a..75f3706 100644
--- a/coders/fits.c
+++ b/coders/fits.c
@@ -152,7 +152,7 @@
     case 4:
     {
       if (bits_per_pixel > 0)
-        return((double) ((long) ReadBlobLong(image)));
+        return((double) ((ssize_t) ReadBlobLong(image)));
       return((double) ReadBlobFloat(image));
     }
     case 8:
@@ -196,18 +196,18 @@
   (void) SeekBlob(image,offset,SEEK_SET);
 }
 
-static inline double GetFITSPixelRange(const unsigned long depth)
+static inline double GetFITSPixelRange(const size_t depth)
 {
   return((double) ((MagickOffsetType) GetQuantumRange(depth)));
 }
 
 static void SetFITSUnsignedPixels(const size_t length,
-  const unsigned long bits_per_pixel,unsigned char *pixels)
+  const size_t bits_per_pixel,unsigned char *pixels)
 {
-  register long
+  register ssize_t
     i;
 
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     *pixels^=0x80;
     pixels+=bits_per_pixel >> 3;
@@ -259,7 +259,7 @@
   int
     c;
 
-  long
+  ssize_t
     scene,
     y;
 
@@ -269,7 +269,7 @@
   MagickSizeType
     number_pixels;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -409,14 +409,14 @@
   if ((fits_info.simple == MagickFalse) || (fits_info.number_axes < 1) ||
       (fits_info.number_axes > 4) || (number_pixels == 0))
     ThrowReaderException(CorruptImageError,"ImageTypeNotSupported");
-  for (scene=0; scene < (long) fits_info.number_planes; scene++)
+  for (scene=0; scene < (ssize_t) fits_info.number_planes; scene++)
   {
-    image->columns=(unsigned long) fits_info.columns;
-    image->rows=(unsigned long) fits_info.rows;
-    image->depth=(unsigned long) (fits_info.bits_per_pixel < 0 ? -1 : 1)*
+    image->columns=(size_t) fits_info.columns;
+    image->rows=(size_t) fits_info.rows;
+    image->depth=(size_t) (fits_info.bits_per_pixel < 0 ? -1 : 1)*
       fits_info.bits_per_pixel;
     image->endian=fits_info.endian;
-    image->scene=(unsigned long) scene;
+    image->scene=(size_t) scene;
     if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
         break;
@@ -426,7 +426,7 @@
     if ((fits_info.min_data != 0.0) || (fits_info.max_data != 0.0))
       {
         if ((fits_info.bits_per_pixel != 0) && (fits_info.max_data == 0.0))
-          fits_info.max_data=GetFITSPixelRange((unsigned long)
+          fits_info.max_data=GetFITSPixelRange((size_t)
             fits_info.bits_per_pixel);
       }
     else
@@ -437,12 +437,12 @@
     */
     scale=(double) QuantumRange/(fits_info.scale*(fits_info.max_data-
       fits_info.min_data)+fits_info.zero);
-    for (y=(long) image->rows-1; y >= 0; y--)
+    for (y=(ssize_t) image->rows-1; y >= 0; y--)
     {
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         pixel=GetFITSPixel(image,fits_info.bits_per_pixel);
         q->red=(Quantum) ClampToQuantum(scale*(fits_info.scale*(pixel-
@@ -472,7 +472,7 @@
     if (image_info->number_scenes != 0)
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
         break;
-    if (scene < (long) (fits_info.number_planes-1))
+    if (scene < (ssize_t) (fits_info.number_planes-1))
       {
         /*
           Allocate next image structure.
@@ -514,10 +514,10 @@
 %
 %  The format of the RegisterFITSImage method is:
 %
-%      unsigned long RegisterFITSImage(void)
+%      size_t RegisterFITSImage(void)
 %
 */
-ModuleExport unsigned long RegisterFITSImage(void)
+ModuleExport size_t RegisterFITSImage(void)
 {
   MagickInfo
     *entry;
@@ -601,7 +601,7 @@
     header[FITSBlocksize],
     *fits_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -693,7 +693,7 @@
       offset+=80;
     }
   (void) FormatMagickString(header,FITSBlocksize,"HISTORY %.72s",
-    GetMagickVersion((unsigned long *) NULL));
+    GetMagickVersion((size_t *) NULL));
   (void) strncpy(fits_info+offset,header,strlen(header));
   offset+=80;
   (void) strncpy(header,"END",FITSBlocksize);
@@ -705,7 +705,7 @@
   */
   pixels=GetQuantumPixels(quantum_info);
   length=GetQuantumExtent(image,quantum_info,GrayQuantum);
-  for (y=(long) image->rows-1; y >= 0; y--)
+  for (y=(ssize_t) image->rows-1; y >= 0; y--)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/fpx.c b/coders/fpx.c
index 47e3d45..f4277de 100644
--- a/coders/fpx.c
+++ b/coders/fpx.c
@@ -169,7 +169,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -178,7 +178,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -203,7 +203,7 @@
     tile_height,
     width;
 
-  unsigned long
+  size_t
     scene;
 
   /*
@@ -282,7 +282,7 @@
       fpx_status=FPX_GetImageResultAspectRatio(flashpix,&aspect_ratio);
       if (fpx_status != FPX_OK)
         ThrowReaderException(DelegateError,"UnableToReadAspectRatio");
-      if (width != (unsigned long) floor((aspect_ratio*height)+0.5))
+      if (width != (size_t) floor((aspect_ratio*height)+0.5))
         Swap(width,height);
     }
   fpx_status=FPX_GetSummaryInformation(flashpix,&summary_info);
@@ -421,7 +421,7 @@
   /*
     Initialize image pixels.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -438,8 +438,8 @@
         else
           fpx_status=FPX_ReadImageTransformRectangle(flashpix,0.0F,
             (float) y/image->rows,(float) image->columns/image->rows,
-            (float) (y+tile_height-1)/image->rows,(long) image->columns,
-            (long) tile_height,&fpx_info);
+            (float) (y+tile_height-1)/image->rows,(ssize_t) image->columns,
+            (ssize_t) tile_height,&fpx_info);
         if (fpx_status == FPX_LOW_MEMORY_ERROR)
           {
             pixels=(unsigned char *) RelinquishMagickMemory(pixels);
@@ -455,7 +455,7 @@
     g=green_component->theData+(y % tile_height)*green_component->lineStride;
     b=blue_component->theData+(y % tile_height)*blue_component->lineStride;
     a=alpha_component->theData+(y % tile_height)*alpha_component->lineStride;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (fpx_info.numberOfComponents > 2)
         {
@@ -513,10 +513,10 @@
 %
 %  The format of the RegisterFPXImage method is:
 %
-%      unsigned long RegisterFPXImage(void)
+%      size_t RegisterFPXImage(void)
 %
 */
-ModuleExport unsigned long RegisterFPXImage(void)
+ModuleExport size_t RegisterFPXImage(void)
 {
   MagickInfo
     *entry;
@@ -804,7 +804,7 @@
   FPXSummaryInformation
     summary_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -819,7 +819,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -963,7 +963,7 @@
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
   pixels=GetQuantumPixels(quantum_info);
   fpx_info.numberOfComponents=colorspace.numberOfComponents;
-  for (i=0; i < (long) fpx_info.numberOfComponents; i++)
+  for (i=0; i < (ssize_t) fpx_info.numberOfComponents; i++)
   {
     fpx_info.components[i].myColorType.myDataType=DATA_TYPE_UNSIGNED_BYTE;
     fpx_info.components[i].horzSubSampFactor=1;
@@ -986,7 +986,7 @@
     quantum_type=RGBAQuantum;
   if (fpx_info.numberOfComponents == 1)
     quantum_type=GrayQuantum;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/gif.c b/coders/gif.c
index b6c9a28..786094e 100644
--- a/coders/gif.c
+++ b/coders/gif.c
@@ -80,7 +80,7 @@
   unsigned char
     buffer[280];
 
-  unsigned long
+  size_t
     count,
     bit;
 
@@ -90,7 +90,7 @@
 
 typedef struct _LZWStack
 {
-  unsigned long
+  size_t
     *codes,
     *index,
     *top;
@@ -107,7 +107,7 @@
   MagickBooleanType
     genesis;
 
-  unsigned long
+  size_t
     data_size,
     maximum_data_value,
     clear_code,
@@ -127,7 +127,7 @@
   Forward declarations.
 */
 static inline int
-  GetNextLZWCode(LZWInfo *,const unsigned long);
+  GetNextLZWCode(LZWInfo *,const size_t);
 
 static MagickBooleanType
   WriteGIFImage(const ImageInfo *,Image *);
@@ -150,7 +150,7 @@
 %
 %  The format of the DecodeImage method is:
 %
-%      MagickBooleanType DecodeImage(Image *image,const long opacity)
+%      MagickBooleanType DecodeImage(Image *image,const ssize_t opacity)
 %
 %  A description of each parameter follows:
 %
@@ -162,16 +162,16 @@
 
 static LZWInfo *RelinquishLZWInfo(LZWInfo *lzw_info)
 {
-  if (lzw_info->table[0] != (unsigned long *) NULL)
-    lzw_info->table[0]=(unsigned long *) RelinquishMagickMemory(
+  if (lzw_info->table[0] != (size_t *) NULL)
+    lzw_info->table[0]=(size_t *) RelinquishMagickMemory(
       lzw_info->table[0]);
-  if (lzw_info->table[1] != (unsigned long *) NULL)
-    lzw_info->table[1]=(unsigned long *) RelinquishMagickMemory(
+  if (lzw_info->table[1] != (size_t *) NULL)
+    lzw_info->table[1]=(size_t *) RelinquishMagickMemory(
       lzw_info->table[1]);
   if (lzw_info->stack != (LZWStack *) NULL)
     {
-      if (lzw_info->stack->codes != (unsigned long *) NULL)
-        lzw_info->stack->codes=(unsigned long *) RelinquishMagickMemory(
+      if (lzw_info->stack->codes != (size_t *) NULL)
+        lzw_info->stack->codes=(size_t *) RelinquishMagickMemory(
           lzw_info->stack->codes);
       lzw_info->stack=(LZWStack *) RelinquishMagickMemory(lzw_info->stack);
     }
@@ -187,12 +187,12 @@
   lzw_info->genesis=MagickTrue;
 }
 
-static LZWInfo *AcquireLZWInfo(Image *image,const unsigned long data_size)
+static LZWInfo *AcquireLZWInfo(Image *image,const size_t data_size)
 {
   LZWInfo
     *lzw_info;
 
-  register long
+  register ssize_t
     i;
 
   lzw_info=(LZWInfo *) AcquireAlignedMemory(1,sizeof(*lzw_info));
@@ -204,20 +204,20 @@
   lzw_info->maximum_data_value=(1UL << data_size)-1;
   lzw_info->clear_code=lzw_info->maximum_data_value+1;
   lzw_info->end_code=lzw_info->maximum_data_value+2;
-  lzw_info->table[0]=(unsigned long *) AcquireQuantumMemory(MaximumLZWCode,
+  lzw_info->table[0]=(size_t *) AcquireQuantumMemory(MaximumLZWCode,
     sizeof(*lzw_info->table));
-  lzw_info->table[1]=(unsigned long *) AcquireQuantumMemory(MaximumLZWCode,
+  lzw_info->table[1]=(size_t *) AcquireQuantumMemory(MaximumLZWCode,
     sizeof(*lzw_info->table));
-  if ((lzw_info->table[0] == (unsigned long *) NULL) ||
-      (lzw_info->table[1] == (unsigned long *) NULL))
+  if ((lzw_info->table[0] == (size_t *) NULL) ||
+      (lzw_info->table[1] == (size_t *) NULL))
     {
       lzw_info=RelinquishLZWInfo(lzw_info);
       return((LZWInfo *) NULL);
     }
-  for (i=0; i <= (long) lzw_info->maximum_data_value; i++)
+  for (i=0; i <= (ssize_t) lzw_info->maximum_data_value; i++)
   {
     lzw_info->table[0][i]=0;
-    lzw_info->table[1][i]=(unsigned long) i;
+    lzw_info->table[1][i]=(size_t) i;
   }
   ResetLZWInfo(lzw_info);
   lzw_info->code_info.buffer[0]='\0';
@@ -232,9 +232,9 @@
       lzw_info=RelinquishLZWInfo(lzw_info);
       return((LZWInfo *) NULL);
     }
-  lzw_info->stack->codes=(unsigned long *) AcquireQuantumMemory(2UL*
+  lzw_info->stack->codes=(size_t *) AcquireQuantumMemory(2UL*
     MaximumLZWCode,sizeof(*lzw_info->stack->codes));
-  if (lzw_info->stack->codes == (unsigned long *) NULL)
+  if (lzw_info->stack->codes == (size_t *) NULL)
     {
       lzw_info=RelinquishLZWInfo(lzw_info);
       return((LZWInfo *) NULL);
@@ -244,12 +244,12 @@
   return(lzw_info);
 }
 
-static inline int GetNextLZWCode(LZWInfo *lzw_info,const unsigned long bits)
+static inline int GetNextLZWCode(LZWInfo *lzw_info,const size_t bits)
 {
   int
     code;
 
-  register long
+  register ssize_t
     i;
 
   while (((lzw_info->code_info.bit+bits) > (8*lzw_info->code_info.count)) &&
@@ -274,7 +274,7 @@
   if ((lzw_info->code_info.bit+bits) > (8*lzw_info->code_info.count))
     return(-1);
   code=0;
-  for (i=0; i < (long) bits; i++)
+  for (i=0; i < (ssize_t) bits; i++)
   {
     code|=((lzw_info->code_info.buffer[lzw_info->code_info.bit/8] &
       (1UL << (lzw_info->code_info.bit % 8))) != 0) << i;
@@ -283,15 +283,15 @@
   return(code);
 }
 
-static inline long PopLZWStack(LZWStack *stack_info)
+static inline ssize_t PopLZWStack(LZWStack *stack_info)
 {
   if (stack_info->index <= stack_info->codes)
     return(-1);
   stack_info->index--;
-  return((long) *stack_info->index);
+  return((ssize_t) *stack_info->index);
 }
 
-static inline void PushLZWStack(LZWStack *stack_info,const unsigned long value)
+static inline void PushLZWStack(LZWStack *stack_info,const size_t value)
 {
   if (stack_info->index >= stack_info->top)
     return;
@@ -307,7 +307,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     value;
 
   if (lzw_info->stack->index != lzw_info->stack->codes)
@@ -317,7 +317,7 @@
       lzw_info->genesis=MagickFalse;
       do
       {
-        lzw_info->first_code=(unsigned long) GetNextLZWCode(lzw_info,
+        lzw_info->first_code=(size_t) GetNextLZWCode(lzw_info,
           lzw_info->bits);
         lzw_info->last_code=lzw_info->first_code;
       } while (lzw_info->first_code == lzw_info->clear_code);
@@ -326,15 +326,15 @@
   code=GetNextLZWCode(lzw_info,lzw_info->bits);
   if (code < 0)
     return(code);
-  if ((unsigned long) code == lzw_info->clear_code)
+  if ((size_t) code == lzw_info->clear_code)
     {
       ResetLZWInfo(lzw_info);
       return(ReadBlobLZWByte(lzw_info));
     }
-  if ((unsigned long) code == lzw_info->end_code)
+  if ((size_t) code == lzw_info->end_code)
     return(-1);
-  if ((unsigned long) code < lzw_info->slot)
-    value=(unsigned long) code;
+  if ((size_t) code < lzw_info->slot)
+    value=(size_t) code;
   else
     {
       PushLZWStack(lzw_info->stack,lzw_info->first_code);
@@ -365,11 +365,11 @@
           lzw_info->maximum_code=1UL << lzw_info->bits;
         }
     }
-  lzw_info->last_code=(unsigned long) code;
+  lzw_info->last_code=(size_t) code;
   return(PopLZWStack(lzw_info->stack));
 }
 
-static MagickBooleanType DecodeImage(Image *image,const long opacity)
+static MagickBooleanType DecodeImage(Image *image,const ssize_t opacity)
 {
   ExceptionInfo
     *exception;
@@ -380,7 +380,7 @@
   int
     c;
 
-  long
+  ssize_t
     offset,
     y;
 
@@ -390,7 +390,7 @@
   unsigned char
     data_size;
 
-  unsigned long
+  size_t
     pass;
 
   /*
@@ -410,12 +410,12 @@
   exception=(&image->exception);
   pass=0;
   offset=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -425,22 +425,22 @@
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetAuthenticIndexQueue(image);
-    for (x=0; x < (long) image->columns; )
+    for (x=0; x < (ssize_t) image->columns; )
     {
       c=ReadBlobLZWByte(lzw_info);
       if (c < 0)
         break;
-      index=ConstrainColormapIndex(image,(unsigned long) c);
-      q->red=image->colormap[(long) index].red;
-      q->green=image->colormap[(long) index].green;
-      q->blue=image->colormap[(long) index].blue;
-      q->opacity=(long) index == opacity ? (Quantum) TransparentOpacity :
+      index=ConstrainColormapIndex(image,(size_t) c);
+      q->red=image->colormap[(ssize_t) index].red;
+      q->green=image->colormap[(ssize_t) index].green;
+      q->blue=image->colormap[(ssize_t) index].blue;
+      q->opacity=(ssize_t) index == opacity ? (Quantum) TransparentOpacity :
         (Quantum) OpaqueOpacity;
       indexes[x]=index;
       x++;
       q++;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
       break;
     if (image->interlace == NoInterlace)
       offset++;
@@ -451,7 +451,7 @@
         default:
         {
           offset+=8;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=4;
@@ -461,7 +461,7 @@
         case 1:
         {
           offset+=8;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=2;
@@ -471,7 +471,7 @@
         case 2:
         {
           offset+=4;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=1;
@@ -488,7 +488,7 @@
       break;
   }
   lzw_info=RelinquishLZWInfo(lzw_info);
-  if (y < (long) image->rows)
+  if (y < (ssize_t) image->rows)
     ThrowBinaryException(CorruptImageError,"CorruptImage",image->filename);
   return(MagickTrue);
 }
@@ -509,7 +509,7 @@
 %  The format of the EncodeImage method is:
 %
 %      MagickBooleanType EncodeImage(const ImageInfo *image_info,Image *image,
-%        const unsigned long data_size)
+%        const size_t data_size)
 %
 %  A description of each parameter follows:
 %
@@ -521,7 +521,7 @@
 %
 */
 static MagickBooleanType EncodeImage(const ImageInfo *image_info,Image *image,
-  const unsigned long data_size)
+  const size_t data_size)
 {
 #define MaxCode(number_bits)  ((1UL << (number_bits))-1)
 #define MaxHashTable  5003
@@ -565,13 +565,13 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     displacement,
     offset,
     k,
     y;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -586,7 +586,7 @@
     *packet,
     *hash_suffix;
 
-  unsigned long
+  size_t
     bits,
     clear_code,
     datum,
@@ -640,7 +640,7 @@
   offset=0;
   pass=0;
   waiting_code=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -648,7 +648,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,offset,image->columns,1,&image->exception);
@@ -657,14 +657,14 @@
     indexes=GetVirtualIndexQueue(image);
     if (y == 0)
       waiting_code=(short) (*indexes);
-    for (x=(y == 0) ? 1 : 0; x < (long) image->columns; x++)
+    for (x=(y == 0) ? 1 : 0; x < (ssize_t) image->columns; x++)
     {
       /*
         Probe hash table.
       */
-      index=(IndexPacket) ((unsigned long) indexes[x] & 0xff);
+      index=(IndexPacket) ((size_t) indexes[x] & 0xff);
       p++;
-      k=(long) (((unsigned long) index << (MaxGIFBits-8))+waiting_code);
+      k=(ssize_t) (((size_t) index << (MaxGIFBits-8))+waiting_code);
       if (k >= MaxHashTable)
         k-=MaxHashTable;
       next_pixel=MagickFalse;
@@ -697,7 +697,7 @@
           if (next_pixel == MagickTrue)
             continue;
         }
-      GIFOutputCode((unsigned long) waiting_code);
+      GIFOutputCode((size_t) waiting_code);
       if (free_code < MaxGIFTable)
         {
           hash_code[k]=(short) free_code++;
@@ -730,7 +730,7 @@
         default:
         {
           offset+=8;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=4;
@@ -740,7 +740,7 @@
         case 1:
         {
           offset+=8;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=2;
@@ -750,7 +750,7 @@
         case 2:
         {
           offset+=4;
-          if (offset >= (long) image->rows)
+          if (offset >= (ssize_t) image->rows)
             {
               pass++;
               offset=1;
@@ -767,7 +767,7 @@
   /*
     Flush out the buffered code.
   */
-  GIFOutputCode((unsigned long) waiting_code);
+  GIFOutputCode((size_t) waiting_code);
   GIFOutputCode(end_of_information_code);
   if (bits > 0)
     {
@@ -957,7 +957,7 @@
   int
     number_extensionss=0;
 
-  long
+  ssize_t
     opacity;
 
   MagickBooleanType
@@ -966,7 +966,7 @@
   RectangleInfo
     page;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -983,7 +983,7 @@
     header[MaxTextExtent],
     magick[12];
 
-  unsigned long
+  size_t
     delay,
     dispose,
     global_colors,
@@ -1019,7 +1019,7 @@
   flag=(unsigned char) ReadBlobByte(image);
   background=(unsigned char) ReadBlobByte(image);
   c=(unsigned char) ReadBlobByte(image);  /* reserved */
-  global_colors=1UL << (((unsigned long) flag & 0x07)+1);
+  global_colors=1UL << (((size_t) flag & 0x07)+1);
   global_colormap=(unsigned char *) AcquireQuantumMemory((size_t)
     MagickMax(global_colors,256),3UL*sizeof(*global_colormap));
   if (global_colormap == (unsigned char *) NULL)
@@ -1060,10 +1060,10 @@
               Read graphics control extension.
             */
             while (ReadBlobBlock(image,header) != 0) ;
-            dispose=(unsigned long) (header[0] >> 2);
-            delay=(unsigned long) ((header[2] << 8) | header[1]);
-            if ((long) (header[0] & 0x01) == 0x01)
-              opacity=(long) header[3];
+            dispose=(size_t) (header[0] >> 2);
+            delay=(size_t) ((header[2] << 8) | header[1]);
+            if ((ssize_t) (header[0] & 0x01) == 0x01)
+              opacity=(ssize_t) header[3];
             break;
           }
           case 0xfe:
@@ -1104,7 +1104,7 @@
             if (loop != MagickFalse)
               {
                 while (ReadBlobBlock(image,header) != 0)
-                  iterations=(unsigned long) ((header[2] << 8) | header[1]);
+                  iterations=(size_t) ((header[2] << 8) | header[1]);
                 break;
               }
             else
@@ -1207,8 +1207,8 @@
     */
     image->storage_class=PseudoClass;
     image->compression=LZWCompression;
-    page.x=(long) ReadBlobLSBShort(image);
-    page.y=(long) ReadBlobLSBShort(image);
+    page.x=(ssize_t) ReadBlobLSBShort(image);
+    page.y=(ssize_t) ReadBlobLSBShort(image);
     image->columns=ReadBlobLSBShort(image);
     image->rows=ReadBlobLSBShort(image);
     image->depth=8;
@@ -1216,8 +1216,8 @@
     image->interlace=BitSet((int) flag,0x40) != 0 ? GIFInterlace :
       NoInterlace;
     image->colors=BitSet((int) flag,0x80) == 0 ? global_colors :
-      1UL << ((unsigned long) (flag & 0x07)+1);
-    if (opacity >= (long) image->colors)
+      1UL << ((size_t) (flag & 0x07)+1);
+    if (opacity >= (ssize_t) image->colors)
       opacity=(-1);
     image->page.width=page.width;
     image->page.height=page.height;
@@ -1252,7 +1252,7 @@
           Use global colormap.
         */
         p=global_colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].red=ScaleCharToQuantum(*p++);
           image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -1292,7 +1292,7 @@
               "InsufficientImageDataInFile");
           }
         p=colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].red=ScaleCharToQuantum(*p++);
           image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -1354,10 +1354,10 @@
 %
 %  The format of the RegisterGIFImage method is:
 %
-%      unsigned long RegisterGIFImage(void)
+%      size_t RegisterGIFImage(void)
 %
 */
-ModuleExport unsigned long RegisterGIFImage(void)
+ModuleExport size_t RegisterGIFImage(void)
 {
   MagickInfo
     *entry;
@@ -1439,7 +1439,7 @@
   int
     c;
 
-  long
+  ssize_t
     j,
     opacity;
 
@@ -1458,7 +1458,7 @@
   RectangleInfo
     page;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -1471,7 +1471,7 @@
     *colormap,
     *global_colormap;
 
-  unsigned long
+  size_t
     bits_per_pixel,
     delay;
 
@@ -1562,7 +1562,7 @@
         */
         if ((image->storage_class == DirectClass) || (image->colors > 256))
           (void) SetImageType(image,PaletteBilevelMatteType);
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
           if (image->colormap[i].opacity != OpaqueOpacity)
             {
               if (opacity < 0)
@@ -1580,7 +1580,7 @@
         if (opacity == -1)
           {
             (void) SetImageType(image,PaletteBilevelMatteType);
-            for (i=0; i < (long) image->colors; i++)
+            for (i=0; i < (ssize_t) image->colors; i++)
               if (image->colormap[i].opacity != OpaqueOpacity)
                 {
                   if (opacity < 0)
@@ -1609,13 +1609,13 @@
       if ((1UL << bits_per_pixel) >= image->colors)
         break;
     q=colormap;
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       *q++=ScaleQuantumToChar(image->colormap[i].red);
       *q++=ScaleQuantumToChar(image->colormap[i].green);
       *q++=ScaleQuantumToChar(image->colormap[i].blue);
     }
-    for ( ; i < (long) (1UL << bits_per_pixel); i++)
+    for ( ; i < (ssize_t) (1UL << bits_per_pixel); i++)
     {
       *q++=(unsigned char) 0x0;
       *q++=(unsigned char) 0x0;
@@ -1631,11 +1631,11 @@
         c|=(8-1) << 4;  /* color resolution */
         c|=(bits_per_pixel-1);   /* size of global colormap */
         (void) WriteBlobByte(image,(unsigned char) c);
-        for (j=0; j < (long) image->colors; j++)
+        for (j=0; j < (ssize_t) image->colors; j++)
           if (IsColorEqual(&image->background_color,image->colormap+j))
             break;
         (void) WriteBlobByte(image,(unsigned char)
-          (j == (long) image->colors ? 0 : j));  /* background color */
+          (j == (ssize_t) image->colors ? 0 : j));  /* background color */
         (void) WriteBlobByte(image,(unsigned char) 0x00);  /* reserved */
         length=(size_t) (3*(1UL << bits_per_pixel));
         (void) WriteBlob(image,length,colormap);
@@ -1654,7 +1654,7 @@
         if (opacity >= 0)
           c|=0x01;
         (void) WriteBlobByte(image,(unsigned char) c);
-        delay=(unsigned long) (100*image->delay/MagickMax((size_t)
+        delay=(size_t) (100*image->delay/MagickMax((size_t)
           image->ticks_per_second,1));
         (void) WriteBlobLSBShort(image,(unsigned short) delay);
         (void) WriteBlobByte(image,(unsigned char) (opacity >= 0 ? opacity :
@@ -1683,7 +1683,7 @@
             {
               count=MagickMin(strlen(p),255);
               (void) WriteBlobByte(image,(unsigned char) count);
-              for (i=0; i < (long) count; i++)
+              for (i=0; i < (ssize_t) count; i++)
                 (void) WriteBlobByte(image,(unsigned char) *p++);
             }
             (void) WriteBlobByte(image,(unsigned char) 0x00);
@@ -1818,10 +1818,10 @@
     c=0x00;
     if (interlace != NoInterlace)
       c|=0x40;  /* pixel data is interlaced */
-    for (j=0; j < (long) (3*image->colors); j++)
+    for (j=0; j < (ssize_t) (3*image->colors); j++)
       if (colormap[j] != global_colormap[j])
         break;
-    if (j == (long) (3*image->colors))
+    if (j == (ssize_t) (3*image->colors))
       (void) WriteBlobByte(image,(unsigned char) c);
     else
       {
@@ -1836,7 +1836,7 @@
     */
     c=(int) MagickMax(bits_per_pixel,2);
     (void) WriteBlobByte(image,(unsigned char) c);
-    status=EncodeImage(write_info,image,(unsigned long)
+    status=EncodeImage(write_info,image,(size_t)
       MagickMax(bits_per_pixel,2)+1);
     if (status == MagickFalse)
       {
diff --git a/coders/gradient.c b/coders/gradient.c
index 843801d..c55bc50 100644
--- a/coders/gradient.c
+++ b/coders/gradient.c
@@ -157,10 +157,10 @@
 %
 %  The format of the RegisterGRADIENTImage method is:
 %
-%      unsigned long RegisterGRADIENTImage(void)
+%      size_t RegisterGRADIENTImage(void)
 %
 */
-ModuleExport unsigned long RegisterGRADIENTImage(void)
+ModuleExport size_t RegisterGRADIENTImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/gray.c b/coders/gray.c
index bbf5c4e..71e54b4 100644
--- a/coders/gray.c
+++ b/coders/gray.c
@@ -102,7 +102,7 @@
     *canvas_image,
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -117,7 +117,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -174,7 +174,7 @@
       */
       image->scene++;
       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
@@ -197,12 +197,12 @@
         length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
         count=ReadBlob(image,length,pixels);
       }
-    for (y=0; y < (long) image->extract_info.height; y++)
+    for (y=0; y < (ssize_t) image->extract_info.height; y++)
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -222,7 +222,7 @@
       if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
         break;
       if (((y-image->extract_info.y) >= 0) && 
-          ((y-image->extract_info.y) < (long) image->rows))
+          ((y-image->extract_info.y) < (ssize_t) image->rows))
         {
           p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
             image->columns,1,exception);
@@ -230,7 +230,7 @@
             1,exception);
           if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             SetRedPixelComponent(q,GetRedPixelComponent(p));
             SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -302,10 +302,10 @@
 %
 %  The format of the RegisterGRAYImage method is:
 %
-%      unsigned long RegisterGRAYImage(void)
+%      size_t RegisterGRAYImage(void)
 %
 */
-ModuleExport unsigned long RegisterGRAYImage(void)
+ModuleExport size_t RegisterGRAYImage(void)
 {
   MagickInfo
     *entry;
@@ -375,7 +375,7 @@
 static MagickBooleanType WriteGRAYImage(const ImageInfo *image_info,
   Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -424,7 +424,7 @@
     if (quantum_info == (QuantumInfo *) NULL)
       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
     pixels=GetQuantumPixels(quantum_info);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register const PixelPacket
         *restrict p;
diff --git a/coders/hald.c b/coders/hald.c
index 47bc79a..f7cef09 100644
--- a/coders/hald.c
+++ b/coders/hald.c
@@ -92,7 +92,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -120,11 +120,11 @@
     level=8;
   status=MagickTrue;
   cube_size=level*level;
-  image->columns=(unsigned long) (level*cube_size);
-  image->rows=(unsigned long) (level*cube_size);
-  for (y=0; y < (long) image->rows; y+=(long) level)
+  image->columns=(size_t) (level*cube_size);
+  image->rows=(size_t) (level*cube_size);
+  for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) level)
   {
-    long
+    ssize_t
       blue,
       green,
       red;
@@ -134,17 +134,17 @@
 
     if (status == MagickFalse)
       continue;
-    q=QueueAuthenticPixels(image,0,y,image->columns,(unsigned long) level,
+    q=QueueAuthenticPixels(image,0,y,image->columns,(size_t) level,
       exception);
     if (q == (PixelPacket *) NULL)
       {
         status=MagickFalse;
         continue;
       }
-    blue=y/(long) level;
-    for (green=0; green < (long) cube_size; green++)
+    blue=y/(ssize_t) level;
+    for (green=0; green < (ssize_t) cube_size; green++)
     {
-      for (red=0; red < (long) cube_size; red++)
+      for (red=0; red < (ssize_t) cube_size; red++)
       {
         q->red=ClampToQuantum(QuantumRange*red/(cube_size-1.0));
         q->green=ClampToQuantum(QuantumRange*green/(cube_size-1.0));
@@ -179,10 +179,10 @@
 %
 %  The format of the RegisterHALDImage method is:
 %
-%      unsigned long RegisterHALDImage(void)
+%      size_t RegisterHALDImage(void)
 %
 */
-ModuleExport unsigned long RegisterHALDImage(void)
+ModuleExport size_t RegisterHALDImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/histogram.c b/coders/histogram.c
index 16008c7..a380b70 100644
--- a/coders/histogram.c
+++ b/coders/histogram.c
@@ -91,10 +91,10 @@
 %
 %  The format of the RegisterHISTOGRAMImage method is:
 %
-%      unsigned long RegisterHISTOGRAMImage(void)
+%      size_t RegisterHISTOGRAMImage(void)
 %
 */
-ModuleExport unsigned long RegisterHISTOGRAMImage(void)
+ModuleExport size_t RegisterHISTOGRAMImage(void)
 {
   MagickInfo
     *entry;
@@ -197,7 +197,7 @@
   ImageInfo
     *write_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -216,7 +216,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -263,12 +263,12 @@
   */
   channel=image_info->channel;
   (void) ResetMagickMemory(histogram,0,length*sizeof(*histogram));
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         histogram[ScaleQuantumToChar(GetRedPixelComponent(p))].red++;
@@ -280,7 +280,7 @@
     }
   }
   maximum=histogram[0].red;
-  for (x=0; x < (long) histogram_image->columns; x++)
+  for (x=0; x < (ssize_t) histogram_image->columns; x++)
   {
     if (((channel & RedChannel) != 0) && (maximum < histogram[x].red))
       maximum=histogram[x].red;
@@ -297,16 +297,16 @@
   (void) QueryColorDatabase("#000000",&histogram_image->background_color,
     &image->exception);
   (void) SetImageBackgroundColor(histogram_image);
-  for (x=0; x < (long) histogram_image->columns; x++)
+  for (x=0; x < (ssize_t) histogram_image->columns; x++)
   {
     q=GetAuthenticPixels(histogram_image,x,0,1,histogram_image->rows,exception);
     if (q == (PixelPacket *) NULL)
       break;
     if ((channel & RedChannel) != 0)
       {
-        y=(long) ceil(histogram_image->rows-scale*histogram[x].red-0.5);
+        y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].red-0.5);
         r=q+y;
-        for ( ; y < (long) histogram_image->rows; y++)
+        for ( ; y < (ssize_t) histogram_image->rows; y++)
         {
           r->red=(Quantum) QuantumRange;
           r++;
@@ -314,9 +314,9 @@
       }
     if ((channel & GreenChannel) != 0)
       {
-        y=(long) ceil(histogram_image->rows-scale*histogram[x].green-0.5);
+        y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].green-0.5);
         r=q+y;
-        for ( ; y < (long) histogram_image->rows; y++)
+        for ( ; y < (ssize_t) histogram_image->rows; y++)
         {
           r->green=(Quantum) QuantumRange;
           r++;
@@ -324,9 +324,9 @@
       }
     if ((channel & BlueChannel) != 0)
       {
-        y=(long) ceil(histogram_image->rows-scale*histogram[x].blue-0.5);
+        y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].blue-0.5);
         r=q+y;
-        for ( ; y < (long) histogram_image->rows; y++)
+        for ( ; y < (ssize_t) histogram_image->rows; y++)
         {
           r->blue=(Quantum) QuantumRange;
           r++;
diff --git a/coders/hrz.c b/coders/hrz.c
index 0be965f..4a9f21c 100644
--- a/coders/hrz.c
+++ b/coders/hrz.c
@@ -95,13 +95,13 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -147,7 +147,7 @@
   if (pixels == (unsigned char *) NULL) 
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   length=(size_t) (3*image->columns);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     count=ReadBlob(image,length,pixels);
     if ((size_t) count != length)
@@ -156,7 +156,7 @@
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=4*ScaleCharToQuantum(*p++);
       q->green=4*ScaleCharToQuantum(*p++);
@@ -196,10 +196,10 @@
 %
 %  The format of the RegisterHRZImage method is:
 %
-%      unsigned long RegisterHRZImage(void)
+%      size_t RegisterHRZImage(void)
 %
 */
-ModuleExport unsigned long RegisterHRZImage(void)
+ModuleExport size_t RegisterHRZImage(void)
 {
   MagickInfo
     *entry;
@@ -273,7 +273,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x,
     y;
 
@@ -317,13 +317,13 @@
   /*
     Convert MIFF to HRZ raster pixels.
   */
-  for (y=0; y < (long) hrz_image->rows; y++)
+  for (y=0; y < (ssize_t) hrz_image->rows; y++)
   {
     p=GetVirtualPixels(hrz_image,0,y,hrz_image->columns,1,&image->exception);
     if (p == (PixelPacket *) NULL)
       break;
     q=pixels;
-    for (x=0; x < (long) hrz_image->columns; x++)
+    for (x=0; x < (ssize_t) hrz_image->columns; x++)
     {
       *q++=ScaleQuantumToChar(GetRedPixelComponent(p))/4;
       *q++=ScaleQuantumToChar(GetGreenPixelComponent(p))/4;
diff --git a/coders/html.c b/coders/html.c
index a9874dc..1fc0ca6 100644
--- a/coders/html.c
+++ b/coders/html.c
@@ -120,10 +120,10 @@
 %
 %  The format of the RegisterHTMLImage method is:
 %
-%      unsigned long RegisterHTMLImage(void)
+%      size_t RegisterHTMLImage(void)
 %
 */
-ModuleExport unsigned long RegisterHTMLImage(void)
+ModuleExport size_t RegisterHTMLImage(void)
 {
   MagickInfo
     *entry;
@@ -352,8 +352,8 @@
             {
               (void) FormatMagickString(buffer,MaxTextExtent,
                 "\" shape=\"rect\" coords=\"%ld,%ld,%ld,%ld\" alt=\"\" />\n",
-                geometry.x,geometry.y,geometry.x+(long) geometry.width-1,
-                geometry.y+(long) geometry.height-1);
+                geometry.x,geometry.y,geometry.x+(ssize_t) geometry.width-1,
+                geometry.y+(ssize_t) geometry.height-1);
               (void) WriteBlobString(image,buffer);
               if (*(p+1) != '\0')
                 {
@@ -362,7 +362,7 @@
                   (void) WriteBlobString(image,buffer);
                 }
               geometry.x+=geometry.width;
-              if ((geometry.x+4) >= (long) image->columns)
+              if ((geometry.x+4) >= (ssize_t) image->columns)
                 {
                   geometry.x=0;
                   geometry.y+=geometry.height;
@@ -427,8 +427,8 @@
         {
           (void) FormatMagickString(buffer,MaxTextExtent,
             "\" shape=\"rect\" coords=\"%ld,%ld,%ld,%ld\" alt=\"\" />\n",
-            geometry.x,geometry.y,geometry.x+(long) geometry.width-1,
-            geometry.y+(long) geometry.height-1);
+            geometry.x,geometry.y,geometry.x+(ssize_t) geometry.width-1,
+            geometry.y+(ssize_t) geometry.height-1);
           (void) WriteBlobString(image,buffer);
           if (*(p+1) != '\0')
             {
@@ -437,7 +437,7 @@
               (void) WriteBlobString(image,buffer);
             }
           geometry.x+=geometry.width;
-          if ((geometry.x+4) >= (long) image->columns)
+          if ((geometry.x+4) >= (ssize_t) image->columns)
             {
               geometry.x=0;
               geometry.y+=geometry.height;
diff --git a/coders/icon.c b/coders/icon.c
index cf61027..2e715b3 100644
--- a/coders/icon.c
+++ b/coders/icon.c
@@ -87,7 +87,7 @@
     planes,
     bits_per_pixel;
 
-  unsigned long
+  size_t
     size,
     offset;
 } IconEntry;
@@ -105,13 +105,13 @@
 
 typedef struct _IconInfo
 {
-  unsigned long
+  size_t
     file_size,
     ba_offset,
     offset_bits,
     size;
 
-  long
+  ssize_t
     width,
     height;
 
@@ -119,7 +119,7 @@
     planes,
     bits_per_pixel;
 
-  unsigned long
+  size_t
     compression,
     image_size,
     x_pixels,
@@ -131,7 +131,7 @@
     alpha_mask,
     colors_important;
 
-  long
+  ssize_t
     colorspace;
 } IconInfo;
 
@@ -180,7 +180,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -189,7 +189,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -203,11 +203,11 @@
     count,
     offset;
 
-  unsigned long
+  size_t
     bit,
     byte;
 
-  unsigned long
+  size_t
     bytes_per_line,
     scanline_pad;
 
@@ -314,12 +314,12 @@
         icon_info.number_colors=ReadBlobLSBLong(image);
         icon_info.colors_important=ReadBlobLSBLong(image);
         image->matte=MagickTrue;
-        image->columns=(unsigned long) icon_file.directory[i].width;
-        if ((long) image->columns > icon_info.width)
-          image->columns=(unsigned long) icon_info.width;
-        image->rows=(unsigned long) icon_file.directory[i].height;
-        if ((long) image->rows > icon_info.height)
-          image->rows=(unsigned long) icon_info.height;
+        image->columns=(size_t) icon_file.directory[i].width;
+        if ((ssize_t) image->columns > icon_info.width)
+          image->columns=(size_t) icon_info.width;
+        image->rows=(size_t) icon_file.directory[i].height;
+        if ((ssize_t) image->rows > icon_info.height)
+          image->rows=(size_t) icon_info.height;
         image->depth=8;
         if (image->debug != MagickFalse)
           {
@@ -347,13 +347,13 @@
         }
       if (image->storage_class == PseudoClass)
         {
-          register long
+          register ssize_t
             i;
 
           unsigned char
             *icon_colormap;
 
-          unsigned long
+          size_t
             number_colors;
 
           /*
@@ -371,7 +371,7 @@
             ThrowReaderException(CorruptImageError,
               "InsufficientImageDataInFile");
           p=icon_colormap;
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             image->colormap[i].blue=(Quantum) ScaleCharToQuantum(*p++);
             image->colormap[i].green=(Quantum) ScaleCharToQuantum(*p++);
@@ -398,27 +398,27 @@
             /*
               Convert bitmap scanline.
             */
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) (image->columns-7); x+=8)
+              for (x=0; x < (ssize_t) (image->columns-7); x+=8)
               {
-                byte=(unsigned long) ReadBlobByte(image);
+                byte=(size_t) ReadBlobByte(image);
                 for (bit=0; bit < 8; bit++)
                   indexes[x+bit]=(IndexPacket)
                     ((byte & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
               }
               if ((image->columns % 8) != 0)
                 {
-                  byte=(unsigned long) ReadBlobByte(image);
+                  byte=(size_t) ReadBlobByte(image);
                   for (bit=0; bit < (image->columns % 8); bit++)
                     indexes[x+bit]=(IndexPacket)
                       ((byte & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
                 }
-              for (x=0; x < (long) scanline_pad; x++)
+              for (x=0; x < (ssize_t) scanline_pad; x++)
                 (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -437,24 +437,24 @@
             /*
               Read 4-bit Icon scanline.
             */
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < ((long) image->columns-1); x+=2)
+              for (x=0; x < ((ssize_t) image->columns-1); x+=2)
               {
-                byte=(unsigned long) ReadBlobByte(image);
+                byte=(size_t) ReadBlobByte(image);
                 indexes[x]=(IndexPacket) ((byte >> 4) & 0xf);
                 indexes[x+1]=(IndexPacket) ((byte) & 0xf);
               }
               if ((image->columns % 2) != 0)
                 {
-                  byte=(unsigned long) ReadBlobByte(image);
+                  byte=(size_t) ReadBlobByte(image);
                   indexes[x]=(IndexPacket) ((byte >> 4) & 0xf);
                 }
-              for (x=0; x < (long) scanline_pad; x++)
+              for (x=0; x < (ssize_t) scanline_pad; x++)
                 (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -473,18 +473,18 @@
             /*
               Convert PseudoColor scanline.
             */
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
-                byte=(unsigned long) ReadBlobByte(image);
+                byte=(size_t) ReadBlobByte(image);
                 indexes[x]=(IndexPacket) byte;
               }
-              for (x=0; x < (long) scanline_pad; x++)
+              for (x=0; x < (ssize_t) scanline_pad; x++)
                 (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -503,19 +503,19 @@
             /*
               Convert PseudoColor scanline.
             */
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
-                byte=(unsigned long) ReadBlobByte(image);
-                byte|=(unsigned long) (ReadBlobByte(image) << 8);
+                byte=(size_t) ReadBlobByte(image);
+                byte|=(size_t) (ReadBlobByte(image) << 8);
                 indexes[x]=(IndexPacket) byte;
               }
-              for (x=0; x < (long) scanline_pad; x++)
+              for (x=0; x < (ssize_t) scanline_pad; x++)
                 (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -535,12 +535,12 @@
             /*
               Convert DirectColor scanline.
             */
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 q->blue=ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
                 q->green=ScaleCharToQuantum((unsigned char)
@@ -552,7 +552,7 @@
                 q++;
               }
               if (icon_info.bits_per_pixel == 24)
-                for (x=0; x < (long) scanline_pad; x++)
+                for (x=0; x < (ssize_t) scanline_pad; x++)
                   (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -576,27 +576,27 @@
               Read the ICON alpha mask.
             */
             image->storage_class=DirectClass;
-            for (y=(long) image->rows-1; y >= 0; y--)
+            for (y=(ssize_t) image->rows-1; y >= 0; y--)
             {
               q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
-              for (x=0; x < ((long) image->columns-7); x+=8)
+              for (x=0; x < ((ssize_t) image->columns-7); x+=8)
               {
-                byte=(unsigned long) ReadBlobByte(image);
+                byte=(size_t) ReadBlobByte(image);
                 for (bit=0; bit < 8; bit++)
                   q[x+bit].opacity=(Quantum) (((byte & (0x80 >> bit)) != 0) ?
                     TransparentOpacity : OpaqueOpacity);
               }
               if ((image->columns % 8) != 0)
                 {
-                  byte=(unsigned long) ReadBlobByte(image);
+                  byte=(size_t) ReadBlobByte(image);
                   for (bit=0; bit < (image->columns % 8); bit++)
                     q[x+bit].opacity=(Quantum) (((byte & (0x80 >> bit)) != 0) ?
                       TransparentOpacity : OpaqueOpacity);
                 }
               if ((image->columns % 32) != 0)
-                for (x=0; x < (long) ((32-(image->columns % 32))/8); x++)
+                for (x=0; x < (ssize_t) ((32-(image->columns % 32))/8); x++)
                   (void) ReadBlobByte(image);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -615,7 +615,7 @@
     if (image_info->number_scenes != 0)
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
         break;
-    if (i < (long) (icon_file.count-1))
+    if (i < (ssize_t) (icon_file.count-1))
       {
         /*
           Allocate next image structure.
@@ -657,10 +657,10 @@
 %
 %  The format of the RegisterICONImage method is:
 %
-%      unsigned long RegisterICONImage(void)
+%      size_t RegisterICONImage(void)
 %
 */
-ModuleExport unsigned long RegisterICONImage(void)
+ModuleExport size_t RegisterICONImage(void)
 {
   MagickInfo
     *entry;
@@ -757,7 +757,7 @@
   Image
     *next;
   
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -773,7 +773,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -785,7 +785,7 @@
     byte,
     *pixels;
 
-  unsigned long
+  size_t
     bytes_per_line,
     scanline_pad;
 
@@ -870,8 +870,8 @@
         icon_file.directory[scene].reserved=0;
         icon_file.directory[scene].planes=1;
         icon_file.directory[scene].bits_per_pixel=32;
-        icon_file.directory[scene].size=(unsigned long) length;
-        icon_file.directory[scene].offset=(unsigned long) TellBlob(image);
+        icon_file.directory[scene].size=(size_t) length;
+        icon_file.directory[scene].offset=(size_t) TellBlob(image);
         (void) WriteBlob(image,(size_t) length,png);
         png=(unsigned char *) RelinquishMagickMemory(png);
       }
@@ -894,7 +894,7 @@
             */
             icon_info.number_colors=0;
             icon_info.bits_per_pixel=32;
-            icon_info.compression=(unsigned long) BI_RGB;
+            icon_info.compression=(size_t) BI_RGB;
           }
         else
           {
@@ -914,7 +914,7 @@
                 (void) SetImageStorageClass(next,DirectClass);
                 icon_info.number_colors=0;
                 icon_info.bits_per_pixel=(unsigned short) 24;
-                icon_info.compression=(unsigned long) BI_RGB;
+                icon_info.compression=(size_t) BI_RGB;
               }
             else
               {
@@ -927,8 +927,8 @@
         bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) &
           ~31) >> 3;
         icon_info.ba_offset=0;
-        icon_info.width=(long) next->columns;
-        icon_info.height=(long) next->rows;
+        icon_info.width=(ssize_t) next->columns;
+        icon_info.height=(ssize_t) next->rows;
         icon_info.planes=1;
         icon_info.image_size=bytes_per_line*next->rows;
         icon_info.size=40;
@@ -943,14 +943,14 @@
           case UndefinedResolution:
           case PixelsPerInchResolution:
           {
-            icon_info.x_pixels=(unsigned long) (100.0*next->x_resolution/2.54);
-            icon_info.y_pixels=(unsigned long) (100.0*next->y_resolution/2.54);
+            icon_info.x_pixels=(size_t) (100.0*next->x_resolution/2.54);
+            icon_info.y_pixels=(size_t) (100.0*next->y_resolution/2.54);
             break;
           }
           case PixelsPerCentimeterResolution:
           {
-            icon_info.x_pixels=(unsigned long) (100.0*next->x_resolution);
-            icon_info.y_pixels=(unsigned long) (100.0*next->y_resolution);
+            icon_info.x_pixels=(size_t) (100.0*next->x_resolution);
+            icon_info.y_pixels=(size_t) (100.0*next->y_resolution);
             break;
           }
         }
@@ -967,14 +967,14 @@
         {
           case 1:
           {
-            unsigned long
+            size_t
               bit,
               byte;
 
             /*
               Convert PseudoClass image to a ICON monochrome image.
             */
-            for (y=0; y < (long) next->rows; y++)
+            for (y=0; y < (ssize_t) next->rows; y++)
             {
               p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
               if (p == (const PixelPacket *) NULL)
@@ -983,7 +983,7 @@
               q=pixels+(next->rows-y-1)*bytes_per_line;
               bit=0;
               byte=0;
-              for (x=0; x < (long) next->columns; x++)
+              for (x=0; x < (ssize_t) next->columns; x++)
               {
                 byte<<=1;
                 byte|=indexes[x] != 0 ? 0x01 : 0x00;
@@ -1008,14 +1008,14 @@
           }
           case 4:
           {
-            unsigned long
+            size_t
               nibble,
               byte;
 
             /*
               Convert PseudoClass image to a ICON monochrome image.
             */
-            for (y=0; y < (long) next->rows; y++)
+            for (y=0; y < (ssize_t) next->rows; y++)
             {
               p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
               if (p == (const PixelPacket *) NULL)
@@ -1024,10 +1024,10 @@
               q=pixels+(next->rows-y-1)*bytes_per_line;
               nibble=0;
               byte=0;
-              for (x=0; x < (long) next->columns; x++)
+              for (x=0; x < (ssize_t) next->columns; x++)
               {
                 byte<<=4;
-                byte|=((unsigned long) indexes[x] & 0x0f);
+                byte|=((size_t) indexes[x] & 0x0f);
                 nibble++;
                 if (nibble == 2)
                   {
@@ -1052,14 +1052,14 @@
             /*
               Convert PseudoClass packet to ICON pixel.
             */
-            for (y=0; y < (long) next->rows; y++)
+            for (y=0; y < (ssize_t) next->rows; y++)
             {
               p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetVirtualIndexQueue(next);
               q=pixels+(next->rows-y-1)*bytes_per_line;
-              for (x=0; x < (long) next->columns; x++)
+              for (x=0; x < (ssize_t) next->columns; x++)
                 *q++=(unsigned char) indexes[x];
               if (next->previous == (Image *) NULL)
                 {
@@ -1076,13 +1076,13 @@
             /*
               Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel.
             */
-            for (y=0; y < (long) next->rows; y++)
+            for (y=0; y < (ssize_t) next->rows; y++)
             {
               p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               q=pixels+(next->rows-y-1)*bytes_per_line;
-              for (x=0; x < (long) next->columns; x++)
+              for (x=0; x < (ssize_t) next->columns; x++)
               {
                 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
                 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1094,7 +1094,7 @@
                 p++;
               }
               if (icon_info.bits_per_pixel == 24)
-                for (x=3L*(long) next->columns; x < (long) bytes_per_line; x++)
+                for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++)
                   *q++=0x00;
               if (next->previous == (Image *) NULL)
                 {
@@ -1117,10 +1117,10 @@
         icon_file.directory[scene].planes=icon_info.planes;
         icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel;
         icon_file.directory[scene].size=icon_info.size;
-        icon_file.directory[scene].offset=(unsigned long) TellBlob(image);
-        (void) WriteBlobLSBLong(image,(unsigned long) 40);
-        (void) WriteBlobLSBLong(image,(unsigned long) icon_info.width);
-        (void) WriteBlobLSBLong(image,(unsigned long) icon_info.height*2);
+        icon_file.directory[scene].offset=(size_t) TellBlob(image);
+        (void) WriteBlobLSBLong(image,(size_t) 40);
+        (void) WriteBlobLSBLong(image,(size_t) icon_info.width);
+        (void) WriteBlobLSBLong(image,(size_t) icon_info.height*2);
         (void) WriteBlobLSBShort(image,icon_info.planes);
         (void) WriteBlobLSBShort(image,icon_info.bits_per_pixel);
         (void) WriteBlobLSBLong(image,icon_info.compression);
@@ -1142,14 +1142,14 @@
             if (icon_colormap == (unsigned char *) NULL)
               ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
             q=icon_colormap;
-            for (i=0; i < (long) next->colors; i++)
+            for (i=0; i < (ssize_t) next->colors; i++)
             {
               *q++=ScaleQuantumToChar(next->colormap[i].blue);
               *q++=ScaleQuantumToChar(next->colormap[i].green);
               *q++=ScaleQuantumToChar(next->colormap[i].red);
               *q++=(unsigned char) 0x0;
             }
-            for ( ; i < (long) (1UL << icon_info.bits_per_pixel); i++)
+            for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++)
             {
               *q++=(unsigned char) 0x00;
               *q++=(unsigned char) 0x00;
@@ -1167,14 +1167,14 @@
           Write matte mask.
         */
         scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3;
-        for (y=((long) next->rows - 1); y >= 0; y--)
+        for (y=((ssize_t) next->rows - 1); y >= 0; y--)
         {
           p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           bit=0;
           byte=0;
-          for (x=0; x < (long) next->columns; x++)
+          for (x=0; x < (ssize_t) next->columns; x++)
           {
             byte<<=1;
             if ((next->matte == MagickTrue) &&
@@ -1191,7 +1191,7 @@
           }
           if (bit != 0)
             (void) WriteBlobByte(image,(unsigned char) (byte << (8-bit)));
-          for (i=0; i < (long) scanline_pad; i++)
+          for (i=0; i < (ssize_t) scanline_pad; i++)
             (void) WriteBlobByte(image,(unsigned char) 0);
         }
       }
diff --git a/coders/info.c b/coders/info.c
index d9c11c6..69aa452 100644
--- a/coders/info.c
+++ b/coders/info.c
@@ -87,10 +87,10 @@
 %
 %  The format of the RegisterINFOImage method is:
 %
-%      unsigned long RegisterINFOImage(void)
+%      size_t RegisterINFOImage(void)
 %
 */
-ModuleExport unsigned long RegisterINFOImage(void)
+ModuleExport size_t RegisterINFOImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/inline.c b/coders/inline.c
index 43218dc..746db24 100644
--- a/coders/inline.c
+++ b/coders/inline.c
@@ -186,10 +186,10 @@
 %
 %  The format of the RegisterINLINEImage method is:
 %
-%      unsigned long RegisterINLINEImage(void)
+%      size_t RegisterINLINEImage(void)
 %
 */
-ModuleExport unsigned long RegisterINLINEImage(void)
+ModuleExport size_t RegisterINLINEImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/ipl.c b/coders/ipl.c
index 8659fb9..6babdf6 100644
--- a/coders/ipl.c
+++ b/coders/ipl.c
@@ -68,7 +68,7 @@
 
 typedef struct _IPLInfo
 {
-  unsigned long
+  size_t
   tag,
   size,
   time,
@@ -181,8 +181,8 @@
   register PixelPacket *q;
   unsigned char magick[12], *pixels;
   ssize_t count;
-  long y;
-  unsigned long t_count=0;
+  ssize_t y;
+  size_t t_count=0;
   size_t length;
   IPLInfo
     ipl_info;
@@ -314,7 +314,7 @@
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
         break;
 /*
-   printf("Length: %lu, Memory size: %lu\n", length,(unsigned long)(image->depth));
+   printf("Length: %lu, Memory size: %lu\n", length,(size_t)(image->depth));
 */
      quantum_info=AcquireQuantumInfo(image_info,image);
      if (quantum_info == (QuantumInfo *) NULL)
@@ -335,7 +335,7 @@
      */
     
   if(ipl_info.colors == 1){
-      for(y = 0; y < (long) image->rows; y++){
+      for(y = 0; y < (ssize_t) image->rows; y++){
         (void) ReadBlob(image, length*image->depth/8, pixels);
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -347,7 +347,7 @@
     }
   }
   else{
-      for(y = 0; y < (long) image->rows; y++){
+      for(y = 0; y < (ssize_t) image->rows; y++){
         (void) ReadBlob(image, length*image->depth/8, pixels);
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -357,7 +357,7 @@
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
       }
-      for(y = 0; y < (long) image->rows; y++){
+      for(y = 0; y < (ssize_t) image->rows; y++){
         (void) ReadBlob(image, length*image->depth/8, pixels);
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -367,7 +367,7 @@
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
       }
-      for(y = 0; y < (long) image->rows; y++){
+      for(y = 0; y < (ssize_t) image->rows; y++){
         (void) ReadBlob(image, length*image->depth/8, pixels);
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -426,7 +426,7 @@
  %
  %
  */
-ModuleExport unsigned long RegisterIPLImage(void)
+ModuleExport size_t RegisterIPLImage(void)
 {
   MagickInfo
     *entry;
@@ -509,7 +509,7 @@
   unsigned char
   *pixels;
  
-  long
+  ssize_t
     y;
   
   IPLInfo
@@ -618,7 +618,7 @@
       pixels=GetQuantumPixels(quantum_info);
   if(ipl_info.colors == 1){
   /* Red frame */
-  for(y = 0; y < (long) ipl_info.height; y++){
+  for(y = 0; y < (ssize_t) ipl_info.height; y++){
     p=GetAuthenticPixels(image,0,y,image->columns,1,exception);
     if (p == (PixelPacket *) NULL)
       break;
@@ -630,7 +630,7 @@
 }
   if(ipl_info.colors == 3){
   /* Red frame */
-  for(y = 0; y < (long) ipl_info.height; y++){
+  for(y = 0; y < (ssize_t) ipl_info.height; y++){
     p=GetAuthenticPixels(image,0,y,image->columns,1,exception);
     if (p == (PixelPacket *) NULL)
       break;
@@ -640,7 +640,7 @@
   }
 
     /* Green frame */
-    for(y = 0; y < (long) ipl_info.height; y++){
+    for(y = 0; y < (ssize_t) ipl_info.height; y++){
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (PixelPacket *) NULL)
         break;
@@ -649,7 +649,7 @@
         (void) WriteBlob(image, image->columns*image->depth/8, pixels);
     }
     /* Blue frame */
-    for(y = 0; y < (long) ipl_info.height; y++){
+    for(y = 0; y < (ssize_t) ipl_info.height; y++){
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (PixelPacket *) NULL)
         break;
diff --git a/coders/jbig.c b/coders/jbig.c
index 4f7ad68..846d89a 100644
--- a/coders/jbig.c
+++ b/coders/jbig.c
@@ -111,7 +111,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     length,
     y;
 
@@ -121,7 +121,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -162,7 +162,7 @@
     Initialize JBIG toolkit.
   */
   jbg_dec_init(&jbig_info);
-  jbg_dec_maxsize(&jbig_info,(unsigned long) image->columns,(unsigned long)
+  jbg_dec_maxsize(&jbig_info,(size_t) image->columns,(size_t)
     image->rows);
   image->columns=jbg_dec_getwidth(&jbig_info);
   image->rows=jbg_dec_getheight(&jbig_info);
@@ -179,7 +179,7 @@
   status=JBG_EAGAIN;
   do
   {
-    length=(long) ReadBlob(image,MagickMaxBufferExtent,buffer);
+    length=(ssize_t) ReadBlob(image,MagickMaxBufferExtent,buffer);
     if (length == 0)
       break;
     p=buffer;
@@ -191,7 +191,7 @@
 
       status=jbg_dec_in(&jbig_info,p,length,&count);
       p+=count;
-      length-=(long) count;
+      length-=(ssize_t) count;
     }
   } while ((status == JBG_EAGAIN) || (status == JBG_EOK));
   /*
@@ -221,7 +221,7 @@
     Convert X bitmap image to pixel packets.
   */
   p=jbg_dec_getimage(&jbig_info,0);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -229,7 +229,7 @@
     indexes=GetAuthenticIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (bit == 0)
         byte=(*p++);
@@ -239,7 +239,7 @@
       if (bit == 8)
         bit=0;
       indexes[x]=index;
-      *q++=image->colormap[(long) index];
+      *q++=image->colormap[(ssize_t) index];
     }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
@@ -277,10 +277,10 @@
 %
 %  The format of the RegisterJBIGImage method is:
 %
-%      unsigned long RegisterJBIGImage(void)
+%      size_t RegisterJBIGImage(void)
 %
 */
-ModuleExport unsigned long RegisterJBIGImage(void)
+ModuleExport size_t RegisterJBIGImage(void)
 {
 #define JBIGDescription  "Joint Bi-level Image experts Group interchange format"
 
@@ -396,7 +396,7 @@
   double
     version;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -411,7 +411,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -425,7 +425,7 @@
     byte,
     *pixels;
 
-  unsigned long
+  size_t
     number_packets;
 
   /*
@@ -459,7 +459,7 @@
     */
     (void) SetImageType(image,BilevelType);
     q=pixels;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
@@ -467,7 +467,7 @@
       indexes=GetVirtualIndexQueue(image);
       bit=0;
       byte=0;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         byte<<=1;
         if (PixelIntensity(p) < (QuantumRange/2.0))
@@ -499,10 +499,10 @@
       jbg_enc_layers(&jbig_info,(int) image_info->scene);
     else
       {
-        long
+        ssize_t
           sans_offset;
 
-        unsigned long
+        size_t
           x_resolution,
           y_resolution;
 
@@ -525,8 +525,8 @@
           }
         if (image->units == PixelsPerCentimeterResolution)
           {
-            x_resolution=(unsigned long) (100.0*2.54*x_resolution+0.5)/100.0;
-            y_resolution=(unsigned long) (100.0*2.54*y_resolution+0.5)/100.0;
+            x_resolution=(size_t) (100.0*2.54*x_resolution+0.5)/100.0;
+            y_resolution=(size_t) (100.0*2.54*y_resolution+0.5)/100.0;
           }
         (void) jbg_enc_lrlmax(&jbig_info,x_resolution,y_resolution);
       }
diff --git a/coders/jp2.c b/coders/jp2.c
index 055c88d..3280c69 100644
--- a/coders/jp2.c
+++ b/coders/jp2.c
@@ -79,11 +79,11 @@
 #if !defined(uint)
 #define uint  unsigned int
 #endif
-#if !defined(longlong)
-#define longlong  long long
+#if !defined(ssize_tssize_t)
+#define ssize_tssize_t  long long
 #endif
-#if !defined(ulonglong)
-#define ulonglong  unsigned long long
+#if !defined(ussize_tssize_t)
+#define ussize_tssize_t  unsigned long long
 #endif
 
 #undef PACKAGE_NAME
@@ -244,13 +244,13 @@
   return((int) count);
 }
 
-static long BlobSeek(jas_stream_obj_t *object,long offset,int origin)
+static ssize_t BlobSeek(jas_stream_obj_t *object,ssize_t offset,int origin)
 {
   StreamManager
     *source;
 
   source=(StreamManager *) object;
-  return((long) SeekBlob(source->image,offset,origin));
+  return((ssize_t) SeekBlob(source->image,offset,origin));
 }
 
 static int BlobClose(jas_stream_obj_t *object)
@@ -346,7 +346,7 @@
   jas_stream_t
     *jp2_stream;
 
-  long
+  ssize_t
     components[4],
     y;
 
@@ -357,14 +357,14 @@
     pixel,
     range[4];
 
-  register long
+  register ssize_t
     i,
     x;
 
   register PixelPacket
     *q;
 
-  unsigned long
+  size_t
     maximum_component_depth,
     number_components,
     x_step[4],
@@ -464,15 +464,15 @@
   image->columns=jas_image_width(jp2_image);
   image->rows=jas_image_height(jp2_image);
   image->compression=JPEG2000Compression;
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
-    unsigned long
+    size_t
       height,
       width;
 
-    width=(unsigned long) (jas_image_cmptwidth(jp2_image,components[i])*
+    width=(size_t) (jas_image_cmptwidth(jp2_image,components[i])*
       jas_image_cmpthstep(jp2_image,components[i]));
-    height=(unsigned long) (jas_image_cmptheight(jp2_image,components[i])*
+    height=(size_t) (jas_image_cmptheight(jp2_image,components[i])*
       jas_image_cmptvstep(jp2_image,components[i]));
     x_step[i]=(unsigned int) jas_image_cmpthstep(jp2_image,components[i]);
     y_step[i]=(unsigned int) jas_image_cmptvstep(jp2_image,components[i]);
@@ -492,7 +492,7 @@
   */
   image->matte=number_components > 3 ? MagickTrue : MagickFalse;
   maximum_component_depth=0;
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
     maximum_component_depth=(unsigned int) MagickMax((size_t)
       jas_image_cmptprec(jp2_image,components[i]),(size_t)
@@ -513,15 +513,15 @@
       jas_image_destroy(jp2_image);
       return(GetFirstImageInList(image));
     }
-  for (i=0; i < (long) number_components; i++)
-    range[i]=GetQuantumRange((unsigned long) jas_image_cmptprec(jp2_image,
+  for (i=0; i < (ssize_t) number_components; i++)
+    range[i]=GetQuantumRange((size_t) jas_image_cmptprec(jp2_image,
       components[i]));
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (i=0; i < (long) number_components; i++)
+    for (i=0; i < (ssize_t) number_components; i++)
       (void) jas_image_readcmpt(jp2_image,(short) components[i],0,
         ((unsigned int) y)/y_step[i],((unsigned int) image->columns)/x_step[i],
         1,pixels[i]);
@@ -532,7 +532,7 @@
         /*
           Grayscale.
         */
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           pixel=(QuantumAny) jas_matrix_getv(pixels[0],x/x_step[0]);
           q->red=(Quantum) ScaleAnyToQuantum((QuantumAny) pixel,range[0]);
@@ -547,7 +547,7 @@
         /*
           RGB.
         */
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           pixel=(QuantumAny) jas_matrix_getv(pixels[0],x/x_step[0]);
           q->red=(Quantum) ScaleAnyToQuantum((QuantumAny) pixel,range[0]);
@@ -564,7 +564,7 @@
         /*
           RGBA.
         */
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           pixel=(QuantumAny) jas_matrix_getv(pixels[0],x/x_step[0]);
           q->red=(Quantum) ScaleAnyToQuantum((QuantumAny) pixel,range[0]);
@@ -613,7 +613,7 @@
           blob=(jas_stream_memobj_t *) icc_stream->obj_;
           if (image->debug != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "Profile: ICC, %lu bytes",(unsigned long) blob->len_);
+              "Profile: ICC, %lu bytes",(size_t) blob->len_);
           profile=AcquireStringInfo(blob->len_);
           SetStringInfoDatum(profile,blob->buf_);
           icc_profile=(StringInfo *) GetImageProfile(image,"icc");
@@ -627,7 +627,7 @@
     }
   (void) jas_stream_close(jp2_stream);
   jas_image_destroy(jp2_image);
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
     jas_matrix_destroy(pixels[i]);
   return(GetFirstImageInList(image));
 }
@@ -652,10 +652,10 @@
 %
 %  The format of the RegisterJP2Image method is:
 %
-%      unsigned long RegisterJP2Image(void)
+%      size_t RegisterJP2Image(void)
 %
 */
-ModuleExport unsigned long RegisterJP2Image(void)
+ModuleExport size_t RegisterJP2Image(void)
 {
   MagickInfo
     *entry;
@@ -800,7 +800,7 @@
   const char
     *option;
 
-  long
+  ssize_t
     format,
     y;
 
@@ -825,11 +825,11 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  unsigned long
+  size_t
     number_components;
 
   /*
@@ -860,7 +860,7 @@
       (image->rows != (unsigned int) image->rows))
     ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
   (void) ResetMagickMemory(&component_info,0,sizeof(component_info));
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
     component_info[i].tlx=0;
     component_info[i].tly=0;
@@ -902,7 +902,7 @@
   /*
     Convert to JPEG 2000 pixels.
   */
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
     pixels[i]=jas_matrix_create(1,(int) image->columns);
     if (pixels[i] == (jas_matrix_t *) NULL)
@@ -913,13 +913,13 @@
         ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
       }
   }
-  range=GetQuantumRange((unsigned long) component_info[0].prec);
-  for (y=0; y < (long) image->rows; y++)
+  range=GetQuantumRange((size_t) component_info[0].prec);
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (number_components == 1)
         jas_matrix_setv(pixels[0],x,(jas_seqent_t) ScaleQuantumToAny(
@@ -938,7 +938,7 @@
         }
       p++;
     }
-    for (i=0; i < (long) number_components; i++)
+    for (i=0; i < (ssize_t) number_components; i++)
       (void) jas_image_writecmpt(jp2_image,(short) i,0,(unsigned int) y,
         (unsigned int) image->columns,1,pixels[i]);
     status=SetImageProgress(image,SaveImageTag,y,image->rows);
@@ -1000,7 +1000,7 @@
   status=jas_image_encode(jp2_image,jp2_stream,format,options) != 0 ?
     MagickTrue : MagickFalse;
   (void) jas_stream_close(jp2_stream);
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
     jas_matrix_destroy(pixels[i]);
   jas_image_destroy(jp2_image);
   if (status != MagickFalse)
diff --git a/coders/jpeg.c b/coders/jpeg.c
index a45abc9..27e11d5 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -319,7 +319,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -330,7 +330,7 @@
   */
   error_manager=(ErrorManager *) jpeg_info->client_data;
   image=error_manager->image;
-  length=(size_t) ((unsigned long) GetCharacter(jpeg_info) << 8);
+  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);
   length+=GetCharacter(jpeg_info);
   length-=2;
   if (length <= 0)
@@ -345,7 +345,7 @@
   /*
     Read comment.
   */
-  i=(long) length-1;
+  i=(ssize_t) length-1;
   for (p=comment; i-- >= 0; p++)
     *p=(char) GetCharacter(jpeg_info);
   *p='\0';
@@ -368,7 +368,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -384,7 +384,7 @@
   /*
     Read color profile.
   */
-  length=(size_t) ((unsigned long) GetCharacter(jpeg_info) << 8);
+  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);
   length+=(size_t) GetCharacter(jpeg_info);
   length-=2;
   if (length <= 14)
@@ -400,7 +400,7 @@
       /*
         Not a ICC profile, return.
       */
-      for (i=0; i < (long) (length-12); i++)
+      for (i=0; i < (ssize_t) (length-12); i++)
         (void) GetCharacter(jpeg_info);
       return(MagickTrue);
     }
@@ -414,7 +414,7 @@
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   p=GetStringInfoDatum(profile);
-  for (i=(long) GetStringInfoLength(profile)-1; i >= 0; i--)
+  for (i=(ssize_t) GetStringInfoLength(profile)-1; i >= 0; i--)
     *p++=(unsigned char) GetCharacter(jpeg_info);
   icc_profile=(StringInfo *) GetImageProfile(image,"icc");
   if (icc_profile != (StringInfo *) NULL)
@@ -432,7 +432,7 @@
     }
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-      "Profile: ICC, %lu bytes",(unsigned long) length);
+      "Profile: ICC, %lu bytes",(size_t) length);
   return(MagickTrue);
 }
 
@@ -450,7 +450,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -466,7 +466,7 @@
   /*
     Determine length of binary data stored here.
   */
-  length=(size_t) ((unsigned long) GetCharacter(jpeg_info) << 8);
+  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);
   length+=(size_t) GetCharacter(jpeg_info);
   length-=2;
   if (length <= 14)
@@ -489,7 +489,7 @@
       /*
         Not a IPTC profile, return.
       */
-      for (i=0; i < (long) length; i++)
+      for (i=0; i < (ssize_t) length; i++)
         (void) GetCharacter(jpeg_info);
       return(MagickTrue);
     }
@@ -510,7 +510,7 @@
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   p=GetStringInfoDatum(profile);
-  for (i=(long) GetStringInfoLength(profile)-1; i >= 0; i--)
+  for (i=(ssize_t) GetStringInfoLength(profile)-1; i >= 0; i--)
     *p++=(unsigned char) GetCharacter(jpeg_info);
   iptc_profile=(StringInfo *) GetImageProfile(image,"8bim");
   if (iptc_profile != (StringInfo *) NULL)
@@ -528,7 +528,7 @@
     }
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-      "Profile: iptc, %lu bytes",(unsigned long) length);
+      "Profile: iptc, %lu bytes",(size_t) length);
   return(MagickTrue);
 }
 
@@ -549,7 +549,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -564,7 +564,7 @@
   /*
     Read generic profile.
   */
-  length=(size_t) ((unsigned long) GetCharacter(jpeg_info) << 8);
+  length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8);
   length+=(size_t) GetCharacter(jpeg_info);
   if (length <= 2)
     return(MagickTrue);
@@ -578,7 +578,7 @@
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   p=GetStringInfoDatum(profile);
-  for (i=(long) GetStringInfoLength(profile)-1; i >= 0; i--)
+  for (i=(ssize_t) GetStringInfoLength(profile)-1; i >= 0; i--)
     *p++=(unsigned char) GetCharacter(jpeg_info);
   if (marker == 1)
     {
@@ -587,20 +587,20 @@
         (void) CopyMagickString(name,"exif",MaxTextExtent);
       if ((length > 5) && (LocaleNCompare((char *) p,"http:",5) == 0))
         {
-          long
+          ssize_t
             j;
 
           /*
             Extract namespace from XMP profile.
           */
           p=GetStringInfoDatum(profile);
-          for (j=0; j < (long) GetStringInfoLength(profile); j++)
+          for (j=0; j < (ssize_t) GetStringInfoLength(profile); j++)
           {
             if (*p == '\0')
               break;
             p++;
           }
-          if (j < (long) GetStringInfoLength(profile))
+          if (j < (ssize_t) GetStringInfoLength(profile))
             (void) DestroyStringInfo(SplitStringInfo(profile,(size_t) (j+1)));
           (void) CopyMagickString(name,"xmp",MaxTextExtent);
         }
@@ -612,11 +612,11 @@
       image->filename);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-      "Profile: %s, %lu bytes",name,(unsigned long) length);
+      "Profile: %s, %lu bytes",name,(size_t) length);
   return(MagickTrue);
 }
 
-static void SkipInputData(j_decompress_ptr cinfo,long number_bytes)
+static void SkipInputData(j_decompress_ptr cinfo,ssize_t number_bytes)
 {
   SourceManager
     *source;
@@ -624,9 +624,9 @@
   if (number_bytes <= 0)
     return;
   source=(SourceManager *) cinfo->src;
-  while (number_bytes > (long) source->manager.bytes_in_buffer)
+  while (number_bytes > (ssize_t) source->manager.bytes_in_buffer)
   {
-    number_bytes-=(long) source->manager.bytes_in_buffer;
+    number_bytes-=(ssize_t) source->manager.bytes_in_buffer;
     (void) FillInputBuffer(cinfo);
   }
   source->manager.next_input_byte+=(size_t) number_bytes;
@@ -673,12 +673,12 @@
   else
 #endif
   {
-    long
+    ssize_t
       j,
       qvalue,
       sum;
 
-    register long
+    register ssize_t
       i;
 
     /*
@@ -694,7 +694,7 @@
      if ((jpeg_info->quant_tbl_ptrs[0] != NULL) &&
          (jpeg_info->quant_tbl_ptrs[1] != NULL))
        {
-         long
+         ssize_t
            hash[101] =
            {
              1020, 1015,  932,  848,  780,  735,  702,  679,  660,  645,
@@ -725,7 +725,7 @@
                128,     0
            };
 
-         qvalue=(long) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
+         qvalue=(ssize_t) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
            jpeg_info->quant_tbl_ptrs[0]->quantval[53]+
            jpeg_info->quant_tbl_ptrs[1]->quantval[0]+
            jpeg_info->quant_tbl_ptrs[1]->quantval[DCTSIZE2-1]);
@@ -734,7 +734,7 @@
            if ((qvalue < hash[i]) && (sum < sums[i]))
              continue;
            if (((qvalue <= hash[i]) && (sum <= sums[i])) || (i >= 50))
-             image->quality=(unsigned long) i+1;
+             image->quality=(size_t) i+1;
            if (image->debug != MagickFalse)
              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                "Quality: %ld (%s)",i+1,(qvalue <= hash[i]) &&
@@ -745,7 +745,7 @@
      else
        if (jpeg_info->quant_tbl_ptrs[0] != NULL)
          {
-           long
+           ssize_t
              hash[101] =
              {
                510,  505,  422,  380,  355,  338,  326,  318,  311,  305,
@@ -776,14 +776,14 @@
                   64,     0
              };
 
-           qvalue=(long) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
+           qvalue=(ssize_t) (jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
              jpeg_info->quant_tbl_ptrs[0]->quantval[53]);
            for (i=0; i < 100; i++)
            {
              if ((qvalue < hash[i]) && (sum < sums[i]))
                continue;
              if (((qvalue <= hash[i]) && (sum <= sums[i])) || (i >= 50))
-               image->quality=(unsigned long) i+1;
+               image->quality=(size_t) i+1;
              if (image->debug != MagickFalse)
                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                  "Quality: %ld (%s)",i+1,(qvalue <= hash[i]) &&
@@ -875,7 +875,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   JSAMPLE
@@ -891,7 +891,7 @@
   MagickSizeType
     number_pixels;
 
-  register long
+  register ssize_t
     i;
 
   struct jpeg_decompress_struct
@@ -903,7 +903,7 @@
   register JSAMPLE
     *p;
 
-  unsigned long
+  size_t
     precision,
     units;
 
@@ -976,7 +976,7 @@
     {
       image->x_resolution=(double) jpeg_info.X_density;
       image->y_resolution=(double) jpeg_info.Y_density;
-      units=(unsigned long) jpeg_info.density_unit;
+      units=(size_t) jpeg_info.density_unit;
     }
   if (units == 1)
     image->units=PixelsPerInchResolution;
@@ -1015,9 +1015,9 @@
       jpeg_calc_output_dimensions(&jpeg_info);
       if (image->debug != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Scale factor: %ld",
-          (long) scale_factor);
+          (ssize_t) scale_factor);
     }
-  precision=(unsigned long) jpeg_info.data_precision;
+  precision=(size_t) jpeg_info.data_precision;
 #if (JPEG_LIB_VERSION >= 61) && defined(D_PROGRESSIVE_SUPPORTED)
 #if defined(D_LOSSLESS_SUPPORTED)
   image->interlace=jpeg_info.process == JPROC_PROGRESSIVE ?
@@ -1094,7 +1094,7 @@
   (void) jpeg_start_decompress(&jpeg_info);
   image->columns=jpeg_info.output_width;
   image->rows=jpeg_info.output_height;
-  image->depth=(unsigned long) jpeg_info.data_precision;
+  image->depth=(size_t) jpeg_info.data_precision;
   if (jpeg_info.out_color_space == JCS_YCbCr)
     image->colorspace=YCbCrColorspace;
   if (jpeg_info.out_color_space == JCS_CMYK)
@@ -1105,10 +1105,10 @@
   if ((jpeg_info.output_components == 1) &&
       (jpeg_info.quantize_colors == MagickFalse))
     {
-      unsigned long
+      size_t
         colors;
 
-      colors=(unsigned long) GetQuantumRange(image->depth)+1;
+      colors=(size_t) GetQuantumRange(image->depth)+1;
       if (AcquireImageColormap(image,colors) == MagickFalse)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     }
@@ -1127,7 +1127,7 @@
     }
   JPEGSetImageQuality(&jpeg_info,image);
   JPEGSetImageSamplingFactor(&jpeg_info,image);
-  (void) FormatMagickString(value,MaxTextExtent,"%ld",(long)
+  (void) FormatMagickString(value,MaxTextExtent,"%ld",(ssize_t)
     jpeg_info.out_color_space);
   (void) SetImageProperty(image,"jpeg:colorspace",value);
   if (image_info->ping != MagickFalse)
@@ -1156,9 +1156,9 @@
     }
   if (jpeg_info.quantize_colors != MagickFalse)
     {
-      image->colors=(unsigned long) jpeg_info.actual_number_of_colors;
+      image->colors=(size_t) jpeg_info.actual_number_of_colors;
       if (jpeg_info.out_color_space == JCS_GRAYSCALE)
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
           image->colormap[i].green=image->colormap[i].red;
@@ -1166,7 +1166,7 @@
           image->colormap[i].opacity=OpaqueOpacity;
         }
       else
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
           image->colormap[i].green=ScaleCharToQuantum(jpeg_info.colormap[1][i]);
@@ -1175,12 +1175,12 @@
         }
     }
   scanline[0]=(JSAMPROW) jpeg_pixels;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1200,15 +1200,15 @@
     if (jpeg_info.data_precision > 8)
       {
         if (jpeg_info.output_components == 1)
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
-            unsigned long
+            size_t
               pixel;
 
             if (precision != 16)
-              pixel=(unsigned long) GETJSAMPLE(*p);
+              pixel=(size_t) GETJSAMPLE(*p);
             else
-              pixel=(unsigned long) ((GETJSAMPLE(*p) ^ 0x80) << 4);
+              pixel=(size_t) ((GETJSAMPLE(*p) ^ 0x80) << 4);
             index=ConstrainColormapIndex(image,pixel);
             indexes[x]=index;
             *q++=image->colormap[(int) index];
@@ -1216,7 +1216,7 @@
           }
         else
           if (image->colorspace != CMYKColorspace)
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               q->red=ScaleShortToQuantum((unsigned char)
                 (GETJSAMPLE(*p++) << 4));
@@ -1228,7 +1228,7 @@
               q++;
             }
           else
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               q->red=(Quantum) QuantumRange-ScaleShortToQuantum((unsigned char)
                 (GETJSAMPLE(*p++) << 4));
@@ -1244,16 +1244,16 @@
       }
     else
       if (jpeg_info.output_components == 1)
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
-          index=ConstrainColormapIndex(image,(unsigned long) GETJSAMPLE(*p));
+          index=ConstrainColormapIndex(image,(size_t) GETJSAMPLE(*p));
           indexes[x]=(IndexPacket) index;
           *q++=image->colormap[(int) index];
           p++;
         }
       else
         if (image->colorspace != CMYKColorspace)
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum((unsigned char) GETJSAMPLE(*p++));
             q->green=ScaleCharToQuantum((unsigned char) GETJSAMPLE(*p++));
@@ -1262,7 +1262,7 @@
             q++;
           }
         else
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=(Quantum) QuantumRange-ScaleCharToQuantum((unsigned char)
               GETJSAMPLE(*p++));
@@ -1311,10 +1311,10 @@
 %
 %  The format of the RegisterJPEGImage method is:
 %
-%      unsigned long RegisterJPEGImage(void)
+%      size_t RegisterJPEGImage(void)
 %
 */
-ModuleExport unsigned long RegisterJPEGImage(void)
+ModuleExport size_t RegisterJPEGImage(void)
 {
   char
     version[MaxTextExtent];
@@ -1487,7 +1487,7 @@
   MagickBooleanType
     iptc;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1496,7 +1496,7 @@
   StringInfo
     *custom_profile;
 
-  unsigned long
+  size_t
     tag_length;
 
   /*
@@ -1509,7 +1509,7 @@
   {
     profile=GetImageProfile(image,name);
     if (LocaleCompare(name,"EXIF") == 0)
-      for (i=0; i < (long) GetStringInfoLength(profile); i+=65533L)
+      for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65533L)
       {
         length=MagickMin(GetStringInfoLength(profile)-i,65533L);
         jpeg_write_marker(jpeg_info,XML_MARKER,GetStringInfoDatum(profile)+i,
@@ -1523,7 +1523,7 @@
         tag_length=14;
         p=GetStringInfoDatum(custom_profile);
         (void) CopyMagickMemory(p,ICC_PROFILE,tag_length);
-        for (i=0; i < (long) GetStringInfoLength(profile); i+=65519L)
+        for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65519L)
         {
           length=MagickMin(GetStringInfoLength(profile)-i,65519L);
           p=GetStringInfoDatum(custom_profile);
@@ -1541,7 +1541,7 @@
         register unsigned char
           *p;
 
-        unsigned long
+        size_t
           roundup;
 
         iptc=MagickTrue;
@@ -1559,10 +1559,10 @@
             p[25]=(unsigned char) (GetStringInfoLength(profile) & 0xff);
             tag_length=26;
           }
-        for (i=0; i < (long) GetStringInfoLength(profile); i+=65500L)
+        for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=65500L)
         {
           length=MagickMin(GetStringInfoLength(profile)-i,65500L);
-          roundup=(unsigned long) (length & 0x01);
+          roundup=(size_t) (length & 0x01);
           (void) CopyMagickMemory(p+tag_length,GetStringInfoDatum(profile)+i,
             length);
           if (roundup != 0)
@@ -1582,7 +1582,7 @@
         xmp_profile=StringToStringInfo("http://ns.adobe.com/xap/1.0/");
         ConcatenateStringInfo(xmp_profile,profile);
         GetStringInfoDatum(xmp_profile)[28]='\0';
-        for (i=0; i < (long) GetStringInfoLength(xmp_profile); i+=65533L)
+        for (i=0; i < (ssize_t) GetStringInfoLength(xmp_profile); i+=65533L)
         {
           length=MagickMin(GetStringInfoLength(xmp_profile)-i,65533L);
           jpeg_write_marker(jpeg_info,XML_MARKER,
@@ -1591,7 +1591,7 @@
         xmp_profile=DestroyStringInfo(xmp_profile);
       }
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),"%s profile: %lu bytes",
-      name,(unsigned long) GetStringInfoLength(profile));
+      name,(size_t) GetStringInfoLength(profile));
     name=GetNextImageProfile(image);
   }
   custom_profile=DestroyStringInfo(custom_profile);
@@ -1622,10 +1622,10 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     lines;
 
   if (text == (char *) NULL)
@@ -1642,7 +1642,7 @@
   if (textlist == (char **) NULL)
     ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
   p=text;
-  for (i=0; i < (long) lines; i++)
+  for (i=0; i < (ssize_t) lines; i++)
   {
     for (q=(char *) p; *q != '\0'; q++)
       if (*q == ',')
@@ -1677,7 +1677,7 @@
   JSAMPROW
     scanline[1];
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1686,7 +1686,7 @@
   register JSAMPLE
     *q;
 
-  register long
+  register ssize_t
     i;
 
   struct jpeg_compress_struct
@@ -1780,8 +1780,8 @@
   jpeg_info.density_unit=(UINT8) 1;
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-      "Image resolution: %ld,%ld",(long) floor(image->x_resolution+0.5),
-      (long) floor(image->y_resolution+0.5));
+      "Image resolution: %ld,%ld",(ssize_t) floor(image->x_resolution+0.5),
+      (ssize_t) floor(image->y_resolution+0.5));
   if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
     {
       /*
@@ -2138,7 +2138,7 @@
   */
   value=GetImageProperty(image,"comment");
   if (value != (char *) NULL)
-    for (i=0; i < (long) strlen(value); i+=65533L)
+    for (i=0; i < (ssize_t) strlen(value); i+=65533L)
       jpeg_write_marker(&jpeg_info,JPEG_COM,(unsigned char *) value+i,
         (unsigned int) MagickMin((size_t) strlen(value+i),65533L));
   if (image->profiles != (void *) NULL)
@@ -2163,19 +2163,19 @@
     {
       if ((jpeg_info.in_color_space == JCS_RGB) ||
           (jpeg_info.in_color_space == JCS_YCbCr))
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           q=jpeg_pixels;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q++=(JSAMPLE) ScaleQuantumToChar(GetRedPixelComponent(p));
             *q++=(JSAMPLE) ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -2188,19 +2188,19 @@
         }
       else
         if (jpeg_info.in_color_space == JCS_GRAYSCALE)
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register const PixelPacket
               *p;
 
-            register long
+            register ssize_t
               x;
 
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
               break;
             q=jpeg_pixels;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               *q++=(JSAMPLE) ScaleQuantumToChar(PixelIntensityToQuantum(p));
               p++;
@@ -2210,7 +2210,7 @@
               break;
           }
         else
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register const IndexPacket
               *indexes;
@@ -2218,7 +2218,7 @@
             register const PixelPacket
               *p;
 
-            register long
+            register ssize_t
               x;
 
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -2226,7 +2226,7 @@
               break;
             q=jpeg_pixels;
             indexes=GetVirtualIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               /*
                 Convert DirectClass packets to contiguous CMYK scanlines.
@@ -2248,19 +2248,19 @@
     }
   else
     if (jpeg_info.in_color_space == JCS_GRAYSCALE)
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         register const PixelPacket
           *p;
 
-        register long
+        register ssize_t
           x;
 
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
         q=jpeg_pixels;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           *q++=(JSAMPLE) (ScaleQuantumToShort(PixelIntensityToQuantum(p)) >>
             4);
@@ -2273,19 +2273,19 @@
     else
       if ((jpeg_info.in_color_space == JCS_RGB) ||
           (jpeg_info.in_color_space == JCS_YCbCr))
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           q=jpeg_pixels;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q++=(JSAMPLE) (ScaleQuantumToShort(GetRedPixelComponent(p)) >>
               4);
@@ -2301,7 +2301,7 @@
             break;
         }
       else
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const IndexPacket
             *indexes;
@@ -2309,7 +2309,7 @@
           register const PixelPacket
             *p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -2317,7 +2317,7 @@
             break;
           q=jpeg_pixels;
           indexes=GetVirtualIndexQueue(image);
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             /*
               Convert DirectClass packets to contiguous CMYK scanlines.
@@ -2336,7 +2336,7 @@
           if (status == MagickFalse)
             break;
         }
-  if (y == (long) image->rows)
+  if (y == (ssize_t) image->rows)
     jpeg_finish_compress(&jpeg_info);
   /*
     Relinquish resources.
diff --git a/coders/label.c b/coders/label.c
index 84351c4..7bc3a48 100644
--- a/coders/label.c
+++ b/coders/label.c
@@ -107,7 +107,7 @@
   TypeMetric
     metrics;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -138,8 +138,8 @@
       status=GetMultilineTypeMetrics(image,draw_info,&metrics);
       for ( ; status != MagickFalse; draw_info->pointsize*=2.0)
       {
-        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+        width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(size_t) floor(metrics.height+draw_info->stroke_width+
           0.5);
         if (((image->columns != 0) && (width > (image->columns+1))) ||
             ((image->rows != 0) && (height > (image->rows+1))))
@@ -148,8 +148,8 @@
       }
       for ( ; status != MagickFalse; draw_info->pointsize--)
       {
-        width=(unsigned long) floor(metrics.width+draw_info->stroke_width+0.5);
-        height=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+        width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
+        height=(size_t) floor(metrics.height+draw_info->stroke_width+
           0.5);
         if ((image->columns != 0) && (width <= (image->columns+1)) &&
            ((image->rows == 0) || (height <= (image->rows+1))))
@@ -170,9 +170,9 @@
       return((Image *) NULL);
     }
   if (image->columns == 0)
-    image->columns=(unsigned long) (metrics.width+draw_info->stroke_width+1.5);
+    image->columns=(size_t) (metrics.width+draw_info->stroke_width+1.5);
   if (image->columns == 0)
-    image->columns=(unsigned long) (draw_info->pointsize+
+    image->columns=(size_t) (draw_info->pointsize+
       draw_info->stroke_width+1.5);
   if (draw_info->gravity == UndefinedGravity)
     {
@@ -182,10 +182,10 @@
       draw_info->geometry=AcquireString(geometry);
     }
   if (image->rows == 0)
-    image->rows=(unsigned long) floor(metrics.height+draw_info->stroke_width+
+    image->rows=(size_t) floor(metrics.height+draw_info->stroke_width+
       0.5);
   if (image->rows == 0)
-    image->rows=(unsigned long) floor(draw_info->pointsize+
+    image->rows=(size_t) floor(draw_info->pointsize+
       draw_info->stroke_width+0.5);
   if (SetImageBackgroundColor(image) == MagickFalse)
     {
@@ -218,10 +218,10 @@
 %
 %  The format of the RegisterLABELImage method is:
 %
-%      unsigned long RegisterLABELImage(void)
+%      size_t RegisterLABELImage(void)
 %
 */
-ModuleExport unsigned long RegisterLABELImage(void)
+ModuleExport size_t RegisterLABELImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/magick.c b/coders/magick.c
index 471d050..d6aa55e 100644
--- a/coders/magick.c
+++ b/coders/magick.c
@@ -5545,7 +5545,7 @@
   ImageInfo
     *blob_info;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -5593,10 +5593,10 @@
 %
 %  The format of the RegisterMAGICKImage method is:
 %
-%      unsigned long RegisterMAGICKImage(void)
+%      size_t RegisterMAGICKImage(void)
 %
 */
-ModuleExport unsigned long RegisterMAGICKImage(void)
+ModuleExport size_t RegisterMAGICKImage(void)
 {
   MagickInfo
     *entry;
@@ -5726,7 +5726,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   void
@@ -5772,7 +5772,7 @@
   (void) WriteBlobString(image,"  {\n");
   (void) WriteBlobString(image,"    ");
   p=(char *) blob;
-  for (i=0; i < (long) length ; i++)
+  for (i=0; i < (ssize_t) length ; i++)
   {
     (void) FormatMagickString(buffer,MaxTextExtent,"0x%02X, ",*p & 0xff);
     (void) WriteBlobString(image,buffer);
diff --git a/coders/map.c b/coders/map.c
index a5b43d7..ee3335d 100644
--- a/coders/map.c
+++ b/coders/map.c
@@ -103,7 +103,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -112,13 +112,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -134,7 +134,7 @@
     *colormap,
     *pixels;
 
-  unsigned long
+  size_t
     depth,
     quantum;
 
@@ -161,7 +161,7 @@
     Initialize image structure.
   */
   image->storage_class=PseudoClass;
-  status=AcquireImageColormap(image,(unsigned long)
+  status=AcquireImageColormap(image,(size_t)
     (image->offset != 0 ? image->offset : 256));
   if (status == MagickFalse)
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
@@ -183,14 +183,14 @@
     ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
   p=colormap;
   if (image->depth <= 8)
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       image->colormap[i].red=ScaleCharToQuantum(*p++);
       image->colormap[i].green=ScaleCharToQuantum(*p++);
       image->colormap[i].blue=ScaleCharToQuantum(*p++);
     }
   else
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       quantum=(*p++ << 8);
       quantum|=(*p++);
@@ -212,7 +212,7 @@
     Read image pixels.
   */
   packet_size=(size_t) (depth/8);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=pixels;
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
@@ -222,23 +222,23 @@
     count=ReadBlob(image,(size_t) packet_size*image->columns,pixels);
     if (count != (ssize_t) (packet_size*image->columns))
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       index=ConstrainColormapIndex(image,*p);
       p++;
       if (image->colors > 256)
         {
-          index=ConstrainColormapIndex(image,((unsigned long) index << 8)+(*p));
+          index=ConstrainColormapIndex(image,((size_t) index << 8)+(*p));
           p++;
         }
       indexes[x]=(IndexPacket) index;
-      *q++=image->colormap[(long) index];
+      *q++=image->colormap[(ssize_t) index];
     }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
   }
   pixels=(unsigned char *) RelinquishMagickMemory(pixels);
-  if (y < (long) image->rows)
+  if (y < (ssize_t) image->rows)
     ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
       image->filename);
   (void) CloseBlob(image);
@@ -265,10 +265,10 @@
 %
 %  The format of the RegisterMAPImage method is:
 %
-%      unsigned long RegisterMAPImage(void)
+%      size_t RegisterMAPImage(void)
 %
 */
-ModuleExport unsigned long RegisterMAPImage(void)
+ModuleExport size_t RegisterMAPImage(void)
 {
   MagickInfo
     *entry;
@@ -338,7 +338,7 @@
 */
 static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -350,7 +350,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -364,7 +364,7 @@
     *colormap,
     *pixels;
 
-  unsigned long
+  size_t
     depth;
 
   /*
@@ -401,20 +401,20 @@
   */
   q=colormap;
   if (image->depth <= 8)
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       *q++=(unsigned char) image->colormap[i].red;
       *q++=(unsigned char) image->colormap[i].green;
       *q++=(unsigned char) image->colormap[i].blue;
     }
   else
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
-      *q++=(unsigned char) ((unsigned long) image->colormap[i].red >> 8);
+      *q++=(unsigned char) ((size_t) image->colormap[i].red >> 8);
       *q++=(unsigned char) image->colormap[i].red;
-      *q++=(unsigned char) ((unsigned long) image->colormap[i].green >> 8);
+      *q++=(unsigned char) ((size_t) image->colormap[i].green >> 8);
       *q++=(unsigned char) image->colormap[i].green;
-      *q++=(unsigned char) ((unsigned long) image->colormap[i].blue >> 8);
+      *q++=(unsigned char) ((size_t) image->colormap[i].blue >> 8);
       *q++=(unsigned char) image->colormap[i].blue;
     }
   (void) WriteBlob(image,packet_size*image->colors,colormap);
@@ -422,17 +422,17 @@
   /*
     Write image pixels to file.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
     q=pixels;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (image->colors > 256)
-        *q++=(unsigned char) ((unsigned long) indexes[x] >> 8);
+        *q++=(unsigned char) ((size_t) indexes[x] >> 8);
       *q++=(unsigned char) indexes[x];
     }
     (void) WriteBlob(image,(size_t) (q-pixels),pixels);
diff --git a/coders/mat.c b/coders/mat.c
index cb45bd0..7106691 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -92,20 +92,20 @@
   char identific[124];
   unsigned short Version;
   char EndianIndicator[2];
-  unsigned long DataType;
-  unsigned long ObjectSize;
-  unsigned long unknown1;
-  unsigned long unknown2;
+  size_t DataType;
+  size_t ObjectSize;
+  size_t unknown1;
+  size_t unknown2;
 
   unsigned short unknown5;
   unsigned char StructureFlag;
   unsigned char StructureClass;
-  unsigned long unknown3;
-  unsigned long unknown4;
-  unsigned long DimFlag;
+  size_t unknown3;
+  size_t unknown4;
+  size_t DimFlag;
 
-  unsigned long SizeX;
-  unsigned long SizeY;
+  size_t SizeX;
+  size_t SizeY;
   unsigned short Flag1;
   unsigned short NameFlag;
 }
@@ -192,7 +192,7 @@
   q = QueueAuthenticPixels(image, 0, y, image->columns, 1,exception);
   if (q == (PixelPacket *) NULL)
     return;
-  for (x = 0; x < (long) image->columns; x++)
+  for (x = 0; x < (ssize_t) image->columns; x++)
   {
     if (*p > 0)
     {
@@ -246,7 +246,7 @@
   q = QueueAuthenticPixels(image, 0, y, image->columns, 1,exception);
   if (q == (PixelPacket *) NULL)
     return;
-  for (x = 0; x < (long) image->columns; x++)
+  for (x = 0; x < (ssize_t) image->columns; x++)
   {
     if (*p > 0)
     {
@@ -330,7 +330,7 @@
 }
 
 /* Calculate minimum and maximum from a given block of data */
-static void CalcMinMax(Image *image, int endian_indicator, int SizeX, int SizeY, unsigned long CellType, unsigned ldblk, void *BImgBuff, double *Min, double *Max)
+static void CalcMinMax(Image *image, int endian_indicator, int SizeX, int SizeY, size_t CellType, unsigned ldblk, void *BImgBuff, double *Min, double *Max)
 {
 MagickOffsetType filepos;
 int i, x;
@@ -378,7 +378,7 @@
       {
         *Min = *Max = *fltrow;
       }
-    for (x = 0; x < (long) SizeX; x++)
+    for (x = 0; x < (ssize_t) SizeX; x++)
       {
         if (*Min > *fltrow)
           *Min = *fltrow;
@@ -588,15 +588,15 @@
 
   unsigned int status;
   MATHeader MATLAB_HDR;
-  unsigned long size;  
-  unsigned long CellType;
+  size_t size;  
+  size_t CellType;
   QuantumInfo *quantum_info;
   ImageInfo *clone_info;
   int i;
-  long ldblk;
+  ssize_t ldblk;
   unsigned char *BImgBuff = NULL;
   double MinVal, MaxVal;
-  unsigned long Unknown6;
+  size_t Unknown6;
   unsigned z;
   int logging;
   int sample_size;
@@ -732,7 +732,7 @@
     {
       case 0:
         size = ReadBlobXXXLong(image2);  /* Object name string size */
-        size = 4 * (long) ((size + 3 + 1) / 4);
+        size = 4 * (ssize_t) ((size + 3 + 1) / 4);
         (void) SeekBlob(image2, size, SEEK_CUR);
         break;
       case 1:
@@ -765,25 +765,25 @@
           image->depth = 1;
         else
           image->depth = 8;         /* Byte type cell */
-        ldblk = (long) MATLAB_HDR.SizeX;      
+        ldblk = (ssize_t) MATLAB_HDR.SizeX;      
         break;
       case miINT16:
       case miUINT16:
         sample_size = 16;
         image->depth = 16;        /* Word type cell */
-        ldblk = (long) (2 * MATLAB_HDR.SizeX);
+        ldblk = (ssize_t) (2 * MATLAB_HDR.SizeX);
         break;
       case miINT32:
       case miUINT32:
         sample_size = 32;
         image->depth = 32;        /* Dword type cell */
-        ldblk = (long) (4 * MATLAB_HDR.SizeX);      
+        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);      
         break;
       case miINT64:
       case miUINT64:
         sample_size = 64;
         image->depth = 64;        /* Qword type cell */
-        ldblk = (long) (8 * MATLAB_HDR.SizeX);      
+        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);      
         break;   
       case miSINGLE:
         sample_size = 32;
@@ -792,7 +792,7 @@
         if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
   {              /* complex float type cell */
   }
-        ldblk = (long) (4 * MATLAB_HDR.SizeX);
+        ldblk = (ssize_t) (4 * MATLAB_HDR.SizeX);
         break;
       case miDOUBLE:
         sample_size = 64; 
@@ -803,7 +803,7 @@
         if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
   {                         /* complex double type cell */        
   }
-        ldblk = (long) (8 * MATLAB_HDR.SizeX);
+        ldblk = (ssize_t) (8 * MATLAB_HDR.SizeX);
         break;
       default:
         ThrowReaderException(CoderError, "UnsupportedCellTypeInTheMatrix");
@@ -834,7 +834,7 @@
     */
     if (image_info->ping)
     {
-      unsigned long temp = image->columns;
+      size_t temp = image->columns;
       image->columns = image->rows;
       image->rows = temp;
       goto done_reading; /* !!!!!! BAD  !!!! */
@@ -857,7 +857,7 @@
     /* else read color scanlines */
     do
     {
-      for (i = 0; i < (long) MATLAB_HDR.SizeY; i++)
+      for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
       {
         q=QueueAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception);
         if (q == (PixelPacket *)NULL)
@@ -917,14 +917,14 @@
       }
 
       if (CellType==miDOUBLE)
-        for (i = 0; i < (long) MATLAB_HDR.SizeY; i++)
+        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
   {
           ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff);
           InsertComplexDoubleRow((double *)BImgBuff, i, image, MinVal, MaxVal);
   }
 
       if (CellType==miSINGLE)
-        for (i = 0; i < (long) MATLAB_HDR.SizeY; i++)
+        for (i = 0; i < (ssize_t) MATLAB_HDR.SizeY; i++)
   {
           ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff);
           InsertComplexFloatRow((float *)BImgBuff, i, image, MinVal, MaxVal);
@@ -981,7 +981,7 @@
     image->columns=image->rows=0;
     image->colors=0;    
 
-      /* row scan buffer is no longer needed */
+      /* row scan buffer is no ssize_ter needed */
     RelinquishMagickMemory(BImgBuff);
     BImgBuff = NULL;
   }
@@ -993,7 +993,7 @@
 
   {
     Image *p;    
-    long scene=0;
+    ssize_t scene=0;
     
     /*
       Rewind list, removing any empty images while rewinding.
@@ -1056,10 +1056,10 @@
 %
 %  The format of the RegisterMATImage method is:
 %
-%      unsigned long RegisterMATImage(void)
+%      size_t RegisterMATImage(void)
 %
 */
-ModuleExport unsigned long RegisterMATImage(void)
+ModuleExport size_t RegisterMATImage(void)
 {
   MagickInfo
     *entry;
@@ -1132,13 +1132,13 @@
   ExceptionInfo
     *exception;
 
-  long y;
+  ssize_t y;
   unsigned z;
   const PixelPacket *p;
 
   unsigned int status;
   int logging;
-  unsigned long DataSize;
+  size_t DataSize;
   char padding;
   char MATLAB_HDR[0x80];
   time_t current_time;
@@ -1228,7 +1228,7 @@
     pixels=GetQuantumPixels(quantum_info);
     do
     {
-      for (y=0; y < (long)image->columns; y++)
+      for (y=0; y < (ssize_t)image->columns; y++)
       {
         p=GetVirtualPixels(image,y,0,1,image->rows,&image->exception);
         if (p == (const PixelPacket *) NULL)
diff --git a/coders/matte.c b/coders/matte.c
index 1c1983b..c7e4783 100644
--- a/coders/matte.c
+++ b/coders/matte.c
@@ -83,10 +83,10 @@
 %
 %  The format of the RegisterMATTEImage method is:
 %
-%      unsigned long RegisterMATTEImage(void)
+%      size_t RegisterMATTEImage(void)
 %
 */
-ModuleExport unsigned long RegisterMATTEImage(void)
+ModuleExport size_t RegisterMATTEImage(void)
 {
   MagickInfo
     *entry;
@@ -159,7 +159,7 @@
   Image
     *matte_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -168,7 +168,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -186,13 +186,13 @@
     Convert image to matte pixels.
   */
   exception=(&image->exception);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     q=QueueAuthenticPixels(matte_image,0,y,matte_image->columns,1,exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=GetOpacityPixelComponent(p);
       q->green=GetOpacityPixelComponent(p);
diff --git a/coders/meta.c b/coders/meta.c
index 8f6ac7e..f48eefb 100644
--- a/coders/meta.c
+++ b/coders/meta.c
@@ -162,7 +162,7 @@
 
 static int stringnicmp(const char *p,const char *q,size_t n)
 {
-  register long
+  register ssize_t
     i,
     j;
 
@@ -288,7 +288,7 @@
 #define IPTC_ID 1028
 #define THUMBNAIL_ID 1033
 
-static long parse8BIM(Image *ifile, Image *ofile)
+static ssize_t parse8BIM(Image *ifile, Image *ofile)
 {
   char
     brkused,
@@ -311,7 +311,7 @@
   int
     inputlen = BUFFER_SZ;
 
-  long
+  ssize_t
     savedolen = 0L,
     outputlen = 0L;
 
@@ -380,7 +380,7 @@
             int
               next;
 
-            long
+            ssize_t
               len;
 
             char
@@ -388,7 +388,7 @@
               quoted;
 
             next=0;
-            len = (long) strlen(token);
+            len = (ssize_t) strlen(token);
             while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,"","&",
               "",0,&brkused,&next,&quoted)==0)
             {
@@ -397,7 +397,7 @@
                   char
                     *s = &token[next-1];
 
-                  len -= (long) convertHTMLcodes(s,(int) strlen(s));
+                  len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));
                 }
             }
 
@@ -414,12 +414,12 @@
                     MagickOffsetType
                       offset;
 
-                    long diff = outputlen - savedolen;
+                    ssize_t diff = outputlen - savedolen;
                     currentpos = TellBlob(ofile);
                     offset=SeekBlob(ofile,savedpos,SEEK_SET);
                     if (offset < 0)
                       return(-1);
-                    (void) WriteBlobMSBLong(ofile,(unsigned long) diff);
+                    (void) WriteBlobMSBLong(ofile,(size_t) diff);
                     offset=SeekBlob(ofile,currentpos,SEEK_SET);
                     if (offset < 0)
                       return(-1);
@@ -447,7 +447,7 @@
                   }
                 if (recnum != IPTC_ID)
                   {
-                    (void) WriteBlobMSBLong(ofile, (unsigned long) len);
+                    (void) WriteBlobMSBLong(ofile, (size_t) len);
                     outputlen += 4;
 
                     next=0;
@@ -500,13 +500,13 @@
       MagickOffsetType
         offset;
 
-      long diff = outputlen - savedolen;
+      ssize_t diff = outputlen - savedolen;
 
       currentpos = TellBlob(ofile);
       offset=SeekBlob(ofile,savedpos,SEEK_SET);
       if (offset < 0)
         return(-1);
-      (void) WriteBlobMSBLong(ofile,(unsigned long) diff);
+      (void) WriteBlobMSBLong(ofile,(size_t) diff);
       offset=SeekBlob(ofile,currentpos,SEEK_SET);
       if (offset < 0)
         return(-1);
@@ -564,7 +564,7 @@
   return((char *) p);
 }
 
-static long parse8BIMW(Image *ifile, Image *ofile)
+static ssize_t parse8BIMW(Image *ifile, Image *ofile)
 {
   char
     brkused,
@@ -587,7 +587,7 @@
   int
     inputlen = BUFFER_SZ;
 
-  long
+  ssize_t
     savedolen = 0L,
     outputlen = 0L;
 
@@ -656,7 +656,7 @@
             int
               next;
 
-            long
+            ssize_t
               len;
 
             char
@@ -664,7 +664,7 @@
               quoted;
 
             next=0;
-            len = (long) strlen(token);
+            len = (ssize_t) strlen(token);
             while (Tokenizer(token_info,0,newstr,(size_t) inputlen,token,"","&",
               "",0,&brkused,&next,&quoted)==0)
             {
@@ -673,7 +673,7 @@
                   char
                     *s = &token[next-1];
 
-                  len -= (long) convertHTMLcodes(s,(int) strlen(s));
+                  len -= (ssize_t) convertHTMLcodes(s,(int) strlen(s));
                 }
             }
 
@@ -690,12 +690,12 @@
                     MagickOffsetType
                       offset;
 
-                    long diff = outputlen - savedolen;
+                    ssize_t diff = outputlen - savedolen;
                     currentpos = TellBlob(ofile);
                     offset=SeekBlob(ofile,savedpos,SEEK_SET);
                     if (offset < 0)
                       return(-1);
-                    (void) WriteBlobMSBLong(ofile,(unsigned long) diff);
+                    (void) WriteBlobMSBLong(ofile,(size_t) diff);
                     offset=SeekBlob(ofile,currentpos,SEEK_SET);
                     if (offset < 0)
                       return(-1);
@@ -723,7 +723,7 @@
                   }
                 if (recnum != IPTC_ID)
                   {
-                    (void) WriteBlobMSBLong(ofile,(unsigned long) len);
+                    (void) WriteBlobMSBLong(ofile,(size_t) len);
                     outputlen += 4;
 
                     next=0;
@@ -775,13 +775,13 @@
       MagickOffsetType
         offset;
 
-      long diff = outputlen - savedolen;
+      ssize_t diff = outputlen - savedolen;
 
       currentpos = TellBlob(ofile);
       offset=SeekBlob(ofile,savedpos,SEEK_SET);
       if (offset < 0)
         return(-1);
-      (void) WriteBlobMSBLong(ofile,(unsigned long) diff);
+      (void) WriteBlobMSBLong(ofile,(size_t) diff);
       offset=SeekBlob(ofile,currentpos,SEEK_SET);
       if (offset < 0)
         return(-1);
@@ -1222,7 +1222,7 @@
             (void) WriteBlobByte(buff,c);
           }
 #else
-          long
+          ssize_t
             i;
 
           unsigned char
@@ -1240,13 +1240,13 @@
               while ((length=ReadBlob(image,MagickMaxBufferExtent,buffer)) != 0)
               {
                 count=0;
-                for (i=0; i < (long) length; i+=count)
+                for (i=0; i < (ssize_t) length; i+=count)
                 {
                   count=WriteBlob(buff,(size_t) (length-i),buffer+i);
                   if (count <= 0)
                     break;
                 }
-                if (i < (long) length)
+                if (i < (ssize_t) length)
                   break;
               }
               buffer=(unsigned char *) RelinquishMagickMemory(buffer);
@@ -1394,10 +1394,10 @@
 %
 %  The format of the RegisterMETAImage method is:
 %
-%      unsigned long RegisterMETAImage(void)
+%      size_t RegisterMETAImage(void)
 %
 */
-ModuleExport unsigned long RegisterMETAImage(void)
+ModuleExport size_t RegisterMETAImage(void)
 {
   MagickInfo
     *entry;
@@ -1593,7 +1593,7 @@
   int
     c;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -1609,7 +1609,7 @@
   unsigned int
     marker;
 
-  unsigned long
+  size_t
     tag_length;
 
   p=(*info);
@@ -1637,8 +1637,8 @@
     extent-=c;
     if (extent < 4)
       break;
-    tag_length=(((unsigned long) *p) << 24) | (((unsigned long) *(p+1)) << 16) |
-      (((unsigned long) *(p+2)) << 8) | ((unsigned long) *(p+3));
+    tag_length=(((size_t) *p) << 24) | (((size_t) *(p+1)) << 16) |
+      (((size_t) *(p+2)) << 8) | ((size_t) *(p+3));
     p+=4;
     extent-=4;
     if (tag_length > extent)
@@ -1709,7 +1709,7 @@
       goto iptc_find;
     info_length++;
     /*
-      Decode the length of the block that follows - long or short format.
+      Decode the length of the block that follows - ssize_t or short format.
     */
     c=(*p++);
     length--;
@@ -1726,13 +1726,13 @@
             break;
           info_length++;
         }
-        tag_length=(((unsigned long) buffer[0]) << 24) |
-          (((unsigned long) buffer[1]) << 16) |
-          (((unsigned long) buffer[2]) << 8) | (((unsigned long) buffer[3])); 
+        tag_length=(((size_t) buffer[0]) << 24) |
+          (((size_t) buffer[1]) << 16) |
+          (((size_t) buffer[2]) << 8) | (((size_t) buffer[3])); 
       }
     else
       {
-        tag_length=(unsigned long) (c << 8);
+        tag_length=(size_t) (c << 8);
         c=(*p++);
         length--;
         if (length == 0)
@@ -1878,7 +1878,7 @@
     *readable,
     *str;
 
-  long
+  ssize_t
     tagindx,
     taglen;
 
@@ -1923,7 +1923,7 @@
     else
       readable = (unsigned char *) "";
     /*
-      We decode the length of the block that follows - long or short fmt.
+      We decode the length of the block that follows - ssize_t or short fmt.
     */
     c=ReadBlobByte(ifile);
     if (c == EOF) return -1;
@@ -1973,7 +1973,7 @@
   return((int) tagsfound);
 }
 
-static int readWordFromBuffer(char **s, long *len)
+static int readWordFromBuffer(char **s, ssize_t *len)
 {
   unsigned char
     buffer[2];
@@ -1992,7 +1992,7 @@
          (((int) buffer[ 1 ]));
 }
 
-static int formatIPTCfromBuffer(Image *ofile, char *s, long len)
+static int formatIPTCfromBuffer(Image *ofile, char *s, ssize_t len)
 {
   char
     temp[MaxTextExtent];
@@ -2009,7 +2009,7 @@
     *readable,
     *str;
 
-  long
+  ssize_t
     tagindx,
     taglen;
 
@@ -2053,7 +2053,7 @@
     else
       readable=(unsigned char *) "";
     /*
-      We decode the length of the block that follows - long or short fmt.
+      We decode the length of the block that follows - ssize_t or short fmt.
     */
     c=(*s++);
     len--;
@@ -2196,7 +2196,7 @@
         printf("MemoryAllocationFailed");
         return 0;
       }
-    for (i=0; i < (long) count; i++)
+    for (i=0; i < (ssize_t) count; i++)
     {
       c=ReadBlobByte(ifile);
       if (c == EOF)
@@ -2221,10 +2221,10 @@
         if (ID == IPTC_ID)
           {
             formatString(ofile, "IPTC", 4);
-            formatIPTCfromBuffer(ofile, (char *)str, (long) count);
+            formatIPTCfromBuffer(ofile, (char *)str, (ssize_t) count);
           }
         else
-          formatString(ofile, (char *)str, (long) count);
+          formatString(ofile, (char *)str, (ssize_t) count);
       }
     str=(unsigned char *) RelinquishMagickMemory(str);
     PString=(unsigned char *) RelinquishMagickMemory(PString);
diff --git a/coders/miff.c b/coders/miff.c
index fb65ca4..b4d4cd7 100644
--- a/coders/miff.c
+++ b/coders/miff.c
@@ -214,7 +214,7 @@
           (void) ThrowMagickException(&image->exception,GetMagickModule(),
             CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
-      *pixel=image->colormap[(long) *index];
+      *pixel=image->colormap[(ssize_t) *index];
       switch (image->depth)
       {
         case 8:
@@ -244,7 +244,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             quantum;
 
           if (image->matte != MagickFalse)
@@ -316,7 +316,7 @@
     }
     case 32:
     {
-      unsigned long
+      size_t
         quantum;
 
       p=PushLongPixel(MSBEndian,p,&quantum);
@@ -402,7 +402,7 @@
   LinkedListInfo
     *profiles;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -423,7 +423,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -437,7 +437,7 @@
     *compress_pixels,
     *pixels;
 
-  unsigned long
+  size_t
     colors;
 
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
@@ -613,7 +613,7 @@
               {
                 if (LocaleCompare(keyword,"class") == 0)
                   {
-                    long
+                    ssize_t
                       storage_class;
 
                     storage_class=ParseMagickOption(MagickClassOptions,
@@ -630,7 +630,7 @@
                   }
                 if (LocaleCompare(keyword,"colorspace") == 0)
                   {
-                    long
+                    ssize_t
                       colorspace;
 
                     colorspace=ParseMagickOption(MagickColorspaceOptions,
@@ -642,7 +642,7 @@
                   }
                 if (LocaleCompare(keyword,"compression") == 0)
                   {
-                    long
+                    ssize_t
                       compression;
 
                     compression=ParseMagickOption(MagickCompressOptions,
@@ -675,7 +675,7 @@
                   }
                 if (LocaleCompare(keyword,"dispose") == 0)
                   {
-                    long
+                    ssize_t
                       dispose;
 
                     dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,
@@ -693,7 +693,7 @@
               {
                 if (LocaleCompare(keyword,"endian") == 0)
                   {
-                    long
+                    ssize_t
                       endian;
 
                     endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
@@ -716,7 +716,7 @@
                   }
                 if (LocaleCompare(keyword,"gravity") == 0)
                   {
-                    long
+                    ssize_t
                       gravity;
 
                     gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
@@ -760,7 +760,7 @@
               {
                 if (LocaleCompare(keyword,"matte") == 0)
                   {
-                    long
+                    ssize_t
                       matte;
 
                     matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
@@ -789,7 +789,7 @@
               {
                 if (LocaleCompare(keyword,"opaque") == 0)
                   {
-                    long
+                    ssize_t
                       matte;
 
                     matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
@@ -801,7 +801,7 @@
                   }
                 if (LocaleCompare(keyword,"orientation") == 0)
                   {
-                    long
+                    ssize_t
                       orientation;
 
                     orientation=ParseMagickOption(MagickOrientationOptions,
@@ -856,7 +856,7 @@
                 if ((LocaleCompare(keyword,"quantum-format") == 0) ||
                     (LocaleCompare(keyword,"quantum:format") == 0))
                   {
-                    long
+                    ssize_t
                       format;
 
                     format=ParseMagickOption(MagickQuantumFormatOptions,
@@ -884,7 +884,7 @@
                   }
                 if (LocaleCompare(keyword,"rendering-intent") == 0)
                   {
-                    long
+                    ssize_t
                       rendering_intent;
 
                     rendering_intent=ParseMagickOption(MagickIntentOptions,
@@ -942,7 +942,7 @@
                   }
                 if (LocaleCompare(keyword,"type") == 0)
                   {
-                    long
+                    ssize_t
                       type;
 
                     type=ParseMagickOption(MagickTypeOptions,MagickFalse,
@@ -960,7 +960,7 @@
               {
                 if (LocaleCompare(keyword,"units") == 0)
                   {
-                    long
+                    ssize_t
                       units;
 
                     units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
@@ -1116,7 +1116,7 @@
                 unsigned char
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushCharPixel(p,&pixel);
                   image->colormap[i].red=ScaleCharToQuantum(pixel);
@@ -1132,7 +1132,7 @@
                 unsigned short
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushShortPixel(MSBEndian,p,&pixel);
                   image->colormap[i].red=ScaleShortToQuantum(pixel);
@@ -1145,10 +1145,10 @@
               }
               case 32:
               {
-                unsigned long
+                size_t
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushLongPixel(MSBEndian,p,&pixel);
                   image->colormap[i].red=ScaleLongToQuantum(pixel);
@@ -1221,12 +1221,12 @@
     pixels=GetQuantumPixels(quantum_info);
     index=(IndexPacket) 0;
     length=0;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -1268,7 +1268,7 @@
             if (inflate(&zip_info,Z_SYNC_FLUSH) == Z_STREAM_END)
               break;
           } while (zip_info.avail_out != 0);
-          if (y == (long) (image->rows-1))
+          if (y == (ssize_t) (image->rows-1))
             {
               if (version == 0)
                 {
@@ -1320,7 +1320,7 @@
             if (BZ2_bzDecompress(&bzip_info) == BZ_STREAM_END)
               break;
           } while (bzip_info.avail_out != 0);
-          if (y == (long) (image->rows-1))
+          if (y == (ssize_t) (image->rows-1))
             {
               if (version == 0)
                 {
@@ -1350,7 +1350,7 @@
               pixel.opacity=(Quantum) TransparentOpacity;
               index=(IndexPacket) 0;
             }
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             if (length == 0)
               {
@@ -1379,7 +1379,7 @@
     SetQuantumImageType(image,quantum_type);
     quantum_info=DestroyQuantumInfo(quantum_info);
     compress_pixels=(unsigned char *) RelinquishMagickMemory(compress_pixels);
-    if (((y != (long) image->rows)) || (status == MagickFalse))
+    if (((y != (ssize_t) image->rows)) || (status == MagickFalse))
       {
         image=DestroyImageList(image);
         return((Image *) NULL);
@@ -1441,10 +1441,10 @@
 %
 %  The format of the RegisterMIFFImage method is:
 %
-%      unsigned long RegisterMIFFImage(void)
+%      size_t RegisterMIFFImage(void)
 %
 */
-ModuleExport unsigned long RegisterMIFFImage(void)
+ModuleExport size_t RegisterMIFFImage(void)
 {
   char
     version[MaxTextExtent];
@@ -1536,11 +1536,11 @@
       {
         case 32:
         {
-          *pixels++=(unsigned char) ((unsigned long) index >> 24);
-          *pixels++=(unsigned char) ((unsigned long) index >> 16);
+          *pixels++=(unsigned char) ((size_t) index >> 24);
+          *pixels++=(unsigned char) ((size_t) index >> 16);
         }
         case 16:
-          *pixels++=(unsigned char) ((unsigned long) index >> 8);
+          *pixels++=(unsigned char) ((size_t) index >> 8);
         case 8:
         {
           *pixels++=(unsigned char) index;
@@ -1554,7 +1554,7 @@
       {
         case 32:
         {
-          unsigned long
+          size_t
             value;
 
           if (image->matte != MagickFalse)
@@ -1599,7 +1599,7 @@
   {
     case 32:
     {
-      unsigned long
+      size_t
         value;
 
       value=ScaleQuantumToLong(pixel.red);
@@ -1698,7 +1698,7 @@
   int
     code;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1716,7 +1716,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1766,7 +1766,7 @@
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
       }
     if ((image->storage_class == PseudoClass) &&
-        (image->colors > (unsigned long) (GetQuantumRange(image->depth)+1)))
+        (image->colors > (size_t) (GetQuantumRange(image->depth)+1)))
       (void) SetImageStorageClass(image,DirectClass);
     if (IsGrayImage(image,&image->exception) != MagickFalse)
       {
@@ -1820,7 +1820,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,
       "class=%s  colors=%lu  matte=%s\n",MagickOptionToMnemonic(
       MagickClassOptions,image->storage_class),image->colors,
-      MagickOptionToMnemonic(MagickBooleanOptions,(long) image->matte));
+      MagickOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"columns=%lu  rows=%lu  "
       "depth=%lu\n",image->columns,image->rows,image->depth);
@@ -1983,7 +1983,7 @@
           if (profile != (StringInfo *) NULL)
             {
               (void) FormatMagickString(buffer,MaxTextExtent,"profile:%s=%lu\n",
-                name,(unsigned long) GetStringInfoLength(profile));
+                name,(size_t) GetStringInfoLength(profile));
               (void) WriteBlobString(image,buffer);
             }
           name=GetNextImageProfile(image);
@@ -2006,13 +2006,13 @@
       value=GetImageProperty(image,property);
       if (value != (const char *) NULL)
         {
-          for (i=0; i < (long) strlen(value); i++)
+          for (i=0; i < (ssize_t) strlen(value); i++)
             if (isspace((int) ((unsigned char) value[i])) != 0)
               break;
-          if (i <= (long) strlen(value))
+          if (i <= (ssize_t) strlen(value))
             (void) WriteBlobByte(image,'{');
           (void) WriteBlob(image,strlen(value),(const unsigned char *) value);
-          if (i <= (long) strlen(value))
+          if (i <= (ssize_t) strlen(value))
             (void) WriteBlobByte(image,'}');
         }
       (void) WriteBlobByte(image,'\n');
@@ -2071,7 +2071,7 @@
           Write colormap to file.
         */
         q=colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           switch (quantum_info->depth)
           {
@@ -2079,7 +2079,7 @@
               ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
             case 32:
             {
-              register unsigned long
+              register size_t
                 pixel;
 
               pixel=ScaleQuantumToLong(image->colormap[i].red);
@@ -2128,7 +2128,7 @@
     quantum_type=GetQuantumType(image,&image->exception);
     pixels=GetQuantumPixels(quantum_info);
     status=MagickTrue;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register const IndexPacket
         *restrict indexes;
@@ -2136,7 +2136,7 @@
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -2179,7 +2179,7 @@
                 (void) WriteBlob(image,length,compress_pixels);
               }
           } while (zip_info.avail_in != 0);
-          if (y == (long) (image->rows-1))
+          if (y == (ssize_t) (image->rows-1))
             {
               for ( ; ; )
               {
@@ -2235,7 +2235,7 @@
                 (void) WriteBlob(image,length,compress_pixels);
               }
           } while (bzip_info.avail_in != 0);
-          if (y == (long) (image->rows-1))
+          if (y == (ssize_t) (image->rows-1))
             {
               for ( ; ; )
               {
@@ -2265,9 +2265,9 @@
           if (indexes != (IndexPacket *) NULL)
             index=(*indexes);
           length=255;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
-            if ((length < 255) && (x < (long) (image->columns-1)) &&
+            if ((length < 255) && (x < (ssize_t) (image->columns-1)) &&
                 (IsColorEqual(p,&pixel) != MagickFalse) &&
                 ((image->matte == MagickFalse) ||
                  (p->opacity == pixel.opacity)) &&
diff --git a/coders/mono.c b/coders/mono.c
index d013c7a..cdef20e 100644
--- a/coders/mono.c
+++ b/coders/mono.c
@@ -99,7 +99,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -108,16 +108,16 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     bit,
     byte;
 
@@ -161,7 +161,7 @@
   /*
     Convert bi-level image to pixel packets.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -169,10 +169,10 @@
     indexes=GetAuthenticIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (bit == 0)
-        byte=(unsigned long) ReadBlobByte(image);
+        byte=(size_t) ReadBlobByte(image);
       if (image_info->endian == LSBEndian)
         indexes[x]=(IndexPacket) (((byte & 0x01) != 0) ? 0x00 : 0x01);
       else
@@ -216,10 +216,10 @@
 %
 %  The format of the RegisterMONOImage method is:
 %
-%      unsigned long RegisterMONOImage(void)
+%      size_t RegisterMONOImage(void)
 %
 */
-ModuleExport unsigned long RegisterMONOImage(void)
+ModuleExport size_t RegisterMONOImage(void)
 {
   MagickInfo
     *entry;
@@ -288,7 +288,7 @@
 static MagickBooleanType WriteMONOImage(const ImageInfo *image_info,
   Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -300,10 +300,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  unsigned long
+  size_t
     bit,
     byte;
 
@@ -325,7 +325,7 @@
     Convert image to a bi-level image.
   */
   (void) SetImageType(image,BilevelType);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -333,7 +333,7 @@
     indexes=GetVirtualIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       byte>>=1;
       if (image->endian == LSBEndian)
diff --git a/coders/mpc.c b/coders/mpc.c
index df6a99f..576a247 100644
--- a/coders/mpc.c
+++ b/coders/mpc.c
@@ -172,7 +172,7 @@
   MagickStatusType
     flags;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -184,7 +184,7 @@
   StringInfo
     *profile;
 
-  unsigned long
+  size_t
     depth,
     quantum_depth;
 
@@ -356,7 +356,7 @@
               {
                 if (LocaleCompare(keyword,"class") == 0)
                   {
-                    long
+                    ssize_t
                       storage_class;
 
                     storage_class=ParseMagickOption(MagickClassOptions,
@@ -373,7 +373,7 @@
                   }
                 if (LocaleCompare(keyword,"colorspace") == 0)
                   {
-                    long
+                    ssize_t
                       colorspace;
 
                     colorspace=ParseMagickOption(MagickColorspaceOptions,
@@ -385,7 +385,7 @@
                   }
                 if (LocaleCompare(keyword,"compression") == 0)
                   {
-                    long
+                    ssize_t
                       compression;
 
                     compression=ParseMagickOption(MagickCompressOptions,
@@ -418,7 +418,7 @@
                   }
                 if (LocaleCompare(keyword,"dispose") == 0)
                   {
-                    long
+                    ssize_t
                       dispose;
 
                     dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,
@@ -436,7 +436,7 @@
               {
                 if (LocaleCompare(keyword,"endian") == 0)
                   {
-                    long
+                    ssize_t
                       endian;
 
                     endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
@@ -496,7 +496,7 @@
               {
                 if (LocaleCompare(keyword,"matte") == 0)
                   {
-                    long
+                    ssize_t
                       matte;
 
                     matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
@@ -535,7 +535,7 @@
               {
                 if (LocaleCompare(keyword,"opaque") == 0)
                   {
-                    long
+                    ssize_t
                       matte;
 
                     matte=ParseMagickOption(MagickBooleanOptions,MagickFalse,
@@ -547,7 +547,7 @@
                   }
                 if (LocaleCompare(keyword,"orientation") == 0)
                   {
-                    long
+                    ssize_t
                       orientation;
 
                     orientation=ParseMagickOption(MagickOrientationOptions,
@@ -617,7 +617,7 @@
                   }
                 if (LocaleCompare(keyword,"rendering-intent") == 0)
                   {
-                    long
+                    ssize_t
                       rendering_intent;
 
                     rendering_intent=ParseMagickOption(MagickIntentOptions,
@@ -660,7 +660,7 @@
               {
                 if (LocaleCompare(keyword,"ticks-per-second") == 0)
                   {
-                    image->ticks_per_second=(long) StringToLong(options);
+                    image->ticks_per_second=(ssize_t) StringToLong(options);
                     break;
                   }
                 if (LocaleCompare(keyword,"tile-offset") == 0)
@@ -674,7 +674,7 @@
                   }
                 if (LocaleCompare(keyword,"type") == 0)
                   {
-                    long
+                    ssize_t
                       type;
 
                     type=ParseMagickOption(MagickTypeOptions,MagickFalse,
@@ -692,7 +692,7 @@
               {
                 if (LocaleCompare(keyword,"units") == 0)
                   {
-                    long
+                    ssize_t
                       units;
 
                     units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
@@ -842,7 +842,7 @@
                 unsigned char
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushCharPixel(p,&pixel);
                   image->colormap[i].red=ScaleCharToQuantum(pixel);
@@ -858,7 +858,7 @@
                 unsigned short
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushShortPixel(MSBEndian,p,&pixel);
                   image->colormap[i].red=ScaleShortToQuantum(pixel);
@@ -871,10 +871,10 @@
               }
               case 32:
               {
-                unsigned long
+                size_t
                   pixel;
 
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   p=PushLongPixel(MSBEndian,p,&pixel);
                   image->colormap[i].red=ScaleLongToQuantum(pixel);
@@ -953,10 +953,10 @@
 %
 %  The format of the RegisterMPCImage method is:
 %
-%      unsigned long RegisterMPCImage(void)
+%      size_t RegisterMPCImage(void)
 %
 */
-ModuleExport unsigned long RegisterMPCImage(void)
+ModuleExport size_t RegisterMPCImage(void)
 {
   MagickInfo
     *entry;
@@ -1042,10 +1042,10 @@
     offset,
     scene;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     depth;
 
   /*
@@ -1080,7 +1080,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,
       "class=%s  colors=%lu  matte=%s\n",MagickOptionToMnemonic(
       MagickClassOptions,image->storage_class),image->colors,
-      MagickOptionToMnemonic(MagickBooleanOptions,(long) image->matte));
+      MagickOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,
       "columns=%lu  rows=%lu  depth=%lu\n",image->columns,image->rows,
@@ -1251,7 +1251,7 @@
           if (profile != (StringInfo *) NULL)
             {
               (void) FormatMagickString(buffer,MaxTextExtent,"profile:%s=%lu\n",
-                name,(unsigned long) GetStringInfoLength(profile));
+                name,(size_t) GetStringInfoLength(profile));
               (void) WriteBlobString(image,buffer);
             }
           name=GetNextImageProfile(image);
@@ -1272,13 +1272,13 @@
       value=GetImageProperty(image,property);
       if (value != (const char *) NULL)
         {
-          for (i=0; i < (long) strlen(value); i++)
+          for (i=0; i < (ssize_t) strlen(value); i++)
             if (isspace((int) ((unsigned char) value[i])) != 0)
               break;
-          if (i <= (long) strlen(value))
+          if (i <= (ssize_t) strlen(value))
             (void) WriteBlobByte(image,'{');
           (void) WriteBlob(image,strlen(value),(unsigned char *) value);
-          if (i <= (long) strlen(value))
+          if (i <= (ssize_t) strlen(value))
             (void) WriteBlobByte(image,'}');
         }
       (void) WriteBlobByte(image,'\n');
@@ -1337,7 +1337,7 @@
           Write colormap to file.
         */
         q=colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           switch (depth)
           {
@@ -1345,7 +1345,7 @@
               ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
             case 32:
             {
-              unsigned long
+              size_t
                 pixel;
 
               pixel=ScaleQuantumToLong(image->colormap[i].red);
diff --git a/coders/mpeg.c b/coders/mpeg.c
index 8bd75ee..6c03d37 100644
--- a/coders/mpeg.c
+++ b/coders/mpeg.c
@@ -83,7 +83,7 @@
 %
 %  The format of the IsAVI method is:
 %
-%      unsigned long IsAVI(const unsigned char *magick,const size_t length)
+%      size_t IsAVI(const unsigned char *magick,const size_t length)
 %
 %  A description of each parameter follows:
 %
@@ -231,10 +231,10 @@
 %
 %  The format of the RegisterMPEGImage method is:
 %
-%      unsigned long RegisterMPEGImage(void)
+%      size_t RegisterMPEGImage(void)
 %
 */
-ModuleExport unsigned long RegisterMPEGImage(void)
+ModuleExport size_t RegisterMPEGImage(void)
 {
   MagickInfo
     *entry;
@@ -479,7 +479,7 @@
   register Image
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -488,7 +488,7 @@
   unsigned char
     *blob;
 
-  unsigned long
+  size_t
     count,
     scene;
 
@@ -527,7 +527,7 @@
     length=0;
     scene=p->scene;
     delay=100.0*p->delay/MagickMax(1.0*p->ticks_per_second,1.0);
-    for (i=0; i < (long) MagickMax((1.0*delay+1.0)/3.0,1.0); i++)
+    for (i=0; i < (ssize_t) MagickMax((1.0*delay+1.0)/3.0,1.0); i++)
     {
       p->scene=count;
       count++;
@@ -609,7 +609,7 @@
   for (p=coalesce_image; p != (Image *) NULL; p=GetNextImageInList(p))
   {
     delay=100.0*p->delay/MagickMax(1.0*p->ticks_per_second,1.0);
-    for (i=0; i < (long) MagickMax((1.0*delay+1.0)/3.0,1.0); i++)
+    for (i=0; i < (ssize_t) MagickMax((1.0*delay+1.0)/3.0,1.0); i++)
     {
       (void) FormatMagickString(p->filename,MaxTextExtent,"%s%lu.%s",
         basename,count++,WriteMPEGIntermediateFormat);
diff --git a/coders/mpr.c b/coders/mpr.c
index 91e20ca..23d1f8d 100644
--- a/coders/mpr.c
+++ b/coders/mpr.c
@@ -124,10 +124,10 @@
 %
 %  The format of the RegisterMPRImage method is:
 %
-%      unsigned long RegisterMPRImage(void)
+%      size_t RegisterMPRImage(void)
 %
 */
-ModuleExport unsigned long RegisterMPRImage(void)
+ModuleExport size_t RegisterMPRImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/msl.c b/coders/msl.c
index ccdb620..b75ae17 100644
--- a/coders/msl.c
+++ b/coders/msl.c
@@ -113,7 +113,7 @@
 */
 typedef struct _MSLGroupInfo
 {
-  unsigned long
+  size_t
     numImages;  /* how many images are in this group */
 } MSLGroupInfo;
 
@@ -122,7 +122,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     n,
     number_groups;
 
@@ -545,7 +545,7 @@
 
 static void MSLPushImage(MSLInfo *msl_info,Image *image)
 {
-  long
+  ssize_t
     n;
 
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
@@ -629,7 +629,7 @@
   int
     flags;
 
-  long
+  ssize_t
     option,
     j,
     n,
@@ -642,10 +642,10 @@
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -1902,11 +1902,11 @@
                 {
                   if (LocaleCompare(keyword,"opacity") == 0)
                     {
-                      long
+                      ssize_t
                         opacity,
                         y;
 
-                      register long
+                      register ssize_t
                         x;
 
                       register PixelPacket
@@ -1927,11 +1927,11 @@
                       if (composite_image->matte != MagickTrue)
                         (void) SetImageOpacity(composite_image,OpaqueOpacity);
                       composite_view=AcquireCacheView(composite_image);
-                      for (y=0; y < (long) composite_image->rows ; y++)
+                      for (y=0; y < (ssize_t) composite_image->rows ; y++)
                       {
-                        q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
+                        q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
                           composite_image->columns,1,&exception);
-                        for (x=0; x < (long) composite_image->columns; x++)
+                        for (x=0; x < (ssize_t) composite_image->columns; x++)
                         {
                           if (q->opacity == OpaqueOpacity)
                             q->opacity=ClampToQuantum(opacity);
@@ -1983,8 +1983,8 @@
                        image=msl_info->image[n];
                        height=composite_image->rows;
                        width=composite_image->columns;
-                       for (y=0; y < (long) image->rows; y+=height)
-                         for (x=0; x < (long) image->columns; x+=width)
+                       for (y=0; y < (ssize_t) image->rows; y+=height)
+                         for (x=0; x < (ssize_t) image->columns; x+=width)
                          {
                            if (rotate_image != (Image *) NULL)
                              (void) CompositeImage(image,compose,rotate_image,
@@ -2051,9 +2051,9 @@
               /*
                 Rotate image.
               */
-              geometry.x-=(long) (rotate_image->columns-
+              geometry.x-=(ssize_t) (rotate_image->columns-
                 composite_image->columns)/2;
-              geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
+              geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2;
               CompositeImageChannel(image,channel,compose,rotate_image,
                 geometry.x,geometry.y);
               rotate_image=DestroyImage(rotate_image);
@@ -2218,7 +2218,7 @@
         }
       if (LocaleCompare((const char *) tag,"cycle-colormap") == 0)
         {
-          long
+          ssize_t
             display;
 
           /*
@@ -3097,8 +3097,8 @@
                 }
               }
             }
-          frame_info.x=(long) frame_info.width;
-          frame_info.y=(long) frame_info.height;
+          frame_info.x=(ssize_t) frame_info.width;
+          frame_info.y=(ssize_t) frame_info.height;
           frame_info.width=msl_info->image[n]->columns+2*frame_info.x;
           frame_info.height=msl_info->image[n]->rows+2*frame_info.y;
           frame_image=FrameImage(msl_info->image[n],&frame_info,
@@ -4345,7 +4345,7 @@
                   if (profile != (StringInfo *) NULL)
                     {
                       (void) ProfileImage(msl_info->image[n],name,
-                        GetStringInfoDatum(profile),(unsigned long)
+                        GetStringInfoDatum(profile),(size_t)
                         GetStringInfoLength(profile),MagickFalse);
                       profile=DestroyStringInfo(profile);
                     }
@@ -4358,7 +4358,7 @@
                 profile=GetImageProfile(profile_image,name);
                 if (profile != (StringInfo *) NULL)
                   (void) ProfileImage(msl_info->image[n],name,
-                    GetStringInfoDatum(profile),(unsigned long)
+                    GetStringInfoDatum(profile),(size_t)
                     GetStringInfoLength(profile),MagickFalse);
                 name=GetNextImageProfile(profile_image);
               }
@@ -5206,7 +5206,7 @@
           {
             if (LocaleCompare(keyword,"geometry") == 0)
               {
-                long
+                ssize_t
                   flags;
 
                 flags=ParseGeometry(value,&geometry_info);
@@ -5261,10 +5261,10 @@
         factor=1.0;
         if (msl_info->image[n]->units == PixelsPerCentimeterResolution)
           factor=2.54;
-        width=(unsigned long) (x_resolution*msl_info->image[n]->columns/
+        width=(size_t) (x_resolution*msl_info->image[n]->columns/
           (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution :
           msl_info->image[n]->x_resolution))+0.5);
-        height=(unsigned long) (y_resolution*msl_info->image[n]->rows/
+        height=(size_t) (y_resolution*msl_info->image[n]->rows/
           (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution :
           msl_info->image[n]->y_resolution))+0.5);
         resample_image=ResizeImage(msl_info->image[n],width,height,
@@ -5970,7 +5970,7 @@
                 }
               if (LocaleCompare(keyword,"colorspace") == 0)
                 {
-                  long
+                  ssize_t
                     colorspace;
 
                   colorspace=(ColorspaceType) ParseMagickOption(
@@ -6006,8 +6006,8 @@
             {
               if (LocaleCompare(keyword, "opacity") == 0)
                 {
-                  long  opac = OpaqueOpacity,
-                  len = (long) strlen( value );
+                  ssize_t  opac = OpaqueOpacity,
+                  len = (ssize_t) strlen( value );
 
                   if (value[len-1] == '%') {
                     char  tmp[100];
@@ -6248,7 +6248,7 @@
               }
             }
           shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho,
-            geometry_info.sigma,(long) ceil(geometry_info.xi-0.5),(long)
+            geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
             ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception);
           if (shadow_image == (Image *) NULL)
             break;
@@ -6790,7 +6790,7 @@
             *q,
             *swap;
 
-          long
+          ssize_t
             index,
             swap_index;
 
@@ -6817,9 +6817,9 @@
                   if (LocaleCompare(keyword,"indexes") == 0)
                     {
                       flags=ParseGeometry(value,&geometry_info);
-                      index=(long) geometry_info.rho;
+                      index=(ssize_t) geometry_info.rho;
                       if ((flags & SigmaValue) == 0)
-                        swap_index=(long) geometry_info.sigma;
+                        swap_index=(ssize_t) geometry_info.sigma;
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -7050,7 +7050,7 @@
         */
         {
         BilevelImageChannel(msl_info->image[n],
-          (ChannelType) ((long) (AllChannels &~ (long) OpacityChannel)),
+          (ChannelType) ((ssize_t) (AllChannels &~ (ssize_t) OpacityChannel)),
           threshold);
         break;
         }
@@ -7187,7 +7187,7 @@
 
 static void MSLEndElement(void *context,const xmlChar *tag)
 {
-  long
+  ssize_t
     n;
 
   MSLInfo
@@ -7224,7 +7224,7 @@
       {
         if (msl_info->group_info[msl_info->number_groups-1].numImages > 0 )
         {
-          long  i = (long)
+          ssize_t  i = (ssize_t)
             (msl_info->group_info[msl_info->number_groups-1].numImages);
           while ( i-- )
           {
@@ -7289,7 +7289,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -7549,7 +7549,7 @@
   int
     status;
 
-  long
+  ssize_t
     n;
 
   MSLInfo
@@ -7644,7 +7644,7 @@
     msl_image->filename);
   while (ReadBlobString(msl_image,message) != (char *) NULL)
   {
-    n=(long) strlen(message);
+    n=(ssize_t) strlen(message);
     if (n == 0)
       continue;
     status=xmlParseChunk(msl_info.parser,message,(int) n,MagickFalse);
@@ -7709,10 +7709,10 @@
 %
 %  The format of the RegisterMSLImage method is:
 %
-%      unsigned long RegisterMSLImage(void)
+%      size_t RegisterMSLImage(void)
 %
 */
-ModuleExport unsigned long RegisterMSLImage(void)
+ModuleExport size_t RegisterMSLImage(void)
 {
   MagickInfo
     *entry;
@@ -7780,7 +7780,7 @@
   int
     flags;
 
-  long
+  ssize_t
     n;
 
   assert(msl_info != (MSLInfo *) NULL);
@@ -7801,7 +7801,7 @@
     {
       if (LocaleCompare(keyword,"adjoin") == 0)
         {
-          long
+          ssize_t
             adjoin;
 
           adjoin=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
@@ -7812,7 +7812,7 @@
         }
       if (LocaleCompare(keyword,"alpha") == 0)
         {
-          long
+          ssize_t
             alpha;
 
           alpha=ParseMagickOption(MagickAlphaOptions,MagickFalse,value);
@@ -7824,7 +7824,7 @@
         }
       if (LocaleCompare(keyword,"antialias") == 0)
         {
-          long
+          ssize_t
             antialias;
 
           antialias=ParseMagickOption(MagickBooleanOptions,MagickFalse,value);
@@ -7928,7 +7928,7 @@
     {
       if (LocaleCompare(keyword,"gravity") == 0)
         {
-          long
+          ssize_t
             gravity;
 
           gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
diff --git a/coders/mtv.c b/coders/mtv.c
index f445aa5..8b8b705 100644
--- a/coders/mtv.c
+++ b/coders/mtv.c
@@ -98,13 +98,13 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -119,7 +119,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -165,7 +165,7 @@
       3UL*sizeof(*pixels));
     if (pixels == (unsigned char *) NULL)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       count=(ssize_t) ReadBlob(image,(size_t) (3*image->columns),pixels);
       if (count != (ssize_t) (3*image->columns))
@@ -174,7 +174,7 @@
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         q->red=ScaleCharToQuantum(*p++);
         q->green=ScaleCharToQuantum(*p++);
@@ -249,10 +249,10 @@
 %
 %  The format of the RegisterMTVImage method is:
 %
-%      unsigned long RegisterMTVImage(void)
+%      size_t RegisterMTVImage(void)
 %
 */
-ModuleExport unsigned long RegisterMTVImage(void)
+ModuleExport size_t RegisterMTVImage(void)
 {
   MagickInfo
     *entry;
@@ -320,7 +320,7 @@
   char
     buffer[MaxTextExtent];
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -332,7 +332,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -371,13 +371,13 @@
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu %lu\n",
       image->columns,image->rows);
     (void) WriteBlobString(image,buffer);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       q=pixels;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
         *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
diff --git a/coders/mvg.c b/coders/mvg.c
index 5c71658..81ef2fd 100644
--- a/coders/mvg.c
+++ b/coders/mvg.c
@@ -175,8 +175,8 @@
           continue;
         (void) sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1,
           &bounds.x2,&bounds.y2);
-        image->columns=(unsigned long) floor((bounds.x2-bounds.x1)+0.5);
-        image->rows=(unsigned long) floor((bounds.y2-bounds.y1)+0.5);
+        image->columns=(size_t) floor((bounds.x2-bounds.x1)+0.5);
+        image->rows=(size_t) floor((bounds.y2-bounds.y1)+0.5);
         break;
       }
     }
@@ -187,8 +187,8 @@
     DefaultResolution;
   draw_info->affine.sy=image->y_resolution == 0.0 ? 1.0 : image->y_resolution/
     DefaultResolution;
-  image->columns=(unsigned long) (draw_info->affine.sx*image->columns);
-  image->rows=(unsigned long) (draw_info->affine.sy*image->rows);
+  image->columns=(size_t) (draw_info->affine.sx*image->columns);
+  image->rows=(size_t) (draw_info->affine.sy*image->rows);
   if (SetImageBackgroundColor(image) == MagickFalse)
     {
       InheritException(exception,&image->exception);
@@ -236,10 +236,10 @@
 %
 %  The format of the RegisterMVGImage method is:
 %
-%      unsigned long RegisterMVGImage(void)
+%      size_t RegisterMVGImage(void)
 %
 */
-ModuleExport unsigned long RegisterMVGImage(void)
+ModuleExport size_t RegisterMVGImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/null.c b/coders/null.c
index 93b3909..b6a3216 100644
--- a/coders/null.c
+++ b/coders/null.c
@@ -99,7 +99,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickPixelPacket
@@ -108,7 +108,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -134,13 +134,13 @@
   background.opacity=(MagickRealType) TransparentOpacity;
   if (image->colorspace == CMYKColorspace)
     ConvertRGBToCMYK(&background);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetAuthenticIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetPixelPacket(image,&background,q,indexes);
       q++;
@@ -172,10 +172,10 @@
 %
 %  The format of the RegisterNULLImage method is:
 %
-%      unsigned long RegisterNULLImage(void)
+%      size_t RegisterNULLImage(void)
 %
 */
-ModuleExport unsigned long RegisterNULLImage(void)
+ModuleExport size_t RegisterNULLImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/otb.c b/coders/otb.c
index 650c8f8..5102d14 100644
--- a/coders/otb.c
+++ b/coders/otb.c
@@ -102,7 +102,7 @@
   int
     byte;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -111,7 +111,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -145,13 +145,13 @@
   info=(unsigned char) ReadBlobByte(image);
   if (GetBit(info,4) == 0)
     {
-      image->columns=(unsigned long) ReadBlobByte(image);
-      image->rows=(unsigned long) ReadBlobByte(image);
+      image->columns=(size_t) ReadBlobByte(image);
+      image->rows=(size_t) ReadBlobByte(image);
     }
   else
     {
-      image->columns=(unsigned long) ReadBlobMSBShort(image);
-      image->rows=(unsigned long) ReadBlobMSBShort(image);
+      image->columns=(size_t) ReadBlobMSBShort(image);
+      image->rows=(size_t) ReadBlobMSBShort(image);
     }
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
@@ -168,7 +168,7 @@
   /*
     Convert bi-level image to pixel packets.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -176,7 +176,7 @@
     indexes=GetAuthenticIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (bit == 0)
         {
@@ -226,10 +226,10 @@
 %
 %  The format of the RegisterOTBImage method is:
 %
-%      unsigned long RegisterOTBImage(void)
+%      size_t RegisterOTBImage(void)
 %
 */
-ModuleExport unsigned long RegisterOTBImage(void)
+ModuleExport size_t RegisterOTBImage(void)
 {
   MagickInfo
     *entry;
@@ -299,7 +299,7 @@
 #define SetBit(a,i,set) \
   a=(unsigned char) ((set) ? (a) | (1L << (i)) : (a) & ~(1L << (i)))
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -308,7 +308,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   unsigned char
@@ -349,14 +349,14 @@
       (void) WriteBlobByte(image,(unsigned char) image->rows);
     }
   (void) WriteBlobByte(image,1);  /* depth */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (PixelIntensity(p) < ((Quantum) QuantumRange/2.0))
         byte|=0x1 << (7-bit);
diff --git a/coders/palm.c b/coders/palm.c
index b77af07..86ca8ef 100644
--- a/coders/palm.c
+++ b/coders/palm.c
@@ -188,7 +188,7 @@
 */
 static int FindColor(PixelPacket *pixel)
 {
-  register long
+  register ssize_t
     i;
 
   for (i=0; i < 256; i++)
@@ -227,7 +227,7 @@
 %
 */
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
@@ -250,7 +250,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -262,7 +262,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -277,7 +277,7 @@
     *one_row,
     *ptr;
 
-  unsigned long
+  size_t
     bytes_per_row,
     flags,
     bits_per_pixel,
@@ -332,13 +332,13 @@
       ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
     bytes_per_row=ReadBlobMSBShort(image);
     flags=ReadBlobMSBShort(image);
-    bits_per_pixel=(unsigned long) ReadBlobByte(image);
+    bits_per_pixel=(size_t) ReadBlobByte(image);
     if (bits_per_pixel > 16)
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-    version=(unsigned long) ReadBlobByte(image);
-    nextDepthOffset=(unsigned long) ReadBlobMSBShort(image);
-    transparentIndex=(unsigned long) ReadBlobByte(image);
-    compressionType=(unsigned long) ReadBlobByte(image);
+    version=(size_t) ReadBlobByte(image);
+    nextDepthOffset=(size_t) ReadBlobMSBShort(image);
+    transparentIndex=(size_t) ReadBlobByte(image);
+    compressionType=(size_t) ReadBlobByte(image);
     pad=ReadBlobMSBShort(image);
     /*
       Initialize image colormap.
@@ -349,9 +349,9 @@
     GetMagickPixelPacket(image,&transpix);
     if (bits_per_pixel == 16)  /* Direct Color */
       {
-        redbits=(unsigned long) ReadBlobByte(image);  /* # of bits of red */
-        greenbits=(unsigned long) ReadBlobByte(image);  /* # of bits of green */
-        bluebits=(unsigned long) ReadBlobByte(image);  /* # of bits of blue */
+        redbits=(size_t) ReadBlobByte(image);  /* # of bits of red */
+        greenbits=(size_t) ReadBlobByte(image);  /* # of bits of green */
+        bluebits=(size_t) ReadBlobByte(image);  /* # of bits of blue */
         ReadBlobByte(image);  /* reserved by Palm */
         ReadBlobByte(image);  /* reserved by Palm */
         transpix.red=(MagickRealType) (QuantumRange*ReadBlobByte(image)/31);
@@ -366,7 +366,7 @@
         if (flags & PALM_HAS_COLORMAP_FLAG)
           {
             count=(ssize_t) ReadBlobMSBShort(image);
-            for (i=0; i < (long) count; i++)
+            for (i=0; i < (ssize_t) count; i++)
             {
               ReadBlobByte(image);
               index=ConstrainColormapIndex(image,255-i);
@@ -380,7 +380,7 @@
         }
       else
         {
-          for (i=0; i < (long) (1L << bits_per_pixel); i++)
+          for (i=0; i < (ssize_t) (1L << bits_per_pixel); i++)
           {
             index=ConstrainColormapIndex(image,255-i);
             image->colormap[(int) index].red=
@@ -412,7 +412,7 @@
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     }
     mask=(1l << bits_per_pixel)-1;
-    for (y = 0; y < (long) image->rows; y++)
+    for (y = 0; y < (ssize_t) image->rows; y++)
     {
       if ((flags & PALM_IS_COMPRESSED_FLAG) == 0)
         {
@@ -426,11 +426,11 @@
             { 
               /* TODO move out of loop! */
               image->compression=RLECompression;
-              for (i=0; i < (long) bytes_per_row; )
+              for (i=0; i < (ssize_t) bytes_per_row; )
               {
                 count=(ssize_t) ReadBlobByte(image);
                 count=MagickMin(count,(ssize_t) bytes_per_row-i);
-                byte=(unsigned long) ReadBlobByte(image);
+                byte=(size_t) ReadBlobByte(image);
                 (void) ResetMagickMemory(one_row+i,(int) byte,(size_t) count);
                 i+=count;
               }
@@ -440,7 +440,7 @@
             {  
               /* TODO move out of loop! */
               image->compression=FaxCompression;
-              for (i=0; i < (long) bytes_per_row; i+=8)
+              for (i=0; i < (ssize_t) bytes_per_row; i+=8)
               {
                 count=(ssize_t) ReadBlobByte(image);
                 byte=1UL*MagickMin((ssize_t) bytes_per_row-i,8);
@@ -464,7 +464,7 @@
         {
           if (image->columns > (2*bytes_per_row))
             ThrowReaderException(CorruptImageError,"CorruptImage");
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             color16=(*ptr++ << 8);
             color16|=(*ptr++);
@@ -478,13 +478,13 @@
       else
         {
           bit=8-bits_per_pixel;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             if ((size_t) (ptr-one_row) >= bytes_per_row)
               ThrowReaderException(CorruptImageError,"CorruptImage");
             index=(IndexPacket) (mask-(((*ptr) & (mask << bit)) >> bit));
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             if (bit)
               bit-=bits_per_pixel;
             else
@@ -575,10 +575,10 @@
 %
 %  The format of the RegisterPALMImage method is:
 %
-%      unsigned long RegisterPALMImage(void)
+%      size_t RegisterPALMImage(void)
 %
 */
-ModuleExport unsigned long RegisterPALMImage(void)
+ModuleExport size_t RegisterPALMImage(void)
 {
   MagickInfo
     *entry;
@@ -671,7 +671,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -689,7 +689,7 @@
   unsigned int
     transparentIndex;
 
-  unsigned long
+  size_t
     count,
     bits_per_pixel,
     bytes_per_row,
@@ -810,12 +810,12 @@
             &exception);
           (void) TransformImageColorspace(affinity_image,affinity_image->colorspace);
           (void) RemapImage(quantize_info,image,affinity_image);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetAuthenticPixels(image,0,y,image->columns,1,&exception);
             indexes=GetAuthenticIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
-              indexes[x]=(IndexPacket) FindColor(&image->colormap[(long)
+            for (x=0; x < (ssize_t) image->columns; x++)
+              indexes[x]=(IndexPacket) FindColor(&image->colormap[(ssize_t)
                 indexes[x]]);
           }
           affinity_image=DestroyImage(affinity_image);
@@ -844,10 +844,10 @@
         {
           for (x=0; x < (int) image->columns; x++)
           {
-            color16=(unsigned short) ((((31*(unsigned long) GetRedPixelComponent(p))/
-              (unsigned long) QuantumRange) << 11) |
-              (((63*(unsigned long) GetGreenPixelComponent(p))/(unsigned long) QuantumRange) << 5) |
-              ((31*(unsigned long) GetBluePixelComponent(p))/(unsigned long) QuantumRange));
+            color16=(unsigned short) ((((31*(size_t) GetRedPixelComponent(p))/
+              (size_t) QuantumRange) << 11) |
+              (((63*(size_t) GetGreenPixelComponent(p))/(size_t) QuantumRange) << 5) |
+              ((31*(size_t) GetBluePixelComponent(p))/(size_t) QuantumRange));
             if (p->opacity == (Quantum) TransparentOpacity)
               {
                 transpix.red=GetRedPixelComponent(p);
@@ -888,12 +888,12 @@
       if (image_info->compression == RLECompression)
         {
           x=0;
-          while (x < (long) bytes_per_row)
+          while (x < (ssize_t) bytes_per_row)
           {
             byte=one_row[x];
             count=1;
             while ((one_row[++x] == byte) && (count < 255) &&
-                   (x < (long) bytes_per_row))
+                   (x < (ssize_t) bytes_per_row))
               count++;
             (void) WriteBlobByte(image,(unsigned char) count);
             (void) WriteBlobByte(image,(unsigned char) byte);
@@ -906,7 +906,7 @@
               tmpbuf[8],
               *tptr;
   
-            for (x = 0;  x < (long) bytes_per_row;  x += 8)
+            for (x = 0;  x < (ssize_t) bytes_per_row;  x += 8)
             {
               tptr = tmpbuf;
               for (bit=0, byte=0; bit < (unsigned char) MagickMin(8,(ssize_t) bytes_per_row-x); bit++)
@@ -959,7 +959,7 @@
     } 
     /* write nextDepthOffset and return to end of image */
     offset=SeekBlob(image,currentOffset+10,SEEK_SET);
-    nextDepthOffset=(unsigned long) ((GetBlobSize(image)-currentOffset)/4);
+    nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)/4);
     (void) WriteBlobMSBShort(image,(unsigned short) nextDepthOffset);
     currentOffset=(MagickOffsetType) GetBlobSize(image);
     offset=SeekBlob(image,currentOffset,SEEK_SET);
diff --git a/coders/pattern.c b/coders/pattern.c
index f0e05c0..6ad904c 100644
--- a/coders/pattern.c
+++ b/coders/pattern.c
@@ -911,7 +911,7 @@
   ImageInfo
     *blob_info;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -971,10 +971,10 @@
 %
 %  The format of the RegisterPATTERNImage method is:
 %
-%      unsigned long RegisterPATTERNImage(void)
+%      size_t RegisterPATTERNImage(void)
 %
 */
-ModuleExport unsigned long RegisterPATTERNImage(void)
+ModuleExport size_t RegisterPATTERNImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/pcd.c b/coders/pcd.c
index e70eaf2..664649d 100644
--- a/coders/pcd.c
+++ b/coders/pcd.c
@@ -144,13 +144,13 @@
       key;
   } PCDTable;
 
-  long
+  ssize_t
     quantum;
 
   PCDTable
     *pcd_table[3];
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -170,7 +170,7 @@
   unsigned char
     *buffer;
 
-  unsigned long
+  size_t
     bits,
     plane,
     pcd_length[3],
@@ -207,7 +207,7 @@
           image->filename);
       }
     r=pcd_table[i];
-    for (j=0; j < (long) length; j++)
+    for (j=0; j < (ssize_t) length; j++)
     {
       PCDGetBits(8);
       r->length=(unsigned int) (sum & 0xff)+1;
@@ -223,7 +223,7 @@
       r->mask=(~((1U << (32-r->length))-1));
       r++;
     }
-    pcd_length[i]=(unsigned long) length;
+    pcd_length[i]=(size_t) length;
   }
   /*
     Search for Sync byte.
@@ -293,7 +293,7 @@
       Decode luminance or chrominance deltas.
     */
     r=pcd_table[plane];
-    for (i=0; ((i < (long) length) && ((sum & r->mask) != r->sequence)); i++)
+    for (i=0; ((i < (ssize_t) length) && ((sum & r->mask) != r->sequence)); i++)
       r++;
     if ((row > image->rows) || (r == (PCDTable *) NULL))
       {
@@ -306,9 +306,9 @@
         continue;
       }
     if (r->key < 128)
-      quantum=(long) (*q)+r->key;
+      quantum=(ssize_t) (*q)+r->key;
     else
-      quantum=(long) (*q)+r->key-256;
+      quantum=(ssize_t) (*q)+r->key-256;
     *q=(unsigned char) ((quantum < 0) ? 0 : (quantum > 255) ? 255 : quantum);
     q++;
     PCDGetBits(r->length);
@@ -423,10 +423,10 @@
   return(montage_image);
 }
 
-static void Upsample(const unsigned long width,const unsigned long height,
-  const unsigned long scaled_width,unsigned char *pixels)
+static void Upsample(const size_t width,const size_t height,
+  const size_t scaled_width,unsigned char *pixels)
 {
-  register long
+  register ssize_t
     x,
     y;
 
@@ -439,39 +439,39 @@
     Create a new image that is a integral size greater than an existing one.
   */
   assert(pixels != (unsigned char *) NULL);
-  for (y=0; y < (long) height; y++)
+  for (y=0; y < (ssize_t) height; y++)
   {
     p=pixels+(height-1-y)*scaled_width+(width-1);
     q=pixels+((height-1-y) << 1)*scaled_width+((width-1) << 1);
     *q=(*p);
     *(q+1)=(*(p));
-    for (x=1; x < (long) width; x++)
+    for (x=1; x < (ssize_t) width; x++)
     {
       p--;
       q-=2;
       *q=(*p);
-      *(q+1)=(unsigned char) ((((unsigned long) *p)+
-        ((unsigned long) *(p+1))+1) >> 1);
+      *(q+1)=(unsigned char) ((((size_t) *p)+
+        ((size_t) *(p+1))+1) >> 1);
     }
   }
-  for (y=0; y < (long) (height-1); y++)
+  for (y=0; y < (ssize_t) (height-1); y++)
   {
-    p=pixels+((unsigned long) y << 1)*scaled_width;
+    p=pixels+((size_t) y << 1)*scaled_width;
     q=p+scaled_width;
     r=q+scaled_width;
-    for (x=0; x < (long) (width-1); x++)
+    for (x=0; x < (ssize_t) (width-1); x++)
     {
-      *q=(unsigned char) ((((unsigned long) *p)+((unsigned long) *r)+1) >> 1);
-      *(q+1)=(unsigned char) ((((unsigned long) *p)+((unsigned long) *(p+2))+
-        ((unsigned long) *r)+((unsigned long) *(r+2))+2) >> 2);
+      *q=(unsigned char) ((((size_t) *p)+((size_t) *r)+1) >> 1);
+      *(q+1)=(unsigned char) ((((size_t) *p)+((size_t) *(p+2))+
+        ((size_t) *r)+((size_t) *(r+2))+2) >> 2);
       q+=2;
       p+=2;
       r+=2;
     }
-    *q++=(unsigned char) ((((unsigned long) *p++)+
-      ((unsigned long) *r++)+1) >> 1);
-    *q++=(unsigned char) ((((unsigned long) *p++)+
-      ((unsigned long) *r++)+1) >> 1);
+    *q++=(unsigned char) ((((size_t) *p++)+
+      ((size_t) *r++)+1) >> 1);
+    *q++=(unsigned char) ((((size_t) *p++)+
+      ((size_t) *r++)+1) >> 1);
   }
   p=pixels+(2*height-2)*scaled_width;
   q=pixels+(2*height-1)*scaled_width;
@@ -483,7 +483,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     x;
 
   MagickBooleanType
@@ -495,7 +495,7 @@
   MagickSizeType
     number_pixels;
 
-  register long
+  register ssize_t
     i,
     y;
 
@@ -519,7 +519,7 @@
   unsigned int
     overview;
 
-  unsigned long
+  size_t
     height,
     number_images,
     rotate,
@@ -575,7 +575,7 @@
       }
     }
   if (image_info->number_scenes != 0)
-    scene=(unsigned long) MagickMin(image_info->scene,6);
+    scene=(size_t) MagickMin(image_info->scene,6);
   if (overview)
     scene=1;
   /*
@@ -583,7 +583,7 @@
   */
   width=192;
   height=128;
-  for (i=1; i < (long) MagickMin(scene,3); i++)
+  for (i=1; i < (ssize_t) MagickMin(scene,3); i++)
   {
     width<<=1;
     height<<=1;
@@ -591,7 +591,7 @@
   image->columns=width;
   image->rows=height;
   image->depth=8;
-  for ( ; i < (long) scene; i++)
+  for ( ; i < (ssize_t) scene; i++)
   {
     image->columns<<=1;
     image->rows<<=1;
@@ -623,7 +623,7 @@
     else
       if (scene <= 1)
         offset=1;
-  for (i=0; i < (long) (offset*0x800); i++)
+  for (i=0; i < (ssize_t) (offset*0x800); i++)
     (void) ReadBlobByte(image);
   if (overview)
     {
@@ -633,13 +633,13 @@
       MagickProgressMonitor
         progress_monitor;
 
-      register long
+      register ssize_t
         j;
 
       /*
         Read thumbnails from overview image.
       */
-      for (j=1; j <= (long) number_images; j++)
+      for (j=1; j <= (ssize_t) number_images; j++)
       {
         progress_monitor=SetImageProgressMonitor(image,
           (MagickProgressMonitor) NULL,image->client_data);
@@ -647,14 +647,14 @@
           "images/img%04ld.pcd",j);
         (void) FormatMagickString(image->magick_filename,MaxTextExtent,
           "images/img%04ld.pcd",j);
-        image->scene=(unsigned long) j;
+        image->scene=(size_t) j;
         image->columns=width;
         image->rows=height;
         image->depth=8;
         yy=luma;
         c1=chroma1;
         c2=chroma2;
-        for (y=0; y < (long) height; y+=2)
+        for (y=0; y < (ssize_t) height; y+=2)
         {
           count=ReadBlob(image,width,yy);
           yy+=image->columns;
@@ -673,12 +673,12 @@
         yy=luma;
         c1=chroma1;
         c2=chroma2;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum(*yy++);
             q->green=ScaleCharToQuantum(*c1++);
@@ -691,7 +691,7 @@
         image->colorspace=YCCColorspace;
         if (LocaleCompare(image_info->magick,"PCDS") == 0)
           image->colorspace=sRGBColorspace;
-        if (j < (long) number_images)
+        if (j < (ssize_t) number_images)
           {
             /*
               Allocate next image structure.
@@ -726,7 +726,7 @@
   yy=luma;
   c1=chroma1;
   c2=chroma2;
-  for (y=0; y < (long) height; y+=2)
+  for (y=0; y < (ssize_t) height; y+=2)
   {
     count=ReadBlob(image,width,yy);
     yy+=image->columns;
@@ -781,12 +781,12 @@
   yy=luma;
   c1=chroma1;
   c2=chroma2;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=ScaleCharToQuantum(*yy++);
       q->green=ScaleCharToQuantum(*c1++);
@@ -867,10 +867,10 @@
 %
 %  The format of the RegisterPCDImage method is:
 %
-%      unsigned long RegisterPCDImage(void)
+%      size_t RegisterPCDImage(void)
 %
 */
-ModuleExport unsigned long RegisterPCDImage(void)
+ModuleExport size_t RegisterPCDImage(void)
 {
   MagickInfo
     *entry;
@@ -953,7 +953,7 @@
     *downsample_image,
     *tile_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -969,7 +969,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -988,8 +988,8 @@
   if (tile_image == (Image *) NULL)
     return(MagickFalse);
   flags=ParseGeometry(page_geometry,&geometry_info);
-  geometry.width=(unsigned long) geometry_info.rho;
-  geometry.height=(unsigned long) geometry_info.sigma;
+  geometry.width=(size_t) geometry_info.rho;
+  geometry.height=(size_t) geometry_info.sigma;
   if ((flags & SigmaValue) == 0)
     geometry.height=geometry.width;
   if ((tile_image->columns != geometry.width) ||
@@ -1022,13 +1022,13 @@
   /*
     Write tile to PCD file.
   */
-  for (y=0; y < (long) tile_image->rows; y+=2)
+  for (y=0; y < (ssize_t) tile_image->rows; y+=2)
   {
     p=GetVirtualPixels(tile_image,0,y,tile_image->columns,2,
       &tile_image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) (tile_image->columns << 1); x++)
+    for (x=0; x < (ssize_t) (tile_image->columns << 1); x++)
     {
       (void) WriteBlobByte(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
       p++;
@@ -1037,7 +1037,7 @@
       1,&downsample_image->exception);
     if (q == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) downsample_image->columns; x++)
+    for (x=0; x < (ssize_t) downsample_image->columns; x++)
     {
       (void) WriteBlobByte(image,ScaleQuantumToChar(q->green));
       q++;
@@ -1046,7 +1046,7 @@
       1,&downsample_image->exception);
     if (q == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) downsample_image->columns; x++)
+    for (x=0; x < (ssize_t) downsample_image->columns; x++)
     {
       (void) WriteBlobByte(image,ScaleQuantumToChar(q->blue));
       q++;
@@ -1070,7 +1070,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   assert(image_info != (const ImageInfo *) NULL);
diff --git a/coders/pcl.c b/coders/pcl.c
index ec1ac38..c588888 100644
--- a/coders/pcl.c
+++ b/coders/pcl.c
@@ -178,7 +178,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     c;
 
   SegmentInfo
@@ -187,7 +187,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -290,8 +290,8 @@
     /*
       Set PCL render geometry.
     */
-    width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
-    height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
+    width=(size_t) floor(bounds.x2-bounds.x1+0.5);
+    height=(size_t) floor(bounds.y2-bounds.y1+0.5);
     if (width > page.width)
       page.width=width;
     if (height > page.height)
@@ -323,8 +323,8 @@
     (void) ParseAbsoluteGeometry(image_info->page,&page);
   (void) FormatMagickString(density,MaxTextExtent,"%gx%g",
     image->x_resolution,image->y_resolution);
-  page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+0.5);
-  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+  page.width=(size_t) floor(page.width*image->x_resolution/delta.x+0.5);
+  page.height=(size_t) floor(page.height*image->y_resolution/delta.y+
     0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
@@ -405,10 +405,10 @@
 %
 %  The format of the RegisterPCLImage method is:
 %
-%      unsigned long RegisterPCLImage(void)
+%      size_t RegisterPCLImage(void)
 %
 */
-ModuleExport unsigned long RegisterPCLImage(void)
+ModuleExport size_t RegisterPCLImage(void)
 {
   MagickInfo
     *entry;
@@ -485,7 +485,7 @@
     j,
     replacement;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -493,10 +493,10 @@
     *q;
 
   q=compress_pixels;
-  for (x=0; x < (long) length; )
+  for (x=0; x < (ssize_t) length; )
   {
     j=0;
-    for (i=0; x < (long) length; x++)
+    for (i=0; x < (ssize_t) length; x++)
     {
       if (*pixels++ != *previous_pixels++)
         {
@@ -505,7 +505,7 @@
         }
       j++;
     }
-    for ( ; x < (long) length; x++)
+    for ( ; x < (ssize_t) length; x++)
     {
       if (*pixels == *previous_pixels)
         break;
@@ -552,10 +552,10 @@
   int
     count;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -568,7 +568,7 @@
     Compress pixels with Packbits encoding.
   */
   q=compress_pixels;
-  for (x=(long) length; x != 0; )
+  for (x=(ssize_t) length; x != 0; )
   {
     switch (x)
     {
@@ -610,7 +610,7 @@
               Packed run.
             */
             count=3;
-            while (((long) count < x) && (*pixels == *(pixels+count)))
+            while (((ssize_t) count < x) && (*pixels == *(pixels+count)))
             {
               count++;
               if (count >= 127)
@@ -631,12 +631,12 @@
         {
           packbits[count+1]=pixels[count];
           count++;
-          if (((long) count >= (x-3)) || (count >= 127))
+          if (((ssize_t) count >= (x-3)) || (count >= 127))
             break;
         }
         x-=count;
         *packbits=(unsigned char) (count-1);
-        for (j=0; j <= (long) count; j++)
+        for (j=0; j <= (ssize_t) count; j++)
           *q++=packbits[j];
         pixels+=count;
         break;
@@ -655,7 +655,7 @@
   const char
     *option;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -670,7 +670,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -687,7 +687,7 @@
     *pixels,
     *previous_pixels;
 
-  unsigned long
+  size_t
     density;
 
   /*
@@ -709,7 +709,7 @@
         geometry;
 
       (void) ParseGeometry(image_info->density,&geometry);
-      density=(unsigned long) geometry.rho;
+      density=(size_t) geometry.rho;
     }
   scene=0;
   do
@@ -773,7 +773,7 @@
           (void) WriteBlobByte(image,8); /* bits per red component */
           (void) WriteBlobByte(image,8); /* bits per green component */
           (void) WriteBlobByte(image,8); /* bits per blue component */
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             (void) FormatMagickString(buffer,MaxTextExtent,
               "\033*v%da%db%dc%ldI",ScaleQuantumToChar(image->colormap[i].red),
@@ -844,7 +844,7 @@
         break;
       }
     }
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
@@ -864,7 +864,7 @@
           */
           bit=0;
           byte=0;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             byte<<=1;
             if (PixelIntensity(p) >= ((MagickRealType) QuantumRange/2.0))
@@ -887,7 +887,7 @@
           /*
             Colormapped image.
           */
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             *q++=(unsigned char) indexes[x];
           break;
         }
@@ -897,7 +897,7 @@
           /*
             Truecolor image.
           */
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -912,7 +912,7 @@
         case NoCompression:
         {
           (void) FormatMagickString(buffer,MaxTextExtent,"\033*b%luW",
-            (unsigned long) length);
+            (size_t) length);
           (void) WriteBlobString(image,buffer);
           (void) WriteBlob(image,length,pixels);
           break;
@@ -922,7 +922,7 @@
           packets=PCLPackbitsCompressImage(length,pixels,
             compress_pixels);
           (void) FormatMagickString(buffer,MaxTextExtent,"\033*b%luW",
-            (unsigned long) packets);
+            (size_t) packets);
           (void) WriteBlobString(image,buffer);
           (void) WriteBlob(image,packets,compress_pixels);
           break;
@@ -930,12 +930,12 @@
         default:
         {
           if (y == 0)
-            for (i=0; i < (long) length; i++)
+            for (i=0; i < (ssize_t) length; i++)
               previous_pixels[i]=(~pixels[i]);
           packets=PCLDeltaCompressImage(length,previous_pixels,pixels,
             compress_pixels);
           (void) FormatMagickString(buffer,MaxTextExtent,"\033*b%luW",
-            (unsigned long) packets);
+            (size_t) packets);
           (void) WriteBlobString(image,buffer);
           (void) WriteBlob(image,packets,compress_pixels);
           (void) CopyMagickMemory(previous_pixels,pixels,length*
diff --git a/coders/pcx.c b/coders/pcx.c
index 9929663..46b0ba6 100644
--- a/coders/pcx.c
+++ b/coders/pcx.c
@@ -197,7 +197,7 @@
 %
 */
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -228,7 +228,7 @@
     id,
     mask;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -244,13 +244,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -266,7 +266,7 @@
     *pcx_pixels,
     *scanline;
 
-  unsigned long
+  size_t
     pcx_packets;
 
   /*
@@ -292,7 +292,7 @@
   page_table=(MagickOffsetType *) NULL;
   if (LocaleCompare(image_info->magick,"DCX") == 0)
     {
-      unsigned long
+      size_t
         magic;
 
       /*
@@ -339,9 +339,9 @@
     /*
       Read PCX raster colormap.
     */
-    image->columns=(unsigned long) MagickAbsoluteValue((long) pcx_info.right-
+    image->columns=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.right-
       pcx_info.left)+1UL;
-    image->rows=(unsigned long) MagickAbsoluteValue((long) pcx_info.bottom-
+    image->rows=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.bottom-
       pcx_info.top)+1UL;
     if ((image->columns == 0) || (image->rows == 0) ||
         (pcx_info.bits_per_pixel == 0))
@@ -361,14 +361,14 @@
     if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
       if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
           ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))
-        image->colors=(unsigned long) MagickMin(1UL << (1UL*
+        image->colors=(size_t) MagickMin(1UL << (1UL*
           (pcx_info.bits_per_pixel*pcx_info.planes)),256UL);
     if (AcquireImageColormap(image,image->colors) == MagickFalse)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1))
       image->storage_class=DirectClass;
     p=pcx_colormap;
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       image->colormap[i].red=ScaleCharToQuantum(*p++);
       image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -384,7 +384,7 @@
     /*
       Read image data.
     */
-    pcx_packets=(unsigned long) image->rows*pcx_info.bytes_per_line*
+    pcx_packets=(size_t) image->rows*pcx_info.bytes_per_line*
       pcx_info.planes;
     pcx_pixels=(unsigned char *) AcquireQuantumMemory(pcx_packets,
       sizeof(*pcx_pixels));
@@ -462,7 +462,7 @@
                 pcx_info.colormap_signature=(unsigned char) ReadBlobByte(image);
                 count=ReadBlob(image,3*image->colors,pcx_colormap);
                 p=pcx_colormap;
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   image->colormap[i].red=ScaleCharToQuantum(*p++);
                   image->colormap[i].green=ScaleCharToQuantum(*p++);
@@ -474,7 +474,7 @@
     /*
       Convert PCX raster image to pixel packets.
     */
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=pcx_pixels+(y*pcx_info.bytes_per_line*pcx_info.planes);
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
@@ -486,7 +486,7 @@
         for (i=0; i < pcx_info.planes; i++)
         {
           r=scanline+i;
-          for (x=0; x < (long) pcx_info.bytes_per_line; x++)
+          for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)
           {
             switch (i)
             {
@@ -518,12 +518,12 @@
       else
         if (pcx_info.planes > 1)
           {
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
               *r++=0;
             for (i=0; i < pcx_info.planes; i++)
             {
               r=scanline;
-              for (x=0; x < (long) pcx_info.bytes_per_line; x++)
+              for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)
               {
                  bits=(*p++);
                  for (mask=0x80; mask != 0; mask>>=1)
@@ -540,10 +540,10 @@
           {
             case 1:
             {
-              register long
+              register ssize_t
                 bit;
 
-              for (x=0; x < ((long) image->columns-7); x+=8)
+              for (x=0; x < ((ssize_t) image->columns-7); x+=8)
               {
                 for (bit=7; bit >= 0; bit--)
                   *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
@@ -551,7 +551,7 @@
               }
               if ((image->columns % 8) != 0)
                 {
-                  for (bit=7; bit >= (long) (8-(image->columns % 8)); bit--)
+                  for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--)
                     *r++=(unsigned char) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
                   p++;
                 }
@@ -559,7 +559,7 @@
             }
             case 2:
             {
-              for (x=0; x < ((long) image->columns-3); x+=4)
+              for (x=0; x < ((ssize_t) image->columns-3); x+=4)
               {
                 *r++=(*p >> 6) & 0x3;
                 *r++=(*p >> 4) & 0x3;
@@ -569,7 +569,7 @@
               }
               if ((image->columns % 4) != 0)
                 {
-                  for (i=3; i >= (long) (4-(image->columns % 4)); i--)
+                  for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--)
                     *r++=(unsigned char) ((*p >> (i*2)) & 0x03);
                   p++;
                 }
@@ -577,7 +577,7 @@
             }
             case 4:
             {
-              for (x=0; x < ((long) image->columns-1); x+=2)
+              for (x=0; x < ((ssize_t) image->columns-1); x+=2)
               {
                 *r++=(*p >> 4) & 0xf;
                 *r++=(*p) & 0xf;
@@ -599,7 +599,7 @@
         Transfer image scanline.
       */
       r=scanline;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if (image->storage_class == PseudoClass)
           indexes[x]=(IndexPacket) (*r++);
@@ -692,10 +692,10 @@
 %
 %  The format of the RegisterPCXImage method is:
 %
-%      unsigned long RegisterPCXImage(void)
+%      size_t RegisterPCXImage(void)
 %
 */
-ModuleExport unsigned long RegisterPCXImage(void)
+ModuleExport size_t RegisterPCXImage(void)
 {
   MagickInfo
     *entry;
@@ -777,7 +777,7 @@
   register const unsigned char
     *q;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -789,11 +789,11 @@
     previous;
 
   q=pixels;
-  for (i=0; i < (long) pcx_info->planes; i++)
+  for (i=0; i < (ssize_t) pcx_info->planes; i++)
   {
     previous=(*q++);
     count=1;
-    for (x=0; x < (long) (pcx_info->bytes_per_line-1); x++)
+    for (x=0; x < (ssize_t) (pcx_info->bytes_per_line-1); x++)
     {
       packet=(*q++);
       if ((packet == previous) && (count < 63))
@@ -822,7 +822,7 @@
 
 static MagickBooleanType WritePCXImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -842,7 +842,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -932,7 +932,7 @@
         if (image->matte != MagickFalse)
           pcx_info.planes++;
       }
-    pcx_info.bytes_per_line=(unsigned short) (((unsigned long) image->columns*
+    pcx_info.bytes_per_line=(unsigned short) (((size_t) image->columns*
       pcx_info.bits_per_pixel+7)/8);
     pcx_info.palette_info=1;
     pcx_info.colormap_signature=0x0c;
@@ -959,7 +959,7 @@
     (void) memset(pcx_colormap,0,3*256*sizeof(*pcx_colormap));
     q=pcx_colormap;
     if ((image->storage_class == PseudoClass) && (image->colors <= 256))
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         *q++=ScaleQuantumToChar(image->colormap[i].red);
         *q++=ScaleQuantumToChar(image->colormap[i].green);
@@ -986,7 +986,7 @@
         /*
           Convert DirectClass image to PCX raster pixels.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           pixels=GetVirtualPixels(image,0,y,image->columns,1,
             &image->exception);
@@ -1000,7 +1000,7 @@
             {
               case 0:
               {
-                for (x=0; x < (long) pcx_info.bytes_per_line; x++)
+                for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)
                 {
                   *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
                   p++;
@@ -1009,7 +1009,7 @@
               }
               case 1:
               {
-                for (x=0; x < (long) pcx_info.bytes_per_line; x++)
+                for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)
                 {
                   *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
                   p++;
@@ -1018,7 +1018,7 @@
               }
               case 2:
               {
-                for (x=0; x < (long) pcx_info.bytes_per_line; x++)
+                for (x=0; x < (ssize_t) pcx_info.bytes_per_line; x++)
                 {
                   *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
                   p++;
@@ -1028,7 +1028,7 @@
               case 3:
               default:
               {
-                for (x=(long) pcx_info.bytes_per_line; x != 0; x--)
+                for (x=(ssize_t) pcx_info.bytes_per_line; x != 0; x--)
                 {
                   *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
                   p++;
@@ -1050,14 +1050,14 @@
     else
       {
         if (pcx_info.bits_per_pixel > 1)
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
               break;
             indexes=GetVirtualIndexQueue(image);
             q=pcx_pixels;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
               *q++=(unsigned char) indexes[x];
             if (PCXWritePixels(&pcx_info,pcx_pixels,image) == MagickFalse)
               break;
@@ -1086,7 +1086,7 @@
               polarity=(IndexPacket) (
                 PixelIntensityToQuantum(&image->colormap[0]) <
                 PixelIntensityToQuantum(&image->colormap[1]) ? 1 : 0);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
@@ -1096,7 +1096,7 @@
               bit=0;
               byte=0;
               q=pcx_pixels;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 byte<<=1;
                 if (indexes[x] == polarity)
@@ -1149,8 +1149,8 @@
       if (offset < 0)
         ThrowWriterException(CorruptImageError,"ImproperImageHeader");
       (void) WriteBlobLSBLong(image,0x3ADE68B1L);
-      for (i=0; i <= (long) scene; i++)
-        (void) WriteBlobLSBLong(image,(unsigned long) page_table[i]);
+      for (i=0; i <= (ssize_t) scene; i++)
+        (void) WriteBlobLSBLong(image,(size_t) page_table[i]);
       page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table);
     }
   if (status == MagickFalse)
diff --git a/coders/pdb.c b/coders/pdb.c
index 97de9f9..160a355 100644
--- a/coders/pdb.c
+++ b/coders/pdb.c
@@ -84,7 +84,7 @@
     attributes,
     version;
 
-  unsigned long
+  size_t
     create_time,
     modify_time,
     archive_time,
@@ -96,7 +96,7 @@
     type[4],  /* database type identifier "vIMG" */
     id[4];    /* database creator identifier "View" */
 
-  unsigned long
+  size_t
     seed,
     next_record;
 
@@ -111,7 +111,7 @@
     version,
     type;
 
-  unsigned long
+  size_t
     reserved_1,
     note;
 
@@ -119,7 +119,7 @@
     x_last,
     y_last;
 
-  unsigned long
+  size_t
     reserved_2;
 
   short int
@@ -271,7 +271,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     img_offset, /* TS */
     comment_offset = 0,
     y;
@@ -288,7 +288,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -303,7 +303,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     num_pad_bytes, /* TS */
     bits_per_pixel,
     packets;
@@ -350,7 +350,7 @@
   /*
     Read record header.
   */
-  img_offset=(long) ReadBlobMSBLong(image); /* TS */
+  img_offset=(ssize_t) ReadBlobMSBLong(image); /* TS */
   attributes=(unsigned char) ReadBlobByte(image);
   count=ReadBlob(image,3,(unsigned char *) tag);
   if (count != 3  ||  memcmp(tag,"\x6f\x80\x00",3) != 0)
@@ -358,14 +358,14 @@
 
   if (pdb_info.number_records > 1)
     {
-      comment_offset=(long) ReadBlobMSBLong(image);
+      comment_offset=(ssize_t) ReadBlobMSBLong(image);
       attributes=(unsigned char) ReadBlobByte(image);
       count=ReadBlob(image,3,(unsigned char *) tag);
       if (count != 3  ||  memcmp(tag,"\x6f\x80\x01",3) != 0)
         ThrowReaderException(CorruptImageError,"CorruptImage");
     }
 
-  num_pad_bytes = (unsigned long) (img_offset - TellBlob( image ));
+  num_pad_bytes = (size_t) (img_offset - TellBlob( image ));
   while (num_pad_bytes--) ReadBlobByte( image );
   /*
     Read image header.
@@ -385,8 +385,8 @@
   /*
     Initialize image structure.
   */
-  image->columns=(unsigned long) pdb_image.width;
-  image->rows=(unsigned long) pdb_image.height;
+  image->columns=(size_t) pdb_image.width;
+  image->rows=(size_t) pdb_image.height;
   image->depth=8;
   image->storage_class=PseudoClass;
   bits_per_pixel=pdb_image.type == 0 ? 2UL : pdb_image.type == 2 ? 4UL : 1UL;
@@ -433,19 +433,19 @@
       /*
         Read 1-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        for (x=0; x < ((ssize_t) image->columns-7); x+=8)
         {
           for (bit=0; bit < 8; bit++)
           {
             index=(IndexPacket) (*p & (0x80 >> bit) ? 0x00 : 0x01);
             indexes[x+bit]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
           }
           p++;
         }
@@ -462,26 +462,26 @@
       /*
         Read 2-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x+=4)
+        for (x=0; x < (ssize_t) image->columns; x+=4)
         {
           index=ConstrainColormapIndex(image,3UL-((*p >> 6) & 0x03));
           indexes[x]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           index=ConstrainColormapIndex(image,3UL-((*p >> 4) & 0x03));
           indexes[x+1]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           index=ConstrainColormapIndex(image,3UL-((*p >> 2) & 0x03));
           indexes[x+2]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           index=ConstrainColormapIndex(image,3UL-((*p) & 0x03));
           indexes[x+3]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           p++;
         }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -497,20 +497,20 @@
       /*
         Read 4-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x+=2)
+        for (x=0; x < (ssize_t) image->columns; x+=2)
         {
           index=ConstrainColormapIndex(image,15UL-((*p >> 4) & 0x0f));
           indexes[x]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           index=ConstrainColormapIndex(image,15UL-((*p) & 0x0f));
           indexes[x+1]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
           p++;
         }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -540,10 +540,10 @@
       register char
         *p;
 
-      unsigned long
+      size_t
         length;
 
-      num_pad_bytes = (unsigned long) (comment_offset - TellBlob( image ));
+      num_pad_bytes = (size_t) (comment_offset - TellBlob( image ));
       while (num_pad_bytes--) ReadBlobByte( image );
 
       /*
@@ -598,10 +598,10 @@
 %
 %  The format of the RegisterPDBImage method is:
 %
-%      unsigned long RegisterPDBImage(void)
+%      size_t RegisterPDBImage(void)
 %
 */
-ModuleExport unsigned long RegisterPDBImage(void)
+ModuleExport size_t RegisterPDBImage(void)
 {
   MagickInfo
     *entry;
@@ -667,7 +667,7 @@
 */
 
 static unsigned char *EncodeRLE(unsigned char *destination,
-  unsigned char *source,unsigned long literal,unsigned long repeat)
+  unsigned char *source,size_t literal,size_t repeat)
 {
   if (literal > 0)
     *destination++=(unsigned char) (literal-1);
@@ -689,7 +689,7 @@
   int
     bits;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -707,7 +707,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -721,7 +721,7 @@
     *runlength,
     *scanline;
 
-  unsigned long
+  size_t
     bits_per_pixel,
     literal,
     packets,
@@ -779,8 +779,8 @@
   (void) WriteBlobMSBLong(image,pdb_info.sort_info);
   (void) WriteBlob(image,4,(unsigned char *) pdb_info.type);
   (void) WriteBlob(image,4,(unsigned char *) pdb_info.id);
-  (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.seed);
-  (void) WriteBlobMSBLong(image,(unsigned long) pdb_info.next_record);
+  (void) WriteBlobMSBLong(image,(size_t) pdb_info.seed);
+  (void) WriteBlobMSBLong(image,(size_t) pdb_info.next_record);
   (void) WriteBlobMSBShort(image,(unsigned short) pdb_info.number_records);
   (void) CopyMagickString(pdb_image.name,pdb_info.name,32);
   pdb_image.version=1;  /* RLE Compressed */
@@ -822,12 +822,12 @@
   quantum_info=AcquireQuantumInfo(image_info,image);
   if (quantum_info == (QuantumInfo *) NULL)
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
-  bits=8/(long) bits_per_pixel-1;  /* start at most significant bits */
+  bits=8/(ssize_t) bits_per_pixel-1;  /* start at most significant bits */
   literal=0;
   repeat=0;
   q=runlength;
   buffer[0]=0x00;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -836,7 +836,7 @@
       GrayQuantum,scanline,&image->exception);
     for (x=0; x < pdb_image.width; x++)
     {
-      if (x < (long) image->columns)
+      if (x < (ssize_t) image->columns)
         buffer[literal+repeat]|=(0xff-scanline[x*packet_size]) >>
           (8-bits_per_pixel) << bits*bits_per_pixel;
       bits--;
@@ -877,7 +877,7 @@
                   literal-=0x80;
                 }
             }
-        bits=8/(long) bits_per_pixel-1;
+        bits=8/(ssize_t) bits_per_pixel-1;
         buffer[literal+repeat]=0x00;
       }
     }
@@ -892,7 +892,7 @@
   /*
     Write the Image record header.
   */
-  (void) WriteBlobMSBLong(image,(unsigned long)
+  (void) WriteBlobMSBLong(image,(size_t)
     (TellBlob(image)+8*pdb_info.number_records));
   (void) WriteBlobByte(image,0x40);
   (void) WriteBlobByte(image,0x6f);
@@ -903,7 +903,7 @@
       /*
         Write the comment record header.
       */
-      (void) WriteBlobMSBLong(image,(unsigned long) (TellBlob(image)+8+58+q-
+      (void) WriteBlobMSBLong(image,(size_t) (TellBlob(image)+8+58+q-
         runlength));
       (void) WriteBlobByte(image,0x40);
       (void) WriteBlobByte(image,0x6f);
diff --git a/coders/pdf.c b/coders/pdf.c
index 3a93f05..498d5ad 100644
--- a/coders/pdf.c
+++ b/coders/pdf.c
@@ -138,7 +138,7 @@
     argc,
     code;
 
-  register long
+  register ssize_t
     i;
 
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
@@ -185,7 +185,7 @@
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
   NTGhostscriptUnLoadDLL();
 #endif
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
     argv[i]=DestroyString(argv[i]);
   argv=(char **) RelinquishMagickMemory(argv);
   if ((status != 0) && (status != -101))
@@ -358,7 +358,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     scene,
     spotcolor;
 
@@ -450,7 +450,7 @@
           property[MaxTextExtent],
           *value;
 
-        register long
+        register ssize_t
           i;
 
         /*
@@ -528,15 +528,15 @@
           "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
            bounds.x1,bounds.y1);
         (void) SetImageProperty(image,"pdf:HiResBoundingBox",geometry);
-        page.width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
-        page.height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
+        page.width=(size_t) floor(bounds.x2-bounds.x1+0.5);
+        page.height=(size_t) floor(bounds.y2-bounds.y1+0.5);
         hires_bounds=bounds;
       }
   }
   (void) CloseBlob(image);
   if ((fabs(angle) == 90.0) || (fabs(angle) == 270.0))
     {
-      unsigned long
+      size_t
         swap;
 
       swap=page.width;
@@ -592,9 +592,9 @@
   if (image_info->page != (char *) NULL)
     {
       (void) ParseAbsoluteGeometry(image_info->page,&page);
-      page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+
+      page.width=(size_t) floor(page.width*image->x_resolution/delta.x+
         0.5);
-      page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+      page.height=(size_t) floor(page.height*image->y_resolution/delta.y+
         0.5);
       (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",page.width,
         page.height);
@@ -662,13 +662,13 @@
       Image
         *clone_image;
 
-      register long
+      register ssize_t
         i;
 
       /*
         Add place holder images to meet the subimage specification requirement.
       */
-      for (i=0; i < (long) image_info->scene; i++)
+      for (i=0; i < (ssize_t) image_info->scene; i++)
       {
         clone_image=CloneImage(pdf_image,1,1,MagickTrue,exception);
         if (clone_image != (Image *) NULL)
@@ -715,10 +715,10 @@
 %
 %  The format of the RegisterPDFImage method is:
 %
-%      unsigned long RegisterPDFImage(void)
+%      size_t RegisterPDFImage(void)
 %
 */
-ModuleExport unsigned long RegisterPDFImage(void)
+ModuleExport size_t RegisterPDFImage(void)
 {
   MagickInfo
     *entry;
@@ -838,18 +838,18 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   static char
     buffer[MaxTextExtent];
 
-  unsigned long
+  size_t
     escapes;
 
   escapes=0;
   p=buffer;
-  for (i=0; i < (long) MagickMin(strlen(text),(MaxTextExtent-escapes-1)); i++)
+  for (i=0; i < (ssize_t) MagickMin(strlen(text),(MaxTextExtent-escapes-1)); i++)
   {
     if ((text[i] == '(') || (text[i] == ')'))
       {
@@ -959,7 +959,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     count,
     y;
 
@@ -1000,7 +1000,7 @@
   register unsigned char
     *q;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1016,7 +1016,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     info_id,
     object,
     pages_id,
@@ -1049,12 +1049,12 @@
   object=0;
   version=3;
   if (image_info->compression == JPEG2000Compression)
-    version=(unsigned long) MagickMax(version,5);
+    version=(size_t) MagickMax(version,5);
   for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
     if (next->matte != MagickFalse)
-      version=(unsigned long) MagickMax(version,4);
+      version=(size_t) MagickMax(version,4);
   if (LocaleCompare(image_info->magick,"PDFA") == 0)
-    version=(unsigned long) MagickMax(version,6);
+    version=(size_t) MagickMax(version,6);
   (void) FormatMagickString(buffer,MaxTextExtent,"%%PDF-1.%lu \n",version);
   (void) WriteBlobString(image,buffer);
   if (LocaleCompare(image_info->magick,"PDFA") == 0)
@@ -1090,7 +1090,7 @@
         timestamp[MaxTextExtent],
         xmp_profile[MaxTextExtent];
 
-      unsigned long
+      size_t
         version;
 
       /*
@@ -1132,7 +1132,7 @@
   (void) WriteBlobString(image,"/Type /Pages\n");
   (void) FormatMagickString(buffer,MaxTextExtent,"/Kids [ %lu 0 R ",object+1);
   (void) WriteBlobString(image,buffer);
-  count=(long) (pages_id+ObjectsPerImage+1);
+  count=(ssize_t) (pages_id+ObjectsPerImage+1);
   if (image_info->adjoin != MagickFalse)
     {
       Image
@@ -1250,8 +1250,8 @@
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(unsigned long) (100.0*2.54*resolution.x+0.5)/100.0;
-        resolution.y=(unsigned long) (100.0*2.54*resolution.y+0.5)/100.0;
+        resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
+        resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
       }
     SetGeometry(image,&geometry);
     (void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu",
@@ -1270,16 +1270,16 @@
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) floor(scale.x+0.5);
+    geometry.width=(size_t) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) floor(scale.y+0.5);
+    geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
     if (image->gravity != UndefinedGravity)
       {
         geometry.x=(-page_info.x);
-        geometry.y=(long) (media_info.height+page_info.y-image->rows);
+        geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows);
       }
     pointsize=12.0;
     if (image_info->pointsize != 0.0)
@@ -1287,7 +1287,7 @@
     text_size=0;
     value=GetImageProperty(image,"Label");
     if (value != (const char *) NULL)
-      text_size=(unsigned long) (MultilineCensus(value)*pointsize+12);
+      text_size=(size_t) (MultilineCensus(value)*pointsize+12);
     /*
       Write Page object.
     */
@@ -1354,7 +1354,7 @@
           image->scene,pointsize);
         (void) WriteBlobString(image,buffer);
         (void) FormatMagickString(buffer,MaxTextExtent,"%ld %ld Td\n",
-          geometry.x,(long) (geometry.y+geometry.height+i*pointsize+12));
+          geometry.x,(ssize_t) (geometry.y+geometry.height+i*pointsize+12));
         (void) WriteBlobString(image,buffer);
         (void) FormatMagickString(buffer,MaxTextExtent,"(%s) Tj\n",labels[i]);
         (void) WriteBlobString(image,buffer);
@@ -1377,7 +1377,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
-      (unsigned long) offset);
+      (size_t) offset);
     (void) WriteBlobString(image,buffer);
     (void) WriteBlobString(image,"endobj\n");
     /*
@@ -1559,13 +1559,13 @@
               Dump Runlength encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
                 p++;
@@ -1600,13 +1600,13 @@
               Dump uncompressed PseudoColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 Ascii85Encode(image,
                   ScaleQuantumToChar(PixelIntensityToQuantum(p)));
@@ -1662,14 +1662,14 @@
               Dump runoffset encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetVirtualIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
                 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1708,14 +1708,14 @@
               Dump uncompressed DirectColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetVirtualIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 Ascii85Encode(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
                 Ascii85Encode(image,ScaleQuantumToChar(GetGreenPixelComponent(p)));
@@ -1758,14 +1758,14 @@
                 Dump Runlength encoded pixels.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                   *q++=(unsigned char) indexes[x];
                 if (image->previous == (Image *) NULL)
                   {
@@ -1797,14 +1797,14 @@
                 Dump uncompressed PseudoColor packets.
               */
               Ascii85Initialize(image);
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                   Ascii85Encode(image,(unsigned char) indexes[x]);
                 if (image->previous == (Image *) NULL)
                   {
@@ -1828,7 +1828,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
-      (unsigned long) offset);
+      (size_t) offset);
     (void) WriteBlobString(image,buffer);
     (void) WriteBlobString(image,"endobj\n");
     /*
@@ -1999,13 +1999,13 @@
               Dump Runlength encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) tile_image->rows; y++)
+            for (y=0; y < (ssize_t) tile_image->rows; y++)
             {
               p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                 &tile_image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) tile_image->columns; x++)
+              for (x=0; x < (ssize_t) tile_image->columns; x++)
               {
                 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
                 p++;
@@ -2034,13 +2034,13 @@
               Dump uncompressed PseudoColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) tile_image->rows; y++)
+            for (y=0; y < (ssize_t) tile_image->rows; y++)
             {
               p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                 &tile_image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) tile_image->columns; x++)
+              for (x=0; x < (ssize_t) tile_image->columns; x++)
               {
                 Ascii85Encode(image,
                   ScaleQuantumToChar(PixelIntensityToQuantum(p)));
@@ -2094,14 +2094,14 @@
               Dump runoffset encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) tile_image->rows; y++)
+            for (y=0; y < (ssize_t) tile_image->rows; y++)
             {
               p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                 &tile_image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetVirtualIndexQueue(tile_image);
-              for (x=0; x < (long) tile_image->columns; x++)
+              for (x=0; x < (ssize_t) tile_image->columns; x++)
               {
                 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
                 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -2134,14 +2134,14 @@
               Dump uncompressed DirectColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) tile_image->rows; y++)
+            for (y=0; y < (ssize_t) tile_image->rows; y++)
             {
               p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                 &tile_image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetVirtualIndexQueue(tile_image);
-              for (x=0; x < (long) tile_image->columns; x++)
+              for (x=0; x < (ssize_t) tile_image->columns; x++)
               {
                 Ascii85Encode(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
                 Ascii85Encode(image,ScaleQuantumToChar(GetGreenPixelComponent(p)));
@@ -2181,14 +2181,14 @@
                 Dump Runlength encoded pixels.
               */
               q=pixels;
-              for (y=0; y < (long) tile_image->rows; y++)
+              for (y=0; y < (ssize_t) tile_image->rows; y++)
               {
                 p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                   &tile_image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(tile_image);
-                for (x=0; x < (long) tile_image->columns; x++)
+                for (x=0; x < (ssize_t) tile_image->columns; x++)
                   *q++=(unsigned char) indexes[x];
               }
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
@@ -2214,14 +2214,14 @@
                 Dump uncompressed PseudoColor packets.
               */
               Ascii85Initialize(image);
-              for (y=0; y < (long) tile_image->rows; y++)
+              for (y=0; y < (ssize_t) tile_image->rows; y++)
               {
                 p=GetVirtualPixels(tile_image,0,y,tile_image->columns,1,
                   &tile_image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(tile_image);
-                for (x=0; x < (long) tile_image->columns; x++)
+                for (x=0; x < (ssize_t) tile_image->columns; x++)
                   Ascii85Encode(image,(unsigned char) indexes[x]);
               }
               Ascii85Flush(image);
@@ -2240,7 +2240,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
-      (unsigned long) offset);
+      (size_t) offset);
     (void) WriteBlobString(image,buffer);
     (void) WriteBlobString(image,"endobj\n");
     xref[object++]=TellBlob(image);
@@ -2263,7 +2263,7 @@
         offset=TellBlob(image);
         if (compression == NoCompression)
           Ascii85Initialize(image);
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           if (compression == NoCompression)
             {
@@ -2292,7 +2292,7 @@
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
-      (unsigned long) offset);
+      (size_t) offset);
     (void) WriteBlobString(image,buffer);
     (void) WriteBlobString(image,"endobj\n");
     /*
@@ -2377,13 +2377,13 @@
               Dump Runlength encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
                 p++;
@@ -2412,13 +2412,13 @@
               Dump uncompressed PseudoColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 Ascii85Encode(image,ScaleQuantumToChar((Quantum) (QuantumRange-
                   GetOpacityPixelComponent(p))));
@@ -2439,7 +2439,7 @@
     xref[object++]=TellBlob(image);
     (void) FormatMagickString(buffer,MaxTextExtent,"%lu 0 obj\n",object);
     (void) WriteBlobString(image,buffer);
-    (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(unsigned long)
+    (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(size_t)
       offset);
     (void) WriteBlobString(image,buffer);
     (void) WriteBlobString(image,"endobj\n");
@@ -2476,7 +2476,7 @@
   (void) FormatMagickString(buffer,MaxTextExtent,"/ModDate (%s)\n",date);
   (void) WriteBlobString(image,buffer);
   (void) FormatMagickString(buffer,MaxTextExtent,"/Producer (%s)\n",
-    EscapeParenthesis(GetMagickVersion((unsigned long *) NULL)));
+    EscapeParenthesis(GetMagickVersion((size_t *) NULL)));
   (void) WriteBlobString(image,buffer);
   (void) WriteBlobString(image,">>\n");
   (void) WriteBlobString(image,"endobj\n");
@@ -2488,10 +2488,10 @@
   (void) FormatMagickString(buffer,MaxTextExtent,"0 %lu\n",object+1);
   (void) WriteBlobString(image,buffer);
   (void) WriteBlobString(image,"0000000000 65535 f \n");
-  for (i=0; i < (long) object; i++)
+  for (i=0; i < (ssize_t) object; i++)
   {
     (void) FormatMagickString(buffer,MaxTextExtent,"%010lu 00000 n \n",
-      (unsigned long) xref[i]);
+      (size_t) xref[i]);
     (void) WriteBlobString(image,buffer);
   }
   (void) WriteBlobString(image,"trailer\n");
@@ -2505,7 +2505,7 @@
   (void) WriteBlobString(image,">>\n");
   (void) WriteBlobString(image,"startxref\n");
   (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",
-    (unsigned long) offset);
+    (size_t) offset);
   (void) WriteBlobString(image,buffer);
   (void) WriteBlobString(image,"%%EOF\n");
   xref=(MagickOffsetType *) RelinquishMagickMemory(xref);
diff --git a/coders/pes.c b/coders/pes.c
index 748e244..11da30c 100644
--- a/coders/pes.c
+++ b/coders/pes.c
@@ -452,7 +452,7 @@
   SegmentInfo
     bounds;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -463,7 +463,7 @@
     magick[4],
     version[4];
 
-  unsigned long
+  size_t
     number_blocks,
     number_colors,
     number_stitches;
@@ -501,8 +501,8 @@
   /*
     Get PES colors.
   */
-  number_colors=(unsigned long) ReadBlobByte(image)+1;
-  for (i=0; i < (long) number_colors; i++)
+  number_colors=(size_t) ReadBlobByte(image)+1;
+  for (i=0; i < (ssize_t) number_colors; i++)
   {
     j=(int) ReadBlobByte(image);
     blocks[i].color=PESColor+j;
@@ -510,7 +510,7 @@
   }
   for ( ; i < 256L; i++)
     blocks[i].offset=0;
-  for (i=0; i < (long) (532L-number_colors-21); i++)
+  for (i=0; i < (ssize_t) (532L-number_colors-21); i++)
     if (ReadBlobByte(image) == EOF)
       break;
   if (EOFBlob(image) != MagickFalse)
@@ -602,7 +602,7 @@
     if ((double) y > bounds.y2)
       bounds.y2=(double) y;
     i++;
-    if (i >= (long) number_stitches)
+    if (i >= (ssize_t) number_stitches)
       {
         /*
           Make room for more stitches.
@@ -616,7 +616,7 @@
   }
   j++;
   blocks[j].offset=(ssize_t) i;
-  number_blocks=(unsigned long) j;
+  number_blocks=(size_t) j;
   /*
     Write stitches as SVG file.
   */
@@ -632,14 +632,14 @@
     "ev=\"http://www.w3.org/2001/xml-events\" version=\"1.1\" "
     "baseProfile=\"full\" width=\"%g\" height=\"%g\">\n",bounds.x2-bounds.x1,
     bounds.y2-bounds.y1);
-  for (i=0; i < (long) number_blocks; i++)
+  for (i=0; i < (ssize_t) number_blocks; i++)
   {
     offset=blocks[i].offset;
     (void) fprintf(file,"  <path stroke=\"#%02x%02x%02x\" fill=\"none\" "
       "d=\"M %g %g",blocks[i].color->red,blocks[i].color->green,
       blocks[i].color->blue,stitches[offset].x-bounds.x1,
       stitches[offset].y-bounds.y1);
-    for (j=1; j < (long) (blocks[i+1].offset-offset); j++)
+    for (j=1; j < (ssize_t) (blocks[i+1].offset-offset); j++)
       (void) fprintf(file," L %g %g",stitches[offset+j].x-bounds.x1,
         stitches[offset+j].y-bounds.y1);
     (void) fprintf(file,"\"/>\n");
@@ -689,10 +689,10 @@
 %
 %  The format of the RegisterPESImage method is:
 %
-%      unsigned long RegisterPESImage(void)
+%      size_t RegisterPESImage(void)
 %
 */
-ModuleExport unsigned long RegisterPESImage(void)
+ModuleExport size_t RegisterPESImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/pict.c b/coders/pict.c
index 08f8715..1430c1c 100644
--- a/coders/pict.c
+++ b/coders/pict.c
@@ -109,7 +109,7 @@
   const char
     *name;
 
-  long
+  ssize_t
     length;
 
   const char
@@ -122,7 +122,7 @@
     version,
     pack_type;
 
-  unsigned long
+  size_t
     pack_size,
     horizontal_resolution,
     vertical_resolution;
@@ -133,7 +133,7 @@
     component_count,
     component_size;
 
-  unsigned long
+  size_t
     plane_bytes,
     table,
     reserved;
@@ -165,8 +165,8 @@
     /* 0x0b */ { "OvSize", 4, "oval size (point)" },
     /* 0x0c */ { "Origin", 4, "dh, dv (word)" },
     /* 0x0d */ { "TxSize", 2, "text size (word)" },
-    /* 0x0e */ { "FgColor", 4, "foreground color (longword)" },
-    /* 0x0f */ { "BkColor", 4, "background color (longword)" },
+    /* 0x0e */ { "FgColor", 4, "foreground color (ssize_tword)" },
+    /* 0x0f */ { "BkColor", 4, "background color (ssize_tword)" },
     /* 0x10 */ { "TxRatio", 8, "numerator (point), denominator (point)" },
     /* 0x11 */ { "Version", 1, "version (byte)" },
     /* 0x12 */ { "BkPixPat", 0, "color background pattern" },
@@ -338,7 +338,7 @@
 %  The format of the DecodeImage method is:
 %
 %      unsigned char *DecodeImage(Image *blob,Image *image,
-%        unsigned long bytes_per_line,const int bits_per_pixel,
+%        size_t bytes_per_line,const int bits_per_pixel,
 %        unsigned size_t extent)
 %
 %  A description of each parameter follows:
@@ -359,7 +359,7 @@
 static unsigned char *ExpandBuffer(unsigned char *pixels,
   MagickSizeType *bytes_per_line,const unsigned int bits_per_pixel)
 {
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -379,7 +379,7 @@
       return(pixels);
     case 4:
     {
-      for (i=0; i < (long) *bytes_per_line; i++)
+      for (i=0; i < (ssize_t) *bytes_per_line; i++)
       {
         *q++=(*p >> 4) & 0xff;
         *q++=(*p & 15);
@@ -390,7 +390,7 @@
     }
     case 2:
     {
-      for (i=0; i < (long) *bytes_per_line; i++)
+      for (i=0; i < (ssize_t) *bytes_per_line; i++)
       {
         *q++=(*p >> 6) & 0x03;
         *q++=(*p >> 4) & 0x03;
@@ -403,7 +403,7 @@
     }
     case 1:
     {
-      for (i=0; i < (long) *bytes_per_line; i++)
+      for (i=0; i < (ssize_t) *bytes_per_line; i++)
       {
         *q++=(*p >> 7) & 0x01;
         *q++=(*p >> 6) & 0x01;
@@ -425,16 +425,16 @@
 }
 
 static unsigned char *DecodeImage(Image *blob,Image *image,
-  unsigned long bytes_per_line,const unsigned int bits_per_pixel,size_t *extent)
+  size_t bytes_per_line,const unsigned int bits_per_pixel,size_t *extent)
 {
-  long
+  ssize_t
     j,
     y;
 
   MagickSizeType
     number_pixels;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -452,7 +452,7 @@
     *pixels,
     *scanline;
 
-  unsigned long
+  size_t
     bytes_per_pixel,
     scanline_length,
     width;
@@ -494,7 +494,7 @@
       /*
         Pixels are already uncompressed.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=pixels+y*width;
         number_pixels=bytes_per_line;
@@ -515,7 +515,7 @@
   /*
     Uncompress RLE pixels into uncompressed pixel buffer.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=pixels+y*width;
     if (bytes_per_line > 200)
@@ -529,7 +529,7 @@
         break;
       }
     count=ReadBlob(blob,scanline_length,scanline);
-    for (j=0; j < (long) scanline_length; )
+    for (j=0; j < (ssize_t) scanline_length; )
       if ((scanline[j] & 0x80) == 0)
         {
           length=(size_t) ((scanline[j] & 0xff)+1);
@@ -538,14 +538,14 @@
           if ((q-pixels+number_pixels) <= *extent)
             (void) CopyMagickMemory(q,p,(size_t) number_pixels);
           q+=number_pixels;
-          j+=(long) (length*bytes_per_pixel+1);
+          j+=(ssize_t) (length*bytes_per_pixel+1);
         }
       else
         {
           length=(size_t) (((scanline[j] ^ 0xff) & 0xff)+2);
           number_pixels=bytes_per_pixel;
           p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             if ((q-pixels+number_pixels) <= *extent)
               (void) CopyMagickMemory(q,p,(size_t) number_pixels);
@@ -575,7 +575,7 @@
 %  The format of the EncodeImage method is:
 %
 %      size_t EncodeImage(Image *image,const unsigned char *scanline,
-%        const unsigned long bytes_per_line,unsigned char *pixels)
+%        const size_t bytes_per_line,unsigned char *pixels)
 %
 %  A description of each parameter follows:
 %
@@ -590,12 +590,12 @@
 %
 */
 static size_t EncodeImage(Image *image,const unsigned char *scanline,
-  const unsigned long bytes_per_line,unsigned char *pixels)
+  const size_t bytes_per_line,unsigned char *pixels)
 {
 #define MaxCount  128
 #define MaxPackbitsRunlength  128
 
-  long
+  ssize_t
     count,
     repeat_count,
     runlength;
@@ -603,7 +603,7 @@
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -629,7 +629,7 @@
   p=scanline+(bytes_per_line-1);
   q=pixels;
   index=(*p);
-  for (i=(long) bytes_per_line-1; i >= 0; i--)
+  for (i=(ssize_t) bytes_per_line-1; i >= 0; i--)
   {
     if (index == *p)
       runlength++;
@@ -781,8 +781,8 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
@@ -805,7 +805,7 @@
     c,
     code;
 
-  long
+  ssize_t
     flags,
     j,
     version,
@@ -824,13 +824,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -929,7 +929,7 @@
             length=ReadBlobMSBShort(image);
             if (length != 0x000a)
               {
-                for (i=0; i < (long) (length-2); i++)
+                for (i=0; i < (ssize_t) (length-2); i++)
                   (void) ReadBlobByte(image);
                 break;
               }
@@ -945,10 +945,10 @@
           case 0x13:
           case 0x14:
           {
-            long
+            ssize_t
               pattern;
 
-            unsigned long
+            size_t
               height,
               width;
 
@@ -976,7 +976,7 @@
             (void) ReadBlobMSBLong(image);
             flags=1L*ReadBlobMSBShort(image);
             length=ReadBlobMSBShort(image);
-            for (i=0; i <= (long) length; i++)
+            for (i=0; i <= (ssize_t) length; i++)
               (void) ReadBlobMSBLong(image);
             width=1UL*(frame.bottom-frame.top);
             height=1UL*(frame.right-frame.left);
@@ -988,16 +988,16 @@
               length=width;
             if (length < 8)
               {
-                for (i=0; i < (long) (length*height); i++)
+                for (i=0; i < (ssize_t) (length*height); i++)
                   (void) ReadBlobByte(image);
               }
             else
               for (j=0; j < (int) height; j++)
                 if (length > 200)
-                  for (j=0; j < (long) ReadBlobMSBShort(image); j++)
+                  for (j=0; j < (ssize_t) ReadBlobMSBShort(image); j++)
                     (void) ReadBlobByte(image);
                 else
-                  for (j=0; j < (long) ReadBlobByte(image); j++)
+                  for (j=0; j < (ssize_t) ReadBlobByte(image); j++)
                     (void) ReadBlobByte(image);
             break;
           }
@@ -1027,7 +1027,7 @@
               Skip polygon or region.
             */
             length=ReadBlobMSBShort(image);
-            for (i=0; i < (long) (length-2); i++)
+            for (i=0; i < (ssize_t) (length-2); i++)
               (void) ReadBlobByte(image);
             break;
           }
@@ -1038,7 +1038,7 @@
           case 0x9a:
           case 0x9b:
           {
-            long
+            ssize_t
               bytes_per_line;
 
             PICTRectangle
@@ -1111,7 +1111,7 @@
                   }
                 if ((bytes_per_line & 0x8000) != 0)
                   {
-                    for (i=0; i < (long) tile_image->colors; i++)
+                    for (i=0; i < (ssize_t) tile_image->colors; i++)
                     {
                       j=ReadBlobMSBShort(image) % tile_image->colors;
                       if ((flags & 0x8000) != 0)
@@ -1126,7 +1126,7 @@
                   }
                 else
                   {
-                    for (i=0; i < (long) tile_image->colors; i++)
+                    for (i=0; i < (ssize_t) tile_image->colors; i++)
                     {
                       tile_image->colormap[i].red=(Quantum) (QuantumRange-
                         tile_image->colormap[i].red);
@@ -1146,7 +1146,7 @@
                   Skip region.
                 */
                 length=ReadBlobMSBShort(image);
-                for (i=0; i < (long) (length-2); i++)
+                for (i=0; i < (ssize_t) (length-2); i++)
                   (void) ReadBlobByte(image);
               }
             if ((code != 0x9a) && (code != 0x9b) &&
@@ -1165,7 +1165,7 @@
               Convert PICT tile image to pixel packets.
             */
             p=pixels;
-            for (y=0; y < (long) tile_image->rows; y++)
+            for (y=0; y < (ssize_t) tile_image->rows; y++)
             {
               if (p > (pixels+extent+image->columns))
                 ThrowReaderException(CorruptImageError,"NotEnoughPixelData");
@@ -1174,15 +1174,15 @@
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(tile_image);
-              for (x=0; x < (long) tile_image->columns; x++)
+              for (x=0; x < (ssize_t) tile_image->columns; x++)
               {
                 if (tile_image->storage_class == PseudoClass)
                   {
                     index=ConstrainColormapIndex(tile_image,*p);
                     indexes[x]=index;
-                    q->red=tile_image->colormap[(long) index].red;
-                    q->green=tile_image->colormap[(long) index].green;
-                    q->blue=tile_image->colormap[(long) index].blue;
+                    q->red=tile_image->colormap[(ssize_t) index].red;
+                    q->green=tile_image->colormap[(ssize_t) index].green;
+                    q->blue=tile_image->colormap[(ssize_t) index].blue;
                   }
                 else
                   {
@@ -1253,7 +1253,7 @@
             unsigned char
               *info;
 
-            unsigned long
+            size_t
               type;
 
             /*
@@ -1313,7 +1313,7 @@
             if (codes[code].length == -1)
               (void) ReadBlobMSBShort(image);
             else
-              for (i=0; i < (long) codes[code].length; i++)
+              for (i=0; i < (ssize_t) codes[code].length; i++)
                 (void) ReadBlobByte(image);
           }
         }
@@ -1369,7 +1369,7 @@
         ReadRectangle(image,frame);
         for (i=0; i < 122; i++)
           (void) ReadBlobByte(image);
-        for (i=0; i < (long) (length-154); i++)
+        for (i=0; i < (ssize_t) (length-154); i++)
         {
           c=ReadBlobByte(image);
           (void) fputc(c,file);
@@ -1403,7 +1403,7 @@
           Skip reserved.
         */
         length=ReadBlobMSBShort(image);
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
           (void) ReadBlobByte(image);
         continue;
       }
@@ -1413,7 +1413,7 @@
           Skip reserved.
         */
         length=(size_t) ((code >> 7) & 0xff);
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
           (void) ReadBlobByte(image);
         continue;
       }
@@ -1443,10 +1443,10 @@
 %
 %  The format of the RegisterPICTImage method is:
 %
-%      unsigned long RegisterPICTImage(void)
+%      size_t RegisterPICTImage(void)
 %
 */
-ModuleExport unsigned long RegisterPICTImage(void)
+ModuleExport size_t RegisterPICTImage(void)
 {
   MagickInfo
     *entry;
@@ -1541,7 +1541,7 @@
     x_resolution,
     y_resolution;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1567,7 +1567,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1579,7 +1579,7 @@
     *packed_scanline,
     *scanline;
 
-  unsigned long
+  size_t
     bytes_per_line,
     storage_class;
 
@@ -1755,7 +1755,7 @@
         return(MagickFalse);
       jpeg_image=DestroyImage(jpeg_image);
       (void) WriteBlobMSBShort(image,PictJPEGOp);
-      (void) WriteBlobMSBLong(image,(unsigned long) length+154);
+      (void) WriteBlobMSBLong(image,(size_t) length+154);
       (void) WriteBlobMSBShort(image,0x0000);
       (void) WriteBlobMSBLong(image,0x00010000UL);
       (void) WriteBlobMSBLong(image,0x00000000UL);
@@ -1814,7 +1814,7 @@
   else
     {
       (void) WriteBlobMSBShort(image,PictPixmapOp);
-      (void) WriteBlobMSBLong(image,(unsigned long) base_address);
+      (void) WriteBlobMSBLong(image,(size_t) base_address);
     }
   (void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000));
   (void) WriteBlobMSBShort(image,(unsigned short) bounds.top);
@@ -1838,9 +1838,9 @@
   */
   (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count);
   (void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size);
-  (void) WriteBlobMSBLong(image,(unsigned long) pixmap.plane_bytes);
-  (void) WriteBlobMSBLong(image,(unsigned long) pixmap.table);
-  (void) WriteBlobMSBLong(image,(unsigned long) pixmap.reserved);
+  (void) WriteBlobMSBLong(image,(size_t) pixmap.plane_bytes);
+  (void) WriteBlobMSBLong(image,(size_t) pixmap.table);
+  (void) WriteBlobMSBLong(image,(size_t) pixmap.reserved);
   if (storage_class == PseudoClass)
     {
       /*
@@ -1849,7 +1849,7 @@
       (void) WriteBlobMSBLong(image,0x00000000L);  /* color seed */
       (void) WriteBlobMSBShort(image,0L);  /* color flags */
       (void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1));
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         (void) WriteBlobMSBShort(image,(unsigned short) i);
         (void) WriteBlobMSBShort(image,ScaleQuantumToShort(
@@ -1877,15 +1877,15 @@
   */
   count=0;
   if ((storage_class == PseudoClass) && (image->matte == MagickFalse))
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetVirtualIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
         scanline[x]=(unsigned char) indexes[x];
-      count+=EncodeImage(image,scanline,(unsigned long) (row_bytes & 0x7FFF),
+      count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
         packed_scanline);
       if (image->previous == (Image *) NULL)
         {
@@ -1898,8 +1898,8 @@
     if (image_info->compression == JPEGCompression)
       {
         (void) ResetMagickMemory(scanline,0,row_bytes);
-        for (y=0; y < (long) image->rows; y++)
-          count+=EncodeImage(image,scanline,(unsigned long)
+        for (y=0; y < (ssize_t) image->rows; y++)
+          count+=EncodeImage(image,scanline,(size_t)
             (row_bytes & 0x7FFF),packed_scanline);
       }
     else
@@ -1914,7 +1914,7 @@
         green=scanline+image->columns;
         blue=scanline+2*image->columns;
         opacity=scanline+3*image->columns;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1929,7 +1929,7 @@
               green=scanline+2*image->columns;
               blue=scanline+3*image->columns;
             }
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *red++=ScaleQuantumToChar(GetRedPixelComponent(p));
             *green++=ScaleQuantumToChar(GetGreenPixelComponent(p));
diff --git a/coders/pix.c b/coders/pix.c
index 91b4ac6..5d4be1b 100644
--- a/coders/pix.c
+++ b/coders/pix.c
@@ -93,7 +93,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -107,7 +107,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -116,7 +116,7 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     bits_per_pixel,
     height,
     width;
@@ -170,13 +170,13 @@
     blue=(Quantum) 0;
     index=(IndexPacket) 0;
     length=0;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if (length == 0)
           {
@@ -270,10 +270,10 @@
 %
 %  The format of the RegisterPIXImage method is:
 %
-%      unsigned long RegisterPIXImage(void)
+%      size_t RegisterPIXImage(void)
 %
 */
-ModuleExport unsigned long RegisterPIXImage(void)
+ModuleExport size_t RegisterPIXImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/plasma.c b/coders/plasma.c
index 9d8e460..940879c 100644
--- a/coders/plasma.c
+++ b/coders/plasma.c
@@ -109,16 +109,16 @@
     *q;
 
   exception=(&image->exception);
-  q=GetAuthenticPixels(image,(long) ceil(x-0.5),(long) ceil(y-0.5),1,1,
+  q=GetAuthenticPixels(image,(ssize_t) ceil(x-0.5),(ssize_t) ceil(y-0.5),1,1,
     exception);
   if (q == (PixelPacket *) NULL)
     return;
   range=GetQuantumRange(16UL);
-  q->red=ScaleAnyToQuantum((unsigned long) (65535.0*
+  q->red=ScaleAnyToQuantum((size_t) (65535.0*
     GetPseudoRandomValue(random_info)+0.5),range);
-  q->green=ScaleAnyToQuantum((unsigned long) (65535.0*
+  q->green=ScaleAnyToQuantum((size_t) (65535.0*
     GetPseudoRandomValue(random_info)+0.5),range);
-  q->blue=ScaleAnyToQuantum((unsigned long) (65535.0*
+  q->blue=ScaleAnyToQuantum((size_t) (65535.0*
     GetPseudoRandomValue(random_info)+0.5),range);
   (void) SyncAuthenticPixels(image,exception);
 }
@@ -132,25 +132,25 @@
   ImageInfo
     *read_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register unsigned long
+  register size_t
     i;
 
   SegmentInfo
     segment_info;
 
-  unsigned long
+  size_t
     depth,
     max_depth;
 
@@ -166,12 +166,12 @@
   if (image == (Image *) NULL)
     return((Image *) NULL);
   image->storage_class=DirectClass;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->opacity=(Quantum) (QuantumRange/2);
       q++;
@@ -208,7 +208,7 @@
       PlasmaPixel(image,random_info,segment_info.x2,segment_info.y2);
       random_info=DestroyRandomInfo(random_info);
     }
-  i=(unsigned long) MagickMax(image->columns,image->rows)/2;
+  i=(size_t) MagickMax(image->columns,image->rows)/2;
   for (max_depth=0; i != 0; max_depth++)
     i>>=1;
   for (depth=1; ; depth++)
@@ -244,10 +244,10 @@
 %
 %  The format of the RegisterPLASMAImage method is:
 %
-%      unsigned long RegisterPLASMAImage(void)
+%      size_t RegisterPLASMAImage(void)
 %
 */
-ModuleExport unsigned long RegisterPLASMAImage(void)
+ModuleExport size_t RegisterPLASMAImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/png.c b/coders/png.c
index 737d78f..630e644 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -172,7 +172,7 @@
 #endif
 
 /*
-  Maximum valid unsigned long in PNG/MNG chunks is (2^31)-1
+  Maximum valid size_t in PNG/MNG chunks is (2^31)-1
   This macro is only defined in libpng-1.0.3 and later.
   Previously it was PNG_MAX_UINT but that was deprecated in libpng-1.2.6
 */
@@ -244,7 +244,7 @@
 
 typedef struct _MngBox
 {
-  long
+  ssize_t
     left,
     right,
     top,
@@ -253,7 +253,7 @@
 
 typedef struct _MngPair
 {
-  volatile long
+  volatile ssize_t
     a,
     b;
 } MngPair;
@@ -262,7 +262,7 @@
 typedef struct _MngBuffer
 {
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -341,7 +341,7 @@
   int
     new_number_colors;
 
-  long
+  ssize_t
     image_found,
     loop_count[256],
     loop_iteration[256],
@@ -387,7 +387,7 @@
   RenderingIntent
     global_srgb_intent;
 
-  unsigned long
+  size_t
     delay,
     global_plte_length,
     global_trns_length,
@@ -419,7 +419,7 @@
     write_png32;
 
 #ifdef MNG_BASI_SUPPORTED
-  unsigned long
+  size_t
     basi_width,
     basi_height;
 
@@ -466,13 +466,13 @@
   WriteJNGImage(const ImageInfo *,Image *);
 #endif
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -512,7 +512,7 @@
     remap_needed,
     k;
 
-  long
+  ssize_t
     j,
     new_number_colors,
     number_colors,
@@ -530,7 +530,7 @@
   IndexPacket
     top_used;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -578,21 +578,21 @@
   /*
     Mark colors that are present.
   */
-  number_colors=(long) image->colors;
+  number_colors=(ssize_t) image->colors;
   for (i=0; i < number_colors; i++)
   {
     marker[i]=MagickFalse;
     opacity[i]=OpaqueOpacity;
   }
   top_used=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
     if (image->matte != MagickFalse)
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         marker[(int) indexes[x]]=MagickTrue;
         opacity[(int) indexes[x]]=GetOpacityPixelComponent(p);
@@ -601,7 +601,7 @@
         p++;
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         marker[(int) indexes[x]]=MagickTrue;
         if (indexes[x] > top_used)
@@ -659,7 +659,7 @@
     }
 
   remap_needed=MagickFalse;
-  if ((long) top_used >= new_number_colors)
+  if ((ssize_t) top_used >= new_number_colors)
      remap_needed=MagickTrue;
 
   /*
@@ -729,7 +729,7 @@
 
             temp_colormap=colormap[0];
             colormap[0]=colormap[(int) map[i]];
-            colormap[(long) map[i]]=temp_colormap;
+            colormap[(ssize_t) map[i]]=temp_colormap;
             for (j=0; j < number_colors; j++)
             {
               if (map[j] == 0)
@@ -761,13 +761,13 @@
         Remap pixels.
       */
       exception=(&image->exception);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         pixels=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           j=(int) pixels[x];
           pixels[x]=map[j];
@@ -779,7 +779,7 @@
         image->colormap[i]=colormap[i];
     }
   colormap=(PixelPacket *) RelinquishMagickMemory(colormap);
-  image->colors=(unsigned long) new_number_colors;
+  image->colors=(size_t) new_number_colors;
   map=(IndexPacket *) RelinquishMagickMemory(map);
   return(MagickTrue);
 }
@@ -805,7 +805,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x,
     y;
@@ -817,17 +817,17 @@
 
   if (image->storage_class == PseudoClass)
     {
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         if (IsGray(image->colormap+i) == MagickFalse)
           return(MagickFalse);
       return(MagickTrue);
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       return(MagickFalse);
-    for (x=(long) image->columns-1; x >= 0; x--)
+    for (x=(ssize_t) image->columns-1; x >= 0; x--)
     {
        if (IsGray(p) == MagickFalse)
           return(MagickFalse);
@@ -858,7 +858,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x,
     y;
@@ -869,7 +869,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->storage_class == PseudoClass)
     {
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((IsGray(image->colormap+i) == MagickFalse) ||
             ((image->colormap[i].red != 0) &&
@@ -878,12 +878,12 @@
       }
       return(MagickTrue);
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       return(MagickFalse);
-    for (x=(long) image->columns-1; x >= 0; x--)
+    for (x=(ssize_t) image->columns-1; x >= 0; x--)
     {
       if ((p->red != 0) && (p->red != (Quantum) QuantumRange))
         return(MagickFalse);
@@ -1010,7 +1010,7 @@
 #endif
 
 #if (PNG_LIBPNG_VER > 10011)
-static size_t WriteBlobMSBULong(Image *image,const unsigned long value)
+static size_t WriteBlobMSBULong(Image *image,const size_t value)
 {
   unsigned char
     buffer[4];
@@ -1056,7 +1056,7 @@
   if (logging != MagickFalse)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
       "  Writing %c%c%c%c chunk, length: %lu",
-      type[0],type[1],type[2],type[3],(unsigned long) length);
+      type[0],type[1],type[2],type[3],(size_t) length);
 }
 #endif /* PNG_LIBPNG_VER > 10011 */
 
@@ -1178,8 +1178,8 @@
             msg[MaxTextExtent];
 
           (void) FormatMagickString(msg,MaxTextExtent,
-            "Expected %lu bytes; found %lu bytes",(unsigned long) length,
-            (unsigned long) check);
+            "Expected %lu bytes; found %lu bytes",(size_t) length,
+            (size_t) check);
           png_warning(png_ptr,msg);
           png_error(png_ptr,"Read Exception");
         }
@@ -1207,7 +1207,7 @@
   png_size_t
     check;
 
-  register long
+  register ssize_t
     i;
 
   i=0;
@@ -1280,7 +1280,7 @@
       png_size_t
         check;
 
-      check=(png_size_t) WriteBlob(image,(unsigned long) length,data);
+      check=(png_size_t) WriteBlob(image,(size_t) length,data);
       if (check != length)
         png_error(png_ptr,"WriteBlob Failed");
     }
@@ -1294,7 +1294,7 @@
 #ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED
 static int PalettesAreEqual(Image *a,Image *b)
 {
-  long
+  ssize_t
     i;
 
   if ((a == (Image *) NULL) || (b == (Image *) NULL))
@@ -1303,7 +1303,7 @@
     return((int) MagickFalse);
   if (a->colors != b->colors)
     return((int) MagickFalse);
-  for (i=0; i < (long) a->colors; i++)
+  for (i=0; i < (ssize_t) a->colors; i++)
   {
     if ((a->colormap[i].red != b->colormap[i].red) ||
         (a->colormap[i].green != b->colormap[i].green) ||
@@ -1340,9 +1340,9 @@
       mng_info->x_off[i]=0;
       mng_info->y_off[i]=0;
       mng_info->object_clip[i].left=0;
-      mng_info->object_clip[i].right=(long) PNG_UINT_31_MAX;
+      mng_info->object_clip[i].right=(ssize_t) PNG_UINT_31_MAX;
       mng_info->object_clip[i].top=0;
-      mng_info->object_clip[i].bottom=(long) PNG_UINT_31_MAX;
+      mng_info->object_clip[i].bottom=(ssize_t) PNG_UINT_31_MAX;
     }
 }
 
@@ -1350,7 +1350,7 @@
 {
   if (*have_mng_structure && (mng_info != (MngInfo *) NULL))
     {
-      register long
+      register ssize_t
         i;
 
       for (i=1; i < MNG_MAX_OBJECTS; i++)
@@ -1388,10 +1388,10 @@
   /*
     Read clipping boundaries from DEFI, CLIP, FRAM, or PAST chunk.
   */
-  box.left=(long) ((p[0]  << 24) | (p[1]  << 16) | (p[2]  << 8) | p[3]);
-  box.right=(long) ((p[4]  << 24) | (p[5]  << 16) | (p[6]  << 8) | p[7]);
-  box.top=(long) ((p[8]  << 24) | (p[9]  << 16) | (p[10] << 8) | p[11]);
-  box.bottom=(long) ((p[12] << 24) | (p[13] << 16) | (p[14] << 8) | p[15]);
+  box.left=(ssize_t) ((p[0]  << 24) | (p[1]  << 16) | (p[2]  << 8) | p[3]);
+  box.right=(ssize_t) ((p[4]  << 24) | (p[5]  << 16) | (p[6]  << 8) | p[7]);
+  box.top=(ssize_t) ((p[8]  << 24) | (p[9]  << 16) | (p[10] << 8) | p[11]);
+  box.bottom=(ssize_t) ((p[12] << 24) | (p[13] << 16) | (p[14] << 8) | p[15]);
   if (delta_type != 0)
     {
       box.left+=previous_box.left;
@@ -1408,10 +1408,10 @@
   MngPair
     pair;
   /*
-    Read two longs from CLON, MOVE or PAST chunk
+    Read two ssize_ts from CLON, MOVE or PAST chunk
   */
-  pair.a=(long) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
-  pair.b=(long) ((p[4] << 24) | (p[5] << 16) | (p[6] << 8) | p[7]);
+  pair.a=(ssize_t) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+  pair.b=(ssize_t) ((p[4] << 24) | (p[5] << 16) | (p[6] << 8) | p[7]);
   if (delta_type != 0)
     {
       pair.a+=previous_pair.a;
@@ -1420,9 +1420,9 @@
   return(pair);
 }
 
-static long mng_get_long(unsigned char *p)
+static ssize_t mng_get_ssize_t(unsigned char *p)
 {
-  return((long) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]));
+  return((ssize_t) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]));
 }
 
 static void PNGErrorHandler(png_struct *ping,png_const_charp message)
@@ -1495,7 +1495,7 @@
 png_read_raw_profile(Image *image, const ImageInfo *image_info,
    png_textp text,int ii)
 {
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -1547,7 +1547,7 @@
   /* copy profile, skipping white space and column 1 "=" signs */
   dp=GetStringInfoDatum(profile);
   nibbles=length*2;
-  for (i=0; i < (long) nibbles; i++)
+  for (i=0; i < (ssize_t) nibbles; i++)
   {
     while (*sp < '0' || (*sp > '9' && *sp < 'a') || *sp > 'f')
     {
@@ -1605,9 +1605,9 @@
 
   image=(Image *) png_get_user_chunk_ptr(ping);
 
-  image->page.width=(unsigned long) ((chunk->data[0] << 24) |
+  image->page.width=(size_t) ((chunk->data[0] << 24) |
      (chunk->data[1] << 16) | (chunk->data[2] << 8) | chunk->data[3]);
-  image->page.height=(unsigned long) ((chunk->data[4] << 24) |
+  image->page.height=(size_t) ((chunk->data[4] << 24) |
      (chunk->data[5] << 16) | (chunk->data[6] << 8) | chunk->data[7]);
 
   /* Return one of the following: */
@@ -1704,7 +1704,7 @@
   unsigned char
     *png_pixels;
 
-  long
+  ssize_t
     y;
 
   register unsigned char
@@ -1713,7 +1713,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1723,7 +1723,7 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     row_offset;
 
 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
@@ -1895,7 +1895,7 @@
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "    PNG width: %lu, height: %lu",
-        (unsigned long) ping_width, (unsigned long) ping_height);
+        (size_t) ping_width, (size_t) ping_height);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "    PNG color_type: %d, bit_depth: %d",
         ping_color_type, ping_bit_depth);
@@ -2056,7 +2056,7 @@
       if (logging != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "    Reading PNG pHYs chunk: xres: %lu, yres: %lu, units: %d.",
-          (unsigned long) x_resolution,(unsigned long) y_resolution,unit_type);
+          (size_t) x_resolution,(size_t) y_resolution,unit_type);
     }
 #endif
   if (png_get_valid(ping,ping_info,PNG_INFO_PLTE))
@@ -2217,9 +2217,9 @@
     Initialize image structure.
   */
   mng_info->image_box.left=0;
-  mng_info->image_box.right=(long) ping_width;
+  mng_info->image_box.right=(ssize_t) ping_width;
   mng_info->image_box.top=0;
-  mng_info->image_box.bottom=(long) ping_height;
+  mng_info->image_box.bottom=(ssize_t) ping_height;
   if (mng_info->mng_type == 0)
     {
       mng_info->mng_width=ping_width;
@@ -2256,7 +2256,7 @@
             palette;
 
           (void) png_get_PLTE(ping,ping_info,&palette,&number_colors);
-          image->colors=(unsigned long) number_colors;
+          image->colors=(size_t) number_colors;
           if (logging != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "    Reading PNG PLTE chunk: number_colors: %d.",number_colors);
@@ -2279,7 +2279,7 @@
             palette;
 
           (void) png_get_PLTE(ping,ping_info,&palette,&number_colors);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             image->colormap[i].red=ScaleCharToQuantum(palette[i].red);
             image->colormap[i].green=ScaleCharToQuantum(palette[i].green);
@@ -2288,13 +2288,13 @@
         }
       else
         {
-          unsigned long
+          size_t
             scale;
 
           scale=(QuantumRange/((1UL << ping_bit_depth)-1));
           if (scale < 1)
              scale=1;
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             image->colormap[i].red=(Quantum) (i*scale);
             image->colormap[i].green=(Quantum) (i*scale);
@@ -2307,7 +2307,7 @@
   */
   if (image->delay != 0)
     mng_info->scenes_found++;
-  if ((image_info->number_scenes != 0) && (mng_info->scenes_found > (long)
+  if ((image_info->number_scenes != 0) && (mng_info->scenes_found > (ssize_t)
       (image_info->first_scene+image_info->number_scenes)))
     {
       if (logging != MagickFalse)
@@ -2376,14 +2376,14 @@
       int
         depth;
 
-      depth=(long) ping_bit_depth;
+      depth=(ssize_t) ping_bit_depth;
 #endif
       image->matte=(((int) ping_color_type == PNG_COLOR_TYPE_RGB_ALPHA) ||
           ((int) ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
           (png_get_valid(ping,ping_info,PNG_INFO_tRNS))) ?
           MagickTrue : MagickFalse;
 
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         if (num_passes > 1)
           row_offset=ping_rowbytes*y;
@@ -2404,7 +2404,7 @@
             p=r;
             if (ping_color_type == PNG_COLOR_TYPE_GRAY)
               {
-                for (x=(long) image->columns-1; x >= 0; x--)
+                for (x=(ssize_t) image->columns-1; x >= 0; x--)
                 {
                   *r++=*p++;
                   p++;
@@ -2421,7 +2421,7 @@
             else if (ping_color_type == PNG_COLOR_TYPE_RGB)
               {
               if (png_get_valid(ping,ping_info,PNG_INFO_tRNS))
-                for (x=(long) image->columns-1; x >= 0; x--)
+                for (x=(ssize_t) image->columns-1; x >= 0; x--)
                 {
                   *r++=*p++;
                   p++;
@@ -2440,7 +2440,7 @@
                        *r++=OpaqueOpacity;
                 }
               else
-                for (x=(long) image->columns-1; x >= 0; x--)
+                for (x=(ssize_t) image->columns-1; x >= 0; x--)
                 {
                   *r++=*p++;
                   p++;
@@ -2452,13 +2452,13 @@
                 }
               }
             else if (ping_color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-              for (x=(long) (4*image->columns); x != 0; x--)
+              for (x=(ssize_t) (4*image->columns); x != 0; x--)
               {
                 *r++=*p++;
                 p++;
               }
             else if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-              for (x=(long) (2*image->columns); x != 0; x--)
+              for (x=(ssize_t) (2*image->columns); x != 0; x--)
               {
                 *r++=*p++;
                 p++;
@@ -2538,7 +2538,7 @@
         (image->matte ?  2 : 1)*sizeof(*quantum_scanline));
       if (quantum_scanline == (Quantum *) NULL)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         if (num_passes > 1)
           row_offset=ping_rowbytes*y;
@@ -2555,10 +2555,10 @@
         {
           case 1:
           {
-            register long
+            register ssize_t
               bit;
 
-            for (x=(long) image->columns-7; x > 0; x-=8)
+            for (x=(ssize_t) image->columns-7; x > 0; x-=8)
             {
               for (bit=7; bit >= 0; bit--)
                 *r++=(Quantum) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
@@ -2566,14 +2566,14 @@
             }
             if ((image->columns % 8) != 0)
               {
-                for (bit=7; bit >= (long) (8-(image->columns % 8)); bit--)
+                for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--)
                   *r++=(Quantum) ((*p) & (0x01 << bit) ? 0x01 : 0x00);
               }
             break;
           }
           case 2:
           {
-            for (x=(long) image->columns-3; x > 0; x-=4)
+            for (x=(ssize_t) image->columns-3; x > 0; x-=4)
             {
               *r++=(*p >> 6) & 0x03;
               *r++=(*p >> 4) & 0x03;
@@ -2582,14 +2582,14 @@
             }
             if ((image->columns % 4) != 0)
               {
-                for (i=3; i >= (long) (4-(image->columns % 4)); i--)
+                for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--)
                   *r++=(Quantum) ((*p >> (i*2)) & 0x03);
               }
             break;
           }
           case 4:
           {
-            for (x=(long) image->columns-1; x > 0; x-=2)
+            for (x=(ssize_t) image->columns-1; x > 0; x-=2)
             {
               *r++=(*p >> 4) & 0x0f;
               *r++=(*p++) & 0x0f;
@@ -2601,7 +2601,7 @@
           case 8:
           {
             if (ping_color_type == 4)
-              for (x=(long) image->columns-1; x >= 0; x--)
+              for (x=(ssize_t) image->columns-1; x >= 0; x--)
               {
                 *r++=*p++;
                 /* In image.h, OpaqueOpacity is 0
@@ -2613,16 +2613,16 @@
                 q++;
               }
             else
-              for (x=(long) image->columns-1; x >= 0; x--)
+              for (x=(ssize_t) image->columns-1; x >= 0; x--)
                 *r++=*p++;
             break;
           }
           case 16:
           {
-            for (x=(long) image->columns-1; x >= 0; x--)
+            for (x=(ssize_t) image->columns-1; x >= 0; x--)
             {
 #if (MAGICKCORE_QUANTUM_DEPTH == 16)
-              unsigned long
+              size_t
                 quantum;
 
               if (image->colors > 256)
@@ -2642,7 +2642,7 @@
                 }
 #else
 #if (MAGICKCORE_QUANTUM_DEPTH == 32)
-              unsigned long
+              size_t
                 quantum;
 
               if (image->colors > 256)
@@ -2682,7 +2682,7 @@
           Transfer image scanline.
         */
         r=quantum_scanline;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           indexes[x]=(IndexPacket) (*r++);
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
@@ -2716,7 +2716,7 @@
   png_read_end(ping,ping_info);
 
   if (image_info->number_scenes != 0 && mng_info->scenes_found-1 <
-      (long) image_info->first_scene && image->delay != 0)
+      (ssize_t) image_info->first_scene && image->delay != 0)
     {
       png_destroy_read_struct(&ping,&ping_info,&end_info);
       png_pixels=(unsigned char *) RelinquishMagickMemory(png_pixels);
@@ -2768,7 +2768,7 @@
    else
    {
 
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         image->storage_class=storage_class;
         q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
@@ -2776,7 +2776,7 @@
           break;
         indexes=GetAuthenticIndexQueue(image);
 
-          for (x=(long) image->columns-1; x >= 0; x--)
+          for (x=(ssize_t) image->columns-1; x >= 0; x--)
           {
             if (ScaleQuantumToChar(q->red) == transparent_color.red &&
                 ScaleQuantumToChar(q->green) == transparent_color.green &&
@@ -2794,7 +2794,7 @@
 #else /* not balfour */
 
 
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         image->storage_class=storage_class;
         q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
@@ -2808,21 +2808,21 @@
               indexpacket;
 
             if ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE)
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 indexpacket=indexes[x];
                 if (indexpacket < ping_num_trans)
                   q->opacity=ScaleCharToQuantum((unsigned char)
-                    (255-ping_trans_alpha[(long) indexpacket]));
+                    (255-ping_trans_alpha[(ssize_t) indexpacket]));
                 else
                   SetOpacityPixelComponent(q,OpaqueOpacity);
                 q++;
               }
             else if (ping_color_type == PNG_COLOR_TYPE_GRAY)
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 indexpacket=indexes[x];
-                q->red=image->colormap[(long) indexpacket].red;
+                q->red=image->colormap[(ssize_t) indexpacket].red;
                 q->green=q->red;
                 q->blue=q->red;
                 if (q->red == transparent_color.opacity)
@@ -2833,7 +2833,7 @@
               }
           }
         else
-          for (x=(long) image->columns-1; x >= 0; x--)
+          for (x=(ssize_t) image->columns-1; x >= 0; x--)
           {
             if (ScaleQuantumToChar(q->red) == transparent_color.red &&
                 ScaleQuantumToChar(q->green) == transparent_color.green &&
@@ -2854,7 +2854,7 @@
     image->depth=8;
 #endif
   if (png_get_text(ping,ping_info,&text,&num_text) != 0)
-    for (i=0; i < (long) num_text; i++)
+    for (i=0; i < (ssize_t) num_text; i++)
     {
       /* Check for a profile */
 
@@ -3134,7 +3134,7 @@
     *alpha_image_info,
     *color_image_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -3157,7 +3157,7 @@
   register const PixelPacket
     *s;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -3173,7 +3173,7 @@
     reading_idat,
     skip_to_iend;
 
-  unsigned long
+  size_t
     length;
 
   jng_alpha_compression_method=0;
@@ -3249,7 +3249,7 @@
         chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk));
         if (chunk == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
           chunk[i]=(unsigned char) ReadBlobByte(image);
         p=chunk;
       }
@@ -3266,9 +3266,9 @@
       {
         if (length == 16)
           {
-            jng_width=(unsigned long) ((p[0] << 24) | (p[1] << 16) |
+            jng_width=(size_t) ((p[0] << 24) | (p[1] << 16) |
                 (p[2] << 8) | p[3]);
-            jng_height=(unsigned long) ((p[4] << 24) | (p[5] << 16) |
+            jng_height=(size_t) ((p[4] << 24) | (p[5] << 16) |
                 (p[6] << 8) | p[7]);
             jng_color_type=p[8];
             jng_image_sample_depth=p[9];
@@ -3283,9 +3283,9 @@
             if (logging != MagickFalse)
               {
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                  "    jng_width:      %16lu",(unsigned long) jng_width);
+                  "    jng_width:      %16lu",(size_t) jng_width);
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                  "    jng_width:      %16lu",(unsigned long) jng_height);
+                  "    jng_width:      %16lu",(size_t) jng_height);
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                   "    jng_color_type: %16d",jng_color_type);
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3425,7 +3425,7 @@
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                 "    Copying IDAT chunk data to alpha_blob.");
 
-            (void) WriteBlobMSBULong(alpha_image,(unsigned long) length);
+            (void) WriteBlobMSBULong(alpha_image,(size_t) length);
             PNGType(data,mng_IDAT);
             LogPNGChunk((int) logging,mng_IDAT,length);
             (void) WriteBlob(alpha_image,4,data);
@@ -3486,7 +3486,7 @@
     if (memcmp(type,mng_gAMA,4) == 0)
       {
         if (length == 4)
-          image->gamma=((float) mng_get_long(p))*0.00001;
+          image->gamma=((float) mng_get_ssize_t(p))*0.00001;
         chunk=(unsigned char *) RelinquishMagickMemory(chunk);
         continue;
       }
@@ -3495,14 +3495,14 @@
       {
         if (length == 32)
           {
-            image->chromaticity.white_point.x=0.00001*mng_get_long(p);
-            image->chromaticity.white_point.y=0.00001*mng_get_long(&p[4]);
-            image->chromaticity.red_primary.x=0.00001*mng_get_long(&p[8]);
-            image->chromaticity.red_primary.y=0.00001*mng_get_long(&p[12]);
-            image->chromaticity.green_primary.x=0.00001*mng_get_long(&p[16]);
-            image->chromaticity.green_primary.y=0.00001*mng_get_long(&p[20]);
-            image->chromaticity.blue_primary.x=0.00001*mng_get_long(&p[24]);
-            image->chromaticity.blue_primary.y=0.00001*mng_get_long(&p[28]);
+            image->chromaticity.white_point.x=0.00001*mng_get_ssize_t(p);
+            image->chromaticity.white_point.y=0.00001*mng_get_ssize_t(&p[4]);
+            image->chromaticity.red_primary.x=0.00001*mng_get_ssize_t(&p[8]);
+            image->chromaticity.red_primary.y=0.00001*mng_get_ssize_t(&p[12]);
+            image->chromaticity.green_primary.x=0.00001*mng_get_ssize_t(&p[16]);
+            image->chromaticity.green_primary.y=0.00001*mng_get_ssize_t(&p[20]);
+            image->chromaticity.blue_primary.x=0.00001*mng_get_ssize_t(&p[24]);
+            image->chromaticity.blue_primary.y=0.00001*mng_get_ssize_t(&p[28]);
           }
         chunk=(unsigned char *) RelinquishMagickMemory(chunk);
         continue;
@@ -3531,8 +3531,8 @@
       {
         if (length > 8)
           {
-            image->page.x=mng_get_long(p);
-            image->page.y=mng_get_long(&p[4]);
+            image->page.x=mng_get_ssize_t(p);
+            image->page.y=mng_get_ssize_t(&p[4]);
             if ((int) p[8] != 0)
               {
                 image->page.x/=10000;
@@ -3548,8 +3548,8 @@
       {
         if (length > 8)
           {
-            image->x_resolution=(double) mng_get_long(p);
-            image->y_resolution=(double) mng_get_long(&p[4]);
+            image->x_resolution=(double) mng_get_ssize_t(p);
+            image->y_resolution=(double) mng_get_ssize_t(&p[4]);
             if ((int) p[8] == PNG_RESOLUTION_METER)
               {
                 image->units=PixelsPerCentimeterResolution;
@@ -3627,7 +3627,7 @@
   image->rows=jng_height;
   image->columns=jng_width;
   length=image->columns*sizeof(PixelPacket);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     s=GetVirtualPixels(jng_image,0,y,image->columns,1,&image->exception);
     q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
@@ -3660,16 +3660,16 @@
 
          jng_image=ReadImage(alpha_image_info,exception);
          if (jng_image != (Image *) NULL)
-           for (y=0; y < (long) image->rows; y++)
+           for (y=0; y < (ssize_t) image->rows; y++)
            {
              s=GetVirtualPixels(jng_image,0,y,image->columns,1,
                 &image->exception);
              q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
              if (image->matte != MagickFalse)
-               for (x=(long) image->columns; x != 0; x--,q++,s++)
+               for (x=(ssize_t) image->columns; x != 0; x--,q++,s++)
                   q->opacity=(Quantum) QuantumRange-s->red;
              else
-               for (x=(long) image->columns; x != 0; x--,q++,s++)
+               for (x=(ssize_t) image->columns; x != 0; x--,q++,s++)
                {
                   q->opacity=(Quantum) QuantumRange-s->red;
                   if (q->opacity != OpaqueOpacity)
@@ -3854,7 +3854,7 @@
     term_chunk_found,
     skip_to_iend;
 
-  volatile long
+  volatile ssize_t
     image_count=0;
 
   MagickBooleanType
@@ -3879,13 +3879,13 @@
   register unsigned char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
     count;
 
-  long
+  ssize_t
     loop_level;
 
   volatile short
@@ -3902,7 +3902,7 @@
 #endif
     mng_type=0;   /* 0: PNG or JNG; 1: MNG; 2: MNG-LC; 3: MNG-VLC */
 
-  unsigned long
+  size_t
     default_frame_timeout,
     frame_timeout,
 #if defined(MNG_INSERT_LAYERS)
@@ -3911,7 +3911,7 @@
 #endif
     length;
 
-  volatile unsigned long
+  volatile size_t
     default_frame_delay,
     final_delay,
     final_image_delay,
@@ -3997,8 +3997,8 @@
       */
       for (i=0; i < MNG_MAX_OBJECTS; i++)
       {
-        mng_info->object_clip[i].right=(long) PNG_UINT_31_MAX;
-        mng_info->object_clip[i].bottom=(long) PNG_UINT_31_MAX;
+        mng_info->object_clip[i].right=(ssize_t) PNG_UINT_31_MAX;
+        mng_info->object_clip[i].bottom=(ssize_t) PNG_UINT_31_MAX;
       }
       mng_info->exists[0]=MagickTrue;
     }
@@ -4058,7 +4058,7 @@
             chunk=(unsigned char *) AcquireQuantumMemory(length,sizeof(*chunk));
             if (chunk == (unsigned char *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-            for (i=0; i < (long) length; i++)
+            for (i=0; i < (ssize_t) length; i++)
               chunk[i]=(unsigned char) ReadBlobByte(image);
             p=chunk;
           }
@@ -4097,9 +4097,9 @@
           }
         if (memcmp(type,mng_MHDR,4) == 0)
           {
-            mng_info->mng_width=(unsigned long) ((p[0] << 24) | (p[1] << 16) |
+            mng_info->mng_width=(size_t) ((p[0] << 24) | (p[1] << 16) |
                 (p[2] << 8) | p[3]);
-            mng_info->mng_height=(unsigned long) ((p[4] << 24) | (p[5] << 16) |
+            mng_info->mng_height=(size_t) ((p[4] << 24) | (p[5] << 16) |
                 (p[6] << 8) | p[7]);
             if (logging != MagickFalse)
               {
@@ -4109,7 +4109,7 @@
                   "  MNG height: %lu",mng_info->mng_height);
               }
             p+=8;
-            mng_info->ticks_per_second=(unsigned long) mng_get_long(p);
+            mng_info->ticks_per_second=(size_t) mng_get_ssize_t(p);
             if (mng_info->ticks_per_second == 0)
               default_frame_delay=0;
             else
@@ -4120,7 +4120,7 @@
             if (length > 16)
               {
                 p+=16;
-                simplicity=(unsigned long) mng_get_long(p);
+                simplicity=(size_t) mng_get_ssize_t(p);
               }
             mng_type=1;    /* Full MNG */
             if ((simplicity != 0) && ((simplicity | 11) == 11))
@@ -4149,9 +4149,9 @@
             (void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu+0+0",
               mng_info->mng_width,mng_info->mng_height);
             mng_info->frame.left=0;
-            mng_info->frame.right=(long) mng_info->mng_width;
+            mng_info->frame.right=(ssize_t) mng_info->mng_width;
             mng_info->frame.top=0;
-            mng_info->frame.bottom=(long) mng_info->mng_height;
+            mng_info->frame.bottom=(ssize_t) mng_info->mng_height;
             mng_info->clip=default_fb=previous_fb=mng_info->frame;
             for (i=0; i < MNG_MAX_OBJECTS; i++)
               mng_info->object_clip[i]=mng_info->frame;
@@ -4169,8 +4169,8 @@
               repeat=p[0];
             if (repeat == 3)
               {
-                final_delay=(png_uint_32) mng_get_long(&p[2]);
-                mng_iterations=(png_uint_32) mng_get_long(&p[6]);
+                final_delay=(png_uint_32) mng_get_ssize_t(&p[2]);
+                mng_iterations=(png_uint_32) mng_get_ssize_t(&p[6]);
                 if (mng_iterations == PNG_UINT_31_MAX)
                   mng_iterations=0;
                 image->iterations=mng_iterations;
@@ -4227,9 +4227,9 @@
             */
             if (length > 11)
               {
-                mng_info->x_off[object_id]=(long) ((p[4] << 24) | (p[5] << 16) |
+                mng_info->x_off[object_id]=(ssize_t) ((p[4] << 24) | (p[5] << 16) |
                 (p[6] << 8) | p[7]);
-                mng_info->y_off[object_id]=(long) ((p[8] << 24) | (p[9] << 16) |
+                mng_info->y_off[object_id]=(ssize_t) ((p[8] << 24) | (p[9] << 16) |
                 (p[10] << 8) | p[11]);
                 if (logging != MagickFalse)
                   {
@@ -4299,7 +4299,7 @@
                 if (mng_info->global_plte == (png_colorp) NULL)
                   mng_info->global_plte=(png_colorp) AcquireQuantumMemory(256,
                     sizeof(*mng_info->global_plte));
-                for (i=0; i < (long) (length/3); i++)
+                for (i=0; i < (ssize_t) (length/3); i++)
                 {
                   mng_info->global_plte[i].red=p[3*i];
                   mng_info->global_plte[i].green=p[3*i+1];
@@ -4327,7 +4327,7 @@
             /* read global tRNS */
 
             if (length < 257)
-              for (i=0; i < (long) length; i++)
+              for (i=0; i < (ssize_t) length; i++)
                 mng_info->global_trns[i]=p[i];
 
 #ifdef MNG_LOOSE
@@ -4342,10 +4342,10 @@
           {
             if (length == 4)
               {
-                long
+                ssize_t
                   igamma;
 
-                igamma=mng_get_long(p);
+                igamma=mng_get_ssize_t(p);
                 mng_info->global_gamma=((float) igamma)*0.00001;
                 mng_info->have_global_gama=MagickTrue;
               }
@@ -4362,19 +4362,19 @@
             */
             if (length == 32)
               {
-                mng_info->global_chrm.white_point.x=0.00001*mng_get_long(p);
-                mng_info->global_chrm.white_point.y=0.00001*mng_get_long(&p[4]);
-                mng_info->global_chrm.red_primary.x=0.00001*mng_get_long(&p[8]);
+                mng_info->global_chrm.white_point.x=0.00001*mng_get_ssize_t(p);
+                mng_info->global_chrm.white_point.y=0.00001*mng_get_ssize_t(&p[4]);
+                mng_info->global_chrm.red_primary.x=0.00001*mng_get_ssize_t(&p[8]);
                 mng_info->global_chrm.red_primary.y=0.00001*
-                  mng_get_long(&p[12]);
+                  mng_get_ssize_t(&p[12]);
                 mng_info->global_chrm.green_primary.x=0.00001*
-                  mng_get_long(&p[16]);
+                  mng_get_ssize_t(&p[16]);
                 mng_info->global_chrm.green_primary.y=0.00001*
-                  mng_get_long(&p[20]);
+                  mng_get_ssize_t(&p[20]);
                 mng_info->global_chrm.blue_primary.x=0.00001*
-                  mng_get_long(&p[24]);
+                  mng_get_ssize_t(&p[24]);
                 mng_info->global_chrm.blue_primary.y=0.00001*
-                  mng_get_long(&p[28]);
+                  mng_get_ssize_t(&p[28]);
                 mng_info->have_global_chrm=MagickTrue;
               }
             else
@@ -4431,10 +4431,10 @@
                   Note the delay and frame clipping boundaries.
                 */
                 p++; /* framing mode */
-                while (*p && ((p-chunk) < (long) length))
+                while (*p && ((p-chunk) < (ssize_t) length))
                   p++;  /* frame name */
                 p++;  /* frame name terminator */
-                if ((p-chunk) < (long) (length-4))
+                if ((p-chunk) < (ssize_t) (length-4))
                   {
                     int
                       change_delay,
@@ -4448,7 +4448,7 @@
                     if (change_delay)
                       {
                         frame_delay=(1UL*image->ticks_per_second*
-                            (mng_get_long(p))/mng_info->ticks_per_second);
+                            (mng_get_ssize_t(p))/mng_info->ticks_per_second);
                         if (change_delay == 2)
                           default_frame_delay=frame_delay;
                         p+=4;
@@ -4459,7 +4459,7 @@
                     if (change_timeout)
                       {
                         frame_timeout=(1UL*image->ticks_per_second*
-                            (mng_get_long(p))/mng_info->ticks_per_second);
+                            (mng_get_ssize_t(p))/mng_info->ticks_per_second);
                         if (change_delay == 2)
                           default_frame_timeout=frame_timeout;
                         p+=4;
@@ -4483,9 +4483,9 @@
               }
             mng_info->clip=fb;
             mng_info->clip=mng_minimum_box(fb,mng_info->frame);
-            subframe_width=(unsigned long) (mng_info->clip.right
+            subframe_width=(size_t) (mng_info->clip.right
                -mng_info->clip.left);
-            subframe_height=(unsigned long) (mng_info->clip.bottom
+            subframe_height=(size_t) (mng_info->clip.bottom
                -mng_info->clip.top);
             /*
               Insert a background layer behind the frame if framing_mode is 4.
@@ -4594,10 +4594,10 @@
               }
             else
               {
-                register long
+                register ssize_t
                   j;
 
-                for (j=0; j < (long) length; j+=2)
+                for (j=0; j < (ssize_t) length; j+=2)
                 {
                   i=p[j] << 8 | p[j+1];
                   MngInfoDiscardObject(mng_info,i);
@@ -4609,7 +4609,7 @@
           }
         if (memcmp(type,mng_MOVE,4) == 0)
           {
-            unsigned long
+            size_t
               first_object,
               last_object;
 
@@ -4618,7 +4618,7 @@
             */
             first_object=(p[0] << 8) | p[1];
             last_object=(p[2] << 8) | p[3];
-            for (i=(long) first_object; i <= (long) last_object; i++)
+            for (i=(ssize_t) first_object; i <= (ssize_t) last_object; i++)
             {
               if (mng_info->exists[i] && !mng_info->frozen[i])
                 {
@@ -4641,13 +4641,13 @@
 
         if (memcmp(type,mng_LOOP,4) == 0)
           {
-            long loop_iters=1;
+            ssize_t loop_iters=1;
             loop_level=chunk[0];
             mng_info->loop_active[loop_level]=1;  /* mark loop active */
             /*
               Record starting point.
             */
-            loop_iters=mng_get_long(&chunk[1]);
+            loop_iters=mng_get_ssize_t(&chunk[1]);
             if (logging != MagickFalse)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                 "  LOOP level %ld  has %ld iterations ",loop_level,loop_iters);
@@ -4867,9 +4867,9 @@
             if (length > 8)
               {
                 mng_info->global_x_pixels_per_unit=
-                    (unsigned long) mng_get_long(p);
+                    (size_t) mng_get_ssize_t(p);
                 mng_info->global_y_pixels_per_unit=
-                    (unsigned long) mng_get_long(&p[4]);
+                    (size_t) mng_get_ssize_t(&p[4]);
                 mng_info->global_phys_unit_type=p[8];
                 mng_info->have_global_phys=MagickTrue;
               }
@@ -4892,9 +4892,9 @@
                 image->filename);
             mng_info->basi_warning++;
 #ifdef MNG_BASI_SUPPORTED
-            basi_width=(unsigned long) ((p[0] << 24) | (p[1] << 16) |
+            basi_width=(size_t) ((p[0] << 24) | (p[1] << 16) |
                (p[2] << 8) | p[3]);
-            basi_height=(unsigned long) ((p[4] << 24) | (p[5] << 16) |
+            basi_height=(size_t) ((p[4] << 24) | (p[5] << 16) |
                (p[6] << 8) | p[7]);
             basi_color_type=p[8];
             basi_compression_method=p[9];
@@ -4958,8 +4958,8 @@
 #if defined(MNG_INSERT_LAYERS)
         if (length < 8)
           ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-        image_width=(unsigned  long) mng_get_long(p);
-        image_height=(unsigned  long) mng_get_long(&p[4]);
+        image_width=(size_t) mng_get_ssize_t(p);
+        image_height=(size_t) mng_get_ssize_t(&p[4]);
 #endif
         chunk=(unsigned char *) RelinquishMagickMemory(chunk);
 
@@ -4972,9 +4972,9 @@
           {
             if ((mng_info->clip.left > 0) || (mng_info->clip.top > 0) ||
                 (image_width < mng_info->mng_width) ||
-                (mng_info->clip.right < (long) mng_info->mng_width) ||
+                (mng_info->clip.right < (ssize_t) mng_info->mng_width) ||
                 (image_height < mng_info->mng_height) ||
-                (mng_info->clip.bottom < (long) mng_info->mng_height))
+                (mng_info->clip.bottom < (ssize_t) mng_info->mng_height))
               {
                 if (GetAuthenticPixelQueue(image) != (PixelPacket *) NULL)
                   {
@@ -5111,7 +5111,7 @@
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
             "  Seeking back to beginning of %c%c%c%c chunk",type[0],type[1],
             type[2],type[3]);
-        offset=SeekBlob(image,-((long) length+12),SEEK_CUR);
+        offset=SeekBlob(image,-((ssize_t) length+12),SEEK_CUR);
         if (offset < 0)
           ThrowReaderException(CorruptImageError,"ImproperImageHeader");
       }
@@ -5207,11 +5207,11 @@
                 int
                   yy;
 
-                long
+                ssize_t
                   m,
                   y;
 
-                register long
+                register ssize_t
                   x;
 
                 register PixelPacket
@@ -5256,11 +5256,11 @@
                      Scale pixels to unsigned shorts to prevent
                      overflow of intermediate values of interpolations
                   */
-                     for (y=0; y < (long) image->rows; y++)
+                     for (y=0; y < (ssize_t) image->rows; y++)
                      {
                        q=GetAuthenticPixels(image,0,y,image->columns,1,
                           exception);
-                       for (x=(long) image->columns-1; x >= 0; x--)
+                       for (x=(ssize_t) image->columns-1; x >= 0; x--)
                        {
                           q->red=ScaleQuantumToShort(q->red);
                           q->green=ScaleQuantumToShort(q->green);
@@ -5297,7 +5297,7 @@
                 if (logging != MagickFalse)
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                     "    Magnify the rows to %lu",large_image->rows);
-                m=(long) mng_info->magn_mt;
+                m=(ssize_t) mng_info->magn_mt;
                 yy=0;
                 length=(size_t) image->columns;
                 next=(PixelPacket *) AcquireQuantumMemory(length,sizeof(*next));
@@ -5312,22 +5312,22 @@
                   }
                 n=GetAuthenticPixels(image,0,0,image->columns,1,exception);
                 (void) CopyMagickMemory(next,n,length);
-                for (y=0; y < (long) image->rows; y++)
+                for (y=0; y < (ssize_t) image->rows; y++)
                 {
                   if (y == 0)
-                    m=(long) mng_info->magn_mt;
-                  else if (magn_methy > 1 && y == (long) image->rows-2)
-                    m=(long) mng_info->magn_mb;
-                  else if (magn_methy <= 1 && y == (long) image->rows-1)
-                    m=(long) mng_info->magn_mb;
-                  else if (magn_methy > 1 && y == (long) image->rows-1)
+                    m=(ssize_t) mng_info->magn_mt;
+                  else if (magn_methy > 1 && y == (ssize_t) image->rows-2)
+                    m=(ssize_t) mng_info->magn_mb;
+                  else if (magn_methy <= 1 && y == (ssize_t) image->rows-1)
+                    m=(ssize_t) mng_info->magn_mb;
+                  else if (magn_methy > 1 && y == (ssize_t) image->rows-1)
                     m=1;
                   else
-                    m=(long) mng_info->magn_my;
+                    m=(ssize_t) mng_info->magn_my;
                   n=prev;
                   prev=next;
                   next=n;
-                  if (y < (long) image->rows-1)
+                  if (y < (ssize_t) image->rows-1)
                     {
                       n=GetAuthenticPixels(image,0,y+1,image->columns,1,
                           exception);
@@ -5338,13 +5338,13 @@
                     register PixelPacket
                       *pixels;
 
-                    assert(yy < (long) large_image->rows);
+                    assert(yy < (ssize_t) large_image->rows);
                     pixels=prev;
                     n=next;
                     q=GetAuthenticPixels(large_image,0,yy,large_image->columns,
                           1,exception);
                     q+=(large_image->columns-image->columns);
-                    for (x=(long) image->columns-1; x >= 0; x--)
+                    for (x=(ssize_t) image->columns-1; x >= 0; x--)
                     {
                       /* TO DO: get color as function of indexes[x] */
                       /*
@@ -5364,20 +5364,20 @@
                           else
                             {
                               /* Interpolate */
-                              (*q).red=(QM) (((long) (2*i*((*n).red
-                                 -(*pixels).red)+m))/((long) (m*2))
+                              (*q).red=(QM) (((ssize_t) (2*i*((*n).red
+                                 -(*pixels).red)+m))/((ssize_t) (m*2))
                                  +(*pixels).red);
-                              (*q).green=(QM) (((long) (2*i*((*n).green
-                                 -(*pixels).green)+m))/((long) (m*2))
+                              (*q).green=(QM) (((ssize_t) (2*i*((*n).green
+                                 -(*pixels).green)+m))/((ssize_t) (m*2))
                                  +(*pixels).green);
-                              (*q).blue=(QM) (((long) (2*i*((*n).blue
-                                 -(*pixels).blue)+m))/((long) (m*2))
+                              (*q).blue=(QM) (((ssize_t) (2*i*((*n).blue
+                                 -(*pixels).blue)+m))/((ssize_t) (m*2))
                                  +(*pixels).blue);
                               if (image->matte != MagickFalse)
-                                 (*q).opacity=(QM) (((long)
+                                 (*q).opacity=(QM) (((ssize_t)
                                  (2*i*((*n).opacity
                                  -(*pixels).opacity)+m))
-                                 /((long) (m*2))+(*pixels).opacity);
+                                 /((ssize_t) (m*2))+(*pixels).opacity);
                             }
                           if (magn_methy == 4)
                             {
@@ -5397,8 +5397,8 @@
                              *q=(*n);
                           if (magn_methy == 5)
                             {
-                              (*q).opacity=(QM) (((long) (2*i*((*n).opacity
-                                 -(*pixels).opacity)+m))/((long) (m*2))
+                              (*q).opacity=(QM) (((ssize_t) (2*i*((*n).opacity
+                                 -(*pixels).opacity)+m))/((ssize_t) (m*2))
                                  +(*pixels).opacity);
                             }
                         }
@@ -5430,7 +5430,7 @@
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                     "    Magnify the columns to %lu",image->columns);
 
-                for (y=0; y < (long) image->rows; y++)
+                for (y=0; y < (ssize_t) image->rows; y++)
                 {
                   register PixelPacket
                     *pixels;
@@ -5438,19 +5438,19 @@
                   q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
                   pixels=q+(image->columns-length);
                   n=pixels+1;
-                  for (x=(long) (image->columns-length);
-                    x < (long) image->columns; x++)
+                  for (x=(ssize_t) (image->columns-length);
+                    x < (ssize_t) image->columns; x++)
                   {
-                    if (x == (long) (image->columns-length))
-                      m=(long) mng_info->magn_ml;
-                    else if (magn_methx > 1 && x == (long) image->columns-2)
-                      m=(long) mng_info->magn_mr;
-                    else if (magn_methx <= 1 && x == (long) image->columns-1)
-                      m=(long) mng_info->magn_mr;
-                    else if (magn_methx > 1 && x == (long) image->columns-1)
+                    if (x == (ssize_t) (image->columns-length))
+                      m=(ssize_t) mng_info->magn_ml;
+                    else if (magn_methx > 1 && x == (ssize_t) image->columns-2)
+                      m=(ssize_t) mng_info->magn_mr;
+                    else if (magn_methx <= 1 && x == (ssize_t) image->columns-1)
+                      m=(ssize_t) mng_info->magn_mr;
+                    else if (magn_methx > 1 && x == (ssize_t) image->columns-1)
                       m=1;
                     else
-                      m=(long) mng_info->magn_mx;
+                      m=(ssize_t) mng_info->magn_mx;
                     for (i=0; i < m; i++)
                     {
                       if (magn_methx <= 1)
@@ -5467,16 +5467,16 @@
                               /* Interpolate */
                               (*q).red=(QM) ((2*i*((*n).red
                                  -(*pixels).red)+m)
-                                 /((long) (m*2))+(*pixels).red);
+                                 /((ssize_t) (m*2))+(*pixels).red);
                               (*q).green=(QM) ((2*i*((*n).green
                                  -(*pixels).green)
-                                 +m)/((long) (m*2))+(*pixels).green);
+                                 +m)/((ssize_t) (m*2))+(*pixels).green);
                               (*q).blue=(QM) ((2*i*((*n).blue
                                  -(*pixels).blue)+m)
-                                 /((long) (m*2))+(*pixels).blue);
+                                 /((ssize_t) (m*2))+(*pixels).blue);
                               if (image->matte != MagickFalse)
                                  (*q).opacity=(QM) ((2*i*((*n).opacity
-                                   -(*pixels).opacity)+m)/((long) (m*2))
+                                   -(*pixels).opacity)+m)/((ssize_t) (m*2))
                                    +(*pixels).opacity);
                             }
                           if (magn_methx == 4)
@@ -5499,7 +5499,7 @@
                             {
                               /* Interpolate */
                               (*q).opacity=(QM) ((2*i*((*n).opacity
-                                 -(*pixels).opacity)+m) /((long) (m*2))
+                                 -(*pixels).opacity)+m) /((ssize_t) (m*2))
                                  +(*pixels).opacity);
                             }
                         }
@@ -5517,10 +5517,10 @@
                 /*
                    Rescale pixels to Quantum
                 */
-                   for (y=0; y < (long) image->rows; y++)
+                   for (y=0; y < (ssize_t) image->rows; y++)
                    {
                      q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
-                     for (x=(long) image->columns-1; x >= 0; x--)
+                     for (x=(ssize_t) image->columns-1; x >= 0; x--)
                      {
                         q->red=ScaleShortToQuantum(q->red);
                         q->green=ScaleShortToQuantum(q->green);
@@ -5576,8 +5576,8 @@
                 */
                 crop_info.x=(crop_box.left-mng_info->x_off[object_id]);
                 crop_info.y=(crop_box.top-mng_info->y_off[object_id]);
-                crop_info.width=(unsigned long) (crop_box.right-crop_box.left);
-                crop_info.height=(unsigned long) (crop_box.bottom-crop_box.top);
+                crop_info.width=(size_t) (crop_box.right-crop_box.left);
+                crop_info.height=(size_t) (crop_box.bottom-crop_box.top);
                 image->page.width=image->columns;
                 image->page.height=image->rows;
                 image->page.x=0;
@@ -5631,26 +5631,26 @@
         const PixelPacket
           *p;
 
-        ok_to_reduce=(((((unsigned long) image->background_color.red >> 8) &
+        ok_to_reduce=(((((size_t) image->background_color.red >> 8) &
                      0xff)
-          == ((unsigned long) image->background_color.red & 0xff)) &&
-           ((((unsigned long) image->background_color.green >> 8) & 0xff)
-          == ((unsigned long) image->background_color.green & 0xff)) &&
-           ((((unsigned long) image->background_color.blue >> 8) & 0xff)
-          == ((unsigned long) image->background_color.blue & 0xff)));
+          == ((size_t) image->background_color.red & 0xff)) &&
+           ((((size_t) image->background_color.green >> 8) & 0xff)
+          == ((size_t) image->background_color.green & 0xff)) &&
+           ((((size_t) image->background_color.blue >> 8) & 0xff)
+          == ((size_t) image->background_color.blue & 0xff)));
         if (ok_to_reduce && image->storage_class == PseudoClass)
           {
             int indx;
 
-            for (indx=0; indx < (long) image->colors; indx++)
+            for (indx=0; indx < (ssize_t) image->colors; indx++)
               {
-                ok_to_reduce=(((((unsigned long) image->colormap[indx].red >>
+                ok_to_reduce=(((((size_t) image->colormap[indx].red >>
                     8) & 0xff)
-                  == ((unsigned long) image->colormap[indx].red & 0xff)) &&
-                  ((((unsigned long) image->colormap[indx].green >> 8) & 0xff)
-                  == ((unsigned long) image->colormap[indx].green & 0xff)) &&
-                  ((((unsigned long) image->colormap[indx].blue >> 8) & 0xff)
-                  == ((unsigned long) image->colormap[indx].blue & 0xff)));
+                  == ((size_t) image->colormap[indx].red & 0xff)) &&
+                  ((((size_t) image->colormap[indx].green >> 8) & 0xff)
+                  == ((size_t) image->colormap[indx].green & 0xff)) &&
+                  ((((size_t) image->colormap[indx].blue >> 8) & 0xff)
+                  == ((size_t) image->colormap[indx].blue & 0xff)));
                 if (ok_to_reduce == MagickFalse)
                   break;
               }
@@ -5658,29 +5658,29 @@
         if ((ok_to_reduce != MagickFalse) &&
             (image->storage_class != PseudoClass))
           {
-            long
+            ssize_t
               y;
 
-            register long
+            register ssize_t
               x;
 
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=(long) image->columns-1; x >= 0; x--)
+              for (x=(ssize_t) image->columns-1; x >= 0; x--)
               {
                 ok_to_reduce=((
-                  (((unsigned long) p->red >> 8) & 0xff) ==
-                  ((unsigned long) p->red & 0xff)) &&
-                  ((((unsigned long) p->green >> 8) & 0xff) ==
-                  ((unsigned long) p->green & 0xff)) &&
-                  ((((unsigned long) p->blue >> 8) & 0xff) ==
-                  ((unsigned long) p->blue & 0xff)) &&
+                  (((size_t) p->red >> 8) & 0xff) ==
+                  ((size_t) p->red & 0xff)) &&
+                  ((((size_t) p->green >> 8) & 0xff) ==
+                  ((size_t) p->green & 0xff)) &&
+                  ((((size_t) p->blue >> 8) & 0xff) ==
+                  ((size_t) p->blue & 0xff)) &&
                   (((!image->matte ||
-                  (((unsigned long) p->opacity >> 8) & 0xff) ==
-                  ((unsigned long) p->opacity & 0xff)))));
+                  (((size_t) p->opacity >> 8) & 0xff) ==
+                  ((size_t) p->opacity & 0xff)))));
                 if (ok_to_reduce == 0)
                   break;
                 p++;
@@ -5702,7 +5702,7 @@
       if (image_info->number_scenes != 0)
         {
           if (mng_info->scenes_found >
-             (long) (image_info->first_scene+image_info->number_scenes))
+             (ssize_t) (image_info->first_scene+image_info->number_scenes))
             break;
         }
       if (logging != MagickFalse)
@@ -5848,7 +5848,7 @@
         *next_image,
         *next;
 
-      unsigned long
+      size_t
         scene;
 
       if (logging != MagickFalse)
@@ -5949,10 +5949,10 @@
 %
 %  The format of the RegisterPNGImage method is:
 %
-%      unsigned long RegisterPNGImage(void)
+%      size_t RegisterPNGImage(void)
 %
 */
-ModuleExport unsigned long RegisterPNGImage(void)
+ModuleExport size_t RegisterPNGImage(void)
 {
   char
     version[MaxTextExtent];
@@ -6200,7 +6200,7 @@
    png_textp
      text;
 
-   register long
+   register ssize_t
      i;
 
    unsigned char
@@ -6242,9 +6242,9 @@
    dp+=description_length;
    *dp++='\n';
    (void) FormatMagickString(dp,allocated_length-
-     (png_size_t) (dp-text[0].text),"%8lu ",(unsigned long) length);
+     (png_size_t) (dp-text[0].text),"%8lu ",(size_t) length);
    dp+=8;
-   for (i=0; i < (long) length; i++)
+   for (i=0; i < (ssize_t) length; i++)
    {
      if (i%36 == 0)
        *dp++='\n';
@@ -6350,7 +6350,7 @@
     ping_height,
     ping_width;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -6362,7 +6362,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -6381,12 +6381,12 @@
     ping_filter_method,
     ping_num_trans;
 
-  volatile unsigned long
+  volatile size_t
     image_colors,
     image_depth,
     old_bit_depth;
 
-  unsigned long
+  size_t
     quality,
     rowbytes,
     save_image_depth;
@@ -6496,9 +6496,9 @@
   if (logging != MagickFalse)
     {
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "    width=%lu",(unsigned long) ping_width);
+        "    width=%lu",(size_t) ping_width);
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "    height=%lu",(unsigned long) ping_height);
+        "    height=%lu",(size_t) ping_height);
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "    image_matte=%u",image->matte);
      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -6560,7 +6560,7 @@
 
       if (image_depth < MAGICKCORE_QUANTUM_DEPTH)
         {
-          unsigned long
+          size_t
              maxval;
 
           maxval=(1UL << image_depth)-1;
@@ -6604,7 +6604,7 @@
           QuantizeInfo
             quantize_info;
 
-          unsigned long
+          size_t
              number_colors,
              save_number_colors;
 
@@ -6644,7 +6644,7 @@
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                 "  Setting up PLTE chunk with %d colors",
                 (int) number_colors);
-          for (i=0; i < (long) number_colors; i++)
+          for (i=0; i < (ssize_t) number_colors; i++)
           {
             palette[i].red=ScaleQuantumToChar(image->colormap[i].red);
             palette[i].green=ScaleQuantumToChar(image->colormap[i].green);
@@ -6682,10 +6682,10 @@
                 Identify which colormap entry is transparent.
               */
               assert(number_colors <= 256);
-              for (i=0; i < (long) number_colors; i++)
+              for (i=0; i < (ssize_t) number_colors; i++)
                  trans_alpha[i]=255;
               exception=(&image->exception);
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 register const PixelPacket
                   *p;
@@ -6694,12 +6694,12 @@
                 if (p == (PixelPacket *) NULL)
                   break;
                 indexes=GetAuthenticIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if (p->opacity != OpaqueOpacity)
                     {
                       indexes[x]=(IndexPacket) (number_colors-1);
-                      trans_alpha[(long) indexes[x]]=(png_byte) (255-
+                      trans_alpha[(ssize_t) indexes[x]]=(png_byte) (255-
                         ScaleQuantumToChar(GetOpacityPixelComponent(p)));
                     }
                   p++;
@@ -6707,7 +6707,7 @@
                 if (SyncAuthenticPixels(image,exception) == MagickFalse)
                   break;
               }
-              for (i=0; i < (long) number_colors; i++)
+              for (i=0; i < (ssize_t) number_colors; i++)
                 if (trans_alpha[i] != 255)
                   ping_num_trans=(unsigned short) (i+1);
 
@@ -6729,7 +6729,7 @@
           /*
             Identify which colormap entry is the background color.
           */
-          for (i=0; i < (long) MagickMax(1L*number_colors-1L,1L); i++)
+          for (i=0; i < (ssize_t) MagickMax(1L*number_colors-1L,1L); i++)
             if (IsPNGColorEqual(ping_background,image->colormap[i]))
               break;
           ping_background.index=(png_byte) i;
@@ -6820,7 +6820,7 @@
       if (ping_color_type == PNG_COLOR_TYPE_PALETTE)
         {
            ping_bit_depth=1;
-           while ((int) (1 << ping_bit_depth) < (long) image_colors)
+           while ((int) (1 << ping_bit_depth) < (ssize_t) image_colors)
              ping_bit_depth <<= 1;
 
            if (logging != MagickFalse)
@@ -6868,12 +6868,12 @@
 
       p=GetVirtualPixels(image,0,0,image->columns,1,&image->exception);
       ping_color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
-        for (x=(long) image->columns-1; x >= 0; x--)
+        for (x=(ssize_t) image->columns-1; x >= 0; x--)
         {
           if (IsGray(p) == MagickFalse)
             {
@@ -6886,12 +6886,12 @@
       /*
         Determine if there is any transparent color.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
-        for (x=(long) image->columns-1; x >= 0; x--)
+        for (x=(ssize_t) image->columns-1; x >= 0; x--)
         {
           if (p->opacity != OpaqueOpacity)
             break;
@@ -6900,7 +6900,7 @@
         if (x != 0)
           break;
       }
-      if ((y == (long) image->rows) && (x == (long) image->columns))
+      if ((y == (ssize_t) image->rows) && (x == (ssize_t) image->columns))
         {
           /*
             No transparent pixels are present.  Change 4 or 6 to 0 or 2.
@@ -6941,14 +6941,14 @@
             Determine if there is one and only one transparent color
             and if so if it is fully transparent.
           */
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,
                &image->exception);
             x=0;
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=(long) image->columns-1; x >= 0; x--)
+            for (x=(ssize_t) image->columns-1; x >= 0; x--)
             {
               if (p->opacity != OpaqueOpacity)
                 {
@@ -7020,7 +7020,7 @@
                   {
                     ping_bit_depth=1;
                     while ((int) (1 << ping_bit_depth)
-                        < (long) image_colors)
+                        < (ssize_t) image_colors)
                       ping_bit_depth <<= 1;
                   }
               }
@@ -7035,7 +7035,7 @@
                   depth_2_ok=MagickTrue,
                   depth_1_ok=MagickTrue;
 
-                for (i=0; i < (long) image_colors; i++)
+                for (i=0; i < (ssize_t) image_colors; i++)
                 {
                    unsigned char
                      intensity;
@@ -7062,7 +7062,7 @@
     else
       if (mng_info->IsPalette)
       {
-        unsigned long
+        size_t
            number_colors;
 
         number_colors=image_colors;
@@ -7083,7 +7083,7 @@
             else
               {
 #if defined(PNG_SORT_PALETTE)
-                unsigned long
+                size_t
                    save_number_colors;
 
                 if (mng_info->optimize)
@@ -7101,7 +7101,7 @@
                 if (palette == (png_color *) NULL)
                   ThrowWriterException(ResourceLimitError,
                      "MemoryAllocationFailed");
-                for (i=0; i < (long) number_colors; i++)
+                for (i=0; i < (ssize_t) number_colors; i++)
                 {
                   palette[i].red=ScaleQuantumToChar(image->colormap[i].red);
                   palette[i].green=ScaleQuantumToChar(image->colormap[i].green);
@@ -7140,16 +7140,16 @@
                 Identify which colormap entry is transparent.
               */
               assert(number_colors <= 256);
-              for (i=0; i < (long) number_colors; i++)
+              for (i=0; i < (ssize_t) number_colors; i++)
                 trans[i]=256;
               exception=(&image->exception);
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 packet_indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if (p->opacity != OpaqueOpacity)
                     {
@@ -7157,10 +7157,10 @@
                         packet_index;
 
                       packet_index=packet_indexes[x];
-                      assert((unsigned long) packet_index < number_colors);
-                      if (trans[(long) packet_index] != 256)
+                      assert((size_t) packet_index < number_colors);
+                      if (trans[(ssize_t) packet_index] != 256)
                         {
-                          if (trans[(long) packet_index] != (png_byte) (255-
+                          if (trans[(ssize_t) packet_index] != (png_byte) (255-
                              ScaleQuantumToChar(GetOpacityPixelComponent(p))))
                             {
                               ping_color_type=(png_byte)
@@ -7168,7 +7168,7 @@
                               break;
                             }
                         }
-                      trans[(long) packet_index]=(png_byte) (255-
+                      trans[(ssize_t) packet_index]=(png_byte) (255-
                         ScaleQuantumToChar(GetOpacityPixelComponent(p)));
                     }
                   p++;
@@ -7188,7 +7188,7 @@
               }
               if (png_get_valid(ping,ping_info,PNG_INFO_tRNS))
               {
-                for (i=0; i < (long) number_colors; i++)
+                for (i=0; i < (ssize_t) number_colors; i++)
                 {
                   if (trans[i] == 256)
                     trans[i]=255;
@@ -7207,7 +7207,7 @@
                 if (ping_trans_alpha == (unsigned char *) NULL)
                   ThrowWriterException(ResourceLimitError,
                      "MemoryAllocationFailed");
-                for (i=0; i < (long) number_colors; i++)
+                for (i=0; i < (ssize_t) number_colors; i++)
                     ping_trans_alpha[i]=(png_byte) trans[i];
               }
             }
@@ -7260,12 +7260,12 @@
            Identify which colormap entry is the background color.
         */
 
-        unsigned long
+        size_t
            number_colors;
 
         number_colors=image_colors;
 
-        for (i=0; i < (long) MagickMax(1L*number_colors-1L,1L); i++)
+        for (i=0; i < (ssize_t) MagickMax(1L*number_colors-1L,1L); i++)
           if (IsPNGColorEqual(ping_background,image->colormap[i]))
             break;
 
@@ -7302,7 +7302,7 @@
       int
         level;
 
-      level=(int) MagickMin((long) quality/10,9);
+      level=(int) MagickMin((ssize_t) quality/10,9);
       if (logging != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "    Compression level: %d",level);
@@ -7611,7 +7611,7 @@
         /*
           Convert PseudoClass image to a PNG monochrome image.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -7625,7 +7625,7 @@
                   mng_info->write_png_depth != old_bit_depth)
                 {
                   /* Undo pixel scaling */
-                  for (i=0; i < (long) image->columns; i++)
+                  for (i=0; i < (ssize_t) image->columns; i++)
                      *(png_pixels+i)=(unsigned char) (*(png_pixels+i)
                      >> (8-old_bit_depth));
                 }
@@ -7636,7 +7636,7 @@
                 quantum_info,RedQuantum,png_pixels,&image->exception);
             }
           if (mng_info->write_png_colortype-1 != PNG_COLOR_TYPE_PALETTE)
-            for (i=0; i < (long) image->columns; i++)
+            for (i=0; i < (ssize_t) image->columns; i++)
                *(png_pixels+i)=(unsigned char) ((*(png_pixels+i) > 127) ?
                       255 : 0);
           if (logging && y == 0)
@@ -7664,7 +7664,7 @@
          (ping_bit_depth >= MAGICKCORE_QUANTUM_DEPTH)) &&
          (mng_info->optimize || mng_info->IsPalette) && ImageIsGray(image))
       {
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -7707,7 +7707,7 @@
         if ((image_depth > 8) || (mng_info->write_png24 ||
             mng_info->write_png32 ||
             (!mng_info->write_png8 && !mng_info->IsPalette)))
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
@@ -7754,7 +7754,7 @@
               quantum_info->depth=8;
               image_depth=8;
             }
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -7798,9 +7798,9 @@
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "  Wrote PNG image data");
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "    Width: %lu",(unsigned long) ping_width);
+        "    Width: %lu",(size_t) ping_width);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "    Height: %lu",(unsigned long) ping_height);
+        "    Height: %lu",(size_t) ping_height);
       if (mng_info->write_png_depth)
         {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -8201,7 +8201,7 @@
     logging,
     transparent;
 
-  unsigned long
+  size_t
     jng_quality;
 
   logging=LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -8311,7 +8311,7 @@
           if (logging != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  Successfully read jpeg_image into a blob, length=%lu.",
-              (unsigned long) length);
+              (size_t) length);
 
         }
       /* Destroy JPEG image and image_info */
@@ -8378,16 +8378,16 @@
       green,
       red;
 
-    long
+    ssize_t
       num_bytes;
 
     if (jng_color_type == 8 || jng_color_type == 12)
       num_bytes=6L;
     else
       num_bytes=10L;
-    (void) WriteBlobMSBULong(image,(unsigned long) (num_bytes-4L));
+    (void) WriteBlobMSBULong(image,(size_t) (num_bytes-4L));
     PNGType(chunk,mng_bKGD);
-    LogPNGChunk((int) logging,mng_bKGD,(unsigned long) (num_bytes-4L));
+    LogPNGChunk((int) logging,mng_bKGD,(size_t) (num_bytes-4L));
     red=ScaleQuantumToChar(image->background_color.red);
     green=ScaleQuantumToChar(image->background_color.green);
     blue=ScaleQuantumToChar(image->background_color.blue);
@@ -8426,7 +8426,7 @@
           (void) WriteBlobMSBULong(image,4L);
           PNGType(chunk,mng_gAMA);
           LogPNGChunk((int) logging,mng_gAMA,4L);
-          PNGLong(chunk+4,(unsigned long) (100000*image->gamma+0.5));
+          PNGLong(chunk+4,(size_t) (100000*image->gamma+0.5));
           (void) WriteBlob(image,8,chunk);
           (void) WriteBlobMSBULong(image,crc32(0,chunk,8));
         }
@@ -8443,17 +8443,17 @@
           PNGType(chunk,mng_cHRM);
           LogPNGChunk((int) logging,mng_cHRM,32L);
           primary=image->chromaticity.white_point;
-          PNGLong(chunk+4,(unsigned long) (100000*primary.x+0.5));
-          PNGLong(chunk+8,(unsigned long) (100000*primary.y+0.5));
+          PNGLong(chunk+4,(size_t) (100000*primary.x+0.5));
+          PNGLong(chunk+8,(size_t) (100000*primary.y+0.5));
           primary=image->chromaticity.red_primary;
-          PNGLong(chunk+12,(unsigned long) (100000*primary.x+0.5));
-          PNGLong(chunk+16,(unsigned long) (100000*primary.y+0.5));
+          PNGLong(chunk+12,(size_t) (100000*primary.x+0.5));
+          PNGLong(chunk+16,(size_t) (100000*primary.y+0.5));
           primary=image->chromaticity.green_primary;
-          PNGLong(chunk+20,(unsigned long) (100000*primary.x+0.5));
-          PNGLong(chunk+24,(unsigned long) (100000*primary.y+0.5));
+          PNGLong(chunk+20,(size_t) (100000*primary.x+0.5));
+          PNGLong(chunk+24,(size_t) (100000*primary.y+0.5));
           primary=image->chromaticity.blue_primary;
-          PNGLong(chunk+28,(unsigned long) (100000*primary.x+0.5));
-          PNGLong(chunk+32,(unsigned long) (100000*primary.y+0.5));
+          PNGLong(chunk+28,(size_t) (100000*primary.x+0.5));
+          PNGLong(chunk+32,(size_t) (100000*primary.y+0.5));
           (void) WriteBlob(image,36,chunk);
           (void) WriteBlobMSBULong(image,crc32(0,chunk,36));
         }
@@ -8468,9 +8468,9 @@
       LogPNGChunk((int) logging,mng_pHYs,9L);
       if (image->units == PixelsPerInchResolution)
         {
-          PNGLong(chunk+4,(unsigned long)
+          PNGLong(chunk+4,(size_t)
             (image->x_resolution*100.0/2.54+0.5));
-          PNGLong(chunk+8,(unsigned long)
+          PNGLong(chunk+8,(size_t)
             (image->y_resolution*100.0/2.54+0.5));
           chunk[12]=1;
         }
@@ -8478,16 +8478,16 @@
         {
           if (image->units == PixelsPerCentimeterResolution)
             {
-              PNGLong(chunk+4,(unsigned long)
+              PNGLong(chunk+4,(size_t)
                 (image->x_resolution*100.0+0.5));
-              PNGLong(chunk+8,(unsigned long)
+              PNGLong(chunk+8,(size_t)
                 (image->y_resolution*100.0+0.5));
               chunk[12]=1;
             }
           else
             {
-              PNGLong(chunk+4,(unsigned long) (image->x_resolution+0.5));
-              PNGLong(chunk+8,(unsigned long) (image->y_resolution+0.5));
+              PNGLong(chunk+4,(size_t) (image->x_resolution+0.5));
+              PNGLong(chunk+8,(size_t) (image->y_resolution+0.5));
               chunk[12]=0;
             }
         }
@@ -8503,8 +8503,8 @@
       (void) WriteBlobMSBULong(image,9L);
       PNGType(chunk,mng_oFFs);
       LogPNGChunk((int) logging,mng_oFFs,9L);
-      PNGsLong(chunk+4,(long) (image->page.x));
-      PNGsLong(chunk+8,(long) (image->page.y));
+      PNGsLong(chunk+4,(ssize_t) (image->page.x));
+      PNGsLong(chunk+8,(ssize_t) (image->page.y));
       chunk[12]=0;
       (void) WriteBlob(image,13,chunk);
       (void) WriteBlobMSBULong(image,crc32(0,chunk,13));
@@ -8526,30 +8526,30 @@
     {
       if (jng_alpha_compression_method==0)
         {
-          register long
+          register ssize_t
             i;
 
-          long
+          ssize_t
             len;
 
           /* Write IDAT chunk header */
           if (logging != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  Write IDAT chunks from blob, length=%lu.",
-              (unsigned long) length);
+              (size_t) length);
 
           /* Copy IDAT chunks */
           len=0;
           p=blob+8;
-          for (i=8; i<(long) length; i+=len+12)
+          for (i=8; i<(ssize_t) length; i+=len+12)
           {
             len=(*p<<24)|((*(p+1))<<16)|((*(p+2))<<8)|(*(p+3));
             p+=4;
             if (*(p)==73 && *(p+1)==68 && *(p+2)==65 && *(p+3)==84) /* IDAT */
               {
                 /* Found an IDAT chunk. */
-                (void) WriteBlobMSBULong(image,(unsigned long) len);
-                LogPNGChunk((int) logging,mng_IDAT,(unsigned long) len);
+                (void) WriteBlobMSBULong(image,(size_t) len);
+                LogPNGChunk((int) logging,mng_IDAT,(size_t) len);
                 (void) WriteBlob(image,(size_t) len+4,p);
                 (void) WriteBlobMSBULong(image,
                     crc32(0,p,(uInt) len+4));
@@ -8570,8 +8570,8 @@
           if (logging != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  Write JDAA chunk, length=%lu.",
-              (unsigned long) length);
-          (void) WriteBlobMSBULong(image,(unsigned long) length);
+              (size_t) length);
+          (void) WriteBlobMSBULong(image,(size_t) length);
           PNGType(chunk,mng_JDAA);
           LogPNGChunk((int) logging,mng_JDAA,length);
           /* Write JDAT chunk(s) data */
@@ -8625,14 +8625,14 @@
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "  Successfully read jpeg_image into a blob, length=%lu.",
-        (unsigned long) length);
+        (size_t) length);
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "  Write JDAT chunk, length=%lu.",
-        (unsigned long) length);
+        (size_t) length);
     }
   /* Write JDAT chunk(s) */
-  (void) WriteBlobMSBULong(image,(unsigned long) length);
+  (void) WriteBlobMSBULong(image,(size_t) length);
   PNGType(chunk,mng_JDAT);
   LogPNGChunk((int) logging,mng_JDAT,length);
   (void) WriteBlob(image,4,chunk);
@@ -8775,7 +8775,7 @@
     optimize,
     use_global_plte;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
@@ -8785,10 +8785,10 @@
     write_jng,
     write_mng;
 
-  volatile unsigned long
+  volatile size_t
     scene;
 
-  unsigned long
+  size_t
     final_delay=0,
     initial_delay;
 
@@ -9200,8 +9200,8 @@
          */
          PNGType(chunk,mng_nEED);
          length=CopyMagickString((char *) chunk+4,"CACHEOFF",20);
-         (void) WriteBlobMSBULong(image,(unsigned long) length);
-         LogPNGChunk((int) logging,mng_nEED,(unsigned long) length);
+         (void) WriteBlobMSBULong(image,(size_t) length);
+         LogPNGChunk((int) logging,mng_nEED,(size_t) length);
          length+=4;
          (void) WriteBlob(image,length,chunk);
          (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) length));
@@ -9228,11 +9228,11 @@
            {
              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                "     TERM delay: %lu",
-               (unsigned long) (mng_info->ticks_per_second*
+               (size_t) (mng_info->ticks_per_second*
                   final_delay/MagickMax(image->ticks_per_second,1)));
              if (image->iterations == 0)
                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                 "     TERM iterations: %lu",(unsigned long) PNG_UINT_31_MAX);
+                 "     TERM iterations: %lu",(size_t) PNG_UINT_31_MAX);
              else
                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                  "     Image iterations: %lu",image->iterations);
@@ -9270,7 +9270,7 @@
              (void) WriteBlobMSBULong(image,4L);
              PNGType(chunk,mng_gAMA);
              LogPNGChunk((int) logging,mng_gAMA,4L);
-             PNGLong(chunk+4,(unsigned long) (100000*image->gamma+0.5));
+             PNGLong(chunk+4,(size_t) (100000*image->gamma+0.5));
              (void) WriteBlob(image,8,chunk);
              (void) WriteBlobMSBULong(image,crc32(0,chunk,8));
              mng_info->have_write_global_gama=MagickTrue;
@@ -9287,17 +9287,17 @@
              PNGType(chunk,mng_cHRM);
              LogPNGChunk((int) logging,mng_cHRM,32L);
              primary=image->chromaticity.white_point;
-             PNGLong(chunk+4,(unsigned long) (100000*primary.x+0.5));
-             PNGLong(chunk+8,(unsigned long) (100000*primary.y+0.5));
+             PNGLong(chunk+4,(size_t) (100000*primary.x+0.5));
+             PNGLong(chunk+8,(size_t) (100000*primary.y+0.5));
              primary=image->chromaticity.red_primary;
-             PNGLong(chunk+12,(unsigned long) (100000*primary.x+0.5));
-             PNGLong(chunk+16,(unsigned long) (100000*primary.y+0.5));
+             PNGLong(chunk+12,(size_t) (100000*primary.x+0.5));
+             PNGLong(chunk+16,(size_t) (100000*primary.y+0.5));
              primary=image->chromaticity.green_primary;
-             PNGLong(chunk+20,(unsigned long) (100000*primary.x+0.5));
-             PNGLong(chunk+24,(unsigned long) (100000*primary.y+0.5));
+             PNGLong(chunk+20,(size_t) (100000*primary.x+0.5));
+             PNGLong(chunk+24,(size_t) (100000*primary.y+0.5));
              primary=image->chromaticity.blue_primary;
-             PNGLong(chunk+28,(unsigned long) (100000*primary.x+0.5));
-             PNGLong(chunk+32,(unsigned long) (100000*primary.y+0.5));
+             PNGLong(chunk+28,(size_t) (100000*primary.x+0.5));
+             PNGLong(chunk+32,(size_t) (100000*primary.y+0.5));
              (void) WriteBlob(image,36,chunk);
              (void) WriteBlobMSBULong(image,crc32(0,chunk,36));
              mng_info->have_write_global_chrm=MagickTrue;
@@ -9313,9 +9313,9 @@
          LogPNGChunk((int) logging,mng_pHYs,9L);
          if (image->units == PixelsPerInchResolution)
            {
-             PNGLong(chunk+4,(unsigned long)
+             PNGLong(chunk+4,(size_t)
                (image->x_resolution*100.0/2.54+0.5));
-             PNGLong(chunk+8,(unsigned long)
+             PNGLong(chunk+8,(size_t)
                (image->y_resolution*100.0/2.54+0.5));
              chunk[12]=1;
            }
@@ -9323,16 +9323,16 @@
            {
              if (image->units == PixelsPerCentimeterResolution)
                {
-                 PNGLong(chunk+4,(unsigned long)
+                 PNGLong(chunk+4,(size_t)
                    (image->x_resolution*100.0+0.5));
-                 PNGLong(chunk+8,(unsigned long)
+                 PNGLong(chunk+8,(size_t)
                    (image->y_resolution*100.0+0.5));
                  chunk[12]=1;
                }
              else
                {
-                 PNGLong(chunk+4,(unsigned long) (image->x_resolution+0.5));
-                 PNGLong(chunk+8,(unsigned long) (image->y_resolution+0.5));
+                 PNGLong(chunk+4,(size_t) (image->x_resolution+0.5));
+                 PNGLong(chunk+8,(size_t) (image->y_resolution+0.5));
                  chunk[12]=0;
                }
            }
@@ -9375,7 +9375,7 @@
          (image->storage_class == PseudoClass) &&
          (all_images_are_gray == MagickFalse))
        {
-         unsigned long
+         size_t
            data_length;
 
          /*
@@ -9385,7 +9385,7 @@
          (void) WriteBlobMSBULong(image,data_length);
          PNGType(chunk,mng_PLTE);
          LogPNGChunk((int) logging,mng_PLTE,data_length);
-         for (i=0; i < (long) image->colors; i++)
+         for (i=0; i < (ssize_t) image->colors; i++)
          {
            chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red) & 0xff;
            chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green) & 0xff;
@@ -9428,14 +9428,14 @@
                 /*
                   Write MNG PLTE chunk
                 */
-                unsigned long
+                size_t
                   data_length;
 
                 data_length=3*image->colors;
                 (void) WriteBlobMSBULong(image,data_length);
                 PNGType(chunk,mng_PLTE);
                 LogPNGChunk((int) logging,mng_PLTE,data_length);
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red);
                   chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green);
@@ -9453,7 +9453,7 @@
 #endif
     if (need_defi)
       {
-        long
+        ssize_t
           previous_x,
           previous_y;
 
diff --git a/coders/pnm.c b/coders/pnm.c
index c933f03..4d4e45f 100644
--- a/coders/pnm.c
+++ b/coders/pnm.c
@@ -134,10 +134,10 @@
 %
 */
 
-static inline long ConstrainPixel(Image *image,const long offset,
-  const unsigned long extent)
+static inline ssize_t ConstrainPixel(Image *image,const ssize_t offset,
+  const size_t extent)
 {
-  if ((offset < 0) || (offset > (long) extent))
+  if ((offset < 0) || (offset > (ssize_t) extent))
     {
       (void) ThrowMagickException(&image->exception,GetMagickModule(),
         CorruptImageError,"InvalidPixel","`%s'",image->filename);
@@ -146,7 +146,7 @@
   return(offset);
 }
 
-static unsigned long PNMInteger(Image *image,const unsigned int base)
+static size_t PNMInteger(Image *image,const unsigned int base)
 {
   char
     *comment;
@@ -160,7 +160,7 @@
   size_t
     extent;
 
-  unsigned long
+  size_t
     value;
 
   /*
@@ -208,7 +208,7 @@
       comment=DestroyString(comment);
     }
   if (base == 2)
-    return((unsigned long) (c-(int) '0'));
+    return((size_t) (c-(int) '0'));
   /*
     Evaluate number.
   */
@@ -235,7 +235,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     row,
     y;
 
@@ -251,7 +251,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -261,7 +261,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     depth,
     max_value;
 
@@ -426,9 +426,9 @@
         /*
           Convert PBM image to pixel packets.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -437,7 +437,7 @@
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=(Quantum) (PNMInteger(image,2) == 0 ? QuantumRange : 0);
             q->green=q->red;
@@ -458,7 +458,7 @@
       }
       case '2':
       {
-        unsigned long
+        size_t
           intensity;
 
         /*
@@ -474,12 +474,12 @@
               sizeof(*scale));
             if (scale == (Quantum *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-            for (i=0; i <= (long) max_value; i++)
+            for (i=0; i <= (ssize_t) max_value; i++)
               scale[i]=(Quantum) (((double) QuantumRange*i)/max_value+0.5);
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -488,12 +488,12 @@
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             intensity=PNMInteger(image,10);
             q->red=(Quantum) intensity;
             if (scale != (Quantum *) NULL)
-              q->red=scale[ConstrainPixel(image,(long) intensity,max_value)];
+              q->red=scale[ConstrainPixel(image,(ssize_t) intensity,max_value)];
             q->green=q->red;
             q->blue=q->red;
             q++;
@@ -530,12 +530,12 @@
               sizeof(*scale));
             if (scale == (Quantum *) NULL)
               ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-            for (i=0; i <= (long) max_value; i++)
+            for (i=0; i <= (ssize_t) max_value; i++)
               scale[i]=(Quantum) (((double) QuantumRange*i)/max_value+0.5);
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -544,18 +544,18 @@
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             pixel.red=(MagickRealType) PNMInteger(image,10);
             pixel.green=(MagickRealType) PNMInteger(image,10);
             pixel.blue=(MagickRealType) PNMInteger(image,10);
             if (scale != (Quantum *) NULL)
               {
-                pixel.red=(MagickRealType) scale[ConstrainPixel(image,(long)
+                pixel.red=(MagickRealType) scale[ConstrainPixel(image,(ssize_t)
                   pixel.red,max_value)];
-                pixel.green=(MagickRealType) scale[ConstrainPixel(image,(long)
+                pixel.green=(MagickRealType) scale[ConstrainPixel(image,(ssize_t)
                   pixel.green,max_value)];
-                pixel.blue=(MagickRealType) scale[ConstrainPixel(image,(long)
+                pixel.blue=(MagickRealType) scale[ConstrainPixel(image,(ssize_t)
                   pixel.blue,max_value)];
               }
             q->red=(Quantum) pixel.red;
@@ -589,9 +589,9 @@
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         SetQuantumMinIsWhite(quantum_info,MagickTrue);
         extent=GetQuantumExtent(image,quantum_info,quantum_type);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          long
+          ssize_t
             offset;
 
           MagickBooleanType
@@ -662,9 +662,9 @@
         quantum_info=AcquireQuantumInfo(image_info,image);
         if (quantum_info == (QuantumInfo *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          long
+          ssize_t
             offset;
 
           MagickBooleanType
@@ -673,7 +673,7 @@
           register const unsigned char
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -720,7 +720,7 @@
                 unsigned char
                   pixel;
 
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   p=PushCharPixel(p,&pixel);
                   SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -734,7 +734,7 @@
                 unsigned short
                   pixel;
 
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   p=PushShortPixel(MSBEndian,p,&pixel);
                   SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -771,9 +771,9 @@
         quantum_info=AcquireQuantumInfo(image_info,image);
         if (quantum_info == (QuantumInfo *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          long
+          ssize_t
             offset;
 
           MagickBooleanType
@@ -782,7 +782,7 @@
           register const unsigned char
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -821,7 +821,7 @@
             }
           p=pixels;
           if (image->depth == 8)
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -835,7 +835,7 @@
                 unsigned short
                   pixel;
 
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   p=PushShortPixel(MSBEndian,p,&pixel);
                   q->red=ScaleShortToQuantum(pixel);
@@ -853,7 +853,7 @@
                   unsigned char
                     pixel;
 
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     p=PushCharPixel(p,&pixel);
                     q->red=ScaleAnyToQuantum(pixel,range);
@@ -870,7 +870,7 @@
                   unsigned short
                     pixel;
 
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     p=PushShortPixel(MSBEndian,p,&pixel);
                     q->red=ScaleAnyToQuantum(pixel,range);
@@ -885,7 +885,7 @@
           if ((type == BilevelType) || (type == GrayscaleType))
             {
               q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 if ((type == BilevelType) &&
                     (IsMonochromePixel(q) == MagickFalse))
@@ -917,7 +917,7 @@
         QuantumAny
           range;
 
-        unsigned long
+        size_t
           channels;
 
         /*
@@ -950,9 +950,9 @@
         quantum_info=AcquireQuantumInfo(image_info,image);
         if (quantum_info == (QuantumInfo *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          long
+          ssize_t
             offset;
 
           MagickBooleanType
@@ -961,7 +961,7 @@
           register const unsigned char
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -1014,7 +1014,7 @@
                     unsigned char
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushCharPixel(p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1034,7 +1034,7 @@
                     unsigned short
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushShortPixel(MSBEndian,p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1059,7 +1059,7 @@
                     unsigned char
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushCharPixel(p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1083,7 +1083,7 @@
                     unsigned short
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushShortPixel(MSBEndian,p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1111,7 +1111,7 @@
                     unsigned char
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushCharPixel(p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1133,7 +1133,7 @@
                     unsigned short
                       pixel;
 
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       p=PushShortPixel(MSBEndian,p,&pixel);
                       SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1184,9 +1184,9 @@
         SetQuantumScale(quantum_info,(MagickRealType) QuantumRange*
           fabs(quantum_scale));
         extent=GetQuantumExtent(image,quantum_info,quantum_type);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          long
+          ssize_t
             offset;
 
           MagickBooleanType
@@ -1223,7 +1223,7 @@
           }
           if ((size_t) count != extent)
             status=MagickFalse;
-          q=QueueAuthenticPixels(image,0,(long) (image->rows-offset-1),
+          q=QueueAuthenticPixels(image,0,(ssize_t) (image->rows-offset-1),
             image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             {
@@ -1311,10 +1311,10 @@
 %
 %  The format of the RegisterPNMImage method is:
 %
-%      unsigned long RegisterPNMImage(void)
+%      size_t RegisterPNMImage(void)
 %
 */
-ModuleExport unsigned long RegisterPNMImage(void)
+ModuleExport size_t RegisterPNMImage(void)
 {
   MagickInfo
     *entry;
@@ -1425,7 +1425,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1443,7 +1443,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -1612,7 +1612,7 @@
         if (image->depth > 16)
           image->depth=16;
         (void) FormatMagickString(buffer,MaxTextExtent,
-          "DEPTH %lu\nMAXVAL %lu\n",(unsigned long) packet_size,(unsigned long)
+          "DEPTH %lu\nMAXVAL %lu\n",(size_t) packet_size,(size_t)
           GetQuantumRange(image->depth));
         (void) WriteBlobString(image,buffer);
         (void) FormatMagickString(buffer,MaxTextExtent,"TUPLTYPE %s\nENDHDR\n",
@@ -1633,7 +1633,7 @@
           Convert image to a PBM image.
         */
         q=pixels;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const IndexPacket
             *restrict indexes;
@@ -1641,14 +1641,14 @@
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           indexes=GetVirtualIndexQueue(image);
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             pixel=PixelIntensityToQuantum(p);
             *q++=(unsigned char) (pixel >= (Quantum) (QuantumRange/2) ?
@@ -1690,18 +1690,18 @@
         else
           (void) WriteBlobString(image,"65535\n");
         q=pixels;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             index=PixelIntensityToQuantum(p);
             if (image->depth <= 8)
@@ -1748,18 +1748,18 @@
         else
           (void) WriteBlobString(image,"65535\n");
         q=pixels;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             if (image->depth <= 8)
               count=(ssize_t) FormatMagickString(buffer,MaxTextExtent,
@@ -1807,7 +1807,7 @@
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
         quantum_info->min_is_white=MagickTrue;
         pixels=GetQuantumPixels(quantum_info);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -1840,7 +1840,7 @@
         */
         if (image->depth > 8)
           image->depth=16;
-        (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(unsigned long)
+        (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(size_t)
           GetQuantumRange(image->depth));
         (void) WriteBlobString(image,buffer);
         quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
@@ -1850,12 +1850,12 @@
         pixels=GetQuantumPixels(quantum_info);
         extent=GetQuantumExtent(image,quantum_info,GrayQuantum);
         range=GetQuantumRange(image->depth);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -1868,7 +1868,7 @@
           else
             {
               if (image->depth <= 8)
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if (IsGrayPixel(p) == MagickFalse)
                     pixel=ScaleQuantumToAny(PixelIntensityToQuantum(p),range);
@@ -1883,7 +1883,7 @@
                   p++;
                 }
               else
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if (IsGrayPixel(p) == MagickFalse)
                     pixel=ScaleQuantumToAny(PixelIntensityToQuantum(p),range);
@@ -1922,7 +1922,7 @@
         */
         if (image->depth > 8)
           image->depth=16;
-        (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(unsigned long)
+        (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",(size_t)
           GetQuantumRange(image->depth));
         (void) WriteBlobString(image,buffer);
         quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
@@ -1931,12 +1931,12 @@
         pixels=GetQuantumPixels(quantum_info);
         extent=GetQuantumExtent(image,quantum_info,quantum_type);
         range=GetQuantumRange(image->depth);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -1949,7 +1949,7 @@
           else
             {
               if (image->depth <= 8)
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   pixel=ScaleQuantumToAny(p->red,range);
                   q=PopCharPixel((unsigned char) pixel,q);
@@ -1960,7 +1960,7 @@
                   p++;
                 }
               else
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   pixel=ScaleQuantumToAny(p->red,range);
                   q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
@@ -1998,7 +1998,7 @@
         quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
         pixels=GetQuantumPixels(quantum_info);
         range=GetQuantumRange(image->depth);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const IndexPacket
             *restrict indexes;
@@ -2006,7 +2006,7 @@
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
@@ -2025,7 +2025,7 @@
                 case GrayAlphaQuantum:
                 {
                   if (image->depth <= 8)
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(PixelIntensityToQuantum(p),range);
                       q=PopCharPixel((unsigned char) pixel,q);
@@ -2038,7 +2038,7 @@
                       p++;
                     }
                   else
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(PixelIntensityToQuantum(p),range);
                       q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
@@ -2056,7 +2056,7 @@
                 case CMYKAQuantum:
                 {
                   if (image->depth <= 8)
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(p->red,range);
                       q=PopCharPixel((unsigned char) pixel,q);
@@ -2075,7 +2075,7 @@
                       p++;
                     }
                   else
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(p->red,range);
                       q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
@@ -2098,7 +2098,7 @@
                 default:
                 {
                   if (image->depth <= 8)
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(p->red,range);
                       q=PopCharPixel((unsigned char) pixel,q);
@@ -2115,7 +2115,7 @@
                       p++;
                     }
                   else
-                    for (x=0; x < (long) image->columns; x++)
+                    for (x=0; x < (ssize_t) image->columns; x++)
                     {
                       pixel=ScaleQuantumToAny(p->red,range);
                       q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
@@ -2163,7 +2163,7 @@
         if (status == MagickFalse)
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
         pixels=GetQuantumPixels(quantum_info);
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           register const PixelPacket
             *restrict p;
diff --git a/coders/preview.c b/coders/preview.c
index 0f7a006..81210c0 100644
--- a/coders/preview.c
+++ b/coders/preview.c
@@ -90,10 +90,10 @@
 %
 %  The format of the RegisterPREVIEWImage method is:
 %
-%      unsigned long RegisterPREVIEWImage(void)
+%      size_t RegisterPREVIEWImage(void)
 %
 */
-ModuleExport unsigned long RegisterPREVIEWImage(void)
+ModuleExport size_t RegisterPREVIEWImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/ps.c b/coders/ps.c
index f8d0e26..0594328 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -130,7 +130,7 @@
     argc,
     code;
 
-  register long
+  register ssize_t
     i;
 
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
@@ -177,7 +177,7 @@
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
   NTGhostscriptUnLoadDLL();
 #endif
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
     argv[i]=DestroyString(argv[i]);
   argv=(char **) RelinquishMagickMemory(argv);
   if ((status != 0) && (status != -101))
@@ -287,7 +287,7 @@
     l,
     value;
 
-  register long
+  register ssize_t
     i;
 
   l=0;
@@ -304,7 +304,7 @@
     c&=0xff;
     if (isxdigit(c) == MagickFalse)
       continue;
-    value=(int) ((unsigned long) value << 4)+hex_digits[c];
+    value=(int) ((size_t) value << 4)+hex_digits[c];
     i++;
   }
   return(value);
@@ -382,7 +382,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   SegmentInfo
@@ -401,7 +401,7 @@
   StringInfo
     *profile;
 
-  unsigned long
+  size_t
     columns,
     extent,
     language_level,
@@ -557,7 +557,7 @@
         length=extent;
         profile=AcquireStringInfo(length);
         p=GetStringInfoDatum(profile);
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
           *p++=(unsigned char) ProfileInteger(image,hex_digits);
         (void) SetImageProfile(image,"8bim",profile);
         profile=DestroyStringInfo(profile);
@@ -666,8 +666,8 @@
           "%gx%g%+.15g%+.15g",bounds.x2-bounds.x1,bounds.y2-bounds.y1,
           bounds.x1,bounds.y1);
         (void) SetImageProperty(image,"ps:HiResBoundingBox",geometry);
-        page.width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
-        page.height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
+        page.width=(size_t) floor(bounds.x2-bounds.x1+0.5);
+        page.height=(size_t) floor(bounds.y2-bounds.y1+0.5);
         hires_bounds=bounds;
       }
   }
@@ -727,8 +727,8 @@
     image->x_resolution,image->y_resolution);
   if (image_info->page != (char *) NULL)
     (void) ParseAbsoluteGeometry(image_info->page,&page);
-  page.width=(unsigned long) floor(page.width*image->x_resolution/delta.x+0.5);
-  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+  page.width=(size_t) floor(page.width*image->x_resolution/delta.x+0.5);
+  page.height=(size_t) floor(page.height*image->y_resolution/delta.y+
     0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
@@ -795,13 +795,13 @@
       Image
         *clone_image;
 
-      register long
+      register ssize_t
         i;
 
       /*
         Add place holder images to meet the subimage specification requirement.
       */
-      for (i=0; i < (long) image_info->scene; i++)
+      for (i=0; i < (ssize_t) image_info->scene; i++)
       {
         clone_image=CloneImage(postscript_image,1,1,MagickTrue,exception);
         if (clone_image != (Image *) NULL)
@@ -852,10 +852,10 @@
 %
 %  The format of the RegisterPSImage method is:
 %
-%      unsigned long RegisterPSImage(void)
+%      size_t RegisterPSImage(void)
 %
 */
-ModuleExport unsigned long RegisterPSImage(void)
+ModuleExport size_t RegisterPSImage(void)
 {
   MagickInfo
     *entry;
@@ -982,7 +982,7 @@
 }
 
 static inline unsigned char *PopHexPixel(const char **hex_digits,
-  const unsigned long pixel,unsigned char *pixels)
+  const size_t pixel,unsigned char *pixels)
 {
   register const char
     *hex;
@@ -1010,7 +1010,7 @@
       q=PopHexPixel(hex_digits,ScaleQuantumToChar(pixel.green),q); \
       q=PopHexPixel(hex_digits,ScaleQuantumToChar(pixel.blue),q); \
     } \
-  q=PopHexPixel(hex_digits,(const unsigned long) MagickMin(length,0xff),q); \
+  q=PopHexPixel(hex_digits,(const size_t) MagickMin(length,0xff),q); \
 }
 
   static const char
@@ -1317,7 +1317,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -1349,7 +1349,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1368,7 +1368,7 @@
   unsigned char
     pixels[2048];
 
-  unsigned long
+  size_t
     bit,
     byte,
     page,
@@ -1419,8 +1419,8 @@
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(unsigned long) (100.0*2.54*resolution.x+0.5)/100.0;
-        resolution.y=(unsigned long) (100.0*2.54*resolution.y+0.5)/100.0;
+        resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
+        resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
       }
     SetGeometry(image,&geometry);
     (void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu",
@@ -1439,16 +1439,16 @@
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) floor(scale.x+0.5);
+    geometry.width=(size_t) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) floor(scale.y+0.5);
+    geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
     if (image->gravity != UndefinedGravity)
       {
         geometry.x=(-page_info.x);
-        geometry.y=(long) (media_info.height+page_info.y-image->rows);
+        geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows);
       }
     pointsize=12.0;
     if (image_info->pointsize != 0.0)
@@ -1456,7 +1456,7 @@
     text_size=0;
     value=GetImageProperty(image,"label");
     if (value != (const char *) NULL)
-      text_size=(unsigned long) (MultilineCensus(value)*pointsize+12);
+      text_size=(size_t) (MultilineCensus(value)*pointsize+12);
     if (page == 1)
       {
         /*
@@ -1488,9 +1488,9 @@
         else
           {
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
-              (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),
-              (long) floor(bounds.y2+0.5));
+              "%%%%BoundingBox: %ld %ld %ld %ld\n",(ssize_t) ceil(bounds.x1-0.5),
+              (ssize_t) ceil(bounds.y1-0.5),(ssize_t) floor(bounds.x2+0.5),
+              (ssize_t) floor(bounds.y2+0.5));
             (void) WriteBlobString(image,buffer);
             (void) FormatMagickString(buffer,MaxTextExtent,
               "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,
@@ -1504,10 +1504,10 @@
               Embed Photoshop profile.
             */
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%%BeginPhotoshop: %lu",(unsigned long) GetStringInfoLength(
+              "%%BeginPhotoshop: %lu",(size_t) GetStringInfoLength(
               profile));
             (void) WriteBlobString(image,buffer);
-            for (i=0; i < (long) GetStringInfoLength(profile); i++)
+            for (i=0; i < (ssize_t) GetStringInfoLength(profile); i++)
             {
               if ((i % 32) == 0)
                 (void) WriteBlobString(image,"\n% ");
@@ -1525,10 +1525,10 @@
             */
             (void) WriteBlobString(image,"\n%begin_xml_code\n");
             (void) FormatMagickString(buffer,MaxTextExtent,
-               "\n%%begin_xml_packet: %lu\n",(unsigned long)
+               "\n%%begin_xml_packet: %lu\n",(size_t)
                GetStringInfoLength(profile));
             (void) WriteBlobString(image,buffer);
-            for (i=0; i < (long) GetStringInfoLength(profile); i++)
+            for (i=0; i < (ssize_t) GetStringInfoLength(profile); i++)
               (void) WriteBlobByte(image,GetStringInfoDatum(profile)[i]);
             (void) WriteBlobString(image,"\n%end_xml_packet\n%end_xml_code\n");
           }
@@ -1548,7 +1548,7 @@
             (void) WriteBlobString(image,"%%Orientation: Portrait\n");
             (void) WriteBlobString(image,"%%PageOrder: Ascend\n");
             (void) FormatMagickString(buffer,MaxTextExtent,"%%%%Pages: %lu\n",
-              image_info->adjoin != MagickFalse ? (unsigned long)
+              image_info->adjoin != MagickFalse ? (size_t)
               GetImageListLength(image) : 1UL);
             (void) WriteBlobString(image,buffer);
           }
@@ -1562,13 +1562,13 @@
             Image
               *preview_image;
 
-            long
+            ssize_t
               y;
 
             Quantum
               pixel;
 
-            register long
+            register ssize_t
               x;
 
             /*
@@ -1586,7 +1586,7 @@
               preview_image->rows+35)/36);
             (void) WriteBlobString(image,buffer);
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(preview_image,0,y,preview_image->columns,1,
                 &preview_image->exception);
@@ -1595,7 +1595,7 @@
               indexes=GetVirtualIndexQueue(preview_image);
               bit=0;
               byte=0;
-              for (x=0; x < (long) preview_image->columns; x++)
+              for (x=0; x < (ssize_t) preview_image->columns; x++)
               {
                 byte<<=1;
                 pixel=PixelIntensityToQuantum(p);
@@ -1647,7 +1647,7 @@
         }
         value=GetImageProperty(image,"label");
         if (value != (const char *) NULL)
-          for (j=(long) MultilineCensus(value)-1; j >= 0; j--)
+          for (j=(ssize_t) MultilineCensus(value)-1; j >= 0; j--)
           {
             (void) WriteBlobString(image,"  /label 512 string def\n");
             (void) WriteBlobString(image,"  currentfile label readline pop\n");
@@ -1669,7 +1669,7 @@
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,
       "%%%%PageBoundingBox: %ld %ld %ld %ld\n",geometry.x,geometry.y,
-      geometry.x+(long) geometry.width,geometry.y+(long) (geometry.height+
+      geometry.x+(ssize_t) geometry.width,geometry.y+(ssize_t) (geometry.height+
       text_size));
     (void) WriteBlobString(image,buffer);
     if ((double) geometry.x < bounds.x1)
@@ -1727,13 +1727,13 @@
               "%lu %lu\n1\n1\n1\n8\n",image->columns,image->rows);
             (void) WriteBlobString(image,buffer);
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
                 q=PopHexPixel(hex_digits,pixel,q);
@@ -1761,7 +1761,7 @@
           }
         else
           {
-            long
+            ssize_t
               y;
 
             Quantum
@@ -1774,7 +1774,7 @@
               "%lu %lu\n1\n1\n1\n1\n",image->columns,image->rows);
             (void) WriteBlobString(image,buffer);
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
@@ -1783,7 +1783,7 @@
               indexes=GetVirtualIndexQueue(image);
               bit=0;
               byte=0;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 byte<<=1;
                 pixel=PixelIntensityToQuantum(p);
@@ -1848,7 +1848,7 @@
                 Dump runlength-encoded DirectColor packets.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
@@ -1856,12 +1856,12 @@
                   break;
                 pixel=(*p);
                 length=255;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if ((p->red == pixel.red) && (p->green == pixel.green) &&
                       (p->blue == pixel.blue) &&
                       (p->opacity == pixel.opacity) && (length < 255) &&
-                      (x < (long) (image->columns-1)))
+                      (x < (ssize_t) (image->columns-1)))
                     length++;
                   else
                     {
@@ -1908,13 +1908,13 @@
                 Dump uncompressed DirectColor packets.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if ((image->matte != MagickFalse) &&
                       (p->opacity == (Quantum) TransparentOpacity))
@@ -1969,7 +1969,7 @@
           */
           (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",image->colors);
           (void) WriteBlobString(image,buffer);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             (void) FormatMagickString(buffer,MaxTextExtent,"%02X%02X%02X\n",
               ScaleQuantumToChar(image->colormap[i].red),
@@ -1985,7 +1985,7 @@
                 Dump runlength-encoded PseudoColor packets.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
@@ -1994,17 +1994,17 @@
                 indexes=GetVirtualIndexQueue(image);
                 index=(*indexes);
                 length=255;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if ((index == indexes[x]) && (length < 255) &&
-                      (x < ((long) image->columns-1)))
+                      (x < ((ssize_t) image->columns-1)))
                     length++;
                   else
                     {
                       if (x > 0)
                         {
                           q=PopHexPixel(hex_digits,index,q);
-                          q=PopHexPixel(hex_digits,(unsigned long)
+                          q=PopHexPixel(hex_digits,(size_t)
                             MagickMin(length,0xff),q);
                           i++;
                           if ((q-pixels+6) >= 80)
@@ -2021,7 +2021,7 @@
                   p++;
                 }
                 q=PopHexPixel(hex_digits,index,q);
-                q=PopHexPixel(hex_digits,(unsigned long)
+                q=PopHexPixel(hex_digits,(size_t)
                   MagickMin(length,0xff),q);
                 if (image->previous == (Image *) NULL)
                   {
@@ -2044,14 +2044,14 @@
                 Dump uncompressed PseudoColor packets.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   q=PopHexPixel(hex_digits,indexes[x],q);
                   if ((q-pixels+4) >= 80)
@@ -2094,8 +2094,8 @@
   if (page > 2)
     {
       (void) FormatMagickString(buffer,MaxTextExtent,
-        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
-        (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+        "%%%%BoundingBox: %ld %ld %ld %ld\n",(ssize_t) ceil(bounds.x1-0.5),
+        (ssize_t) ceil(bounds.y1-0.5),(ssize_t) floor(bounds.x2+0.5),(ssize_t)
         floor(bounds.y2+0.5));
       (void) WriteBlobString(image,buffer);
       (void) FormatMagickString(buffer,MaxTextExtent,
diff --git a/coders/ps2.c b/coders/ps2.c
index 1b152d7..958f7a2 100644
--- a/coders/ps2.c
+++ b/coders/ps2.c
@@ -103,10 +103,10 @@
 %
 %  The format of the RegisterPS2Image method is:
 %
-%      unsigned long RegisterPS2Image(void)
+%      size_t RegisterPS2Image(void)
 %
 */
-ModuleExport unsigned long RegisterPS2Image(void)
+ModuleExport size_t RegisterPS2Image(void)
 {
   MagickInfo
     *entry;
@@ -391,7 +391,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -429,10 +429,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   SegmentInfo
@@ -447,7 +447,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     page,
     text_size;
 
@@ -511,8 +511,8 @@
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(unsigned long) (100.0*2.54*resolution.x+0.5)/100.0;
-        resolution.y=(unsigned long) (100.0*2.54*resolution.y+0.5)/100.0;
+        resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
+        resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
       }
     SetGeometry(image,&geometry);
     (void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu",
@@ -531,16 +531,16 @@
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) floor(scale.x+0.5);
+    geometry.width=(size_t) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) floor(scale.y+0.5);
+    geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
     if (image->gravity != UndefinedGravity)
       {
         geometry.x=(-page_info.x);
-        geometry.y=(long) (media_info.height+page_info.y-image->rows);
+        geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows);
       }
     pointsize=12.0;
     if (image_info->pointsize != 0.0)
@@ -548,7 +548,7 @@
     text_size=0;
     value=GetImageProperty(image,"label");
     if (value != (const char *) NULL)
-      text_size=(unsigned long) (MultilineCensus(value)*pointsize+12);
+      text_size=(size_t) (MultilineCensus(value)*pointsize+12);
     if (page == 1)
       {
         /*
@@ -580,8 +580,8 @@
         else
           {
             (void) FormatMagickString(buffer,MaxTextExtent,
-              "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
-              (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+              "%%%%BoundingBox: %ld %ld %ld %ld\n",(ssize_t) ceil(bounds.x1-0.5),
+              (ssize_t) ceil(bounds.y1-0.5),(ssize_t) floor(bounds.x2+0.5),(ssize_t)
               floor(bounds.y2+0.5));
             (void) WriteBlobString(image,buffer);
             (void) FormatMagickString(buffer,MaxTextExtent,
@@ -604,7 +604,7 @@
               (void) CopyMagickString(buffer,"%%Pages: 1\n",MaxTextExtent);
             else
               (void) FormatMagickString(buffer,MaxTextExtent,"%%%%Pages: %lu\n",
-                (unsigned long) GetImageListLength(image));
+                (size_t) GetImageListLength(image));
             (void) WriteBlobString(image,buffer);
           }
         (void) WriteBlobString(image,"%%EndComments\n");
@@ -653,7 +653,7 @@
         }
         value=GetImageProperty(image,"label");
         if (value != (const char *) NULL)
-          for (j=(long) MultilineCensus(value)-1; j >= 0; j--)
+          for (j=(ssize_t) MultilineCensus(value)-1; j >= 0; j--)
           {
             (void) WriteBlobString(image,"  /label 512 string def\n");
             (void) WriteBlobString(image,"  currentfile label readline pop\n");
@@ -675,7 +675,7 @@
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,
       "%%%%PageBoundingBox: %ld %ld %ld %ld\n",geometry.x,geometry.y,
-      geometry.x+(long) geometry.width,geometry.y+(long)
+      geometry.x+(ssize_t) geometry.width,geometry.y+(ssize_t)
       (geometry.height+text_size));
     (void) WriteBlobString(image,buffer);
     if ((double) geometry.x < bounds.x1)
@@ -779,13 +779,13 @@
               Dump Runlength encoded pixels.
             */
             q=pixels;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
                 p++;
@@ -813,13 +813,13 @@
               Dump uncompressed PseudoColor packets.
             */
             Ascii85Initialize(image);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 Ascii85Encode(image,
                   ScaleQuantumToChar(PixelIntensityToQuantum(p)));
@@ -874,14 +874,14 @@
                 Dump Packbit encoded pixels.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if ((image->matte != MagickFalse) &&
                       (p->opacity == (Quantum) TransparentOpacity))
@@ -929,14 +929,14 @@
                 Dump uncompressed DirectColor packets.
               */
               Ascii85Initialize(image);
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   if ((image->matte != MagickFalse) &&
                       (p->opacity == (Quantum) TransparentOpacity))
@@ -987,7 +987,7 @@
           (void) WriteBlobString(image,buffer);
           (void) FormatMagickString(buffer,MaxTextExtent,"%lu\n",image->colors);
           (void) WriteBlobString(image,buffer);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             (void) FormatMagickString(buffer,MaxTextExtent,"%02X%02X%02X\n",
               ScaleQuantumToChar(image->colormap[i].red),
@@ -1016,14 +1016,14 @@
                 Dump Runlength encoded pixels.
               */
               q=pixels;
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                   *q++=(unsigned char) indexes[x];
                 progress=SetImageProgress(image,SaveImageTag,y,image->rows);
                 if (progress == MagickFalse)
@@ -1048,14 +1048,14 @@
                 Dump uncompressed PseudoColor packets.
               */
               Ascii85Initialize(image);
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 p=GetVirtualPixels(image,0,y,image->columns,1,
                   &image->exception);
                 if (p == (const PixelPacket *) NULL)
                   break;
                 indexes=GetVirtualIndexQueue(image);
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                   Ascii85Encode(image,(unsigned char) indexes[x]);
                 progress=SetImageProgress(image,SaveImageTag,y,image->rows);
                 if (progress == MagickFalse)
@@ -1073,7 +1073,7 @@
     if (offset < 0)
       ThrowWriterException(CorruptImageError,"ImproperImageHeader");
     (void) FormatMagickString(buffer,MaxTextExtent,
-      "%%%%BeginData:%13ld %s Bytes\n",(long) length,
+      "%%%%BeginData:%13ld %s Bytes\n",(ssize_t) length,
       compression == NoCompression ? "ASCII" : "Binary");
     (void) WriteBlobString(image,buffer);
     offset=SeekBlob(image,stop,SEEK_SET);
@@ -1093,8 +1093,8 @@
   if (page > 1)
     {
       (void) FormatMagickString(buffer,MaxTextExtent,
-        "%%%%BoundingBox: %ld %ld %ld %ld\n",(long) ceil(bounds.x1-0.5),
-        (long) ceil(bounds.y1-0.5),(long) floor(bounds.x2+0.5),(long)
+        "%%%%BoundingBox: %ld %ld %ld %ld\n",(ssize_t) ceil(bounds.x1-0.5),
+        (ssize_t) ceil(bounds.y1-0.5),(ssize_t) floor(bounds.x2+0.5),(ssize_t)
         floor(bounds.y2+0.5));
       (void) WriteBlobString(image,buffer);
       (void) FormatMagickString(buffer,MaxTextExtent,
diff --git a/coders/ps3.c b/coders/ps3.c
index 3207a21..1ee28de 100644
--- a/coders/ps3.c
+++ b/coders/ps3.c
@@ -117,10 +117,10 @@
 %
 %  The format of the RegisterPS3Image method is:
 %
-%      unsigned long RegisterPS3Image(void)
+%      size_t RegisterPS3Image(void)
 %
 */
-ModuleExport unsigned long RegisterPS3Image(void)
+ModuleExport size_t RegisterPS3Image(void)
 {
   MagickInfo
     *entry;
@@ -232,7 +232,7 @@
 static MagickBooleanType SerializeImage(const ImageInfo *image_info,
   Image *image,unsigned char **pixels,size_t *length)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -244,7 +244,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -261,14 +261,14 @@
   if (*pixels == (unsigned char *) NULL)
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
   q=(*pixels);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
     if (image->colorspace != CMYKColorspace)
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
         *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -276,7 +276,7 @@
         p++;
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
         *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -299,7 +299,7 @@
 static MagickBooleanType SerializeImageChannel(const ImageInfo *image_info,
   Image *image,unsigned char **pixels,size_t *length)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -308,7 +308,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -318,7 +318,7 @@
     code,
     bit;
 
-  unsigned long
+  size_t
     pack,
     padded_columns;
 
@@ -334,13 +334,13 @@
   if (*pixels == (unsigned char *) NULL)
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
   q=(*pixels);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     if (pack == 1)
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
         p++;
@@ -348,10 +348,10 @@
     else
       {
         code='\0';
-        for (x=0; x < (long) padded_columns; x++)
+        for (x=0; x < (ssize_t) padded_columns; x++)
         {
           bit=(unsigned char) 0x00;
-          if (x < (long) image->columns)
+          if (x < (ssize_t) image->columns)
             bit=(unsigned char) (PixelIntensityToQuantum(p) ==
               (Quantum) TransparentOpacity ? 0x01 : 0x00);
           code=(code << 1)+bit;
@@ -375,7 +375,7 @@
 static MagickBooleanType SerializeImageIndexes(const ImageInfo *image_info,
   Image *image,unsigned char **pixels,size_t *length)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -387,7 +387,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -403,13 +403,13 @@
   if (*pixels == (unsigned char *) NULL)
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
   q=(*pixels);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *q++=(unsigned char) indexes[x];
     if (image->previous == (Image *) NULL)
       {
@@ -440,7 +440,7 @@
     start,
     stop;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -534,7 +534,7 @@
       if (status == MagickFalse)
         break;
       Ascii85Initialize(image);
-      for (i=0; i < (long) length; i++)
+      for (i=0; i < (ssize_t) length; i++)
         Ascii85Encode(image,pixels[i]);
       Ascii85Flush(image);
       pixels=(unsigned char *) RelinquishMagickMemory(pixels);
@@ -586,7 +586,7 @@
   if (offset < 0)
     ThrowWriterException(CorruptImageError,"ImproperImageHeader");
   (void) FormatMagickString(buffer,MaxTextExtent,
-    "%%%%BeginData:%13ld %s Bytes\n",(long) length,
+    "%%%%BeginData:%13ld %s Bytes\n",(ssize_t) length,
     compression == NoCompression ? "ASCII" : "BINARY");
   (void) WriteBlobString(image,buffer);
   offset=SeekBlob(image,stop,SEEK_SET);
@@ -809,7 +809,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     j;
 
   MagickBooleanType
@@ -834,7 +834,7 @@
     media_info,
     page_info;
 
-  register long
+  register ssize_t
     i;
 
   SegmentInfo
@@ -849,7 +849,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     page,
     pixel,
     text_size;
@@ -932,8 +932,8 @@
       }
     if (image->units == PixelsPerCentimeterResolution)
       {
-        resolution.x=(unsigned long) (100.0*2.54*resolution.x+0.5)/100.0;
-        resolution.y=(unsigned long) (100.0*2.54*resolution.y+0.5)/100.0;
+        resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0;
+        resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0;
       }
     SetGeometry(image,&geometry);
     (void) FormatMagickString(page_geometry,MaxTextExtent,"%lux%lu",
@@ -952,16 +952,16 @@
     (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
       &geometry.width,&geometry.height);
     scale.x=(double) (geometry.width*delta.x)/resolution.x;
-    geometry.width=(unsigned long) floor(scale.x+0.5);
+    geometry.width=(size_t) floor(scale.x+0.5);
     scale.y=(double) (geometry.height*delta.y)/resolution.y;
-    geometry.height=(unsigned long) floor(scale.y+0.5);
+    geometry.height=(size_t) floor(scale.y+0.5);
     (void) ParseAbsoluteGeometry(page_geometry,&media_info);
     (void) ParseGravityGeometry(image,page_geometry,&page_info,
       &image->exception);
     if (image->gravity != UndefinedGravity)
       {
         geometry.x=(-page_info.x);
-        geometry.y=(long) (media_info.height+page_info.y-image->rows);
+        geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows);
       }
     pointsize=12.0;
     if (image_info->pointsize != 0.0)
@@ -969,7 +969,7 @@
     text_size=0;
     value=GetImageProperty(image,"label");
     if (value != (const char *) NULL)
-      text_size=(unsigned long) (MultilineCensus(value)*pointsize+12);
+      text_size=(size_t) (MultilineCensus(value)*pointsize+12);
     page++;
     if (page == 1)
       {
@@ -1042,7 +1042,7 @@
               (void) CopyMagickString(buffer,"%%Pages: 1\n",MaxTextExtent);
             else
               (void) FormatMagickString(buffer,MaxTextExtent,"%%%%Pages: %lu\n",
-                (unsigned long) GetImageListLength(image));
+                (size_t) GetImageListLength(image));
             (void) WriteBlobString(image,buffer);
           }
         (void) WriteBlobString(image,"%%EndComments\n");
@@ -1063,7 +1063,7 @@
           {
               (void) WriteBlobString(image,"\n  %% Labels.\n  /Helvetica "
               " findfont pointsize scalefont setfont\n");
-            for (i=(long) MultilineCensus(value)-1; i >= 0; i--)
+            for (i=(ssize_t) MultilineCensus(value)-1; i >= 0; i--)
             {
               (void) WriteBlobString(image,
                 "  currentfile buffer readline pop token pop\n");
@@ -1089,7 +1089,7 @@
     */
     (void) FormatMagickString(buffer,MaxTextExtent,
       "%%%%PageBoundingBox: %ld %ld %ld %ld\n",geometry.x,geometry.y,geometry.x+
-      (long) geometry.width,geometry.y+(long) (geometry.height+text_size));
+      (ssize_t) geometry.width,geometry.y+(ssize_t) (geometry.height+text_size));
     (void) WriteBlobString(image,buffer);
     /*
       Page process colors if not RGB.
@@ -1317,7 +1317,7 @@
                 default:
                 {
                   Ascii85Initialize(image);
-                  for (i=0; i < (long) length; i++)
+                  for (i=0; i < (ssize_t) length; i++)
                     Ascii85Encode(image,pixels[i]);
                   Ascii85Flush(image);
                   status=MagickTrue;
@@ -1402,7 +1402,7 @@
                 default:
                 {
                   Ascii85Initialize(image);
-                  for (i=0; i < (long) length; i++)
+                  for (i=0; i < (ssize_t) length; i++)
                     Ascii85Encode(image,pixels[i]);
                   Ascii85Flush(image);
                   status=MagickTrue;
@@ -1474,7 +1474,7 @@
             if ((compression != NoCompression) &&
                 (compression != UndefinedCompression))
               {
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   pixel=ScaleQuantumToChar(image->colormap[i].red);
                   (void) WriteBlobByte(image,(unsigned char) pixel);
@@ -1487,7 +1487,7 @@
             else
               {
                 Ascii85Initialize(image);
-                for (i=0; i < (long) image->colors; i++)
+                for (i=0; i < (ssize_t) image->colors; i++)
                 {
                   pixel=ScaleQuantumToChar(image->colormap[i].red);
                   Ascii85Encode(image,(unsigned char) pixel);
@@ -1510,7 +1510,7 @@
               default:
               {
                 Ascii85Initialize(image);
-                for (i=0; i < (long) length; i++)
+                for (i=0; i < (ssize_t) length; i++)
                   Ascii85Encode(image,pixels[i]);
                 Ascii85Flush(image);
                 status=MagickTrue;
@@ -1555,7 +1555,7 @@
     if (offset < 0)
       ThrowWriterException(CorruptImageError,"ImproperImageHeader");
     (void) FormatMagickString(buffer,MaxTextExtent,
-      "%%%%BeginData:%13ld %s Bytes\n",(long) length,
+      "%%%%BeginData:%13ld %s Bytes\n",(ssize_t) length,
       compression == NoCompression ? "ASCII" : "BINARY");
     (void) WriteBlobString(image,buffer);
     offset=SeekBlob(image,stop,SEEK_SET);
diff --git a/coders/psd.c b/coders/psd.c
index 1565b62..037c7d8 100644
--- a/coders/psd.c
+++ b/coders/psd.c
@@ -69,7 +69,7 @@
   Define declaractions.
 */
 #define MaxPSDChannels  56
-#define PSDQuantum(x) (((long) (x)+1) & -2)
+#define PSDQuantum(x) (((ssize_t) (x)+1) & -2)
 
 /*
   Enumerated declaractions.
@@ -94,7 +94,7 @@
   short int
     type;
 
-  unsigned long
+  size_t
     size;
 } ChannelInfo;
 
@@ -121,7 +121,7 @@
     visible,
     flags;
 
-  unsigned long
+  size_t
     offset_x,
     offset_y;
 
@@ -144,7 +144,7 @@
   unsigned char
     reserved[6];
 
-  unsigned long
+  size_t
     rows,
     columns;
 
@@ -246,7 +246,7 @@
 }
 
 static ssize_t DecodePSDPixels(const size_t number_compact_pixels,
-  const unsigned char *compact_pixels,const long depth,
+  const unsigned char *compact_pixels,const ssize_t depth,
   const size_t number_pixels,unsigned char *pixels)
 {
   int
@@ -378,7 +378,7 @@
   return((MagickSizeType) ReadBlobMSBLongLong(image));
 }
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -410,9 +410,9 @@
   StringInfo
     *profile;
 
-  unsigned long
+  size_t
     count,
-    long_sans;
+    ssize_t_sans;
 
   unsigned short
     id,
@@ -428,7 +428,7 @@
   {
     if (LocaleNCompare((const char *) p,"8BIM",4) != 0)
       break;
-    p=PushLongPixel(MSBEndian,p,&long_sans);
+    p=PushLongPixel(MSBEndian,p,&ssize_t_sans);
     p=PushShortPixel(MSBEndian,p,&id);
     p=PushShortPixel(MSBEndian,p,&short_sans);
     p=PushLongPixel(MSBEndian,p,&count);
@@ -514,10 +514,10 @@
   return(OverCompositeOp);
 }
 
-static MagickBooleanType ReadPSDLayer(Image *image,const unsigned long channels,
-  const long type,const MagickOffsetType *offsets,ExceptionInfo *exception)
+static MagickBooleanType ReadPSDLayer(Image *image,const size_t channels,
+  const ssize_t type,const MagickOffsetType *offsets,ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
   Quantum
@@ -526,7 +526,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -573,7 +573,7 @@
         length;
 
       length=0;
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
         if ((MagickOffsetType) length < offsets[y])
           length=(size_t) offsets[y];
       compact_pixels=(unsigned char *) AcquireQuantumMemory(length,
@@ -583,7 +583,7 @@
           image->filename);
       (void) ResetMagickMemory(compact_pixels,0,length*sizeof(*compact_pixels));
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     if (image->compression != RLECompression)
       count=ReadBlob(image,packet_size*image->columns,pixels);
@@ -593,7 +593,7 @@
         if (count != (ssize_t) offsets[y])
           break;
         count=DecodePSDPixels((size_t) offsets[y],compact_pixels,
-          (long) image->depth,packet_size*image->columns,pixels);
+          (ssize_t) image->depth,packet_size*image->columns,pixels);
       }
     if (count < (ssize_t) (packet_size*image->columns))
       break;
@@ -602,7 +602,7 @@
       break;
     indexes=GetAuthenticIndexQueue(image);
     p=pixels;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (packet_size == 1)
         pixel=ScaleCharToQuantum(*p++);
@@ -632,10 +632,10 @@
                 indexes[x]=(IndexPacket) ScaleQuantumToChar(pixel);
               else
                 indexes[x]=(IndexPacket) ScaleQuantumToShort(pixel);
-              *q=image->colormap[(long) indexes[x]];
-              q->red=image->colormap[(long) indexes[x]].red;
-              q->green=image->colormap[(long) indexes[x]].green;
-              q->blue=image->colormap[(long) indexes[x]].blue;
+              *q=image->colormap[(ssize_t) indexes[x]];
+              q->red=image->colormap[(ssize_t) indexes[x]].red;
+              q->green=image->colormap[(ssize_t) indexes[x]].green;
+              q->blue=image->colormap[(ssize_t) indexes[x]].blue;
             }
           break;
         }
@@ -694,7 +694,7 @@
   LayerInfo
     *layer_info;
 
-  long
+  ssize_t
     j,
     number_layers,
     y;
@@ -714,7 +714,7 @@
   PSDInfo
     psd_info;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -730,7 +730,7 @@
   unsigned short
     compression;
 
-  unsigned long
+  size_t
     mask_size,
     skip_first_alpha = 0;
 
@@ -837,15 +837,15 @@
           /*
             Read PSD raster colormap.
           */
-          if (AcquireImageColormap(image,(unsigned long) (length/3)) == MagickFalse)
+          if (AcquireImageColormap(image,(size_t) (length/3)) == MagickFalse)
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             image->colormap[i].red=ScaleCharToQuantum((unsigned char)
               ReadBlobByte(image));
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             image->colormap[i].green=ScaleCharToQuantum((unsigned char)
               ReadBlobByte(image));
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             image->colormap[i].blue=ScaleCharToQuantum((unsigned char)
               ReadBlobByte(image));
           image->matte=psd_info.channels >= 2 ? MagickTrue : MagickFalse;
@@ -862,7 +862,7 @@
       */
       if (image->debug != MagickFalse)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "  reading image resource blocks - %ld bytes",(long) length);
+          "  reading image resource blocks - %ld bytes",(ssize_t) length);
       blocks=(unsigned char *) AcquireQuantumMemory((size_t) length,
         sizeof(*blocks));
       if (blocks == (unsigned char *) NULL)
@@ -916,14 +916,14 @@
       size=GetPSDSize(&psd_info,image);
       if (size == 0)
         {
-          unsigned long
+          size_t
             quantum;
 
           /*
             Skip layers & masks.
           */
           quantum=psd_info.version == 1 ? 4UL : 8UL;
-          for (j=0; j < (long) (length-quantum); j++)
+          for (j=0; j < (ssize_t) (length-quantum); j++)
             (void) ReadBlobByte(image);
         }
       else
@@ -963,11 +963,11 @@
             if (image->debug != MagickFalse)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                 "  reading layer #%ld",i+1);
-            layer_info[i].page.y=(long) ReadBlobMSBLong(image);
-            layer_info[i].page.x=(long) ReadBlobMSBLong(image);
-            layer_info[i].page.height=(unsigned long)
+            layer_info[i].page.y=(ssize_t) ReadBlobMSBLong(image);
+            layer_info[i].page.x=(ssize_t) ReadBlobMSBLong(image);
+            layer_info[i].page.height=(size_t)
               (ReadBlobMSBLong(image)-layer_info[i].page.y);
-            layer_info[i].page.width=(unsigned long)
+            layer_info[i].page.width=(size_t)
               (ReadBlobMSBLong(image)-layer_info[i].page.x);
             if (layer_info[i].page.height > 300000)
               layer_info[i].page.height+=4294967295UL;
@@ -982,17 +982,17 @@
                 layer_info[i].page.x, layer_info[i].page.y,
                 layer_info[i].page.height,layer_info[i].page.width,
                 layer_info[i].channels);
-            for (j=0; j < (long) layer_info[i].channels; j++)
+            for (j=0; j < (ssize_t) layer_info[i].channels; j++)
             {
               layer_info[i].channel_info[j].type=(short)
                 ReadBlobMSBShort(image);
-              layer_info[i].channel_info[j].size=(unsigned long)
+              layer_info[i].channel_info[j].size=(size_t)
                 GetPSDSize(&psd_info,image);
               if (image->debug != MagickFalse)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                   "    channel[%ld]: type=%d, size=%ld",j,
                   layer_info[i].channel_info[j].type,
-              (long) layer_info[i].channel_info[j].size);
+              (ssize_t) layer_info[i].channel_info[j].size);
             }
             count=ReadBlob(image,4,(unsigned char *) type);
             if ((count == 0) || (LocaleNCompare(type,"8BIM",4) != 0))
@@ -1011,7 +1011,7 @@
             if (image->debug != MagickFalse)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                 "   blend=%.4s, opacity=%lu, clipping=%s, flags=%d, visible=%s",
-                layer_info[i].blendkey,(unsigned long) layer_info[i].opacity,
+                layer_info[i].blendkey,(size_t) layer_info[i].opacity,
                 layer_info[i].clipping ? "true" : "false",layer_info[i].flags,
                 layer_info[i].visible ? "true" : "false");
             (void) ReadBlobByte(image);  /* filler */
@@ -1028,11 +1028,11 @@
                     /*
                       Layer mask info.
                     */
-                    layer_info[i].mask.y=(long) ReadBlobMSBLong(image);
-                    layer_info[i].mask.x=(long) ReadBlobMSBLong(image);
-                    layer_info[i].mask.height=(unsigned long)
+                    layer_info[i].mask.y=(ssize_t) ReadBlobMSBLong(image);
+                    layer_info[i].mask.x=(ssize_t) ReadBlobMSBLong(image);
+                    layer_info[i].mask.height=(size_t)
                       (ReadBlobMSBLong(image)-layer_info[i].mask.y);
-                    layer_info[i].mask.width=(unsigned long)
+                    layer_info[i].mask.width=(size_t)
                       (ReadBlobMSBLong(image)-layer_info[i].mask.x);
                     if (layer_info[i].mask.height > 300000)
                       layer_info[i].mask.height+=4294967295UL;
@@ -1043,11 +1043,11 @@
                         "      layer mask: offset(%ld,%ld), size(%ld,%ld), length=%ld",
                         layer_info[i].mask.x,layer_info[i].mask.y,
                         layer_info[i].mask.width, layer_info[i].mask.height,
-                        (long) length-16);
+                        (ssize_t) length-16);
                     /*
                       Skip over the rest of the layer mask information.
                     */
-                    for (j=0; j < (long) (length-16); j++)
+                    for (j=0; j < (ssize_t) (length-16); j++)
                       (void) ReadBlobByte(image);
                   }
                 combinedlength+=length+4;  /* +4 for length */
@@ -1059,11 +1059,11 @@
                     */
                     if (image->debug != MagickFalse)
                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                        "      layer blending ranges: length=%ld",(long) length);
+                        "      layer blending ranges: length=%ld",(ssize_t) length);
                     /*
                       We read it, but don't use it...
                     */
-                    for (j=0; j < (long) (length); j+=8)
+                    for (j=0; j < (ssize_t) (length); j+=8)
                     {
                       size_t blend_source=ReadBlobMSBLong(image);
                       size_t blend_dest=ReadBlobMSBLong(image);
@@ -1078,7 +1078,7 @@
                   Layer name.
                 */
                 length=(size_t) ReadBlobByte(image);
-                for (j=0; j < (long) length; j++)
+                for (j=0; j < (ssize_t) length; j++)
                   layer_info[i].name[j]=(unsigned char) ReadBlobByte(image);
                 layer_info[i].name[j]='\0';
                 if (image->debug != MagickFalse)
@@ -1114,7 +1114,7 @@
               }
 
               if ( length ) {
-              for (j=0; j < (long) (length); j++)
+              for (j=0; j < (ssize_t) (length); j++)
                 (void) ReadBlobByte(image);
               }
 
@@ -1127,9 +1127,9 @@
                 */
                 if (image->debug != MagickFalse)
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                    "      unsupported data: length=%ld",(long)
+                    "      unsupported data: length=%ld",(ssize_t)
                     (size-combinedlength));
-                for (j=0; j < (long) (size-combinedlength); j++)
+                for (j=0; j < (ssize_t) (size-combinedlength); j++)
                   (void) ReadBlobByte(image);
               }
             /*
@@ -1161,7 +1161,7 @@
                 (psd_info.mode == GrayscaleMode) ||
                 (psd_info.mode == DuotoneMode))
               layer_info[i].image->colorspace=GRAYColorspace;
-            for (j=0; j < (long) layer_info[i].channels; j++)
+            for (j=0; j < (ssize_t) layer_info[i].channels; j++)
               if (layer_info[i].channel_info[j].type == -1)
                 layer_info[i].image->matte=MagickTrue;
             /*
@@ -1174,7 +1174,7 @@
               layer_info[i].page.y);
             (void) SetImageArtifact(layer_info[i].image,"psd:layer.y",message);
             (void) FormatMagickString(message,MaxTextExtent,"%lu",
-              (unsigned long) layer_info[i].opacity);
+              (size_t) layer_info[i].opacity);
             (void) SetImageArtifact(layer_info[i].image,"psd:layer.opacity",
               message);
             (void) SetImageProperty(layer_info[i].image,"label",(char *)
@@ -1191,7 +1191,7 @@
           if (image->debug != MagickFalse)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  reading data for layer %ld",i);
-            for (j=0; j < (long) layer_info[i].channels; j++)
+            for (j=0; j < (ssize_t) layer_info[i].channels; j++)
             {
               if (image->debug != MagickFalse)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -1199,7 +1199,7 @@
 #if     1
               if (layer_info[i].channel_info[j].size <= (2*layer_info[i].image->rows))
                 {
-                  long
+                  ssize_t
                     k;
 
                   if (image->debug != MagickFalse)
@@ -1208,7 +1208,7 @@
                   /*
                     A layer without data.
                   */
-                  for (k=0; k < (long) layer_info[i].channel_info[j].size; k++)
+                  for (k=0; k < (ssize_t) layer_info[i].channel_info[j].size; k++)
                     (void) ReadBlobByte(layer_info[i].image);
                   continue;
                 }
@@ -1233,7 +1233,7 @@
                       if (offsets == (MagickOffsetType *) NULL)
                         ThrowReaderException(ResourceLimitError,
                           "MemoryAllocationFailed");
-                      for (y=0; y < (long) layer_info[i].image->rows; y++)
+                      for (y=0; y < (ssize_t) layer_info[i].image->rows; y++)
                         offsets[y]=GetPSDOffset(&psd_info,layer_info[i].image);
                     }
                   status=ReadPSDLayer(layer_info[i].image,
@@ -1251,14 +1251,14 @@
                 /*
                   Correct for opacity level.
                 */
-                for (y=0; y < (long) layer_info[i].image->rows; y++)
+                for (y=0; y < (ssize_t) layer_info[i].image->rows; y++)
                 {
                   q=GetAuthenticPixels(layer_info[i].image,0,y,
                     layer_info[i].image->columns,1,exception);
                   if (q == (PixelPacket *) NULL)
                     break;
                   indexes=GetAuthenticIndexQueue(layer_info[i].image);
-                  for (x=0; x < (long) layer_info[i].image->columns; x++)
+                  for (x=0; x < (ssize_t) layer_info[i].image->columns; x++)
                   {
                     q->opacity=(Quantum) (QuantumRange-(Quantum) (QuantumScale*
                       ((QuantumRange-q->opacity)*(QuantumRange-
@@ -1361,10 +1361,10 @@
         psd_info.channels*sizeof(*offsets));
       if (offsets == (MagickOffsetType *) NULL)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-      for (i=0; i < (long) (image->rows*psd_info.channels); i++)
+      for (i=0; i < (ssize_t) (image->rows*psd_info.channels); i++)
         offsets[i]=GetPSDOffset(&psd_info,image);
     }
-  for (i=0; i < (long) psd_info.channels; i++)
+  for (i=0; i < (ssize_t) psd_info.channels; i++)
   {
     status=ReadPSDLayer(image,psd_info.channels,i,offsets+i*image->rows,
       exception);
@@ -1402,10 +1402,10 @@
 %
 %  The format of the RegisterPSDImage method is:
 %
-%      unsigned long RegisterPSDImage(void)
+%      size_t RegisterPSDImage(void)
 %
 */
-ModuleExport unsigned long RegisterPSDImage(void)
+ModuleExport size_t RegisterPSDImage(void)
 {
   MagickInfo
     *entry;
@@ -1500,7 +1500,7 @@
   int
     count;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -1523,7 +1523,7 @@
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   q=compact_pixels;
-  for (i=(long) length; i != 0; )
+  for (i=(ssize_t) length; i != 0; )
   {
     switch (i)
     {
@@ -1565,7 +1565,7 @@
               Packed run.
             */
             count=3;
-            while (((long) count < i) && (*pixels == *(pixels+count)))
+            while (((ssize_t) count < i) && (*pixels == *(pixels+count)))
             {
               count++;
               if (count >= 127)
@@ -1586,12 +1586,12 @@
         {
           packbits[count+1]=pixels[count];
           count++;
-          if (((long) count >= (i-3)) || (count >= 127))
+          if (((ssize_t) count >= (i-3)) || (count >= 127))
             break;
         }
         i-=count;
         *packbits=(unsigned char) (count-1);
-        for (j=0; j <= (long) count; j++)
+        for (j=0; j <= (ssize_t) count; j++)
           *q++=packbits[j];
         pixels+=count;
         break;
@@ -1625,7 +1625,7 @@
     tmp_image->depth=16;
   packet_size=tmp_image->depth > 8UL ? 2UL : 1UL;
   quantum_info=AcquireQuantumInfo(image_info,image);
-  for (y=0; y < (long) tmp_image->rows; y++)
+  for (y=0; y < (ssize_t) tmp_image->rows; y++)
   {
     p=GetVirtualPixels(tmp_image,0,y,tmp_image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -1655,7 +1655,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1671,7 +1671,7 @@
   monochrome=IsMonochromeImage(image,&image->exception);
   packet_size=tmp_image->depth > 8UL ? 2UL : 1UL;
   quantum_info=AcquireQuantumInfo(image_info,image);
-  for (y=0; y < (long) tmp_image->rows; y++)
+  for (y=0; y < (ssize_t) tmp_image->rows; y++)
   {
     p=GetVirtualPixels(tmp_image,0,y,tmp_image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -1679,7 +1679,7 @@
     length=ExportQuantumPixels(tmp_image,(CacheView *) NULL,quantum_info,
       quantum_type,pixels,&image->exception);
     if (monochrome != MagickFalse)
-      for (i=0; i < (long) length; i++)
+      for (i=0; i < (ssize_t) length; i++)
         pixels[i]=(~pixels[i]);
     if (tmp_image->compression != RLECompression)
       (void) WriteBlob(image,length,pixels);
@@ -1850,7 +1850,7 @@
 
   if ( (strLength % inPad) == 0 )
     return;
-  for (i=0; i < (long) (inPad-(strLength % inPad)); i++)
+  for (i=0; i < (ssize_t) (inPad-(strLength % inPad)); i++)
     (void) WriteBlobByte(inImage,0);
 }
 
@@ -1895,9 +1895,9 @@
   unsigned char
     *datum;
 
-  unsigned long
+  size_t
     count,
-    long_sans;
+    ssize_t_sans;
 
   unsigned short
     id,
@@ -1915,7 +1915,7 @@
     q=(unsigned char *) p;
     if (LocaleNCompare((const char *) p,"8BIM",4) != 0)
       break;
-    p=PushLongPixel(MSBEndian,p,&long_sans);
+    p=PushLongPixel(MSBEndian,p,&ssize_t_sans);
     p=PushShortPixel(MSBEndian,p,&id);
     p=PushShortPixel(MSBEndian,p,&short_sans);
     p=PushLongPixel(MSBEndian,p,&count);
@@ -1943,9 +1943,9 @@
   unsigned char
     *datum;
 
-  unsigned long
+  size_t
     count,
-    long_sans;
+    ssize_t_sans;
 
   unsigned short
     id,
@@ -1963,7 +1963,7 @@
     q=(unsigned char *) p;
     if (LocaleNCompare((const char *) p,"8BIM",4) != 0)
       break;
-    p=PushLongPixel(MSBEndian,p,&long_sans);
+    p=PushLongPixel(MSBEndian,p,&ssize_t_sans);
     p=PushShortPixel(MSBEndian,p,&id);
     p=PushShortPixel(MSBEndian,p,&short_sans);
     p=PushLongPixel(MSBEndian,p,&count);
@@ -1994,7 +1994,7 @@
   PSDInfo
     psd_info;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2008,7 +2008,7 @@
   unsigned char
     layer_name[4];
 
-  unsigned long
+  size_t
     channel_size,
     channelLength,
     layer_count,
@@ -2100,15 +2100,15 @@
         Write PSD raster colormap.
       */
       (void) WriteBlobMSBLong(image,768);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].red));
       for ( ; i < 256; i++)
         (void) WriteBlobByte(image,0);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].green));
       for ( ; i < 256; i++)
         (void) WriteBlobByte(image,0);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         (void) WriteBlobByte(image,ScaleQuantumToChar(image->colormap[i].blue));
       for ( ; i < 256; i++)
         (void) WriteBlobByte(image,0);
@@ -2168,9 +2168,9 @@
         else
           num_channels=tmp_image->matte != MagickFalse ? 5UL : 4UL;
 
-    channelLength=(unsigned long) (tmp_image->columns * tmp_image->rows *
+    channelLength=(size_t) (tmp_image->columns * tmp_image->rows *
       packet_size + 2);
-    layer_info_size += (unsigned long) (4*4 + 2 + num_channels * 6 +
+    layer_info_size += (size_t) (4*4 + 2 + num_channels * 6 +
       (psd_info.version == 1 ? 8 : 16) + 4 * 1 + 4 + num_channels *
       channelLength);
     theAttr=(const char *) GetImageProperty(tmp_image,"label");
diff --git a/coders/pwp.c b/coders/pwp.c
index 0fe9d3e..0ff20e2 100644
--- a/coders/pwp.c
+++ b/coders/pwp.c
@@ -142,7 +142,7 @@
   register Image
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -154,7 +154,7 @@
   unsigned char
     magick[MaxTextExtent];
 
-  unsigned long
+  size_t
     filesize;
 
   /*
@@ -209,7 +209,7 @@
       }
     length=fwrite("SFW94A",1,6,file);
     filesize=65535UL*magick[2]+256L*magick[1]+magick[0];
-    for (i=0; i < (long) filesize; i++)
+    for (i=0; i < (ssize_t) filesize; i++)
     {
       c=ReadBlobByte(pwp_image);
       (void) fputc(c,file);
@@ -278,10 +278,10 @@
 %
 %  The format of the RegisterPWPImage method is:
 %
-%      unsigned long RegisterPWPImage(void)
+%      size_t RegisterPWPImage(void)
 %
 */
-ModuleExport unsigned long RegisterPWPImage(void)
+ModuleExport size_t RegisterPWPImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/raw.c b/coders/raw.c
index c84d3ea..9fa8034 100644
--- a/coders/raw.c
+++ b/coders/raw.c
@@ -100,7 +100,7 @@
     *canvas_image,
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -115,7 +115,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -172,7 +172,7 @@
       */
       image->scene++;
       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
@@ -195,12 +195,12 @@
         length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
         count=ReadBlob(image,length,pixels);
       }
-    for (y=0; y < (long) image->extract_info.height; y++)
+    for (y=0; y < (ssize_t) image->extract_info.height; y++)
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -220,7 +220,7 @@
       if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
         break;
       if (((y-image->extract_info.y) >= 0) && 
-          ((y-image->extract_info.y) < (long) image->rows))
+          ((y-image->extract_info.y) < (ssize_t) image->rows))
         {
           p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
             image->columns,1,exception);
@@ -228,7 +228,7 @@
             1,exception);
           if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             SetRedPixelComponent(q,GetRedPixelComponent(p));
             SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -299,10 +299,10 @@
 %
 %  The format of the RegisterRAWImage method is:
 %
-%      unsigned long RegisterRAWImage(void)
+%      size_t RegisterRAWImage(void)
 %
 */
-ModuleExport unsigned long RegisterRAWImage(void)
+ModuleExport size_t RegisterRAWImage(void)
 {
   MagickInfo
     *entry;
@@ -448,7 +448,7 @@
 */
 static MagickBooleanType WriteRAWImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickOffsetType
@@ -573,7 +573,7 @@
     if (quantum_info == (QuantumInfo *) NULL)
       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
     pixels=GetQuantumPixels(quantum_info);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
diff --git a/coders/rgb.c b/coders/rgb.c
index 861856b..956fd3a 100644
--- a/coders/rgb.c
+++ b/coders/rgb.c
@@ -100,7 +100,7 @@
     *canvas_image,
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -115,7 +115,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -206,7 +206,7 @@
       */
       image->scene++;
       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
@@ -250,12 +250,12 @@
             if (count != (ssize_t) length)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -276,7 +276,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) &&
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -285,7 +285,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 qx[0]=GetRedPixelComponent(p);
                 qx[1]=GetGreenPixelComponent(p);
@@ -327,12 +327,12 @@
             length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[0]);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           register const PixelPacket
             *restrict p;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -355,7 +355,7 @@
             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
               break;
             if (((y-image->extract_info.y) >= 0) &&
-                ((y-image->extract_info.y) < (long) image->rows))
+                ((y-image->extract_info.y) < (ssize_t) image->rows))
               {
                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
                   0,canvas_image->columns,1,exception);
@@ -365,7 +365,7 @@
                     (q == (PixelPacket *) NULL))
                   break;
                 if (i == (channels - 1))
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     SetRedPixelComponent(q,GetRedPixelComponent(p));
                     SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -400,12 +400,12 @@
           }
         for (i=0; i < channels; i++)
         {
-          for (y=0; y < (long) image->extract_info.height; y++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
           {
             register const PixelPacket
               *restrict p;
 
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -426,7 +426,7 @@
             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
               break;
             if (((y-image->extract_info.y) >= 0) &&
-                ((y-image->extract_info.y) < (long) image->rows))
+                ((y-image->extract_info.y) < (ssize_t) image->rows))
               {
                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                   canvas_image->columns,1,exception);
@@ -435,7 +435,7 @@
                 if ((p == (const PixelPacket *) NULL) ||
                     (q == (PixelPacket *) NULL))
                   break;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   switch(quantum_types[i])
                   {
@@ -494,8 +494,8 @@
                   break;
                 }
           length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[i]);
-          for (j=0; j < (long) scene; j++)
-            for (y=0; y < (long) image->extract_info.height; y++)
+          for (j=0; j < (ssize_t) scene; j++)
+            for (y=0; y < (ssize_t) image->extract_info.height; y++)
               if (ReadBlob(image,length,pixels) != (ssize_t) length)
                 {
                   ThrowFileException(exception,CorruptImageError,
@@ -503,12 +503,12 @@
                   break;
                 }
           count=ReadBlob(image,length,pixels);
-          for (y=0; y < (long) image->extract_info.height; y++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
           {
             register const PixelPacket
               *restrict p;
 
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -529,7 +529,7 @@
             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
               break;
             if (((y-image->extract_info.y) >= 0) &&
-                ((y-image->extract_info.y) < (long) image->rows))
+                ((y-image->extract_info.y) < (ssize_t) image->rows))
               {
                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                   canvas_image->columns,1,exception);
@@ -538,7 +538,7 @@
                 if ((p == (const PixelPacket *) NULL) ||
                     (q == (PixelPacket *) NULL))
                   break;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   switch(quantum_types[i])
                   {
@@ -628,10 +628,10 @@
 %
 %  The format of the RegisterRGBImage method is:
 %
-%      unsigned long RegisterRGBImage(void)
+%      size_t RegisterRGBImage(void)
 %
 */
-ModuleExport unsigned long RegisterRGBImage(void)
+ModuleExport size_t RegisterRGBImage(void)
 {
   MagickInfo
     *entry;
@@ -780,7 +780,7 @@
 */
 static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -796,7 +796,7 @@
     quantum_type,
     quantum_types[4];
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -808,7 +808,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     channels;
 
   /*
@@ -843,7 +843,7 @@
       image->matte=MagickTrue;
       channels=4;
     }
-  for (i=0; i < (long) channels; i++)
+  for (i=0; i < (ssize_t) channels; i++)
   {
     switch (image_info->magick[i])
     {
@@ -887,9 +887,9 @@
           No interlacing:  RGBRGBRGBRGBRGBRGB...
         */
         image_view=AcquireCacheView(image);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -899,7 +899,7 @@
             &image->exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             px=(*q);
             qx[0]=&(q->red);
@@ -935,7 +935,7 @@
         /*
           Line interlacing:  RRR...GGG...BBB...RRR...GGG...BBB...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -943,7 +943,7 @@
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (i=0; i < (long) channels; i++)
+          for (i=0; i < (ssize_t) channels; i++)
           {
             length=ExportQuantumPixels(image,(const CacheView *) NULL,
               quantum_info,quantum_types[i],pixels,&image->exception);
@@ -965,9 +965,9 @@
         /*
           Plane interlacing:  RRRRRR...GGGGGG...BBBBBB...
         */
-        for (i=0; i < (long) channels; i++)
+        for (i=0; i < (ssize_t) channels; i++)
         {
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register const PixelPacket
               *restrict p;
@@ -1004,7 +1004,7 @@
         /*
           Partition interlacing:  RRRRRR..., GGGGGG..., BBBBBB...
         */
-        for (i=0; i < (long) channels; i++)
+        for (i=0; i < (ssize_t) channels; i++)
         {
           sfx[0]=image_info->magick[i];
           AppendImageFormat(sfx,image->filename);
@@ -1012,7 +1012,7 @@
             AppendBinaryBlobMode,&image->exception);
           if (status == MagickFalse)
             return(status);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register const PixelPacket
               *restrict p;
diff --git a/coders/rla.c b/coders/rla.c
index b033428..9a3fdb3 100644
--- a/coders/rla.c
+++ b/coders/rla.c
@@ -118,7 +118,7 @@
       blue_primary[24],
       white_point[24];
 
-    long
+    ssize_t
       job_number;
 
     char
@@ -150,7 +150,7 @@
       auxiliary[32],
       space[36];
 
-    long
+    ssize_t
       next;
   } RLAInfo;
 
@@ -162,10 +162,10 @@
     length,
     runlength;
 
-  long
+  ssize_t
     y;
 
-  long
+  ssize_t
     *scanlines;
 
   MagickBooleanType
@@ -174,7 +174,7 @@
   MagickOffsetType
     offset;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -229,7 +229,7 @@
   count=ReadBlob(image,24,(unsigned char *) rla_info.green_primary);
   count=ReadBlob(image,24,(unsigned char *) rla_info.blue_primary);
   count=ReadBlob(image,24,(unsigned char *) rla_info.white_point);
-  rla_info.job_number=(long) ReadBlobMSBLong(image);
+  rla_info.job_number=(ssize_t) ReadBlobMSBLong(image);
   count=ReadBlob(image,128,(unsigned char *) rla_info.name);
   count=ReadBlob(image,128,(unsigned char *) rla_info.description);
   count=ReadBlob(image,64,(unsigned char *) rla_info.program);
@@ -251,7 +251,7 @@
   count=ReadBlob(image,36,(unsigned char *) rla_info.space);
   if ((size_t) count != 36)
     ThrowReaderException(CorruptImageError,"UnableToReadImageData");
-  rla_info.next=(long) ReadBlobMSBLong(image);
+  rla_info.next=(ssize_t) ReadBlobMSBLong(image);
   /*
     Initialize image structure.
   */
@@ -263,21 +263,21 @@
       (void) CloseBlob(image);
       return(GetFirstImageInList(image));
     }
-  scanlines=(long *) AcquireQuantumMemory(image->rows,sizeof(*scanlines));
-  if (scanlines == (long *) NULL)
+  scanlines=(ssize_t *) AcquireQuantumMemory(image->rows,sizeof(*scanlines));
+  if (scanlines == (ssize_t *) NULL)
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   if (*rla_info.description != '\0')
     (void) SetImageProperty(image,"comment",rla_info.description);
   /*
     Read offsets to each scanline data.
   */
-  for (i=0; i < (long) image->rows; i++)
-    scanlines[i]=(long) ReadBlobMSBLong(image);
+  for (i=0; i < (ssize_t) image->rows; i++)
+    scanlines[i]=(ssize_t) ReadBlobMSBLong(image);
   /*
     Read image data.
   */
   x=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     offset=SeekBlob(image,scanlines[image->rows-y-1],SEEK_SET);
     if (offset < 0)
@@ -298,8 +298,8 @@
           {
             while (runlength < 0)
             {
-              q=GetAuthenticPixels(image,(long) (x % image->columns),
-                (long) (y % image->rows),1,1,exception);
+              q=GetAuthenticPixels(image,(ssize_t) (x % image->columns),
+                (ssize_t) (y % image->rows),1,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               byte=(unsigned char) ReadBlobByte(image);
@@ -340,8 +340,8 @@
         runlength++;
         do
         {
-          q=GetAuthenticPixels(image,(long) (x % image->columns),
-            (long) (y % image->rows),1,1,exception);
+          q=GetAuthenticPixels(image,(ssize_t) (x % image->columns),
+            (ssize_t) (y % image->rows),1,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           switch (channel)
@@ -407,10 +407,10 @@
 %
 %  The format of the RegisterRLAImage method is:
 %
-%      unsigned long RegisterRLAImage(void)
+%      size_t RegisterRLAImage(void)
 %
 */
-ModuleExport unsigned long RegisterRLAImage(void)
+ModuleExport size_t RegisterRLAImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/rle.c b/coders/rle.c
index 9a2f883..14aabdc 100644
--- a/coders/rle.c
+++ b/coders/rle.c
@@ -141,7 +141,7 @@
     operand,
     status;
 
-  long
+  ssize_t
     y;
 
   MagickStatusType
@@ -153,13 +153,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -175,7 +175,7 @@
     plane,
     *rle_pixels;
 
-  unsigned long
+  size_t
     bits_per_pixel,
     map_length,
     number_colormaps,
@@ -227,7 +227,7 @@
         /*
           No background color-- initialize to black.
         */
-        for (i=0; i < (long) number_planes; i++)
+        for (i=0; i < (ssize_t) number_planes; i++)
           background_color[i]=0;
         (void) ReadBlobByte(image);
       }
@@ -237,7 +237,7 @@
           Initialize background color.
         */
         p=background_color;
-        for (i=0; i < (long) number_planes; i++)
+        for (i=0; i < (ssize_t) number_planes; i++)
           *p++=(unsigned char) ReadBlobByte(image);
       }
     if ((number_planes & 0x01) == 0)
@@ -253,8 +253,8 @@
         if (colormap == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         p=colormap;
-        for (i=0; i < (long) number_colormaps; i++)
-          for (x=0; x < (long) map_length; x++)
+        for (i=0; i < (ssize_t) number_colormaps; i++)
+          for (x=0; x < (ssize_t) map_length; x++)
             *p++=(unsigned char) ScaleShortToQuantum(ReadBlobLSBShort(image));
       }
     if ((flags & 0x08) != 0)
@@ -262,7 +262,7 @@
         char
           *comment;
 
-        unsigned long
+        size_t
           length;
 
         /*
@@ -299,21 +299,21 @@
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     if ((flags & 0x01) && !(flags & 0x02))
       {
-        long
+        ssize_t
           j;
 
         /*
           Set background color.
         */
         p=rle_pixels;
-        for (i=0; i < (long) number_pixels; i++)
+        for (i=0; i < (ssize_t) number_pixels; i++)
         {
           if (image->matte == MagickFalse)
-            for (j=0; j < (long) number_planes; j++)
+            for (j=0; j < (ssize_t) number_planes; j++)
               *p++=background_color[j];
           else
             {
-              for (j=0; j < (long) (number_planes-1); j++)
+              for (j=0; j < (ssize_t) (number_planes-1); j++)
                 *p++=background_color[j];
               *p++=0;  /* initialize matte channel */
             }
@@ -364,10 +364,10 @@
           p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
             x*number_planes+plane;
           operand++;
-          for (i=0; i < (long) operand; i++)
+          for (i=0; i < (ssize_t) operand; i++)
           {
             pixel=(unsigned char) ReadBlobByte(image);
-            if ((y < (long) image->rows) && ((x+i) < (long) image->columns))
+            if ((y < (ssize_t) image->rows) && ((x+i) < (ssize_t) image->columns))
               *p=pixel;
             p+=number_planes;
           }
@@ -386,9 +386,9 @@
           operand++;
           p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
             x*number_planes+plane;
-          for (i=0; i < (long) operand; i++)
+          for (i=0; i < (ssize_t) operand; i++)
           {
-            if ((y < (long) image->rows) && ((x+i) < (long) image->columns))
+            if ((y < (ssize_t) image->rows) && ((x+i) < (ssize_t) image->columns))
               *p=pixel;
             p+=number_planes;
           }
@@ -411,15 +411,15 @@
         mask=(MagickStatusType) (map_length-1);
         p=rle_pixels;
         if (number_colormaps == 1)
-          for (i=0; i < (long) number_pixels; i++)
+          for (i=0; i < (ssize_t) number_pixels; i++)
           {
             *p=colormap[*p & mask];
             p++;
           }
         else
           if ((number_planes >= 3) && (number_colormaps >= 3))
-            for (i=0; i < (long) number_pixels; i++)
-              for (x=0; x < (long) number_planes; x++)
+            for (i=0; i < (ssize_t) number_pixels; i++)
+              for (x=0; x < (ssize_t) number_planes; x++)
               {
                 *p=colormap[x*map_length+(*p & mask)];
                 p++;
@@ -434,12 +434,12 @@
           Convert raster image to DirectClass pixel packets.
         */
         p=rle_pixels;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum(*p++);
             q->green=ScaleCharToQuantum(*p++);
@@ -469,7 +469,7 @@
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         p=colormap;
         if (number_colormaps == 1)
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             /*
               Pseudocolor.
@@ -480,7 +480,7 @@
           }
         else
           if (number_colormaps > 1)
-            for (i=0; i < (long) image->colors; i++)
+            for (i=0; i < (ssize_t) image->colors; i++)
             {
               image->colormap[i].red=ScaleCharToQuantum(*p);
               image->colormap[i].green=ScaleCharToQuantum(*(p+map_length));
@@ -493,13 +493,13 @@
             /*
               Convert raster image to PseudoClass pixel packets.
             */
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
                 indexes[x]=(IndexPacket) (*p++);
               if (SyncAuthenticPixels(image,exception) == MagickFalse)
                 break;
@@ -517,12 +517,12 @@
             /*
               Image has a matte channel-- promote to DirectClass.
             */
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 q->red=image->colormap[*p++].red;
                 q->green=image->colormap[*p++].green;
@@ -604,10 +604,10 @@
 %
 %  The format of the RegisterRLEImage method is:
 %
-%      unsigned long RegisterRLEImage(void)
+%      size_t RegisterRLEImage(void)
 %
 */
-ModuleExport unsigned long RegisterRLEImage(void)
+ModuleExport size_t RegisterRLEImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/scr.c b/coders/scr.c
index 37d9158..f7dfcae 100644
--- a/coders/scr.c
+++ b/coders/scr.c
@@ -253,10 +253,10 @@
 %
 %  The format of the RegisterSCRImage method is:
 %
-%      unsigned long RegisterSCRImage(void)
+%      size_t RegisterSCRImage(void)
 %
 */
-ModuleExport unsigned long RegisterSCRImage(void)
+ModuleExport size_t RegisterSCRImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/sct.c b/coders/sct.c
index ff8d500..4d74831 100644
--- a/coders/sct.c
+++ b/coders/sct.c
@@ -126,7 +126,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -142,7 +142,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -155,7 +155,7 @@
   unsigned char
     buffer[768];
 
-  unsigned long
+  size_t
     separations,
     separations_mask,
     units;
@@ -227,15 +227,15 @@
   /*
     Convert SCT raster image to pixel packets.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    for (i=0; i < (long) separations; i++)
+    for (i=0; i < (ssize_t) separations; i++)
     {
       q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         pixel=(Quantum) ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
         if (image->colorspace == CMYKColorspace)
@@ -304,10 +304,10 @@
 %
 %  The format of the RegisterSCTImage method is:
 %
-%      unsigned long RegisterSCTImage(void)
+%      size_t RegisterSCTImage(void)
 %
 */
-ModuleExport unsigned long RegisterSCTImage(void)
+ModuleExport size_t RegisterSCTImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/sfw.c b/coders/sfw.c
index 71d1d4e..14de5cf 100644
--- a/coders/sfw.c
+++ b/coders/sfw.c
@@ -122,7 +122,7 @@
 static unsigned char *SFWScan(unsigned char *p,const unsigned char *q,
   const unsigned char *target,const int length)
 {
-  register long
+  register ssize_t
     i;
 
   for ( ; p < q; p++)
@@ -375,10 +375,10 @@
 %
 %  The format of the RegisterSFWImage method is:
 %
-%      unsigned long RegisterSFWImage(void)
+%      size_t RegisterSFWImage(void)
 %
 */
-ModuleExport unsigned long RegisterSFWImage(void)
+ModuleExport size_t RegisterSFWImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/sgi.c b/coders/sgi.c
index 669d3fd..2494f1b 100644
--- a/coders/sgi.c
+++ b/coders/sgi.c
@@ -80,7 +80,7 @@
     rows,
     depth;
 
-  unsigned long
+  size_t
     minimum_value,
     maximum_value,
     sans;
@@ -88,7 +88,7 @@
   char
     name[80];
 
-  unsigned long
+  size_t
     pixel_format;
 
   unsigned char
@@ -170,7 +170,7 @@
 }
 
 static MagickBooleanType SGIDecode(const size_t bytes_per_pixel,
-  long number_packets,unsigned char *packets,long number_pixels,
+  ssize_t number_packets,unsigned char *packets,ssize_t number_pixels,
   unsigned char *pixels)
 {
   register unsigned char
@@ -180,7 +180,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     pixel;
 
   p=packets;
@@ -191,7 +191,7 @@
       {
         if (number_packets-- == 0)
           return(MagickFalse);
-        pixel=(unsigned long) (*p++) << 8;
+        pixel=(size_t) (*p++) << 8;
         pixel|=(*p++);
         count=(ssize_t) (pixel & 0x7f);
         if (count == 0)
@@ -210,7 +210,7 @@
           }
         else
           {
-            pixel=(unsigned long) (*p++) << 8;
+            pixel=(size_t) (*p++) << 8;
             pixel|=(*p++);
             for ( ; count != 0; count--)
             {
@@ -228,7 +228,7 @@
   {
     if (number_packets-- == 0)
       return(MagickFalse);
-    pixel=(unsigned long) (*p++);
+    pixel=(size_t) (*p++);
     count=(ssize_t) (pixel & 0x7f);
     if (count == 0)
       break;
@@ -247,7 +247,7 @@
       {
         if (number_packets-- == 0)
           return(MagickFalse);
-        pixel=(unsigned long) (*p++);
+        pixel=(size_t) (*p++);
         for ( ; count != 0; count--)
         {
           *q=(unsigned char) pixel;
@@ -263,7 +263,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y,
     z;
 
@@ -276,7 +276,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -298,7 +298,7 @@
   unsigned char
     *iris_pixels;
 
-  unsigned long
+  size_t
     quantum;
 
   /*
@@ -360,9 +360,9 @@
     count=ReadBlob(image,sizeof(iris_info.filler),iris_info.filler);
     image->columns=iris_info.columns;
     image->rows=iris_info.rows;
-    image->depth=(unsigned long) MagickMin(iris_info.depth,MAGICKCORE_QUANTUM_DEPTH);
+    image->depth=(size_t) MagickMin(iris_info.depth,MAGICKCORE_QUANTUM_DEPTH);
     if (iris_info.pixel_format == 0)
-      image->depth=(unsigned long) MagickMin((size_t) 8*
+      image->depth=(size_t) MagickMin((size_t) 8*
         iris_info.bytes_per_pixel,MAGICKCORE_QUANTUM_DEPTH);
     if (iris_info.depth < 3)
       {
@@ -396,23 +396,23 @@
           bytes_per_pixel*sizeof(*scanline));
         if (scanline == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (z=0; z < (long) iris_info.depth; z++)
+        for (z=0; z < (ssize_t) iris_info.depth; z++)
         {
           p=iris_pixels+bytes_per_pixel*z;
-          for (y=0; y < (long) iris_info.rows; y++)
+          for (y=0; y < (ssize_t) iris_info.rows; y++)
           {
             count=ReadBlob(image,bytes_per_pixel*iris_info.columns,scanline);
             if (EOFBlob(image) != MagickFalse)
               break;
             if (bytes_per_pixel == 2)
-              for (x=0; x < (long) iris_info.columns; x++)
+              for (x=0; x < (ssize_t) iris_info.columns; x++)
               {
                 *p=scanline[2*x];
                 *(p+1)=scanline[2*x+1];
                 p+=8;
               }
             else
-              for (x=0; x < (long) iris_info.columns; x++)
+              for (x=0; x < (ssize_t) iris_info.columns; x++)
               {
                 *p=scanline[x];
                 p+=4;
@@ -433,7 +433,7 @@
         unsigned int
           data_order;
 
-        unsigned long
+        size_t
           *runlength;
 
         /*
@@ -443,15 +443,15 @@
           iris_info.depth*sizeof(*offsets));
         packets=(unsigned char *) AcquireQuantumMemory((size_t)
           iris_info.columns+10UL,4UL*sizeof(*packets));
-        runlength=(unsigned long *) AcquireQuantumMemory(iris_info.rows,
+        runlength=(size_t *) AcquireQuantumMemory(iris_info.rows,
           iris_info.depth*sizeof(*runlength));
         if ((offsets == (ssize_t *) NULL) ||
             (packets == (unsigned char *) NULL) ||
-            (runlength == (unsigned long *) NULL))
+            (runlength == (size_t *) NULL))
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (i=0; i < (long) (iris_info.rows*iris_info.depth); i++)
+        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)
           offsets[i]=(ssize_t) ReadBlobMSBLong(image);
-        for (i=0; i < (long) (iris_info.rows*iris_info.depth); i++)
+        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)
         {
           runlength[i]=ReadBlobMSBLong(image);
           if (runlength[i] > (4*(size_t) iris_info.columns+10))
@@ -462,8 +462,8 @@
         */
         offset=0;
         data_order=0;
-        for (y=0; ((y < (long) iris_info.rows) && (data_order == 0)); y++)
-          for (z=0; ((z < (long) iris_info.depth) && (data_order == 0)); z++)
+        for (y=0; ((y < (ssize_t) iris_info.rows) && (data_order == 0)); y++)
+          for (z=0; ((z < (ssize_t) iris_info.depth) && (data_order == 0)); z++)
           {
             if (offsets[y+z*iris_info.rows] < offset)
               data_order=1;
@@ -472,22 +472,22 @@
         offset=(ssize_t) TellBlob(image);
         if (data_order == 1)
           {
-            for (z=0; z < (long) iris_info.depth; z++)
+            for (z=0; z < (ssize_t) iris_info.depth; z++)
             {
               p=iris_pixels;
-              for (y=0; y < (long) iris_info.rows; y++)
+              for (y=0; y < (ssize_t) iris_info.rows; y++)
               {
                 if (offset != offsets[y+z*iris_info.rows])
                   {
                     offset=offsets[y+z*iris_info.rows];
-                    offset=(ssize_t) SeekBlob(image,(long) offset,SEEK_SET);
+                    offset=(ssize_t) SeekBlob(image,(ssize_t) offset,SEEK_SET);
                   }
                 count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows],
                   packets);
                 if (EOFBlob(image) != MagickFalse)
                   break;
                 offset+=runlength[y+z*iris_info.rows];
-                status=SGIDecode(bytes_per_pixel,(long)
+                status=SGIDecode(bytes_per_pixel,(ssize_t)
                   (runlength[y+z*iris_info.rows]/bytes_per_pixel),packets,
                   1L*iris_info.columns,p+bytes_per_pixel*z);
                 if (status == MagickFalse)
@@ -503,21 +503,21 @@
            
             position=TellBlob(image);
             p=iris_pixels;
-            for (y=0; y < (long) iris_info.rows; y++)
+            for (y=0; y < (ssize_t) iris_info.rows; y++)
             {
-              for (z=0; z < (long) iris_info.depth; z++)
+              for (z=0; z < (ssize_t) iris_info.depth; z++)
               {
                 if (offset != offsets[y+z*iris_info.rows])
                   {
                     offset=offsets[y+z*iris_info.rows];
-                    offset=(ssize_t) SeekBlob(image,(long) offset,SEEK_SET);
+                    offset=(ssize_t) SeekBlob(image,(ssize_t) offset,SEEK_SET);
                   }
                 count=ReadBlob(image,(size_t) runlength[y+z*iris_info.rows],
                   packets);
                 if (EOFBlob(image) != MagickFalse)
                   break;
                 offset+=runlength[y+z*iris_info.rows];
-                status=SGIDecode(bytes_per_pixel,(long)
+                status=SGIDecode(bytes_per_pixel,(ssize_t)
                   (runlength[y+z*iris_info.rows]/bytes_per_pixel),packets,
                   1L*iris_info.columns,p+bytes_per_pixel*z);
                 if (status == MagickFalse)
@@ -527,7 +527,7 @@
             }
             offset=(ssize_t) SeekBlob(image,position,SEEK_SET);
           }
-        runlength=(unsigned long *) RelinquishMagickMemory(runlength);
+        runlength=(size_t *) RelinquishMagickMemory(runlength);
         packets=(unsigned char *) RelinquishMagickMemory(packets);
         offsets=(ssize_t *) RelinquishMagickMemory(offsets);
       }
@@ -547,13 +547,13 @@
         */
         if (bytes_per_pixel == 2)
           {
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=iris_pixels+(image->rows-y-1)*8*image->columns;
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 q->red=ScaleShortToQuantum((unsigned short)
                   ((*(p+0) << 8) | (*(p+1))));
@@ -579,13 +579,13 @@
             }
           }
         else
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=iris_pixels+(image->rows-y-1)*4*image->columns;
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               q->red=ScaleCharToQuantum(*p);
               q->green=ScaleCharToQuantum(*(p+1));
@@ -618,14 +618,14 @@
         */
         if (bytes_per_pixel == 2)
           {
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=iris_pixels+(image->rows-y-1)*8*image->columns;
               q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=GetAuthenticIndexQueue(image);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 quantum=(*p << 8);
                 quantum|=(*(p+1));
@@ -644,14 +644,14 @@
             }
           }
         else
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=iris_pixels+(image->rows-y-1)*4*image->columns;
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
             indexes=GetAuthenticIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               indexes[x]=(IndexPacket) (*p);
               p+=4;
@@ -724,10 +724,10 @@
 %
 %  The format of the RegisterSGIImage method is:
 %
-%      unsigned long RegisterSGIImage(void)
+%      size_t RegisterSGIImage(void)
 %
 */
-ModuleExport unsigned long RegisterSGIImage(void)
+ModuleExport size_t RegisterSGIImage(void)
 {
   MagickInfo
     *entry;
@@ -853,7 +853,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     y,
     z;
 
@@ -872,7 +872,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -934,7 +934,7 @@
           iris_info.depth=3;
       }
     iris_info.minimum_value=0;
-    iris_info.maximum_value=(unsigned long) (image->depth <= 8 ?
+    iris_info.maximum_value=(size_t) (image->depth <= 8 ?
       1UL*ScaleQuantumToChar((Quantum) QuantumRange) :
       1UL*ScaleQuantumToShort((Quantum) QuantumRange));
     /*
@@ -971,13 +971,13 @@
     /*
       Convert image pixels to uncompressed SGI pixels.
     */
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       if (image->depth <= 8)
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           register unsigned char
             *q;
@@ -991,7 +991,7 @@
           p++;
         }
       else
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           register unsigned short
             *q;
@@ -1018,12 +1018,12 @@
         /*
           Write uncompressed SGI pixels.
         */
-        for (z=0; z < (long) iris_info.depth; z++)
+        for (z=0; z < (ssize_t) iris_info.depth; z++)
         {
-          for (y=0; y < (long) iris_info.rows; y++)
+          for (y=0; y < (ssize_t) iris_info.rows; y++)
           {
             if (image->depth <= 8)
-              for (x=0; x < (long) iris_info.columns; x++)
+              for (x=0; x < (ssize_t) iris_info.columns; x++)
               {
                 register unsigned char
                   *q;
@@ -1033,7 +1033,7 @@
                 (void) WriteBlobByte(image,*q);
               }
             else
-              for (x=0; x < (long) iris_info.columns; x++)
+              for (x=0; x < (ssize_t) iris_info.columns; x++)
               {
                 register unsigned short
                   *q;
@@ -1056,7 +1056,7 @@
           length,
           number_packets;
 
-        unsigned long
+        size_t
           *runlength;
 
         /*
@@ -1066,24 +1066,24 @@
           sizeof(*offsets));
         packets=(unsigned char *) AcquireQuantumMemory((2*(size_t)
           iris_info.columns+10)*image->rows,4*sizeof(*packets));
-        runlength=(unsigned long *) AcquireQuantumMemory(iris_info.rows,
+        runlength=(size_t *) AcquireQuantumMemory(iris_info.rows,
           iris_info.depth*sizeof(*runlength));
         if ((offsets == (ssize_t *) NULL) ||
             (packets == (unsigned char *) NULL) ||
-            (runlength == (unsigned long *) NULL))
+            (runlength == (size_t *) NULL))
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
         offset=512+4*2*((ssize_t) iris_info.rows*iris_info.depth);
         number_packets=0;
         q=iris_pixels;
-        for (y=0; y < (long) iris_info.rows; y++)
+        for (y=0; y < (ssize_t) iris_info.rows; y++)
         {
-          for (z=0; z < (long) iris_info.depth; z++)
+          for (z=0; z < (ssize_t) iris_info.depth; z++)
           {
             length=SGIEncode(q+z,(size_t) iris_info.columns,packets+
               number_packets);
             number_packets+=length;
             offsets[y+z*iris_info.rows]=offset;
-            runlength[y+z*iris_info.rows]=(unsigned long) length;
+            runlength[y+z*iris_info.rows]=(size_t) length;
             offset+=(ssize_t) length;
           }
           q+=(iris_info.columns*4);
@@ -1091,15 +1091,15 @@
         /*
           Write out line start and length tables and runlength-encoded pixels.
         */
-        for (i=0; i < (long) (iris_info.rows*iris_info.depth); i++)
-          (void) WriteBlobMSBLong(image,(unsigned long) offsets[i]);
-        for (i=0; i < (long) (iris_info.rows*iris_info.depth); i++)
+        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)
+          (void) WriteBlobMSBLong(image,(size_t) offsets[i]);
+        for (i=0; i < (ssize_t) (iris_info.rows*iris_info.depth); i++)
           (void) WriteBlobMSBLong(image,runlength[i]);
         (void) WriteBlob(image,number_packets,packets);
         /*
           Relinquish resources.
         */
-        runlength=(unsigned long *) RelinquishMagickMemory(runlength);
+        runlength=(size_t *) RelinquishMagickMemory(runlength);
         packets=(unsigned char *) RelinquishMagickMemory(packets);
         offsets=(ssize_t *) RelinquishMagickMemory(offsets);
         break;
diff --git a/coders/stegano.c b/coders/stegano.c
index 6780d46..e87e535 100644
--- a/coders/stegano.c
+++ b/coders/stegano.c
@@ -87,8 +87,8 @@
 %
 */
 
-static inline unsigned long MagickMin(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMin(const size_t x,
+  const size_t y)
 {
   if (x < y)
     return(x);
@@ -98,11 +98,11 @@
 static Image *ReadSTEGANOImage(const ImageInfo *image_info,
   ExceptionInfo *exception)
 {
-#define GetBit(alpha,i) MagickMin((((unsigned long) (alpha) >> (unsigned long) \
+#define GetBit(alpha,i) MagickMin((((size_t) (alpha) >> (size_t) \
   (i)) & 0x01),16)
 #define SetBit(alpha,i,set) (alpha)=(IndexPacket) ((set) != 0 ? \
-  (unsigned long) (alpha) | (1UL << (unsigned long) (i)) : (unsigned long) \
-  (alpha) & ~(1UL << (unsigned long) (i)))
+  (size_t) (alpha) | (1UL << (size_t) (i)) : (size_t) \
+  (alpha) & ~(1UL << (size_t) (i)))
 
   Image
     *image,
@@ -111,7 +111,7 @@
   ImageInfo
     *read_info;
 
-  long
+  ssize_t
     c,
     i,
     j,
@@ -127,13 +127,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  unsigned long
+  size_t
     depth;
 
   /*
@@ -172,17 +172,17 @@
   j=0;
   i=MAGICKCORE_QUANTUM_DEPTH-1;
   depth=MAGICKCORE_QUANTUM_DEPTH;
-  for (k=image->offset; (i >= 0) && (j < (long) depth); i--)
+  for (k=image->offset; (i >= 0) && (j < (ssize_t) depth); i--)
   {
-    for (y=0; (y < (long) image->rows) && (j < (long) depth); y++)
+    for (y=0; (y < (ssize_t) image->rows) && (j < (ssize_t) depth); y++)
     {
       x=0;
-      for (; (x < (long) image->columns) && (j < (long) depth); x++)
+      for (; (x < (ssize_t) image->columns) && (j < (ssize_t) depth); x++)
       {
-        if ((k/(long) watermark->columns) >= (long) watermark->rows)
+        if ((k/(ssize_t) watermark->columns) >= (ssize_t) watermark->rows)
           break;
-        (void) GetOneVirtualPixel(watermark,k % (long) watermark->columns,
-          k/(long) watermark->columns,&pixel,exception);
+        (void) GetOneVirtualPixel(watermark,k % (ssize_t) watermark->columns,
+          k/(ssize_t) watermark->columns,&pixel,exception);
         q=GetAuthenticPixels(image,x,y,1,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
@@ -211,7 +211,7 @@
         if (c == 3)
           c=0;
         k++;
-        if (k == (long) (watermark->columns*watermark->columns))
+        if (k == (ssize_t) (watermark->columns*watermark->columns))
           k=0;
         if (k == image->offset)
           j++;
@@ -246,10 +246,10 @@
 %
 %  The format of the RegisterSTEGANOImage method is:
 %
-%      unsigned long RegisterSTEGANOImage(void)
+%      size_t RegisterSTEGANOImage(void)
 %
 */
-ModuleExport unsigned long RegisterSTEGANOImage(void)
+ModuleExport size_t RegisterSTEGANOImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/sun.c b/coders/sun.c
index 0b51e4a..0cf90f0 100644
--- a/coders/sun.c
+++ b/coders/sun.c
@@ -232,7 +232,7 @@
   int
     bit;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -244,13 +244,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -352,13 +352,13 @@
         if (sun_colormap == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         count=ReadBlob(image,image->colors,sun_colormap);
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].red=ScaleCharToQuantum(sun_colormap[i]);
         count=ReadBlob(image,image->colors,sun_colormap);
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].green=ScaleCharToQuantum(sun_colormap[i]);
         count=ReadBlob(image,image->colors,sun_colormap);
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
           image->colormap[i].blue=ScaleCharToQuantum(sun_colormap[i]);
         sun_colormap=(unsigned char *) RelinquishMagickMemory(sun_colormap);
         break;
@@ -408,7 +408,7 @@
     bytes_per_line=0;
     if (sun_info.type == RT_ENCODED)
       {
-        unsigned long
+        size_t
           height;
 
         /*
@@ -437,13 +437,13 @@
     */
     p=sun_pixels;
     if (sun_info.depth == 1)
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        for (x=0; x < ((ssize_t) image->columns-7); x+=8)
         {
           for (bit=7; bit >= 0; bit--)
             indexes[x+7-bit]=(IndexPacket) ((*p) & (0x01 << bit) ? 0x00 : 0x01);
@@ -451,7 +451,7 @@
         }
         if ((image->columns % 8) != 0)
           {
-            for (bit=7; bit >= (long) (8-(image->columns % 8)); bit--)
+            for (bit=7; bit >= (ssize_t) (8-(image->columns % 8)); bit--)
               indexes[x+7-bit]=(IndexPacket)
                 ((*p) & (0x01 << bit) ? 0x00 : 0x01);
             p++;
@@ -475,13 +475,13 @@
                (length > (bytes_per_line*image->rows))) ||
               ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
             indexes=GetAuthenticIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
               indexes[x]=(IndexPacket) (*p++);
             if ((image->columns % 2) != 0)
               p++;
@@ -509,12 +509,12 @@
                (length > (bytes_per_line*image->rows))) ||
               ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (image->matte != MagickFalse)
                 q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*p++));
@@ -532,9 +532,9 @@
                 }
               if (image->colors != 0)
                 {
-                  q->red=image->colormap[(long) q->red].red;
-                  q->green=image->colormap[(long) q->green].green;
-                  q->blue=image->colormap[(long) q->blue].blue;
+                  q->red=image->colormap[(ssize_t) q->red].red;
+                  q->green=image->colormap[(ssize_t) q->green].green;
+                  q->blue=image->colormap[(ssize_t) q->blue].blue;
                 }
               q++;
             }
@@ -608,10 +608,10 @@
 %
 %  The format of the RegisterSUNImage method is:
 %
-%      unsigned long RegisterSUNImage(void)
+%      size_t RegisterSUNImage(void)
 %
 */
-ModuleExport unsigned long RegisterSUNImage(void)
+ModuleExport size_t RegisterSUNImage(void)
 {
   MagickInfo
     *entry;
@@ -702,7 +702,7 @@
       maplength;
   } SUNInfo;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -720,10 +720,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   SUNInfo
@@ -835,13 +835,13 @@
         /*
           Convert DirectClass packet to SUN RGB pixel.
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           q=pixels;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             if (image->matte != MagickFalse)
               *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
@@ -873,7 +873,7 @@
             Convert PseudoClass image to a SUN monochrome image.
           */
           (void) SetImageType(image,BilevelType);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
@@ -881,7 +881,7 @@
             indexes=GetVirtualIndexQueue(image);
             bit=0;
             byte=0;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               byte<<=1;
               if (PixelIntensity(p) < (MagickRealType) (QuantumRange/2.0))
@@ -913,25 +913,25 @@
           /*
             Dump colormap to file.
           */
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             (void) WriteBlobByte(image,
               ScaleQuantumToChar(image->colormap[i].red));
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             (void) WriteBlobByte(image,
               ScaleQuantumToChar(image->colormap[i].green));
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             (void) WriteBlobByte(image,
               ScaleQuantumToChar(image->colormap[i].blue));
           /*
             Convert PseudoClass packet to SUN colormapped pixel.
           */
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
               break;
             indexes=GetVirtualIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               (void) WriteBlobByte(image,(unsigned char) indexes[x]);
               p++;
diff --git a/coders/svg.c b/coders/svg.c
index 385ff0d..c526026 100644
--- a/coders/svg.c
+++ b/coders/svg.c
@@ -141,7 +141,7 @@
   AffineMatrix
     affine;
 
-  unsigned long
+  size_t
     width,
     height;
 
@@ -375,7 +375,7 @@
     *text,
     **tokens;
 
-  register long
+  register ssize_t
     i;
 
   SVGInfo
@@ -406,7 +406,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i;
 
   SVGInfo
@@ -792,7 +792,7 @@
   SVGInfo
     *svg_info;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -2114,8 +2114,8 @@
           if ((svg_info->view_box.width == 0.0) ||
               (svg_info->view_box.height == 0.0))
             svg_info->view_box=svg_info->bounds;
-          svg_info->width=(unsigned long) floor(svg_info->bounds.width+0.5);
-          svg_info->height=(unsigned long) floor(svg_info->bounds.height+0.5);
+          svg_info->width=(size_t) floor(svg_info->bounds.width+0.5);
+          svg_info->height=(size_t) floor(svg_info->bounds.height+0.5);
           MVGPrintf(svg_info->file,"viewbox 0 0 %lu %lu\n",svg_info->width,
             svg_info->height);
           sx=(double) svg_info->width/svg_info->view_box.width;
@@ -2401,7 +2401,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   SVGInfo
@@ -2411,7 +2411,7 @@
     Receiving some characters from the parser.
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-    "  SAX.characters(%s,%lu)",c,(unsigned long) length);
+    "  SAX.characters(%s,%lu)",c,(size_t) length);
   svg_info=(SVGInfo *) context;
   if (svg_info->text != (char *) NULL)
     svg_info->text=(char *) ResizeQuantumMemory(svg_info->text,
@@ -2426,7 +2426,7 @@
   if (svg_info->text == (char *) NULL)
     return;
   p=svg_info->text+strlen(svg_info->text);
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
     *p++=c[i];
   *p='\0';
 }
@@ -2687,7 +2687,7 @@
     status,
     unique_file;
 
-  long
+  ssize_t
     n;
 
   SVGInfo
@@ -2750,13 +2750,13 @@
       GError
         *error;
 
-      long
+      ssize_t
         y;
 
       PixelPacket
         fill_color;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -2843,12 +2843,12 @@
 #else
           p=gdk_pixbuf_get_pixels(pixel_info);
 #endif
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
 #if defined(MAGICKCORE_CAIRO_DELEGATE)
               fill_color.blue=ScaleCharToQuantum(*p++);
@@ -3042,10 +3042,10 @@
 %
 %  The format of the RegisterSVGImage method is:
 %
-%      unsigned long RegisterSVGImage(void)
+%      size_t RegisterSVGImage(void)
 %
 */
-ModuleExport unsigned long RegisterSVGImage(void)
+ModuleExport size_t RegisterSVGImage(void)
 {
   char
     version[MaxTextExtent];
@@ -3220,7 +3220,7 @@
   char
     *p;
 
-  long
+  ssize_t
     value;
 
   value=strtol(point,&p,10);
@@ -3229,13 +3229,13 @@
 
 static MagickBooleanType TraceSVGImage(Image *image)
 {
-  long
+  ssize_t
     y;
 
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
 #if defined(MAGICKCORE_AUTOTRACE_DELEGATE)
@@ -3255,10 +3255,10 @@
     ImageType
       type;
 
-    register long
+    register ssize_t
       i;
 
-    unsigned long
+    size_t
       number_planes;
 
     /*
@@ -3272,12 +3272,12 @@
       number_planes=1;
     trace=at_bitmap_new(image->columns,image->rows,number_planes);
     i=0;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         trace->bitmap[i++]=GetRedPixelComponent(p);
         if (number_planes == 3)
@@ -3322,13 +3322,13 @@
       "<svg width=\"%lu\" height=\"%lu\">\n",image->columns,image->rows);
     (void) WriteBlobString(image,message);
     GetMagickPixelPacket(image,&pixel);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetVirtualIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         SetMagickPixelPacket(image,p,indexes+x,&pixel);
         (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
@@ -3367,7 +3367,7 @@
   int
     n;
 
-  long
+  ssize_t
     j;
 
   MagickBooleanType
@@ -3383,10 +3383,10 @@
   PrimitiveType
     primitive_type;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -3395,7 +3395,7 @@
   SVGInfo
     svg_info;
 
-  unsigned long
+  size_t
     number_points;
 
   /*
@@ -3993,7 +3993,7 @@
           {
             if (IsPoint(q))
               {
-                long
+                ssize_t
                   k;
 
                 p=q;
@@ -4158,7 +4158,7 @@
       primitive_info[i].coordinates=0;
       primitive_info[i].method=FloodfillMethod;
       i++;
-      if (i < (long) (number_points-6*BezierQuantum-360))
+      if (i < (ssize_t) (number_points-6*BezierQuantum-360))
         continue;
       number_points+=6*BezierQuantum+360;
       primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
@@ -4354,7 +4354,7 @@
         for (p=token; *p != '\0'; p++)
           if (isalpha((int) *p))
             number_attributes++;
-        if (i > (long) (number_points-6*BezierQuantum*number_attributes-1))
+        if (i > (ssize_t) (number_points-6*BezierQuantum*number_attributes-1))
           {
             number_points+=6*BezierQuantum*number_attributes;
             primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
diff --git a/coders/tga.c b/coders/tga.c
index 9eefab9..bbacc4a 100644
--- a/coders/tga.c
+++ b/coders/tga.c
@@ -134,7 +134,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -146,7 +146,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -164,7 +164,7 @@
     k,
     runlength;
 
-  unsigned long
+  size_t
     base,
     flag,
     offset,
@@ -226,12 +226,12 @@
     image->matte=tga_info.bits_per_pixel == 32 ? MagickTrue : MagickFalse;
     if ((tga_info.image_type != TGAColormap) &&
         (tga_info.image_type != TGARLEColormap))
-      image->depth=(unsigned long) ((tga_info.bits_per_pixel <= 8) ? 8 :
+      image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :
         (tga_info.bits_per_pixel <= 16) ? 5 :
         (tga_info.bits_per_pixel == 24) ? 8 :
         (tga_info.bits_per_pixel == 32) ? 8 : 8);
     else
-      image->depth=(unsigned long) ((tga_info.colormap_size <= 8) ? 8 :
+      image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :
         (tga_info.colormap_size <= 16) ? 5 :
         (tga_info.colormap_size == 24) ? 8 :
         (tga_info.colormap_size == 32) ? 8 : 8);
@@ -287,7 +287,7 @@
         */
         if (AcquireImageColormap(image,image->colors) == MagickFalse)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           switch (tga_info.colormap_size)
           {
@@ -351,16 +351,16 @@
     index=(IndexPacket) 0;
     runlength=0;
     offset=0;
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       real=offset;
       if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0)
         real=image->rows-real-1;
-      q=QueueAuthenticPixels(image,0,(long) real,image->columns,1,exception);
+      q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if ((tga_info.image_type == TGARLEColormap) ||
             (tga_info.image_type == TGARLERGB) ||
@@ -394,7 +394,7 @@
               */
               index=(IndexPacket) ReadBlobByte(image);
               if (tga_info.colormap_type != 0)
-                pixel=image->colormap[(long) ConstrainColormapIndex(image,
+                pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image,
                   1UL*index)];
               else
                 {
@@ -424,7 +424,7 @@
                 pixel.opacity=(k & 0x80) != 0 ? (Quantum) OpaqueOpacity :
                   (Quantum) TransparentOpacity; 
               if (image->storage_class == PseudoClass)
-                index=ConstrainColormapIndex(image,((unsigned long) k << 8)+j);
+                index=ConstrainColormapIndex(image,((size_t) k << 8)+j);
               break;
             }
             case 24:
@@ -539,10 +539,10 @@
 %
 %  The format of the RegisterTGAImage method is:
 %
-%      unsigned long RegisterTGAImage(void)
+%      size_t RegisterTGAImage(void)
 %
 */
-ModuleExport unsigned long RegisterTGAImage(void)
+ModuleExport size_t RegisterTGAImage(void)
 {
   MagickInfo
     *entry;
@@ -671,7 +671,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -686,10 +686,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -801,7 +801,7 @@
         if (targa_colormap == (unsigned char *) NULL)
           ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
         q=targa_colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           *q++=ScaleQuantumToChar(image->colormap[i].blue);
           *q++=ScaleQuantumToChar(image->colormap[i].green);
@@ -819,14 +819,14 @@
       sizeof(*targa_pixels));
     if (targa_pixels == (unsigned char *) NULL)
       ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
-    for (y=(long) (image->rows-1); y >= 0; y--)
+    for (y=(ssize_t) (image->rows-1); y >= 0; y--)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       q=targa_pixels;
       indexes=GetVirtualIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if (targa_info.image_type == TargaColormap)
           *q++=(unsigned char) indexes[x];
diff --git a/coders/thumbnail.c b/coders/thumbnail.c
index ae65a98..cb22bb6 100644
--- a/coders/thumbnail.c
+++ b/coders/thumbnail.c
@@ -83,10 +83,10 @@
 %
 %  The format of the RegisterTHUMBNAILImage method is:
 %
-%      unsigned long RegisterTHUMBNAILImage(void)
+%      size_t RegisterTHUMBNAILImage(void)
 %
 */
-ModuleExport unsigned long RegisterTHUMBNAILImage(void)
+ModuleExport size_t RegisterTHUMBNAILImage(void)
 {
   MagickInfo
     *entry;
@@ -166,7 +166,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -190,7 +190,7 @@
     ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail");
   length=(size_t) StringToLong(property);
   (void) ResetMagickMemory(magick,0,sizeof(magick));
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     magick[0]=magick[1];
     magick[1]=magick[2];
diff --git a/coders/tiff.c b/coders/tiff.c
index 02dcafe..eabf2e2 100644
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -341,25 +341,25 @@
   length=fwrite("\006\001\003\000\001\000\000\000\000\000\000\000",1,12,file);
   length=fwrite("\021\001\003\000\001\000\000\000",1,8,file);
   strip_offset=10+(12*14)+4+8;
-  length=WriteLSBLong(file,(unsigned long) strip_offset);
+  length=WriteLSBLong(file,(size_t) strip_offset);
   length=fwrite("\022\001\003\000\001\000\000\000",1,8,file);
-  length=WriteLSBLong(file,(unsigned long) image_info->orientation);
+  length=WriteLSBLong(file,(size_t) image_info->orientation);
   length=fwrite("\025\001\003\000\001\000\000\000\001\000\000\000",1,12,file);
   length=fwrite("\026\001\004\000\001\000\000\000",1,8,file);
   length=WriteLSBLong(file,image->rows);
   length=fwrite("\027\001\004\000\001\000\000\000\000\000\000\000",1,12,file);
   offset=(ssize_t) ftell(file)-4;
   length=fwrite("\032\001\005\000\001\000\000\000",1,8,file);
-  length=WriteLSBLong(file,(unsigned long) (strip_offset-8));
+  length=WriteLSBLong(file,(size_t) (strip_offset-8));
   length=fwrite("\033\001\005\000\001\000\000\000",1,8,file);
-  length=WriteLSBLong(file,(unsigned long) (strip_offset-8));
+  length=WriteLSBLong(file,(size_t) (strip_offset-8));
   length=fwrite("\050\001\003\000\001\000\000\000\002\000\000\000",1,12,file);
   length=fwrite("\000\000\000\000",1,4,file);
   length=WriteLSBLong(file,image->x_resolution);
   length=WriteLSBLong(file,1);
   for (length=0; (c=ReadBlobByte(image)) != EOF; length++)
     (void) fputc(c,file);
-  offset=(ssize_t) fseek(file,(long) offset,SEEK_SET);
+  offset=(ssize_t) fseek(file,(ssize_t) offset,SEEK_SET);
   length=WriteLSBLong(file,(unsigned int) length);
   (void) fclose(file);
   (void) CloseBlob(image);
@@ -421,7 +421,7 @@
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -429,12 +429,12 @@
 }
 
 static MagickBooleanType ReadProfile(Image *image,const char *name,
-  unsigned char *datum,long length)
+  unsigned char *datum,ssize_t length)
 {
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   StringInfo
@@ -506,30 +506,30 @@
 #if defined(TIFFTAG_ICCPROFILE)
   length=0;
   if (TIFFGetField(tiff,TIFFTAG_ICCPROFILE,&length,&profile) == 1)
-    (void) ReadProfile(image,"icc",profile,(long) length);
+    (void) ReadProfile(image,"icc",profile,(ssize_t) length);
 #endif
 #if defined(TIFFTAG_PHOTOSHOP)
   length=0;
   if (TIFFGetField(tiff,TIFFTAG_PHOTOSHOP,&length,&profile) == 1)
-    (void) ReadProfile(image,"8bim",profile,(long) length);
+    (void) ReadProfile(image,"8bim",profile,(ssize_t) length);
 #endif
 #if defined(TIFFTAG_RICHTIFFIPTC)
   length=0;
   if (TIFFGetField(tiff,TIFFTAG_RICHTIFFIPTC,&length,&profile) == 1)
     {
       if (TIFFIsByteSwapped(tiff) != 0)
-        TIFFSwabArrayOfLong((uint32 *) profile,(unsigned long) length);
+        TIFFSwabArrayOfLong((uint32 *) profile,(size_t) length);
       (void) ReadProfile(image,"iptc",profile,4L*length);
     }
 #endif
 #if defined(TIFFTAG_XMLPACKET)
   length=0;
   if (TIFFGetField(tiff,TIFFTAG_XMLPACKET,&length,&profile) == 1)
-    (void) ReadProfile(image,"xmp",profile,(long) length);
+    (void) ReadProfile(image,"xmp",profile,(ssize_t) length);
 #endif
   length=0;
   if (TIFFGetField(tiff,37724,&length,&profile) == 1)
-    (void) ReadProfile(image,"tiff:37724",profile,(long) length);
+    (void) ReadProfile(image,"tiff:37724",profile,(ssize_t) length);
 }
 
 static void TIFFGetProperties(TIFF *tiff,Image *image)
@@ -565,7 +565,7 @@
   char
     value[MaxTextExtent];
 
-  register long
+  register ssize_t
     i;
 
   tdir_t
@@ -608,10 +608,10 @@
       case TIFF_LONG:
       {
         uint32
-          longy;
+          ssize_ty;
 
-        if (TIFFGetField(tiff,exif_info[i].tag,&longy) != 0)
-          (void) FormatMagickString(value,MaxTextExtent,"%d",longy);
+        if (TIFFGetField(tiff,exif_info[i].tag,&ssize_ty) != 0)
+          (void) FormatMagickString(value,MaxTextExtent,"%d",ssize_ty);
         break;
       }
       case TIFF_RATIONAL:
@@ -657,8 +657,8 @@
   return(count);
 }
 
-static int32 TIFFReadPixels(TIFF *tiff,unsigned long bits_per_sample,
-  tsample_t sample,long row,tdata_t scanline)
+static int32 TIFFReadPixels(TIFF *tiff,size_t bits_per_sample,
+  tsample_t sample,ssize_t row,tdata_t scanline)
 {
   int32
     status;
@@ -745,7 +745,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -762,7 +762,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -804,7 +804,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     lsb_first;
 
   /*
@@ -843,7 +843,7 @@
       /*
         Generate blank images for subimage specification (e.g. image.tif[4].
       */
-      for (i=0; i < (long) image_info->scene; i++)
+      for (i=0; i < (ssize_t) image_info->scene; i++)
       {
         (void) TIFFReadDirectory(tiff);
         AcquireNextImage(image_info,image);
@@ -923,9 +923,9 @@
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Photometric "
           "interpretation: %s",GetImageProperty(image,"tiff:photometric"));
       }
-    image->columns=(unsigned long) width;
-    image->rows=(unsigned long) height;
-    image->depth=(unsigned long) bits_per_sample;
+    image->columns=(size_t) width;
+    image->rows=(size_t) height;
+    image->depth=(size_t) bits_per_sample;
     if (image->debug != MagickFalse)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image depth: %lu",
         image->depth);
@@ -950,8 +950,8 @@
     y_position=(float) image->page.y/y_resolution;
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position);
     (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position);
-    image->page.x=(long) ceil(x_position*x_resolution-0.5);
-    image->page.y=(long) ceil(y_position*y_resolution-0.5);
+    image->page.x=(ssize_t) ceil(x_position*x_resolution-0.5);
+    image->page.y=(ssize_t) ceil(y_position*y_resolution-0.5);
     image->orientation=(OrientationType) orientation;
     chromaticity=(float *) NULL;
     (void) TIFFGetField(tiff,TIFFTAG_WHITEPOINT,&chromaticity);
@@ -1088,10 +1088,10 @@
     if ((photometric == PHOTOMETRIC_PALETTE) &&
         (pow(2.0,1.0*bits_per_sample) <= MaxColormapSize))
       {
-        unsigned long
+        size_t
           colors;
 
-        colors=(unsigned long) GetQuantumRange(bits_per_sample)+1;
+        colors=(size_t) GetQuantumRange(bits_per_sample)+1;
         if (AcquireImageColormap(image,colors) == MagickFalse)
           {
             TIFFClose(tiff);
@@ -1153,7 +1153,7 @@
         if ((image->storage_class == PseudoClass) &&
             (photometric == PHOTOMETRIC_PALETTE))
           {
-            unsigned long
+            size_t
               range;
 
             uint16
@@ -1167,14 +1167,14 @@
             (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
               &green_colormap,&blue_colormap);
             range=255;  /* might be old style 8-bit colormap */
-            for (i=0; i < (long) image->colors; i++)
+            for (i=0; i < (ssize_t) image->colors; i++)
               if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) ||
                   (blue_colormap[i] >= 256))
                 {
                   range=65535;
                   break;
                 }
-            for (i=0; i < (long) image->colors; i++)
+            for (i=0; i < (ssize_t) image->colors; i++)
             {
               image->colormap[i].red=ClampToQuantum(((double) QuantumRange*
                 red_colormap[i])/range);
@@ -1213,7 +1213,7 @@
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
           }
         pixels=GetQuantumPixels(quantum_info);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           int
             status;
@@ -1269,7 +1269,7 @@
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
           }
         pixels=GetQuantumPixels(quantum_info);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           int
             status;
@@ -1301,9 +1301,9 @@
         /*
           Convert TIFF image to DirectClass MIFF image.
         */
-        for (i=0; i < (long) samples_per_pixel; i++)
+        for (i=0; i < (ssize_t) samples_per_pixel; i++)
         {
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register PixelPacket
               *restrict q;
@@ -1361,9 +1361,9 @@
         */
         i=0;
         p=(unsigned char *) NULL;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -1376,11 +1376,11 @@
             {
               if (TIFFReadRGBAStrip(tiff,(tstrip_t) y,(uint32 *) pixels) == 0)
                 break;
-              i=(long) MagickMin((long) rows_per_strip,(long) image->rows-y);
+              i=(ssize_t) MagickMin((ssize_t) rows_per_strip,(ssize_t) image->rows-y);
             }
           i--;
           p=pixels+image->columns*i;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum((unsigned char) (TIFFGetR(*p)));
             q->green=ScaleCharToQuantum((unsigned char) (TIFFGetG(*p)));
@@ -1411,7 +1411,7 @@
           columns,
           rows;
 
-        unsigned long
+        size_t
           number_pixels;
 
         /*
@@ -1432,38 +1432,38 @@
             TIFFClose(tiff);
             ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
           }
-        for (y=0; y < (long) image->rows; y+=rows)
+        for (y=0; y < (ssize_t) image->rows; y+=rows)
         {
           PixelPacket
             *tile;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
             *restrict q;
 
-          unsigned long
+          size_t
             columns_remaining,
             rows_remaining;
 
           rows_remaining=image->rows-y;
-          if ((long) (y+rows) < (long) image->rows)
+          if ((ssize_t) (y+rows) < (ssize_t) image->rows)
             rows_remaining=rows;
           tile=QueueAuthenticPixels(image,0,y,image->columns,rows_remaining,
             exception);
           if (tile == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x+=columns)
+          for (x=0; x < (ssize_t) image->columns; x+=columns)
           {
-            unsigned long
+            size_t
               column,
               row;
 
             if (TIFFReadRGBATile(tiff,(uint32) x,(uint32) y,tile_pixels) == 0)
               break;
             columns_remaining=image->columns-x;
-            if ((long) (x+columns) < (long) image->columns)
+            if ((ssize_t) (x+columns) < (ssize_t) image->columns)
               columns_remaining=columns;
             p=tile_pixels+(rows-rows_remaining)*columns;
             q=tile+(image->columns*(rows_remaining-1)+x);
@@ -1537,9 +1537,9 @@
           Convert image to DirectClass pixel packets.
         */
         p=pixels+number_pixels-1;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -1549,7 +1549,7 @@
           if (q == (PixelPacket *) NULL)
             break;
           q+=image->columns-1;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum((unsigned char) TIFFGetR(*p));
             q->green=ScaleCharToQuantum((unsigned char) TIFFGetG(*p));
@@ -1648,10 +1648,10 @@
 %
 %  The format of the RegisterTIFFImage method is:
 %
-%      unsigned long RegisterTIFFImage(void)
+%      size_t RegisterTIFFImage(void)
 %
 */
-ModuleExport unsigned long RegisterTIFFImage(void)
+ModuleExport size_t RegisterTIFFImage(void)
 {
 #define TIFFDescription  "Tagged Image File Format"
 
@@ -1680,7 +1680,7 @@
     const char
       *p;
 
-    register long int
+    register ssize_t
       i;
 
     p=TIFFGetVersion();
@@ -1843,7 +1843,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -1929,7 +1929,7 @@
       return(MagickFalse);
     }
   strip_size=byte_count[0];
-  for (i=1; i < (long) TIFFNumberOfStrips(tiff); i++)
+  for (i=1; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
     if (byte_count[i] > strip_size)
       strip_size=byte_count[i];
   buffer=(unsigned char *) AcquireQuantumMemory((size_t) strip_size,
@@ -1946,7 +1946,7 @@
   /*
     Compress runlength encoded to 2D Huffman pixels.
   */
-  for (i=0; i < (long) TIFFNumberOfStrips(tiff); i++)
+  for (i=0; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
   {
     count=(ssize_t) TIFFReadRawStrip(tiff,(uint32) i,buffer,strip_size);
     if (WriteBlob(image,(size_t) count,buffer) != count)
@@ -2003,7 +2003,7 @@
   MagickBooleanType
     status;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -2122,26 +2122,26 @@
   return(MagickTrue);
 }
 
-static int32 TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,long row,
+static int32 TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,
   tsample_t sample,Image *image)
 {
   int32
     status;
 
-  long
+  ssize_t
     bytes_per_pixel,
     j,
     k,
     l;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
     *p,
     *q;
 
-  unsigned long
+  size_t
     number_tiles,
     tile_width;
 
@@ -2150,26 +2150,26 @@
   /*
     Fill scanlines to tile height.
   */
-  i=(long) (row % tiff_info->tile_geometry.height)*TIFFScanlineSize(tiff);
+  i=(ssize_t) (row % tiff_info->tile_geometry.height)*TIFFScanlineSize(tiff);
   (void) CopyMagickMemory(tiff_info->scanlines+i,(char *) tiff_info->scanline,
     (size_t) TIFFScanlineSize(tiff));
-  if (((unsigned long) (row % tiff_info->tile_geometry.height) !=
-      (tiff_info->tile_geometry.height-1)) && (row != (long) (image->rows-1)))
+  if (((size_t) (row % tiff_info->tile_geometry.height) !=
+      (tiff_info->tile_geometry.height-1)) && (row != (ssize_t) (image->rows-1)))
     return(0);
   /*
     Write tile to TIFF image.
   */
   status=0;
-  bytes_per_pixel=TIFFTileSize(tiff)/(long) (tiff_info->tile_geometry.height*
+  bytes_per_pixel=TIFFTileSize(tiff)/(ssize_t) (tiff_info->tile_geometry.height*
     tiff_info->tile_geometry.width);
   number_tiles=(image->columns+tiff_info->tile_geometry.width)/
     tiff_info->tile_geometry.width;
-  for (i=0; i < (long) number_tiles; i++)
+  for (i=0; i < (ssize_t) number_tiles; i++)
   {
-    tile_width=(i == (long) (number_tiles-1)) ? image->columns-(i*
+    tile_width=(i == (ssize_t) (number_tiles-1)) ? image->columns-(i*
       tiff_info->tile_geometry.width) : tiff_info->tile_geometry.width;
-    for (j=0; j < (long) ((row % tiff_info->tile_geometry.height)+1); j++)
-      for (k=0; k < (long) tile_width; k++)
+    for (j=0; j < (ssize_t) ((row % tiff_info->tile_geometry.height)+1); j++)
+      for (k=0; k < (ssize_t) tile_width; k++)
       {
         if (bytes_per_pixel == 0)
           {
@@ -2234,7 +2234,7 @@
         SetStringInfoLength(iptc_profile,length);
         if (TIFFIsByteSwapped(tiff))
           TIFFSwabArrayOfLong((uint32 *) GetStringInfoDatum(iptc_profile),
-            (unsigned long) (length/4));
+            (size_t) (length/4));
         (void) TIFFSetField(tiff,TIFFTAG_RICHTIFFIPTC,(uint32)
           GetStringInfoLength(iptc_profile)/4,GetStringInfoDatum(iptc_profile));
         iptc_profile=DestroyStringInfo(iptc_profile);
@@ -2272,7 +2272,7 @@
   if (value != (const char *) NULL)
     (void) TIFFSetField(tiff,TIFFTAG_MODEL,value);
   (void) TIFFSetField(tiff,TIFFTAG_SOFTWARE,
-    GetMagickVersion((unsigned long *) NULL));
+    GetMagickVersion((size_t *) NULL));
   (void) TIFFSetField(tiff,TIFFTAG_DOCUMENTNAME,image->filename);
   value=GetImageProperty(image,"tiff:copyright");
   if (value != (const char *) NULL)
@@ -2297,7 +2297,7 @@
   const char
     *value;
 
-  register long
+  register ssize_t
     i;
 
   uint32
@@ -2332,10 +2332,10 @@
       case TIFF_LONG:
       {
         uint16
-          longy;
+          ssize_ty;
 
-        longy=(uint16) StringToLong(value);
-        (void) TIFFSetField(tiff,exif_info[i].tag,longy);
+        ssize_ty=(uint16) StringToLong(value);
+        (void) TIFFSetField(tiff,exif_info[i].tag,ssize_ty);
         break;
       }
       case TIFF_RATIONAL:
@@ -2373,7 +2373,7 @@
   CompressionType
     compression;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2389,7 +2389,7 @@
   QuantumType
     quantum_type;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2417,7 +2417,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     lsb_first;
 
   /*
@@ -2538,7 +2538,7 @@
       {
         (void) ThrowMagickException(&image->exception,GetMagickModule(),
           CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
-          MagickCompressOptions,(long) compression));
+          MagickCompressOptions,(ssize_t) compression));
         compress_tag=COMPRESSION_NONE;
         compression=NoCompression;
       }
@@ -2567,7 +2567,7 @@
         {
           (void) ThrowMagickException(&image->exception,GetMagickModule(),
             CoderError,"CompressionNotSupported","`%s'",MagickOptionToMnemonic(
-              MagickCompressOptions,(long) compression));
+              MagickCompressOptions,(ssize_t) compression));
           compress_tag=COMPRESSION_NONE;
           compression=NoCompression;
           break;
@@ -2640,7 +2640,7 @@
             else
               if (image->storage_class == PseudoClass)
                 {
-                  unsigned long
+                  size_t
                     depth;
 
                   /*
@@ -2752,11 +2752,11 @@
         (void) TIFFSetField(tiff,TIFFTAG_PLANARCONFIG,PLANARCONFIG_SEPARATE);
     rows_per_strip=1;
     if (TIFFScanlineSize(tiff) != 0)
-      rows_per_strip=(unsigned long) MagickMax((size_t)
+      rows_per_strip=(size_t) MagickMax((size_t)
         TIFFDefaultStripSize(tiff,0),1);
     option=GetImageOption(image_info,"tiff:rows-per-strip");
     if (option != (const char *) NULL)
-      rows_per_strip=(unsigned long) strtol(option,(char **) NULL,10);
+      rows_per_strip=(size_t) strtol(option,(char **) NULL,10);
     switch (compress_tag)
     {
       case COMPRESSION_JPEG:
@@ -2944,7 +2944,7 @@
             quantum_type=RGBQuantum;
             if (image->matte != MagickFalse)
               quantum_type=RGBAQuantum;
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
@@ -2972,7 +2972,7 @@
             /*
               Plane interlacing:  RRRRRR...GGGGGG...BBBBBB...
             */
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
@@ -2992,7 +2992,7 @@
                 if (status == MagickFalse)
                   break;
               }
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
@@ -3012,7 +3012,7 @@
                 if (status == MagickFalse)
                   break;
               }
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               register const PixelPacket
                 *restrict p;
@@ -3033,7 +3033,7 @@
                   break;
               }
             if (image->matte != MagickFalse)
-              for (y=0; y < (long) image->rows; y++)
+              for (y=0; y < (ssize_t) image->rows; y++)
               {
                 register const PixelPacket
                   *restrict p;
@@ -3068,7 +3068,7 @@
           quantum_type=CMYKAQuantum;
         if (image->colorspace != CMYKColorspace)
           (void) TransformImageColorspace(image,CMYKColorspace);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
@@ -3111,7 +3111,7 @@
         (void) ResetMagickMemory(red,0,65536*sizeof(*red));
         (void) ResetMagickMemory(green,0,65536*sizeof(*green));
         (void) ResetMagickMemory(blue,0,65536*sizeof(*blue));
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           red[i]=ScaleQuantumToShort(image->colormap[i].red);
           green[i]=ScaleQuantumToShort(image->colormap[i].green);
@@ -3138,7 +3138,7 @@
          else
            if (photometric != PHOTOMETRIC_PALETTE)
              quantum_type=GrayQuantum;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           register const PixelPacket
             *restrict p;
diff --git a/coders/tile.c b/coders/tile.c
index 20ee745..c07977a 100644
--- a/coders/tile.c
+++ b/coders/tile.c
@@ -150,10 +150,10 @@
 %
 %  The format of the RegisterTILEImage method is:
 %
-%      unsigned long RegisterTILEImage(void)
+%      size_t RegisterTILEImage(void)
 %
 */
-ModuleExport unsigned long RegisterTILEImage(void)
+ModuleExport size_t RegisterTILEImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/tim.c b/coders/tim.c
index 5175d2d..bed4dc9 100644
--- a/coders/tim.c
+++ b/coders/tim.c
@@ -90,7 +90,7 @@
 {
   typedef struct _TIMInfo
   {
-    unsigned long
+    size_t
       id,
       flag;
   } TIMInfo;
@@ -105,7 +105,7 @@
     bits_per_pixel,
     has_clut;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -114,13 +114,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -136,7 +136,7 @@
   unsigned short
     word;
 
-  unsigned long
+  size_t
     bytes_per_line,
     height,
     image_size,
@@ -207,7 +207,7 @@
         if (count != (ssize_t) (2*image->colors))
           ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
         p=tim_colormap;
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           word=(*p++);
           word|=(unsigned short) (*p++ << 8);
@@ -257,14 +257,14 @@
         /*
           Convert PseudoColor scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
           p=tim_pixels+y*bytes_per_line;
-          for (x=0; x < ((long) image->columns-1); x+=2)
+          for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
             indexes[x]=(IndexPacket) ((*p) & 0x0f);
             indexes[x+1]=(IndexPacket) ((*p >> 4) & 0x0f);
@@ -291,14 +291,14 @@
         /*
           Convert PseudoColor scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
           p=tim_pixels+y*bytes_per_line;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             indexes[x]=(*p++);
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
             break;
@@ -316,13 +316,13 @@
         /*
           Convert DirectColor scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=tim_pixels+y*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             word=(*p++);
             word|=(*p++ << 8);
@@ -347,13 +347,13 @@
         /*
           Convert DirectColor scanline.
         */
-        for (y=(long) image->rows-1; y >= 0; y--)
+        for (y=(ssize_t) image->rows-1; y >= 0; y--)
         {
           p=tim_pixels+y*bytes_per_line;
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum(*p++);
             q->green=ScaleCharToQuantum(*p++);
@@ -429,10 +429,10 @@
 %
 %  The format of the RegisterTIMImage method is:
 %
-%      unsigned long RegisterTIMImage(void)
+%      size_t RegisterTIMImage(void)
 %
 */
-ModuleExport unsigned long RegisterTIMImage(void)
+ModuleExport size_t RegisterTIMImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/ttf.c b/coders/ttf.c
index a7b40d4..eecdfef 100644
--- a/coders/ttf.c
+++ b/coders/ttf.c
@@ -187,7 +187,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -196,7 +196,7 @@
   PixelPacket
     background_color;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -230,12 +230,12 @@
     Color canvas with background color
   */
   background_color=image_info->background_color;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *q++=background_color;
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
@@ -306,10 +306,10 @@
 %
 %  The format of the RegisterTTFImage method is:
 %
-%      unsigned long RegisterTTFImage(void)
+%      size_t RegisterTTFImage(void)
 %
 */
-ModuleExport unsigned long RegisterTTFImage(void)
+ModuleExport size_t RegisterTTFImage(void)
 {
   char
     version[MaxTextExtent];
diff --git a/coders/txt.c b/coders/txt.c
index 6a71657..937be74 100644
--- a/coders/txt.c
+++ b/coders/txt.c
@@ -109,7 +109,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     columns,
     depth,
     rows;
@@ -170,7 +170,7 @@
   Image
     *texture;
 
-  long
+  ssize_t
     offset;
 
   MagickBooleanType
@@ -223,9 +223,9 @@
   /*
     Initialize Image structure.
   */
-  image->columns=(unsigned long) floor((((double) page.width*
+  image->columns=(size_t) floor((((double) page.width*
     image->x_resolution)/delta.x)+0.5);
-  image->rows=(unsigned long) floor((((double) page.height*
+  image->rows=(size_t) floor((((double) page.height*
     image->y_resolution)/delta.y)+0.5);
   image->page.x=0;
   image->page.y=0;
@@ -253,7 +253,7 @@
   status=GetTypeMetrics(image,draw_info,&metrics);
   if (status == MagickFalse)
     ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
-  page.y=(long) ceil((double) page.y+metrics.ascent-0.5);
+  page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
   (void) CloneString(&draw_info->geometry,geometry);
   (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
@@ -267,7 +267,7 @@
     */
     (void) ConcatenateString(&draw_info->text,text);
     (void) ConcatenateString(&draw_info->text,"\n");
-    offset+=(long) (metrics.ascent-metrics.descent);
+    offset+=(ssize_t) (metrics.ascent-metrics.descent);
     if (image->previous == (Image *) NULL)
       {
         status=SetImageProgress(image,LoadImageTag,offset,image->rows);
@@ -275,7 +275,7 @@
           break;
       }
     p=ReadBlobString(image,text);
-    if ((offset < (long) image->rows) && (p != (char *) NULL))
+    if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))
       continue;
     if (texture != (Image *) NULL)
       {
@@ -368,7 +368,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     type,
     x_offset,
     y,
@@ -383,7 +383,7 @@
   QuantumAny
     range;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -393,7 +393,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     depth,
     max_value;
 
@@ -428,7 +428,7 @@
     for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
     image->depth=depth;
     LocaleLower(colorspace);
-    i=(long) strlen(colorspace)-1;
+    i=(ssize_t) strlen(colorspace)-1;
     image->matte=MagickFalse;
     if ((i > 0) && (colorspace[i] == 'a'))
       {
@@ -442,9 +442,9 @@
     (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
     (void) SetImageBackgroundColor(image);
     range=GetQuantumRange(image->depth);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if (ReadBlobString(image,text) == (char *) NULL)
           break;
@@ -530,10 +530,10 @@
 %
 %  The format of the RegisterTXTImage method is:
 %
-%      unsigned long RegisterTXTImage(void)
+%      size_t RegisterTXTImage(void)
 %
 */
-ModuleExport unsigned long RegisterTXTImage(void)
+ModuleExport size_t RegisterTXTImage(void)
 {
   MagickInfo
     *entry;
@@ -612,7 +612,7 @@
     colorspace[MaxTextExtent],
     tuple[MaxTextExtent];
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -630,7 +630,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -649,23 +649,23 @@
   do
   {
     (void) CopyMagickString(colorspace,MagickOptionToMnemonic(
-      MagickColorspaceOptions,(long) image->colorspace),MaxTextExtent);
+      MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent);
     LocaleLower(colorspace);
     image->depth=GetImageQuantumDepth(image,MagickTrue);
     if (image->matte != MagickFalse)
       (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
     (void) FormatMagickString(buffer,MaxTextExtent,
       "# ImageMagick pixel enumeration: %lu,%lu,%lu,%s\n",image->columns,
-      image->rows,(unsigned long) GetQuantumRange(image->depth),colorspace);
+      image->rows,(size_t) GetQuantumRange(image->depth),colorspace);
     (void) WriteBlobString(image,buffer);
     GetMagickPixelPacket(image,&pixel);
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetVirtualIndexQueue(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         (void) FormatMagickString(buffer,MaxTextExtent,"%ld,%ld: ",x,y);
         (void) WriteBlobString(image,buffer);
diff --git a/coders/uil.c b/coders/uil.c
index 7bf46cf..fabe986 100644
--- a/coders/uil.c
+++ b/coders/uil.c
@@ -86,10 +86,10 @@
 %
 %  The format of the RegisterUILImage method is:
 %
-%      unsigned long RegisterUILImage(void)
+%      size_t RegisterUILImage(void)
 %
 */
-ModuleExport unsigned long RegisterUILImage(void)
+ModuleExport size_t RegisterUILImage(void)
 {
   MagickInfo
     *entry;
@@ -168,7 +168,7 @@
   int
     j;
 
-  long
+  ssize_t
     k,
     y;
 
@@ -188,7 +188,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -196,7 +196,7 @@
     Cixel[MaxCixels+1] = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjk"
                          "lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";
 
-  unsigned long
+  size_t
     characters_per_pixel,
     colors;
 
@@ -241,12 +241,12 @@
             image->rows*sizeof(*matte_image));
           if (matte_image == (unsigned char *) NULL)
             ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               matte_image[i]=(unsigned char)
               (p->opacity == (Quantum) TransparentOpacity ? 1 : 0);
@@ -268,13 +268,13 @@
             *q;
 
           colors++;
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
             indexes=GetAuthenticIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (matte_image[i] != 0)
                 indexes[x]=(IndexPacket) image->colors;
@@ -289,7 +289,7 @@
     Compute the character per pixel.
   */
   characters_per_pixel=1;
-  for (k=MaxCixels; (long) colors > k; k*=MaxCixels)
+  for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)
     characters_per_pixel++;
   /*
     UIL header.
@@ -301,7 +301,7 @@
     "value\n  %s_ct : color_table(\n",basename);
   (void) WriteBlobString(image,buffer);
   GetMagickPixelPacket(image,&pixel);
-  for (i=0; i < (long) colors; i++)
+  for (i=0; i < (ssize_t) colors; i++)
   {
     /*
       Define UIL color.
@@ -312,7 +312,7 @@
     pixel.opacity=(MagickRealType) OpaqueOpacity;
     GetColorTuple(&pixel,MagickTrue,name);
     if (transparent != MagickFalse)
-      if (i == (long) (colors-1))
+      if (i == (ssize_t) (colors-1))
         (void) CopyMagickString(name,"None",MaxTextExtent);
     /*
       Write UIL color.
@@ -336,7 +336,7 @@
         ((Quantum) QuantumRange/2) ? "background" : "foreground",symbol);
     (void) WriteBlobString(image,buffer);
     (void) FormatMagickString(buffer,MaxTextExtent,"%s",
-      (i == (long) (colors-1) ? ");\n" : ",\n"));
+      (i == (ssize_t) (colors-1) ? ");\n" : ",\n"));
     (void) WriteBlobString(image,buffer);
   }
   /*
@@ -346,16 +346,16 @@
   (void) FormatMagickString(buffer,MaxTextExtent,
     "  %s_icon : icon(color_table = %s_ct,\n",basename,basename);
   (void) WriteBlobString(image,buffer);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
     (void) WriteBlobString(image,"    \"");
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      k=((long) indexes[x] % MaxCixels);
+      k=((ssize_t) indexes[x] % MaxCixels);
       symbol[0]=Cixel[k];
       for (j=1; j < (int) characters_per_pixel; j++)
       {
@@ -368,7 +368,7 @@
       p++;
     }
     (void) FormatMagickString(buffer,MaxTextExtent,"\"%s\n",
-      (y == (long) (image->rows-1) ? ");" : ","));
+      (y == (ssize_t) (image->rows-1) ? ");" : ","));
     (void) WriteBlobString(image,buffer);
     status=SetImageProgress(image,SaveImageTag,y,image->rows);
     if (status == MagickFalse)
diff --git a/coders/url.c b/coders/url.c
index 4df19b4..4bda1e0 100644
--- a/coders/url.c
+++ b/coders/url.c
@@ -248,10 +248,10 @@
 %
 %  The format of the RegisterURLImage method is:
 %
-%      unsigned long RegisterURLImage(void)
+%      size_t RegisterURLImage(void)
 %
 */
-ModuleExport unsigned long RegisterURLImage(void)
+ModuleExport size_t RegisterURLImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/uyvy.c b/coders/uyvy.c
index aacfc67..7876ea9 100644
--- a/coders/uyvy.c
+++ b/coders/uyvy.c
@@ -99,19 +99,19 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
@@ -155,12 +155,12 @@
   /*
     Accumulate UYVY, then unpack into two pixels.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) (image->columns >> 1); x++)
+    for (x=0; x < (ssize_t) (image->columns >> 1); x++)
     {
       u=(unsigned char) ReadBlobByte(image);
       y1=(unsigned char) ReadBlobByte(image);
@@ -209,10 +209,10 @@
 %
 %  The format of the RegisterUYVYImage method is:
 %
-%      unsigned long RegisterUYVYImage(void)
+%      size_t RegisterUYVYImage(void)
 %
 */
-ModuleExport unsigned long RegisterUYVYImage(void)
+ModuleExport size_t RegisterUYVYImage(void)
 {
   MagickInfo
     *entry;
@@ -300,7 +300,7 @@
   Image
     *uyvy_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -310,7 +310,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -336,12 +336,12 @@
   (void) TransformImageColorspace(uyvy_image,YCbCrColorspace);
   full=MagickFalse;
   (void) ResetMagickMemory(&pixel,0,sizeof(MagickPixelPacket));
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(uyvy_image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (full != MagickFalse)
         {
diff --git a/coders/vicar.c b/coders/vicar.c
index 6ef63ed..1aacb80 100644
--- a/coders/vicar.c
+++ b/coders/vicar.c
@@ -153,7 +153,7 @@
   int
     c;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -297,7 +297,7 @@
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   pixels=GetQuantumPixels(quantum_info);
   length=GetQuantumExtent(image,quantum_info,IndexQuantum);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -340,10 +340,10 @@
 %
 %  The format of the RegisterVICARImage method is:
 %
-%      unsigned long RegisterVICARImage(void)
+%      size_t RegisterVICARImage(void)
 %
 */
-ModuleExport unsigned long RegisterVICARImage(void)
+ModuleExport size_t RegisterVICARImage(void)
 {
   MagickInfo
     *entry;
@@ -463,7 +463,7 @@
   (void) FormatMagickString(header,MaxTextExtent,
     "LBLSIZE=%lu FORMAT='BYTE' TYPE='IMAGE' BUFSIZE=20000 DIM=2 EOL=0 "
     "RECSIZE=%lu ORG='BSQ' NL=%lu NS=%lu NB=1 N1=0 N2=0 N3=0 N4=0 NBB=0 "
-    "NLB=0 TASK='ImageMagick'",(unsigned long) MaxTextExtent,image->columns,
+    "NLB=0 TASK='ImageMagick'",(size_t) MaxTextExtent,image->columns,
     image->rows,image->columns);
   (void) WriteBlob(image,MaxTextExtent,(unsigned char *) header);
   /*
@@ -474,7 +474,7 @@
   if (quantum_info == (QuantumInfo *) NULL)
     ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
   pixels=GetQuantumPixels(quantum_info);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
diff --git a/coders/vid.c b/coders/vid.c
index 0a29ad9..0370445 100644
--- a/coders/vid.c
+++ b/coders/vid.c
@@ -125,7 +125,7 @@
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -158,7 +158,7 @@
     (void *) NULL);
   if (read_info->size == (char *) NULL)
     (void) CloneString(&read_info->size,DefaultTileGeometry);
-  for (i=0; i < (long) number_files; i++)
+  for (i=0; i < (ssize_t) number_files; i++)
   {
     if (image_info->debug != MagickFalse)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"name: %s",
@@ -232,10 +232,10 @@
 %
 %  The format of the RegisterVIDImage method is:
 %
-%      unsigned long RegisterVIDImage(void)
+%      size_t RegisterVIDImage(void)
 %
 */
-ModuleExport unsigned long RegisterVIDImage(void)
+ModuleExport size_t RegisterVIDImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/viff.c b/coders/viff.c
index ab51c11..2f08242 100644
--- a/coders/viff.c
+++ b/coders/viff.c
@@ -173,12 +173,12 @@
     char
       comment[512];
 
-    unsigned long
+    size_t
       rows,
       columns,
       subrows;
 
-    long
+    ssize_t
       x_offset,
       y_offset;
 
@@ -186,7 +186,7 @@
       x_bits_per_pixel,
       y_bits_per_pixel;
 
-    unsigned long
+    size_t
       location_type,
       location_dimension,
       number_of_images,
@@ -214,7 +214,7 @@
   int
     bit;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -226,13 +226,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -245,7 +245,7 @@
     buffer[7],
     *viff_pixels;
 
-  unsigned long
+  size_t
     bytes_per_pixel,
     lsb_first,
     max_packets,
@@ -300,8 +300,8 @@
         viff_info.rows=ReadBlobLSBLong(image);
         viff_info.columns=ReadBlobLSBLong(image);
         viff_info.subrows=ReadBlobLSBLong(image);
-        viff_info.x_offset=(long) ReadBlobLSBLong(image);
-        viff_info.y_offset=(long) ReadBlobLSBLong(image);
+        viff_info.x_offset=(ssize_t) ReadBlobLSBLong(image);
+        viff_info.y_offset=(ssize_t) ReadBlobLSBLong(image);
         viff_info.x_bits_per_pixel=(float) ReadBlobLSBLong(image);
         viff_info.y_bits_per_pixel=(float) ReadBlobLSBLong(image);
         viff_info.location_type=ReadBlobLSBLong(image);
@@ -324,8 +324,8 @@
         viff_info.rows=ReadBlobMSBLong(image);
         viff_info.columns=ReadBlobMSBLong(image);
         viff_info.subrows=ReadBlobMSBLong(image);
-        viff_info.x_offset=(long) ReadBlobMSBLong(image);
-        viff_info.y_offset=(long) ReadBlobMSBLong(image);
+        viff_info.x_offset=(ssize_t) ReadBlobMSBLong(image);
+        viff_info.y_offset=(ssize_t) ReadBlobMSBLong(image);
         viff_info.x_bits_per_pixel=(float) ReadBlobMSBLong(image);
         viff_info.y_bits_per_pixel=(float) ReadBlobMSBLong(image);
         viff_info.location_type=ReadBlobMSBLong(image);
@@ -452,7 +452,7 @@
             }
             default: break;
           }
-        for (i=0; i < (long) (viff_info.map_rows*image->colors); i++)
+        for (i=0; i < (ssize_t) (viff_info.map_rows*image->colors); i++)
         {
           switch ((int) viff_info.map_storage_type)
           {
@@ -462,7 +462,7 @@
             case VFF_MAPTYP_DOUBLE: value=((double *) viff_colormap)[i]; break;
             default: value=1.0*viff_colormap[i]; break;
           }
-          if (i < (long) image->colors)
+          if (i < (ssize_t) image->colors)
             {
               image->colormap[i].red=ScaleCharToQuantum((unsigned char) value);
               image->colormap[i].green=
@@ -470,11 +470,11 @@
               image->colormap[i].blue=ScaleCharToQuantum((unsigned char) value);
             }
           else
-            if (i < (long) (2*image->colors))
+            if (i < (ssize_t) (2*image->colors))
               image->colormap[i % image->colors].green=
                 ScaleCharToQuantum((unsigned char) value);
             else
-              if (i < (long) (3*image->colors))
+              if (i < (ssize_t) (3*image->colors))
                 image->colormap[i % image->colors].blue=
                   ScaleCharToQuantum((unsigned char) value);
         }
@@ -509,7 +509,7 @@
     if (viff_info.data_storage_type == VFF_TYP_BIT)
       max_packets=((image->columns+7UL) >> 3UL)*image->rows;
     else
-      max_packets=(unsigned long) (number_pixels*viff_info.number_data_bands);
+      max_packets=(size_t) (number_pixels*viff_info.number_data_bands);
     viff_pixels=(unsigned char *) AcquireQuantumMemory(max_packets,
       bytes_per_pixel*sizeof(*viff_pixels));
     if (viff_pixels == (unsigned char *) NULL)
@@ -555,7 +555,7 @@
         }
         max_value=value;
         min_value=value;
-        for (i=0; i < (long) max_packets; i++)
+        for (i=0; i < (ssize_t) max_packets; i++)
         {
           switch ((int) viff_info.data_storage_type)
           {
@@ -586,7 +586,7 @@
       Convert pixels to Quantum size.
     */
     p=(unsigned char *) viff_pixels;
-    for (i=0; i < (long) max_packets; i++)
+    for (i=0; i < (ssize_t) max_packets; i++)
     {
       switch ((int) viff_info.data_storage_type)
       {
@@ -619,18 +619,18 @@
         */
         (void) SetImageType(image,BilevelType);
         (void) SetImageType(image,PaletteType);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < (long) (image->columns-7); x+=8)
+          for (x=0; x < (ssize_t) (image->columns-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
               if (PixelIntensity(q) < ((MagickRealType) QuantumRange/2.0))
                 {
-                  quantum=(unsigned long) indexes[x+bit];
+                  quantum=(size_t) indexes[x+bit];
                   quantum|=0x01;
                   indexes[x+bit]=(IndexPacket) quantum;
                 }
@@ -638,10 +638,10 @@
           }
           if ((image->columns % 8) != 0)
             {
-              for (bit=0; bit < (long) (image->columns % 8); bit++)
+              for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
                 if (PixelIntensity(q) < ((MagickRealType) QuantumRange/2.0))
                   {
-                    quantum=(unsigned long) indexes[x+bit];
+                    quantum=(size_t) indexes[x+bit];
                     quantum|=0x01;
                     indexes[x+bit]=(IndexPacket) quantum;
                   }
@@ -659,13 +659,13 @@
       }
     else
       if (image->storage_class == PseudoClass)
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             indexes[x]=(IndexPacket) (*p++);
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
             break;
@@ -682,21 +682,21 @@
             Convert DirectColor scanline.
           */
           number_pixels=(MagickSizeType) image->columns*image->rows;
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               q->red=ScaleCharToQuantum(*p);
               q->green=ScaleCharToQuantum(*(p+number_pixels));
               q->blue=ScaleCharToQuantum(*(p+2*number_pixels));
               if (image->colors != 0)
                 {
-                  q->red=image->colormap[(long) q->red].red;
-                  q->green=image->colormap[(long) q->green].green;
-                  q->blue=image->colormap[(long) q->blue].blue;
+                  q->red=image->colormap[(ssize_t) q->red].red;
+                  q->green=image->colormap[(ssize_t) q->green].green;
+                  q->blue=image->colormap[(ssize_t) q->blue].blue;
                 }
               q->opacity=(Quantum) (image->matte ? QuantumRange-
                 ScaleCharToQuantum(*(p+number_pixels*3)) : OpaqueOpacity);
@@ -771,10 +771,10 @@
 %
 %  The format of the RegisterVIFFImage method is:
 %
-%      unsigned long RegisterVIFFImage(void)
+%      size_t RegisterVIFFImage(void)
 %
 */
-ModuleExport unsigned long RegisterVIFFImage(void)
+ModuleExport size_t RegisterVIFFImage(void)
 {
   MagickInfo
     *entry;
@@ -879,12 +879,12 @@
       reserve[3],
       comment[512];
 
-    unsigned long
+    size_t
       rows,
       columns,
       subrows;
 
-    long
+    ssize_t
       x_offset,
       y_offset;
 
@@ -892,7 +892,7 @@
       x_bits_per_pixel,
       y_bits_per_pixel;
 
-    unsigned long
+    size_t
       location_type,
       location_dimension,
       number_of_images,
@@ -912,7 +912,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -931,10 +931,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -1050,12 +1050,12 @@
     (void) WriteBlobMSBLong(image,viff_info.rows);
     (void) WriteBlobMSBLong(image,viff_info.columns);
     (void) WriteBlobMSBLong(image,viff_info.subrows);
-    (void) WriteBlobMSBLong(image,(unsigned long) viff_info.x_offset);
-    (void) WriteBlobMSBLong(image,(unsigned long) viff_info.y_offset);
+    (void) WriteBlobMSBLong(image,(size_t) viff_info.x_offset);
+    (void) WriteBlobMSBLong(image,(size_t) viff_info.y_offset);
     viff_info.x_bits_per_pixel=1U*(63 << 24) | (128 << 16);
-    (void) WriteBlobMSBLong(image,(unsigned long) viff_info.x_bits_per_pixel);
+    (void) WriteBlobMSBLong(image,(size_t) viff_info.x_bits_per_pixel);
     viff_info.y_bits_per_pixel=1U*(63 << 24) | (128 << 16);
-    (void) WriteBlobMSBLong(image,(unsigned long) viff_info.y_bits_per_pixel);
+    (void) WriteBlobMSBLong(image,(size_t) viff_info.y_bits_per_pixel);
     (void) WriteBlobMSBLong(image,viff_info.location_type);
     (void) WriteBlobMSBLong(image,viff_info.location_dimension);
     (void) WriteBlobMSBLong(image,viff_info.number_of_images);
@@ -1086,12 +1086,12 @@
           Convert DirectClass packet to VIFF RGB pixel.
         */
         number_pixels=(MagickSizeType) image->columns*image->rows;
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             *q=ScaleQuantumToChar(GetRedPixelComponent(p));
             *(q+number_pixels)=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1124,11 +1124,11 @@
           if (viff_colormap == (unsigned char *) NULL)
             ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
           q=viff_colormap;
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             *q++=ScaleQuantumToChar(image->colormap[i].red);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             *q++=ScaleQuantumToChar(image->colormap[i].green);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             *q++=ScaleQuantumToChar(image->colormap[i].blue);
           (void) WriteBlob(image,3*image->colors,viff_colormap);
           viff_colormap=(unsigned char *) RelinquishMagickMemory(viff_colormap);
@@ -1136,13 +1136,13 @@
             Convert PseudoClass packet to VIFF colormapped pixels.
           */
           q=viff_pixels;
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
             if (p == (const PixelPacket *) NULL)
               break;
             indexes=GetVirtualIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
               *q++=(unsigned char) indexes[x];
             if (image->previous == (Image *) NULL)
               {
@@ -1155,7 +1155,7 @@
       else
         if (image->colors <= 2)
           {
-            long
+            ssize_t
               x,
               y;
 
@@ -1167,7 +1167,7 @@
               Convert PseudoClass image to a VIFF monochrome image.
             */
             (void) SetImageType(image,BilevelType);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
@@ -1176,7 +1176,7 @@
               indexes=GetVirtualIndexQueue(image);
               bit=0;
               byte=0;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 byte>>=1;
                 if (PixelIntensity(p) < ((MagickRealType) QuantumRange/2.0))
@@ -1204,13 +1204,13 @@
             /*
               Convert PseudoClass packet to VIFF grayscale pixel.
             */
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
               if (p == (const PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *q++=(unsigned char) PixelIntensityToQuantum(p);
                 p++;
diff --git a/coders/wbmp.c b/coders/wbmp.c
index bd2cd3d..791801e 100644
--- a/coders/wbmp.c
+++ b/coders/wbmp.c
@@ -95,7 +95,7 @@
 %
 */
 
-static MagickBooleanType WBMPReadInteger(Image *image,unsigned long *value)
+static MagickBooleanType WBMPReadInteger(Image *image,size_t *value)
 {
   int
     byte;
@@ -121,7 +121,7 @@
   int
     byte;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -130,13 +130,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
@@ -192,7 +192,7 @@
   /*
     Convert bi-level image to pixel packets.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -200,7 +200,7 @@
     indexes=GetAuthenticIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (bit == 0)
         {
@@ -247,10 +247,10 @@
 %
 %  The format of the RegisterWBMPImage method is:
 %
-%      unsigned long RegisterWBMPImage(void)
+%      size_t RegisterWBMPImage(void)
 %
 */
-ModuleExport unsigned long RegisterWBMPImage(void)
+ModuleExport size_t RegisterWBMPImage(void)
 {
   MagickInfo
     *entry;
@@ -319,14 +319,14 @@
 %
 */
 
-static void WBMPWriteInteger(Image *image,const unsigned long value)
+static void WBMPWriteInteger(Image *image,const size_t value)
 {
   int
     bits,
     flag,
     n;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
@@ -353,7 +353,7 @@
 static MagickBooleanType WriteWBMPImage(const ImageInfo *image_info,
   Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -365,7 +365,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   unsigned char
@@ -393,7 +393,7 @@
   (void) WriteBlobMSBShort(image,0);
   WBMPWriteInteger(image,image->columns);
   WBMPWriteInteger(image,image->rows);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -401,7 +401,7 @@
     indexes=GetVirtualIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (PixelIntensity(p) >= ((MagickRealType) QuantumRange/2.0))
         byte|=0x1 << (7-bit);
diff --git a/coders/wmf.c b/coders/wmf.c
index 62e42fb..b0a6e80 100644
--- a/coders/wmf.c
+++ b/coders/wmf.c
@@ -99,14 +99,14 @@
   return(ReadBlobByte((Image *) image));
 }
 
-static int WMFSeekBlob(void *image,long offset)
+static int WMFSeekBlob(void *image,ssize_t offset)
 {
   return((int) SeekBlob((Image *) image,(MagickOffsetType) offset,SEEK_SET));
 }
 
-static long WMFTellBlob(void *image)
+static ssize_t WMFTellBlob(void *image)
 {
-  return((long) TellBlob((Image*) image));
+  return((ssize_t) TellBlob((Image*) image));
 }
 
 static Image *ReadWMFImage(const ImageInfo *image_info,ExceptionInfo *exception)
@@ -129,7 +129,7 @@
   MagickBooleanType
     status;
 
-  unsigned long
+  size_t
     flags;
 
   wmfAPI
@@ -248,10 +248,10 @@
 %
 %  The format of the RegisterWMFImage method is:
 %
-%      unsigned long RegisterWMFImage(void)
+%      size_t RegisterWMFImage(void)
 %
 */
-ModuleExport unsigned long RegisterWMFImage(void)
+ModuleExport size_t RegisterWMFImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/wpg.c b/coders/wpg.c
index 4131cc7..411be69 100644
--- a/coders/wpg.c
+++ b/coders/wpg.c
@@ -239,7 +239,7 @@
 }
 
 
-static void Rd_WP_DWORD(Image *image,unsigned long *d)
+static void Rd_WP_DWORD(Image *image,size_t *d)
 {
   unsigned char
     b;
@@ -249,20 +249,20 @@
   if (b < 0xFFU)
     return;
   b=ReadBlobByte(image);
-  *d=(unsigned long) b;
+  *d=(size_t) b;
   b=ReadBlobByte(image);
-  *d+=(unsigned long) b*256l;
+  *d+=(size_t) b*256l;
   if (*d < 0x8000)
     return;
   *d=(*d & 0x7FFF) << 16;
   b=ReadBlobByte(image);
-  *d+=(unsigned long) b;
+  *d+=(size_t) b;
   b=ReadBlobByte(image);
-  *d+=(unsigned long) b*256l;
+  *d+=(size_t) b*256l;
   return;
 }
 
-static void InsertRow(unsigned char *p,long y,Image *image, int bpp)
+static void InsertRow(unsigned char *p,ssize_t y,Image *image, int bpp)
 {
   ExceptionInfo
     *exception;
@@ -270,7 +270,7 @@
   int
     bit;
 
-  long
+  ssize_t
     x;
 
   register PixelPacket
@@ -291,7 +291,7 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        for (x=0; x < ((ssize_t) image->columns-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
               {
@@ -303,7 +303,7 @@
           }
         if ((image->columns % 8) != 0)
           {
-            for (bit=0; bit < (long) (image->columns % 8); bit++)
+            for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
               {
                 index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
                 indexes[x+bit]=index;
@@ -321,39 +321,39 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-1); x+=2)
+        for (x=0; x < ((ssize_t) image->columns-1); x+=2)
         {
             index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p) & 0x3);
             indexes[x+1]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
         }
        if ((image->columns % 4) != 0)
           {
             index=ConstrainColormapIndex(image,(*p >> 6) & 0x3);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             if ((image->columns % 4) >= 1)
 
               {
                 index=ConstrainColormapIndex(image,(*p >> 4) & 0x3);
                 indexes[x]=index;
-                *q++=image->colormap[(long) index];
+                *q++=image->colormap[(ssize_t) index];
                 if ((image->columns % 4) >= 2)
 
                   {
                     index=ConstrainColormapIndex(image,(*p >> 2) & 0x3);
                     indexes[x]=index;
-                    *q++=image->colormap[(long) index];
+                    *q++=image->colormap[(ssize_t) index];
                   }
               }
             p++;
@@ -369,21 +369,21 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < ((long) image->columns-1); x+=2)
+        for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           { 
             index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             index=ConstrainColormapIndex(image,(*p) & 0x0f);
             indexes[x+1]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if ((image->columns % 2) != 0)
           {
             index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -396,11 +396,11 @@
         if (q == (PixelPacket *) NULL) break;
         indexes=GetAuthenticIndexQueue(image);
 
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           {
             index=ConstrainColormapIndex(image,*p);
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
             p++;
           }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -412,7 +412,7 @@
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=ScaleCharToQuantum(*p++);
           q->green=ScaleCharToQuantum(*p++);
@@ -431,9 +431,9 @@
 { \
   BImgBuff[x]=b; \
   x++; \
-  if((long) x>=ldblk) \
+  if((ssize_t) x>=ldblk) \
   { \
-    InsertRow(BImgBuff,(long) y,image,bpp); \
+    InsertRow(BImgBuff,(ssize_t) y,image,bpp); \
     x=0; \
     y++; \
     } \
@@ -451,18 +451,18 @@
     *BImgBuff,
     RunCount;
 
-  long
+  ssize_t
     ldblk;
 
   x=0;
   y=0;
 
-  ldblk=(long) ((bpp*image->columns+7)/8);
+  ldblk=(ssize_t) ((bpp*image->columns+7)/8);
   BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk,
     sizeof(*BImgBuff));
   if(BImgBuff==NULL) return(-2);
 
-  while(y<(long) image->rows)
+  while(y<(ssize_t) image->rows)
     {
       bbuf=ReadBlobByte(image);
 
@@ -500,7 +500,7 @@
               x=0;
               y++;    /* Here I need to duplicate previous row RUNCOUNT* */
               if(y<2) continue;
-              if(y>(long) image->rows)
+              if(y>(ssize_t) image->rows)
                 {
                   BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff);
                   return(-4);
@@ -523,9 +523,9 @@
   else\
     BImgBuff[x] = b;\
   x++; \
-  if((long) x >= ldblk) \
+  if((ssize_t) x >= ldblk) \
   { \
-    InsertRow(BImgBuff,(long) y,image,bpp); \
+    InsertRow(BImgBuff,(ssize_t) y,image,bpp); \
     x=0; \
     y++; \
    } \
@@ -542,21 +542,21 @@
     RunCount,
     SampleBuffer[8];
 
-  unsigned long
+  size_t
     x,
     y;
 
   unsigned int
     i;
 
-  long
+  ssize_t
     ldblk;
 
   int XorMe = 0;
 
   x=0;
   y=0;
-  ldblk=(long) ((bpp*image->columns+7)/8);
+  ldblk=(ssize_t) ((bpp*image->columns+7)/8);
   BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk,
     sizeof(*BImgBuff));
   if(BImgBuff==NULL)
@@ -605,7 +605,7 @@
             /* duplicate the previous row RunCount x */
             for(i=0;i<=RunCount;i++)
               {      
-                InsertRow(BImgBuff,(long) (image->rows >= y ? y : image->rows-1),
+                InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1),
                           image,bpp);
                 y++;
               }    
@@ -648,7 +648,7 @@
 static unsigned LoadWPG2Flags(Image *image,char Precision,float *Angle,tCTM *CTM)
 {
 const unsigned char TPR=1,TRN=2,SKW=4,SCL=8,ROT=0x10,OID=0x20,LCK=0x80;
-long x;
+ssize_t x;
 unsigned DenX;
 unsigned Flags;
 
@@ -707,7 +707,7 @@
 
 
 static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
-  MagickOffsetType PS_Offset,long PS_Size,ExceptionInfo *exception)
+  MagickOffsetType PS_Offset,ssize_t PS_Size,ExceptionInfo *exception)
 {
   char
     postscript_file[MaxTextExtent];
@@ -825,7 +825,7 @@
 {
   typedef struct
   {
-    unsigned long FileId;
+    size_t FileId;
     MagickOffsetType DataOffset;
     unsigned int ProductType;
     unsigned int FileType;
@@ -838,15 +838,15 @@
   typedef struct
   {
     unsigned char RecType;
-    unsigned long RecordLength;
+    size_t RecordLength;
   } WPGRecord;
 
   typedef struct
   {
     unsigned char Class;
     unsigned char RecType;
-    unsigned long Extension;
-    unsigned long RecordLength;
+    size_t Extension;
+    size_t RecordLength;
   } WPG2Record;
 
   typedef struct
@@ -894,7 +894,7 @@
   } WPGColorMapRec;
 
   typedef struct {
-    unsigned long PS_unknown1;
+    size_t PS_unknown1;
     unsigned int PS_unknown2;
     unsigned int PS_unknown3;
   } WPGPSl1Record;  
@@ -934,7 +934,7 @@
     bpp,
     WPG2Flags;
 
-  long
+  ssize_t
     ldblk;
 
   unsigned char
@@ -1042,7 +1042,7 @@
               if(Rec.RecordLength > 8)
                 image=ExtractPostscript(image,image_info,
                   TellBlob(image)+8,   /* skip PS header in the wpg */
-                  (long) Rec.RecordLength-8,exception);
+                  (ssize_t) Rec.RecordLength-8,exception);
               break;     
 
             case 0x14:  /* bitmap type 2 */
@@ -1168,7 +1168,7 @@
               if(Rec.RecordLength>0x3C)
                 image=ExtractPostscript(image,image_info,
                   TellBlob(image)+0x3C,   /* skip PS l2 header in the wpg */
-                  (long) Rec.RecordLength-0x3C,exception);
+                  (ssize_t) Rec.RecordLength-0x3C,exception);
               break;
             }
         }
@@ -1274,13 +1274,13 @@
                 {
                 case 0:    /*Uncompressed raster*/
                   {
-                    ldblk=(long) ((bpp*image->columns+7)/8);
+                    ldblk=(ssize_t) ((bpp*image->columns+7)/8);
                     BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t)
                       ldblk,sizeof(*BImgBuff));
                     if (BImgBuff == (unsigned char *) NULL)
                       goto NoMemory;
 
-                    for(i=0; i< (long) image->rows; i++)
+                    for(i=0; i< (ssize_t) image->rows; i++)
                       {
                         (void) ReadBlob(image,ldblk,BImgBuff);
                         InsertRow(BImgBuff,i,image,bpp);
@@ -1342,7 +1342,7 @@
               if(Rec2.RecordLength > (unsigned int) i)
                 image=ExtractPostscript(image,image_info,
                   TellBlob(image)+i,    /*skip PS header in the wpg2*/
-                  (long) (Rec2.RecordLength-i-2),exception);
+                  (ssize_t) (Rec2.RecordLength-i-2),exception);
               break;
 
       case 0x1B:          /*bitmap rectangle*/
@@ -1366,7 +1366,7 @@
     Image
       *p;
 
-    long
+    ssize_t
       scene=0;
 
     /*
@@ -1389,7 +1389,7 @@
       Fix scene numbers.
     */
     for (p=image; p != (Image *) NULL; p=p->next)
-      p->scene=(unsigned long) scene++;
+      p->scene=(size_t) scene++;
   }
   if (image == (Image *) NULL)
     ThrowReaderException(CorruptImageError,
@@ -1417,10 +1417,10 @@
 %
 %  The format of the RegisterWPGImage method is:
 %
-%      unsigned long RegisterWPGImage(void)
+%      size_t RegisterWPGImage(void)
 %
 */
-ModuleExport unsigned long RegisterWPGImage(void)
+ModuleExport size_t RegisterWPGImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/x.c b/coders/x.c
index a92bff5..8f31ac2 100644
--- a/coders/x.c
+++ b/coders/x.c
@@ -130,10 +130,10 @@
 %
 %  The format of the RegisterXImage method is:
 %
-%      unsigned long RegisterXImage(void)
+%      size_t RegisterXImage(void)
 %
 */
-ModuleExport unsigned long RegisterXImage(void)
+ModuleExport size_t RegisterXImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/xbm.c b/coders/xbm.c
index bc0c231..dfb7ca7 100644
--- a/coders/xbm.c
+++ b/coders/xbm.c
@@ -148,7 +148,7 @@
     c&=0xff;
     if (isxdigit(c) != MagickFalse)
       {
-        value=(int) ((unsigned long) value << 4)+hex_digits[c];
+        value=(int) ((size_t) value << 4)+hex_digits[c];
         flag++;
         continue;
       }
@@ -167,7 +167,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -176,7 +176,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -195,7 +195,7 @@
   unsigned char
     *data;
 
-  unsigned long
+  size_t
     bit,
     byte,
     bytes_per_line,
@@ -328,24 +328,24 @@
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   p=data;
   if (version == 10)
-    for (i=0; i < (long) (bytes_per_line*image->rows); (i+=2))
+    for (i=0; i < (ssize_t) (bytes_per_line*image->rows); (i+=2))
     {
-      value=(unsigned long) XBMInteger(image,hex_digits);
+      value=(size_t) XBMInteger(image,hex_digits);
       *p++=(unsigned char) value;
       if ((padding == 0) || (((i+2) % bytes_per_line) != 0))
         *p++=(unsigned char) (value >> 8);
     }
   else
-    for (i=0; i < (long) (bytes_per_line*image->rows); i++)
+    for (i=0; i < (ssize_t) (bytes_per_line*image->rows); i++)
     {
-      value=(unsigned long) XBMInteger(image,hex_digits);
+      value=(size_t) XBMInteger(image,hex_digits);
       *p++=(unsigned char) value;
     }
   /*
     Convert X bitmap image to pixel packets.
   */
   p=data;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
@@ -353,10 +353,10 @@
     indexes=GetAuthenticIndexQueue(image);
     bit=0;
     byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (bit == 0)
-        byte=(unsigned long) (*p++);
+        byte=(size_t) (*p++);
       indexes[x]=(IndexPacket) ((byte & 0x01) != 0 ? 0x01 : 0x00);
       bit++;
       byte>>=1;
@@ -395,10 +395,10 @@
 %
 %  The format of the RegisterXBMImage method is:
 %
-%      unsigned long RegisterXBMImage(void)
+%      size_t RegisterXBMImage(void)
 %
 */
-ModuleExport unsigned long RegisterXBMImage(void)
+ModuleExport size_t RegisterXBMImage(void)
 {
   MagickInfo
     *entry;
@@ -470,7 +470,7 @@
     basename[MaxTextExtent],
     buffer[MaxTextExtent];
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -479,13 +479,13 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   ssize_t
     count;
 
-  unsigned long
+  size_t
     bit,
     byte;
 
@@ -529,12 +529,12 @@
   y=0;
   (void) CopyMagickString(buffer," ",MaxTextExtent);
   (void) WriteBlob(image,strlen(buffer),(unsigned char *) buffer);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       byte>>=1;
       if (PixelIntensity(p) < ((MagickRealType) QuantumRange/2.0))
diff --git a/coders/xc.c b/coders/xc.c
index 7cd4c03..9720434 100644
--- a/coders/xc.c
+++ b/coders/xc.c
@@ -102,13 +102,13 @@
   MagickPixelPacket
     color;
 
-  long
+  ssize_t
     y;
 
   PixelPacket
     pixel;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -140,17 +140,17 @@
   image->matte=color.matte;
   index=0;
   SetPixelPacket(image,&color,&pixel,&index);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *q++=pixel;
     if (image->colorspace == CMYKColorspace)
       {
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           indexes[x]=index;
       }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -179,10 +179,10 @@
 %
 %  The format of the RegisterXCImage method is:
 %
-%      unsigned long RegisterXCImage(void)
+%      size_t RegisterXCImage(void)
 %
 */
-ModuleExport unsigned long RegisterXCImage(void)
+ModuleExport size_t RegisterXCImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/xcf.c b/coders/xcf.c
index 945c08c..8130e3c 100644
--- a/coders/xcf.c
+++ b/coders/xcf.c
@@ -107,7 +107,7 @@
 
 typedef struct
 {
-  unsigned long
+  size_t
     width,
     height,
     image_type,
@@ -131,7 +131,7 @@
   unsigned int
     active;
 
-  unsigned long
+  size_t
     width,
     height,
     type,
@@ -148,7 +148,7 @@
     offset_x,
     offset_y;
 
-  unsigned long
+  size_t
     mode,
     tattoo;
 
@@ -231,7 +231,7 @@
   ImageMagick compositing operators
 */
 static CompositeOperator GIMPBlendModeToCompositeOperator(
-  unsigned long blendMode)
+  size_t blendMode)
 {
   switch ( blendMode )
   {
@@ -272,7 +272,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  ReadBlobStringWithLongSize reads characters from a blob or file
-%  starting with a long length byte and then characters to that length
+%  starting with a ssize_t length byte and then characters to that length
 %
 %  The format of the ReadBlobStringWithLongSize method is:
 %
@@ -301,10 +301,10 @@
   MagickOffsetType
     offset;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     length;
 
   assert(image != (Image *) NULL);
@@ -313,7 +313,7 @@
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   length=ReadBlobMSBLong(image);
-  for (i=0; i < (long) MagickMin(length,max-1); i++)
+  for (i=0; i < (ssize_t) MagickMin(length,max-1); i++)
   {
     c=ReadBlobByte(image);
     if (c == EOF)
@@ -334,10 +334,10 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -364,14 +364,14 @@
     ThrowBinaryException(CorruptImageError,"NotEnoughPixelData",
       image->filename);
   exception=(&image->exception);
-  for (y=0; y < (long) tile_image->rows; y++)
+  for (y=0; y < (ssize_t) tile_image->rows; y++)
   {
     q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
     if (inDocInfo->image_type == GIMP_GRAY)
       {
-        for (x=0; x < (long) tile_image->columns; x++)
+        for (x=0; x < (ssize_t) tile_image->columns; x++)
         {
           q->red=ScaleCharToQuantum(*graydata);
           q->green=q->red;
@@ -384,7 +384,7 @@
     else
       if (inDocInfo->image_type == GIMP_RGB)
         {
-          for (x=0; x < (long) tile_image->columns; x++)
+          for (x=0; x < (ssize_t) tile_image->columns; x++)
           {
             q->red=ScaleCharToQuantum(xcfdata->red);
             q->green=ScaleCharToQuantum(xcfdata->green);
@@ -408,7 +408,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     i,
     j;
 
@@ -441,7 +441,7 @@
   count=ReadBlob(image, (size_t) data_length, xcfdata);
   xcfdatalimit = xcfodata+count-1;
   exception=(&image->exception);
-  for (i=0; i < (long) bytes_per_pixel; i++)
+  for (i=0; i < (ssize_t) bytes_per_pixel; i++)
   {
     q=GetAuthenticPixels(tile_image,0,0,tile_image->columns,tile_image->rows,exception);
     size=(MagickOffsetType) tile_image->rows*tile_image->columns;
@@ -524,7 +524,7 @@
             if (xcfdata > xcfdatalimit)
               goto bogus_rle;
             pixel=(*xcfdata++);
-            for (j= 0; j < (long) length; j++)
+            for (j= 0; j < (ssize_t) length; j++)
             {
               data=pixel;
               switch (i)
@@ -600,10 +600,10 @@
     offset,
     offset2;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width,
     height,
     ntiles,
@@ -629,7 +629,7 @@
   ntile_rows=(height+TILE_HEIGHT-1)/TILE_HEIGHT;
   ntile_cols=(width+TILE_WIDTH-1)/TILE_WIDTH;
   ntiles=ntile_rows*ntile_cols;
-  for (i = 0; i < (long) ntiles; i++)
+  for (i = 0; i < (ssize_t) ntiles; i++)
   {
     status=MagickFalse;
     if (offset == 0)
@@ -651,10 +651,10 @@
       /* allocate the image for the tile
         NOTE: the last tile in a row or column may not be a full tile!
       */
-      tile_image_width=(unsigned long) (destLeft == (int) ntile_cols-1 ?
+      tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ?
         (int) width % TILE_WIDTH : TILE_WIDTH);
       if (tile_image_width == 0) tile_image_width=TILE_WIDTH;
-      tile_image_height = (unsigned long) (destTop == (int) ntile_rows-1 ?
+      tile_image_height = (size_t) (destTop == (int) ntile_rows-1 ?
         (int) height % TILE_HEIGHT : TILE_HEIGHT);
       if (tile_image_height == 0) tile_image_height=TILE_HEIGHT;
       tile_image=CloneImage(inLayerInfo->image,tile_image_width,
@@ -714,7 +714,7 @@
     offset,
     junk;
 
-  unsigned long
+  size_t
     width,
     height,
     bytes_per_pixel;
@@ -758,7 +758,7 @@
 static MagickBooleanType ReadOneLayer(Image* image,XCFDocInfo* inDocInfo,
   XCFLayerInfo *outLayer )
 {
-  long
+  ssize_t
     i;
 
   MagickOffsetType
@@ -767,7 +767,7 @@
   unsigned int
     foundPropEnd = 0;
 
-  unsigned long
+  size_t
     hierarchy_offset,
     layer_mask_offset;
 
@@ -788,7 +788,7 @@
   foundPropEnd = 0;
   while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) {
   PropType    prop_type = (PropType) ReadBlobMSBLong(image);
-  unsigned long  prop_size = ReadBlobMSBLong(image);
+  size_t  prop_size = ReadBlobMSBLong(image);
     switch (prop_type)
     {
     case PROP_END:
@@ -822,8 +822,8 @@
       outLayer->show_mask = ReadBlobMSBLong(image);
       break;
     case PROP_OFFSETS:
-      outLayer->offset_x = (long) ReadBlobMSBLong(image);
-      outLayer->offset_y = (long) ReadBlobMSBLong(image);
+      outLayer->offset_x = (ssize_t) ReadBlobMSBLong(image);
+      outLayer->offset_y = (ssize_t) ReadBlobMSBLong(image);
       break;
     case PROP_MODE:
       outLayer->mode = ReadBlobMSBLong(image);
@@ -833,11 +833,11 @@
       break;
      case PROP_PARASITES:
      {
-        for (i=0; i < (long) prop_size; i++ )
+        for (i=0; i < (ssize_t) prop_size; i++ )
           (void) ReadBlobByte(image);
 
         /*
-       long base = info->cp;
+       ssize_t base = info->cp;
        GimpParasite *p;
        while (info->cp - base < prop_size)
        {
@@ -866,7 +866,7 @@
         if (!amount)
           ThrowBinaryException(CorruptImageError,"CorruptImage",
             image->filename);
-        prop_size -= (unsigned long) MagickMin(16, (size_t) amount);
+        prop_size -= (size_t) MagickMin(16, (size_t) amount);
         }
       }
       break;
@@ -980,7 +980,7 @@
   MagickOffsetType
     offset;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -989,7 +989,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     image_type;
 
   XCFDocInfo
@@ -1048,7 +1048,7 @@
   while ((foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse))
   {
     PropType prop_type = (PropType) ReadBlobMSBLong(image);
-    unsigned long prop_size = ReadBlobMSBLong(image);
+    size_t prop_size = ReadBlobMSBLong(image);
 
     switch (prop_type)
     {
@@ -1060,8 +1060,8 @@
         /* Cannot rely on prop_size here--the value is set incorrectly
            by some Gimp versions.
         */
-        unsigned long num_colours = ReadBlobMSBLong(image);
-        for (i=0; i < (long) (3L*num_colours); i++ )
+        size_t num_colours = ReadBlobMSBLong(image);
+        for (i=0; i < (ssize_t) (3L*num_colours); i++ )
           (void) ReadBlobByte(image);
     /*
       if (info->file_version == 0)
@@ -1108,7 +1108,7 @@
       case PROP_GUIDES:
       {
          /* just skip it - we don't care about guides */
-        for (i=0; i < (long) prop_size; i++ )
+        for (i=0; i < (ssize_t) prop_size; i++ )
           if (ReadBlobByte(image) == EOF)
             ThrowFileException(exception,CorruptImageError,
               "UnexpectedEndOfFile",image->filename);
@@ -1142,20 +1142,20 @@
     case PROP_TATTOO:
       {
         /* we need to read it, even if we ignore it */
-        /*unsigned long  tattoo_state = */ (void) ReadBlobMSBLong(image);
+        /*size_t  tattoo_state = */ (void) ReadBlobMSBLong(image);
       }
       break;
 
     case PROP_PARASITES:
       {
         /* BOGUS: we may need these for IPTC stuff */
-        for (i=0; i < (long) prop_size; i++ )
+        for (i=0; i < (ssize_t) prop_size; i++ )
           if (ReadBlobByte(image) == EOF)
             ThrowFileException(exception,CorruptImageError,
               "UnexpectedEndOfFile",image->filename);
 
         /*
-      glong         base = info->cp;
+      gssize_t         base = info->cp;
       GimpParasite *p;
 
       while (info->cp - base < prop_size)
@@ -1173,14 +1173,14 @@
     case PROP_UNIT:
       {
         /* BOGUS: ignore for now... */
-      /*unsigned long unit =  */ (void) ReadBlobMSBLong(image);
+      /*size_t unit =  */ (void) ReadBlobMSBLong(image);
       }
       break;
 
     case PROP_PATHS:
       {
       /* BOGUS: just skip it for now */
-        for (i=0; i< (long) prop_size; i++ )
+        for (i=0; i< (ssize_t) prop_size; i++ )
           if (ReadBlobByte(image) == EOF)
             ThrowFileException(exception,CorruptImageError,
               "UnexpectedEndOfFile",image->filename);
@@ -1197,7 +1197,7 @@
         char  unit_string[1000];
         /*BOGUS: ignored for now */
         /*float  factor = (float) */ (void) ReadBlobMSBLong(image);
-        /* unsigned long digits =  */ (void) ReadBlobMSBLong(image);
+        /* size_t digits =  */ (void) ReadBlobMSBLong(image);
         for (i=0; i<5; i++)
          (void) ReadBlobStringWithLongSize(image, unit_string,
            sizeof(unit_string));
@@ -1207,16 +1207,16 @@
       default:
       {
         int buf[16];
-        long amount;
+        ssize_t amount;
 
       /* read over it... */
       while ((prop_size > 0) && (EOFBlob(image) == MagickFalse))
       {
-        amount=(long) MagickMin(16, prop_size);
-        amount=(long) ReadBlob(image,(size_t) amount,(unsigned char *) &buf);
+        amount=(ssize_t) MagickMin(16, prop_size);
+        amount=(ssize_t) ReadBlob(image,(size_t) amount,(unsigned char *) &buf);
         if (!amount)
           ThrowReaderException(CorruptImageError,"CorruptImage");
-        prop_size -= (unsigned long) MagickMin(16,(size_t) amount);
+        prop_size -= (size_t) MagickMin(16,(size_t) amount);
       }
     }
     break;
@@ -1247,7 +1247,7 @@
       */
       do
       {
-        long offset = (long) ReadBlobMSBLong(image);
+        ssize_t offset = (ssize_t) ReadBlobMSBLong(image);
         if (offset == 0)
           foundAllLayers=MagickTrue;
         else
@@ -1445,10 +1445,10 @@
 %
 %  The format of the RegisterXCFImage method is:
 %
-%      unsigned long RegisterXCFImage(void)
+%      size_t RegisterXCFImage(void)
 %
 */
-ModuleExport unsigned long RegisterXCFImage(void)
+ModuleExport size_t RegisterXCFImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/xpm.c b/coders/xpm.c
index 102cca6..99dad05 100644
--- a/coders/xpm.c
+++ b/coders/xpm.c
@@ -184,7 +184,7 @@
   register const char
     *q;
 
-  register long
+  register ssize_t
     i;
 
   static const char
@@ -225,7 +225,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -241,7 +241,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -257,7 +257,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     width;
 
   /*
@@ -349,7 +349,7 @@
   */
   i=1;
   next=NextXPMLine(xpm_buffer);
-  for (j=0; (j < (long) image->colors) && (next != (char*) NULL); j++)
+  for (j=0; (j < (ssize_t) image->colors) && (next != (char*) NULL); j++)
   {
     p=next;
     next=NextXPMLine(p);
@@ -382,7 +382,7 @@
     if (QueryColorDatabase(target,&image->colormap[j],exception) == MagickFalse)
       break;
   }
-  if (j < (long) image->colors)
+  if (j < (ssize_t) image->colors)
     ThrowReaderException(CorruptImageError,"CorruptImage");
   j=0;
   if (image_info->ping == MagickFalse)
@@ -390,7 +390,7 @@
       /*
         Read image pixels.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         p=NextXPMLine(p);
         if (p == (char *) NULL)
@@ -399,10 +399,10 @@
         if (r == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           (void) CopyXPMColor(key,p,(size_t) width);
-          j=(long) GetValueFromSplayTree(xpm_colors,key);
+          j=(ssize_t) GetValueFromSplayTree(xpm_colors,key);
           if (image->storage_class == PseudoClass)
             indexes[x]=(IndexPacket) j;
           *r=image->colormap[j];
@@ -412,7 +412,7 @@
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
           break;
       }
-      if (y < (long) image->rows)
+      if (y < (ssize_t) image->rows)
         ThrowReaderException(CorruptImageError,"NotEnoughPixelData");
     }
   /*
@@ -443,10 +443,10 @@
 %
 %  The format of the RegisterXPMImage method is:
 %
-%      unsigned long RegisterXPMImage(void)
+%      size_t RegisterXPMImage(void)
 %
 */
-ModuleExport unsigned long RegisterXPMImage(void)
+ModuleExport size_t RegisterXPMImage(void)
 {
   MagickInfo
     *entry;
@@ -587,7 +587,7 @@
   ImageInfo
     *blob_info;
 
-  long
+  ssize_t
     j,
     k,
     y;
@@ -611,14 +611,14 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
   register PixelPacket
     *q;
 
-  unsigned long
+  size_t
     characters_per_pixel,
     colors;
 
@@ -676,12 +676,12 @@
           /*
             Map all the transparent pixels.
           */
-          for (y=0; y < (long) picon->rows; y++)
+          for (y=0; y < (ssize_t) picon->rows; y++)
           {
             q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) picon->columns; x++)
+            for (x=0; x < (ssize_t) picon->columns; x++)
             {
               if (q->opacity == (Quantum) TransparentOpacity)
                 transparent=MagickTrue;
@@ -706,13 +706,13 @@
         picon->colormap,(size_t) colors,sizeof(*picon->colormap));
       if (picon->colormap == (PixelPacket *) NULL)
         ThrowWriterException(ResourceLimitError,"MemoryAllocationError");
-      for (y=0; y < (long) picon->rows; y++)
+      for (y=0; y < (ssize_t) picon->rows; y++)
       {
         q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(picon);
-        for (x=0; x < (long) picon->columns; x++)
+        for (x=0; x < (ssize_t) picon->columns; x++)
         {
           if (q->opacity == (Quantum) TransparentOpacity)
             indexes[x]=(IndexPacket) picon->colors;
@@ -726,7 +726,7 @@
     Compute the character per pixel.
   */
   characters_per_pixel=1;
-  for (k=MaxCixels; (long) colors > k; k*=MaxCixels)
+  for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)
     characters_per_pixel++;
   /*
     XPM header.
@@ -741,7 +741,7 @@
     picon->columns,picon->rows,colors,characters_per_pixel);
   (void) WriteBlobString(image,buffer);
   GetMagickPixelPacket(image,&pixel);
-  for (i=0; i < (long) colors; i++)
+  for (i=0; i < (ssize_t) colors; i++)
   {
     /*
       Define XPM color.
@@ -754,7 +754,7 @@
       &image->exception);
     if (transparent != MagickFalse)
       {
-        if (i == (long) (colors-1))
+        if (i == (ssize_t) (colors-1))
           (void) CopyMagickString(name,"grey75",MaxTextExtent);
       }
     /*
@@ -762,7 +762,7 @@
     */
     k=i % MaxCixels;
     symbol[0]=Cixel[k];
-    for (j=1; j < (long) characters_per_pixel; j++)
+    for (j=1; j < (ssize_t) characters_per_pixel; j++)
     {
       k=((i-k)/MaxCixels) % MaxCixels;
       symbol[j]=Cixel[k];
@@ -776,18 +776,18 @@
     Define XPM pixels.
   */
   (void) WriteBlobString(image,"/* pixels */\n");
-  for (y=0; y < (long) picon->rows; y++)
+  for (y=0; y < (ssize_t) picon->rows; y++)
   {
     p=GetVirtualPixels(picon,0,y,picon->columns,1,&picon->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(picon);
     (void) WriteBlobString(image,"\"");
-    for (x=0; x < (long) picon->columns; x++)
+    for (x=0; x < (ssize_t) picon->columns; x++)
     {
-      k=((long) indexes[x] % MaxCixels);
+      k=((ssize_t) indexes[x] % MaxCixels);
       symbol[0]=Cixel[k];
-      for (j=1; j < (long) characters_per_pixel; j++)
+      for (j=1; j < (ssize_t) characters_per_pixel; j++)
       {
         k=(((int) indexes[x]-k)/MaxCixels) % MaxCixels;
         symbol[j]=Cixel[k];
@@ -797,7 +797,7 @@
       (void) WriteBlobString(image,buffer);
     }
     (void) FormatMagickString(buffer,MaxTextExtent,"\"%s\n",
-      y == (long) (picon->rows-1) ? "" : ",");
+      y == (ssize_t) (picon->rows-1) ? "" : ",");
     (void) WriteBlobString(image,buffer);
     status=SetImageProgress(image,SaveImageTag,y,picon->rows);
     if (status == MagickFalse)
@@ -848,7 +848,7 @@
     name[MaxTextExtent],
     symbol[MaxTextExtent];
 
-  long
+  ssize_t
     j,
     k,
     opacity,
@@ -866,11 +866,11 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  unsigned long
+  size_t
     characters_per_pixel;
 
   /*
@@ -904,7 +904,7 @@
       */
       if ((image->storage_class == DirectClass) || (image->colors > 256))
         (void) SetImageType(image,PaletteBilevelMatteType);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         if (image->colormap[i].opacity != OpaqueOpacity)
           {
             if (opacity < 0)
@@ -922,7 +922,7 @@
       if (opacity == -1)
         {
           (void) SetImageType(image,PaletteBilevelMatteType);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             if (image->colormap[i].opacity != OpaqueOpacity)
               {
                 if (opacity < 0)
@@ -949,7 +949,7 @@
     Compute the character per pixel.
   */
   characters_per_pixel=1;
-  for (k=MaxCixels; (long) image->colors > k; k*=MaxCixels)
+  for (k=MaxCixels; (ssize_t) image->colors > k; k*=MaxCixels)
     characters_per_pixel++;
   /*
     XPM header.
@@ -972,7 +972,7 @@
     image->columns,image->rows,image->colors,characters_per_pixel);
   (void) WriteBlobString(image,buffer);
   GetMagickPixelPacket(image,&pixel);
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < (ssize_t) image->colors; i++)
   {
     /*
       Define XPM color.
@@ -990,7 +990,7 @@
     */
     k=i % MaxCixels;
     symbol[0]=Cixel[k];
-    for (j=1; j < (long) characters_per_pixel; j++)
+    for (j=1; j < (ssize_t) characters_per_pixel; j++)
     {
       k=((i-k)/MaxCixels) % MaxCixels;
       symbol[j]=Cixel[k];
@@ -1004,18 +1004,18 @@
     Define XPM pixels.
   */
   (void) WriteBlobString(image,"/* pixels */\n");
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
     (void) WriteBlobString(image,"\"");
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      k=((long) indexes[x] % MaxCixels);
+      k=((ssize_t) indexes[x] % MaxCixels);
       symbol[0]=Cixel[k];
-      for (j=1; j < (long) characters_per_pixel; j++)
+      for (j=1; j < (ssize_t) characters_per_pixel; j++)
       {
         k=(((int) indexes[x]-k)/MaxCixels) % MaxCixels;
         symbol[j]=Cixel[k];
@@ -1025,7 +1025,7 @@
       (void) WriteBlobString(image,buffer);
     }
     (void) FormatMagickString(buffer,MaxTextExtent,"\"%s\n",
-      (y == (long) (image->rows-1) ? "" : ","));
+      (y == (ssize_t) (image->rows-1) ? "" : ","));
     (void) WriteBlobString(image,buffer);
     if (image->previous == (Image *) NULL)
       {
diff --git a/coders/xps.c b/coders/xps.c
index 51a347c..29b9359 100644
--- a/coders/xps.c
+++ b/coders/xps.c
@@ -134,7 +134,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     c;
 
   SegmentInfo
@@ -143,7 +143,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -248,8 +248,8 @@
     /*
       Set XPS render geometry.
     */
-    width=(unsigned long) floor(bounds.x2-bounds.x1+0.5);
-    height=(unsigned long) floor(bounds.y2-bounds.y1+0.5);
+    width=(size_t) floor(bounds.x2-bounds.x1+0.5);
+    height=(size_t) floor(bounds.y2-bounds.y1+0.5);
     if (width > page.width)
       page.width=width;
     if (height > page.height)
@@ -279,8 +279,8 @@
     (void) ParseAbsoluteGeometry(PSPageGeometry,&page);
   if (image_info->page != (char *) NULL)
     (void) ParseAbsoluteGeometry(image_info->page,&page);
-  page.width=(unsigned long) floor(page.width*image->y_resolution/delta.x+0.5);
-  page.height=(unsigned long) floor(page.height*image->y_resolution/delta.y+
+  page.width=(size_t) floor(page.width*image->y_resolution/delta.x+0.5);
+  page.height=(size_t) floor(page.height*image->y_resolution/delta.y+
     0.5);
   (void) FormatMagickString(options,MaxTextExtent,"-g%lux%lu ",
     page.width,page.height);
@@ -361,10 +361,10 @@
 %
 %  The format of the RegisterXPSImage method is:
 %
-%      unsigned long RegisterXPSImage(void)
+%      size_t RegisterXPSImage(void)
 %
 */
-ModuleExport unsigned long RegisterXPSImage(void)
+ModuleExport size_t RegisterXPSImage(void)
 {
   MagickInfo
     *entry;
diff --git a/coders/xtrn.c b/coders/xtrn.c
index d264323..30f2f93 100644
--- a/coders/xtrn.c
+++ b/coders/xtrn.c
@@ -204,7 +204,7 @@
       size_t
         blob_length;
 
-                  long
+                  ssize_t
         lBoundl,
         lBoundu;
 
@@ -440,7 +440,7 @@
   SAFEARRAY *pSafeArray = (SAFEARRAY *)image->client_data;
   if (pSafeArray != NULL)
   {
-                long lBoundl, lBoundu, lCount;
+                ssize_t lBoundl, lBoundu, lCount;
           HRESULT hr = S_OK;
     /* First see how big the buffer currently is */
                 hr = SafeArrayGetLBound(pSafeArray, 1, &lBoundl);
@@ -455,7 +455,7 @@
     {
             unsigned char       *pReturnBuffer = NULL;
       NewArrayBounds[0].lLbound = 0;   /* Start-Index 0 */
-      NewArrayBounds[0].cElements = (unsigned long) (length+lCount);  /* # Elemente */
+      NewArrayBounds[0].cElements = (size_t) (length+lCount);  /* # Elemente */
       hr = SafeArrayRedim(pSafeArray, NewArrayBounds);
       if (FAILED(hr))
         return 0;
diff --git a/coders/xwd.c b/coders/xwd.c
index 7ae5691..f2133c7 100644
--- a/coders/xwd.c
+++ b/coders/xwd.c
@@ -162,7 +162,7 @@
   int
     x_status;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -174,16 +174,16 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  register unsigned long
+  register size_t
     pixel;
 
   size_t
@@ -192,7 +192,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     lsb_first;
 
   XColor
@@ -296,7 +296,7 @@
       colors=(XColor *) AcquireQuantumMemory(length,sizeof(*colors));
       if (colors == (XColor *) NULL)
         ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-      for (i=0; i < (long) header.ncolors; i++)
+      for (i=0; i < (ssize_t) header.ncolors; i++)
       {
         count=ReadBlob(image,sz_XWDColor,(unsigned char *) &color);
         if (count == 0)
@@ -314,7 +314,7 @@
       */
       lsb_first=1;
       if ((int) (*(char *) &lsb_first) != 0)
-        for (i=0; i < (long) header.ncolors; i++)
+        for (i=0; i < (ssize_t) header.ncolors; i++)
         {
           MSBOrderLong((unsigned char *) &colors[i].pixel,
             sizeof(colors[i].pixel));
@@ -347,8 +347,8 @@
   /*
     Convert image to MIFF format.
   */
-  image->columns=(unsigned long) ximage->width;
-  image->rows=(unsigned long) ximage->height;
+  image->columns=(size_t) ximage->width;
+  image->rows=(size_t) ximage->height;
   if ((colors == (XColor *) NULL) || (ximage->red_mask != 0) ||
       (ximage->green_mask != 0) || (ximage->blue_mask != 0))
     image->storage_class=DirectClass;
@@ -361,10 +361,10 @@
       case DirectClass:
       default:
       {
-        register unsigned long
+        register size_t
           color;
 
-        unsigned long
+        size_t
           blue_mask,
           blue_shift,
           green_mask,
@@ -400,20 +400,20 @@
           Convert X image to DirectClass packets.
         */
         if ((image->colors != 0) && (authentic_colormap != MagickFalse))
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               pixel=XGetPixel(ximage,(int) x,(int) y);
               index=(IndexPacket) ((pixel >> red_shift) & red_mask);
-              q->red=ScaleShortToQuantum(colors[(long) index].red);
+              q->red=ScaleShortToQuantum(colors[(ssize_t) index].red);
               index=(IndexPacket) ((pixel >> green_shift) & green_mask);
-              q->green=ScaleShortToQuantum(colors[(long) index].green);
+              q->green=ScaleShortToQuantum(colors[(ssize_t) index].green);
               index=(IndexPacket) ((pixel >> blue_shift) & blue_mask);
-              q->blue=ScaleShortToQuantum(colors[(long) index].blue);
+              q->blue=ScaleShortToQuantum(colors[(ssize_t) index].blue);
               q++;
             }
             if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -423,12 +423,12 @@
               break;
           }
         else
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               pixel=XGetPixel(ximage,(int) x,(int) y);
               color=(pixel >> red_shift) & red_mask;
@@ -457,24 +457,24 @@
         */
         if (AcquireImageColormap(image,image->colors) == MagickFalse)
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-        for (i=0; i < (long) image->colors; i++)
+        for (i=0; i < (ssize_t) image->colors; i++)
         {
           image->colormap[i].red=ScaleShortToQuantum(colors[i].red);
           image->colormap[i].green=ScaleShortToQuantum(colors[i].green);
           image->colormap[i].blue=ScaleShortToQuantum(colors[i].blue);
         }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
           indexes=GetAuthenticIndexQueue(image);
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             index=ConstrainColormapIndex(image,XGetPixel(ximage,(int) x,
               (int) y));
             indexes[x]=index;
-            *q++=image->colormap[(long) index];
+            *q++=image->colormap[(ssize_t) index];
           }
           if (SyncAuthenticPixels(image,exception) == MagickFalse)
             break;
@@ -520,10 +520,10 @@
 %
 %  The format of the RegisterXWDImage method is:
 %
-%      unsigned long RegisterXWDImage(void)
+%      size_t RegisterXWDImage(void)
 %
 */
-ModuleExport unsigned long RegisterXWDImage(void)
+ModuleExport size_t RegisterXWDImage(void)
 {
   MagickInfo
     *entry;
@@ -596,7 +596,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -608,10 +608,10 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -623,7 +623,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     bits_per_pixel,
     bytes_per_line,
     lsb_first,
@@ -665,7 +665,7 @@
   xwd_info.bitmap_unit=(CARD32) (image->storage_class == DirectClass ? 32 : 8);
   xwd_info.bitmap_bit_order=(CARD32) MSBFirst;
   xwd_info.bitmap_pad=(CARD32) (image->storage_class == DirectClass ? 32 : 8);
-  bits_per_pixel=(unsigned long) (image->storage_class == DirectClass ? 24 : 8);
+  bits_per_pixel=(size_t) (image->storage_class == DirectClass ? 24 : 8);
   xwd_info.bits_per_pixel=(CARD32) bits_per_pixel;
   bytes_per_line=(CARD32) ((((xwd_info.bits_per_pixel*
     xwd_info.pixmap_width)+((xwd_info.bitmap_pad)-1))/
@@ -714,9 +714,9 @@
         sizeof(*colors));
       if (colors == (XColor *) NULL)
         ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
-        colors[i].pixel=(unsigned long) i;
+        colors[i].pixel=(size_t) i;
         colors[i].red=ScaleQuantumToShort(image->colormap[i].red);
         colors[i].green=ScaleQuantumToShort(image->colormap[i].green);
         colors[i].blue=ScaleQuantumToShort(image->colormap[i].blue);
@@ -730,7 +730,7 @@
               3*sizeof(colors[i].red));
           }
       }
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         color.pixel=(CARD32) colors[i].pixel;
         color.red=colors[i].red;
@@ -755,7 +755,7 @@
     Convert MIFF to XWD raster pixels.
   */
   scanline_pad=(bytes_per_line-((image->columns*bits_per_pixel) >> 3));
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
     if (p == (const PixelPacket *) NULL)
@@ -764,18 +764,18 @@
     if (image->storage_class == PseudoClass)
       {
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           *q++=(unsigned char) indexes[x];
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
         *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
         *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
         p++;
       }
-    for (x=0; x < (long) scanline_pad; x++)
+    for (x=0; x < (ssize_t) scanline_pad; x++)
       *q++='\0';
     (void) WriteBlob(image,(size_t) (q-pixels),pixels);
     status=SetImageProgress(image,SaveImageTag,y,image->rows);
diff --git a/coders/ycbcr.c b/coders/ycbcr.c
index 12f21df..2686541 100644
--- a/coders/ycbcr.c
+++ b/coders/ycbcr.c
@@ -102,7 +102,7 @@
     *canvas_image,
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -120,7 +120,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -190,7 +190,7 @@
       */
       image->scene++;
       length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         count=ReadBlob(image,length,pixels);
         if (count != (ssize_t) length)
@@ -222,7 +222,7 @@
             length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -239,7 +239,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -248,7 +248,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -290,7 +290,7 @@
             length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           for (i=0; i < (image->matte != MagickFalse ? 4 : 3); i++)
           {
@@ -310,7 +310,7 @@
             if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
               break;
             if (((y-image->extract_info.y) >= 0) && 
-                ((y-image->extract_info.y) < (long) image->rows))
+                ((y-image->extract_info.y) < (ssize_t) image->rows))
               {
                 p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
                   0,canvas_image->columns,1,exception);
@@ -319,7 +319,7 @@
                 if ((p == (const PixelPacket *) NULL) ||
                     (q == (PixelPacket *) NULL))
                   break;
-                for (x=0; x < (long) image->columns; x++)
+                for (x=0; x < (ssize_t) image->columns; x++)
                 {
                   switch (quantum_type)
                   {
@@ -356,7 +356,7 @@
             length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
             count=ReadBlob(image,length,pixels);
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -373,7 +373,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -382,7 +382,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 p++;
@@ -399,7 +399,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -416,7 +416,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -425,7 +425,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
                 p++;
@@ -442,7 +442,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -459,7 +459,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -468,7 +468,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetBluePixelComponent(q,GetBluePixelComponent(p));
                 p++;
@@ -487,7 +487,7 @@
           }
         if (image->matte != MagickFalse)
           {
-            for (y=0; y < (long) image->extract_info.height; y++)
+            for (y=0; y < (ssize_t) image->extract_info.height; y++)
             {
               if (count != (ssize_t) length)
                 {
@@ -504,7 +504,7 @@
               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
                 break;
               if (((y-image->extract_info.y) >= 0) && 
-                  ((y-image->extract_info.y) < (long) image->rows))
+                  ((y-image->extract_info.y) < (ssize_t) image->rows))
                 {
                   p=GetVirtualPixels(canvas_image,
                     canvas_image->extract_info.x,0,canvas_image->columns,1,
@@ -514,7 +514,7 @@
                   if ((p == (const PixelPacket *) NULL) ||
                       (q == (PixelPacket *) NULL))
                     break;
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
                     p++;
@@ -561,8 +561,8 @@
               break;
             }
         length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -570,7 +570,7 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -587,7 +587,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -596,7 +596,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetRedPixelComponent(q,GetRedPixelComponent(p));
                 p++;
@@ -623,8 +623,8 @@
             return((Image *) NULL);
           }
         length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -632,7 +632,7 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -649,7 +649,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -658,7 +658,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
                 p++;
@@ -685,8 +685,8 @@
             return((Image *) NULL);
           }
         length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
-        for (i=0; i < (long) scene; i++)
-          for (y=0; y < (long) image->extract_info.height; y++)
+        for (i=0; i < (ssize_t) scene; i++)
+          for (y=0; y < (ssize_t) image->extract_info.height; y++)
             if (ReadBlob(image,length,pixels) != (ssize_t) length)
               {
                 ThrowFileException(exception,CorruptImageError,
@@ -694,7 +694,7 @@
                 break;
               }
         count=ReadBlob(image,length,pixels);
-        for (y=0; y < (long) image->extract_info.height; y++)
+        for (y=0; y < (ssize_t) image->extract_info.height; y++)
         {
           if (count != (ssize_t) length)
             {
@@ -711,7 +711,7 @@
           if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
             break;
           if (((y-image->extract_info.y) >= 0) && 
-              ((y-image->extract_info.y) < (long) image->rows))
+              ((y-image->extract_info.y) < (ssize_t) image->rows))
             {
               p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
                 canvas_image->columns,1,exception);
@@ -720,7 +720,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 SetBluePixelComponent(q,GetBluePixelComponent(p));
                 p++;
@@ -749,8 +749,8 @@
                 return((Image *) NULL);
               }
             length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
-            for (i=0; i < (long) scene; i++)
-              for (y=0; y < (long) image->extract_info.height; y++)
+            for (i=0; i < (ssize_t) scene; i++)
+              for (y=0; y < (ssize_t) image->extract_info.height; y++)
                 if (ReadBlob(image,length,pixels) != (ssize_t) length)
                   {
                     ThrowFileException(exception,CorruptImageError,
@@ -758,7 +758,7 @@
                     break;
                   }
             count=ReadBlob(image,length,pixels);
-            for (y=0; y < (long) image->extract_info.height; y++)
+            for (y=0; y < (ssize_t) image->extract_info.height; y++)
             {
               if (count != (ssize_t) length)
                 {
@@ -775,7 +775,7 @@
               if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
                 break;
               if (((y-image->extract_info.y) >= 0) && 
-                  ((y-image->extract_info.y) < (long) image->rows))
+                  ((y-image->extract_info.y) < (ssize_t) image->rows))
                 {
                   p=GetVirtualPixels(canvas_image,
                     canvas_image->extract_info.x,0,canvas_image->columns,1,
@@ -785,7 +785,7 @@
                   if ((p == (const PixelPacket *) NULL) ||
                       (q == (PixelPacket *) NULL))
                     break;
-                  for (x=0; x < (long) image->columns; x++)
+                  for (x=0; x < (ssize_t) image->columns; x++)
                   {
                     SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
                     p++;
@@ -865,10 +865,10 @@
 %
 %  The format of the RegisterYCBCRImage method is:
 %
-%      unsigned long RegisterYCBCRImage(void)
+%      size_t RegisterYCBCRImage(void)
 %
 */
-ModuleExport unsigned long RegisterYCBCRImage(void)
+ModuleExport size_t RegisterYCBCRImage(void)
 {
   MagickInfo
     *entry;
@@ -946,7 +946,7 @@
 static MagickBooleanType WriteYCBCRImage(const ImageInfo *image_info,
   Image *image)
 {
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1020,7 +1020,7 @@
         /*
           No interlacing:  YCbCrYCbCrYCbCrYCbCrYCbCrYCbCr...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1044,7 +1044,7 @@
         /*
           Line interlacing:  YYY...CbCbCb...CrCrCr...YYY...CbCbCb...CrCrCr...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1086,7 +1086,7 @@
         /*
           Plane interlacing:  YYYYYY...CbCbCbCbCbCb...CrCrCrCrCrCr...
         */
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1103,7 +1103,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1120,7 +1120,7 @@
             if (status == MagickFalse)
               break;
           }
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1139,7 +1139,7 @@
           }
         if (quantum_type == RGBAQuantum)
           {
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
@@ -1173,7 +1173,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1196,7 +1196,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1219,7 +1219,7 @@
           AppendBinaryBlobMode,&image->exception);
         if (status == MagickFalse)
           return(status);
-        for (y=0; y < (long) image->rows; y++)
+        for (y=0; y < (ssize_t) image->rows; y++)
         {
           p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
@@ -1244,7 +1244,7 @@
               AppendBinaryBlobMode,&image->exception);
             if (status == MagickFalse)
               return(status);
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               p=GetVirtualPixels(image,0,y,image->columns,1,
                 &image->exception);
diff --git a/coders/yuv.c b/coders/yuv.c
index fe524d6..b058fe6 100644
--- a/coders/yuv.c
+++ b/coders/yuv.c
@@ -105,7 +105,7 @@
   InterlaceType
     interlace;
 
-  long
+  ssize_t
     horizontal_factor,
     vertical_factor,
     y;
@@ -116,13 +116,13 @@
   register const PixelPacket
     *chroma_pixels;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -160,8 +160,8 @@
         flags;
 
       flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
-      horizontal_factor=(long) geometry_info.rho;
-      vertical_factor=(long) geometry_info.sigma;
+      horizontal_factor=(ssize_t) geometry_info.rho;
+      vertical_factor=(ssize_t) geometry_info.sigma;
       if ((flags & SigmaValue) == 0)
         vertical_factor=horizontal_factor;
       if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
@@ -227,7 +227,7 @@
             return((Image *) NULL);
           }
       }
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register PixelPacket
         *chroma_pixels;
@@ -244,7 +244,7 @@
             chroma_image->columns,1,exception);
           if (chroma_pixels == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x+=2)
+          for (x=0; x < (ssize_t) image->columns; x+=2)
           {
             chroma_pixels->red=(Quantum) 0;
             chroma_pixels->green=ScaleCharToQuantum(*p++);
@@ -268,7 +268,7 @@
           q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             q->red=ScaleCharToQuantum(*p++);
             q->green=0;
@@ -301,7 +301,7 @@
       }
     if (interlace != NoInterlace)
       {
-        for (y=0; y < (long) chroma_image->rows; y++)
+        for (y=0; y < (ssize_t) chroma_image->rows; y++)
         {
           count=ReadBlob(image,(size_t) chroma_image->columns,scanline);
           p=scanline;
@@ -309,7 +309,7 @@
             exception);
           if (q == (PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) chroma_image->columns; x++)
+          for (x=0; x < (ssize_t) chroma_image->columns; x++)
           {
             q->red=(Quantum) 0;
             q->green=ScaleCharToQuantum(*p++);
@@ -330,7 +330,7 @@
               return((Image *) NULL);
             }
         }
-      for (y=0; y < (long) chroma_image->rows; y++)
+      for (y=0; y < (ssize_t) chroma_image->rows; y++)
       {
         count=ReadBlob(image,(size_t) chroma_image->columns,scanline);
         p=scanline;
@@ -338,7 +338,7 @@
           exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) chroma_image->columns; x++)
+        for (x=0; x < (ssize_t) chroma_image->columns; x++)
         {
           q->blue=ScaleCharToQuantum(*p++);
           q++;
@@ -355,7 +355,7 @@
     chroma_image=DestroyImage(chroma_image);
     if (resize_image == (Image *) NULL)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
       chroma_pixels=GetVirtualPixels(resize_image,0,y,resize_image->columns,1,
@@ -363,7 +363,7 @@
       if ((q == (PixelPacket *) NULL) ||
           (chroma_pixels == (const PixelPacket *) NULL))
         break;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         q->green=chroma_pixels->green;
         q->blue=chroma_pixels->blue;
@@ -437,10 +437,10 @@
 %
 %  The format of the RegisterYUVImage method is:
 %
-%      unsigned long RegisterYUVImage(void)
+%      size_t RegisterYUVImage(void)
 %
 */
-ModuleExport unsigned long RegisterYUVImage(void)
+ModuleExport size_t RegisterYUVImage(void)
 {
   MagickInfo
     *entry;
@@ -515,7 +515,7 @@
   InterlaceType
     interlace;
 
-  long
+  ssize_t
     horizontal_factor,
     vertical_factor,
     y;
@@ -530,10 +530,10 @@
     *p,
     *s;
 
-  register long
+  register ssize_t
     x;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -555,8 +555,8 @@
         flags;
 
       flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
-      horizontal_factor=(long) geometry_info.rho;
-      vertical_factor=(long) geometry_info.sigma;
+      horizontal_factor=(ssize_t) geometry_info.rho;
+      vertical_factor=(ssize_t) geometry_info.sigma;
       if ((flags & SigmaValue) == 0)
         vertical_factor=horizontal_factor;
       if ((horizontal_factor != 1) && (horizontal_factor != 2) &&
@@ -613,7 +613,7 @@
         /*
           Write noninterlaced YUV.
         */
-        for (y=0; y < (long) yuv_image->rows; y++)
+        for (y=0; y < (ssize_t) yuv_image->rows; y++)
         {
           p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,
             &yuv_image->exception);
@@ -623,7 +623,7 @@
             &chroma_image->exception);
           if (s == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) yuv_image->columns; x++)
+          for (x=0; x < (ssize_t) yuv_image->columns; x++)
           {
             (void) WriteBlobByte(image,ScaleQuantumToChar(s->green));
             (void) WriteBlobByte(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
@@ -648,13 +648,13 @@
         /*
           Initialize Y channel.
         */
-        for (y=0; y < (long) yuv_image->rows; y++)
+        for (y=0; y < (ssize_t) yuv_image->rows; y++)
         {
           p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1,
             &yuv_image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) yuv_image->columns; x++)
+          for (x=0; x < (ssize_t) yuv_image->columns; x++)
           {
             (void) WriteBlobByte(image,ScaleQuantumToChar(GetRedPixelComponent(p)));
             p++;
@@ -685,13 +685,13 @@
             if (status == MagickFalse)
               return(status);
           }
-        for (y=0; y < (long) chroma_image->rows; y++)
+        for (y=0; y < (ssize_t) chroma_image->rows; y++)
         {
           p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,
             &chroma_image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) chroma_image->columns; x++)
+          for (x=0; x < (ssize_t) chroma_image->columns; x++)
           {
             (void) WriteBlobByte(image,ScaleQuantumToChar(GetGreenPixelComponent(p)));
             p++;
@@ -715,13 +715,13 @@
             if (status == MagickFalse)
               return(status);
           }
-        for (y=0; y < (long) chroma_image->rows; y++)
+        for (y=0; y < (ssize_t) chroma_image->rows; y++)
         {
           p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1,
             &chroma_image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) chroma_image->columns; x++)
+          for (x=0; x < (ssize_t) chroma_image->columns; x++)
           {
             (void) WriteBlobByte(image,ScaleQuantumToChar(GetBluePixelComponent(p)));
             p++;
diff --git a/config/configure.xml b/config/configure.xml
index dc0c95b..459b653 100644
--- a/config/configure.xml
+++ b/config/configure.xml
@@ -9,7 +9,7 @@
   <configure name="NAME" value="ImageMagick"/>
   <configure name="LIB_VERSION" value="0x662"/>
   <configure name="LIB_VERSION_NUMBER" value="6,6,2,1"/>
-  <configure name="RELEASE_DATE" value="2010-05-23"/>
+  <configure name="RELEASE_DATE" value="2010-05-27"/>
   <configure name="CONFIGURE" value="./configure "/>
   <configure name="PREFIX" value="/usr/local"/>
   <configure name="EXEC-PREFIX" value="/usr/local"/>
diff --git a/filters/analyze.c b/filters/analyze.c
index ce8a649..cc3b882 100644
--- a/filters/analyze.c
+++ b/filters/analyze.c
@@ -61,7 +61,7 @@
 %
 %  The format of the analyzeImage method is:
 %
-%      unsigned long analyzeImage(Image *images,const int argc,
+%      size_t analyzeImage(Image *images,const int argc,
 %        char **argv,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -77,7 +77,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-ModuleExport unsigned long analyzeImage(Image **images,const int argc,
+ModuleExport size_t analyzeImage(Image **images,const int argc,
   const char **argv,ExceptionInfo *exception)
 {
   char
@@ -119,7 +119,7 @@
     CacheView
       *image_view;
 
-    long
+    ssize_t
       y;
 
     MagickBooleanType
@@ -147,12 +147,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
     #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register const PixelPacket
         *p;
 
-      register long
+      register ssize_t
         x;
 
       if (status == MagickFalse)
@@ -163,7 +163,7 @@
           status=MagickFalse;
           continue;
         }
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         ConvertRGBToHSB(p->red,p->green,p->blue,&hue,&saturation,&brightness);
         brightness*=QuantumRange;
diff --git a/index.html b/index.html
index 46d6d8f..0f1542d 100644
--- a/index.html
+++ b/index.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -223,7 +223,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/ltdl/argz.c b/ltdl/argz.c
index 8567723..857c901 100644
--- a/ltdl/argz.c
+++ b/ltdl/argz.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/argz_.h b/ltdl/argz_.h
index 0557575..45fdde2 100644
--- a/ltdl/argz_.h
+++ b/ltdl/argz_.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/ltdl/libltdl/lt__alloc.h b/ltdl/libltdl/lt__alloc.h
index 1ceddf0..75384b0 100644
--- a/ltdl/libltdl/lt__alloc.h
+++ b/ltdl/libltdl/lt__alloc.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/ltdl/libltdl/lt__dirent.h b/ltdl/libltdl/lt__dirent.h
index 4f24f82..4fc496b 100644
--- a/ltdl/libltdl/lt__dirent.h
+++ b/ltdl/libltdl/lt__dirent.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/ltdl/libltdl/lt__glibc.h b/ltdl/libltdl/lt__glibc.h
index f284773..a8bbaa3 100644
--- a/ltdl/libltdl/lt__glibc.h
+++ b/ltdl/libltdl/lt__glibc.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/ltdl/libltdl/lt__private.h b/ltdl/libltdl/lt__private.h
index f4c4a3d..4076c67 100644
--- a/ltdl/libltdl/lt__private.h
+++ b/ltdl/libltdl/lt__private.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy con be downloaded from http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
diff --git a/ltdl/libltdl/lt__strl.h b/ltdl/libltdl/lt__strl.h
index 5799dc8..c5cf28e 100644
--- a/ltdl/libltdl/lt__strl.h
+++ b/ltdl/libltdl/lt__strl.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/libltdl/lt_dlloader.h b/ltdl/libltdl/lt_dlloader.h
index ae131fa..df598ff 100644
--- a/ltdl/libltdl/lt_dlloader.h
+++ b/ltdl/libltdl/lt_dlloader.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/libltdl/lt_error.h b/ltdl/libltdl/lt_error.h
index e789b3a..67052b5 100644
--- a/ltdl/libltdl/lt_error.h
+++ b/ltdl/libltdl/lt_error.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -36,7 +36,7 @@
 
 LT_BEGIN_C_DECLS
 
-/* Defining error strings alongside their symbolic names in a macro in
+/* Defining error strings assize_tside their symbolic names in a macro in
    this way allows us to expand the macro in different contexts with
    confidence that the enumeration of symbolic names will map correctly
    onto the table of error strings.  \0 is appended to the strings to
diff --git a/ltdl/libltdl/lt_system.h b/ltdl/libltdl/lt_system.h
index dab2ab6..549c328 100644
--- a/ltdl/libltdl/lt_system.h
+++ b/ltdl/libltdl/lt_system.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/libltdl/slist.h b/ltdl/libltdl/slist.h
index e4b7ead..e653bad 100644
--- a/ltdl/libltdl/slist.h
+++ b/ltdl/libltdl/slist.h
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/loaders/dld_link.c b/ltdl/loaders/dld_link.c
index 7e882c9..b3782f4 100644
--- a/ltdl/loaders/dld_link.c
+++ b/ltdl/loaders/dld_link.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -95,7 +95,7 @@
 #endif
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/loaders/dlopen.c b/ltdl/loaders/dlopen.c
index 1d052b4..c986747 100644
--- a/ltdl/loaders/dlopen.c
+++ b/ltdl/loaders/dlopen.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -150,7 +150,7 @@
 
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/loaders/dyld.c b/ltdl/loaders/dyld.c
index b139d6c..e8e79e8 100644
--- a/ltdl/loaders/dyld.c
+++ b/ltdl/loaders/dyld.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -171,10 +171,10 @@
 static NSSymbol lt__linkedlib_symbol (const char *symname, const mach_header *mh);
 
 static const mach_header *(*lt__addimage)	(const char *image_name,
-						 unsigned long options) = 0;
+						 size_t options) = 0;
 static NSSymbol	(*lt__image_symbol)		(const mach_header *image,
 						 const char *symbolName,
-						 unsigned long options) = 0;
+						 size_t options) = 0;
 static enum DYLD_BOOL (*lt__image_symbol_p)	(const mach_header *image,
 						 const char *symbolName) = 0;
 static enum DYLD_BOOL (*lt__module_export)	(NSModule module) = 0;
@@ -183,7 +183,7 @@
 
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
@@ -206,13 +206,13 @@
       else
 	{
 	  (void) _dyld_func_lookup ("__dyld_NSAddImage",
-				    (unsigned long*) &lt__addimage);
+				    (size_t*) &lt__addimage);
 	  (void) _dyld_func_lookup ("__dyld_NSLookupSymbolInImage",
-				    (unsigned long*)&lt__image_symbol);
+				    (size_t*)&lt__image_symbol);
 	  (void) _dyld_func_lookup ("__dyld_NSIsSymbolNameDefinedInImage",
-				    (unsigned long*) &lt__image_symbol_p);
+				    (size_t*) &lt__image_symbol_p);
 	  (void) _dyld_func_lookup ("__dyld_NSMakePrivateModulePublic",
-				    (unsigned long*) &lt__module_export);
+				    (size_t*) &lt__module_export);
 	  dyld_cannot_close = lt_dladderror ("can't close a dylib");
 	}
     }
@@ -328,7 +328,7 @@
   if (module == (lt_module) -1)
     {
       void *address, *unused;
-      _dyld_lookup_and_bind (name, (unsigned long*) &address, &unused);
+      _dyld_lookup_and_bind (name, (size_t*) &address, &unused);
       return address;
     }
 
@@ -423,7 +423,7 @@
 static const char *
 lt__header_get_instnam (const mach_header *mh)
 {
-  unsigned long offset = sizeof(mach_header);
+  size_t offset = sizeof(mach_header);
   const char* result   = 0;
   int j;
 
@@ -431,11 +431,11 @@
     {
       struct load_command *lc;
 
-      lc = (struct load_command*) (((unsigned long) mh) + offset);
+      lc = (struct load_command*) (((size_t) mh) + offset);
       if (LC_ID_DYLIB == lc->cmd)
 	{
 	  result=(char*)(((dylib_command*) lc)->dylib.name.offset +
-			 (unsigned long) lc);
+			 (size_t) lc);
 	}
       offset += lc->cmdsize;
     }
@@ -473,17 +473,17 @@
 
   if (lt__image_symbol && NSIsSymbolNameDefined (symname))
     {
-      unsigned long offset = sizeof(mach_header);
+      size_t offset = sizeof(mach_header);
       struct load_command *lc;
       int j;
 
       for (j = 0; j < mh->ncmds; j++)
 	{
-	  lc = (struct load_command*) (((unsigned long) mh) + offset);
+	  lc = (struct load_command*) (((size_t) mh) + offset);
 	  if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd))
 	    {
-	      unsigned long base = ((dylib_command *) lc)->dylib.name.offset;
-	      char *name = (char *) (base + (unsigned long) lc);
+	      size_t base = ((dylib_command *) lc)->dylib.name.offset;
+	      char *name = (char *) (base + (size_t) lc);
 	      const mach_header *mh1 = lt__match_loadedlib (name);
 
 	      if (!mh1)
diff --git a/ltdl/loaders/load_add_on.c b/ltdl/loaders/load_add_on.c
index 379f9ba..9b1952e 100644
--- a/ltdl/loaders/load_add_on.c
+++ b/ltdl/loaders/load_add_on.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -93,7 +93,7 @@
 #include <kernel/image.h>
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/loaders/loadlibrary.c b/ltdl/loaders/loadlibrary.c
index 5644676..fd584ef 100644
--- a/ltdl/loaders/loadlibrary.c
+++ b/ltdl/loaders/loadlibrary.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -99,7 +99,7 @@
 #include <windows.h>
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/loaders/preopen.c b/ltdl/loaders/preopen.c
index 7149287..74b5cd7 100644
--- a/ltdl/loaders/preopen.c
+++ b/ltdl/loaders/preopen.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -128,7 +128,7 @@
 
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/loaders/shl_load.c b/ltdl/loaders/shl_load.c
index 5a09d87..386477c 100644
--- a/ltdl/loaders/shl_load.c
+++ b/ltdl/loaders/shl_load.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -136,7 +136,7 @@
 
 
 /* A function called through the vtable when this loader is no
-   longer needed by the application.  */
+   ssize_ter needed by the application.  */
 static int
 vl_exit (lt_user_data LT__UNUSED loader_data)
 {
diff --git a/ltdl/lt__alloc.c b/ltdl/lt__alloc.c
index d39e17e..28e04c7 100644
--- a/ltdl/lt__alloc.c
+++ b/ltdl/lt__alloc.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/lt__dirent.c b/ltdl/lt__dirent.c
index 30dc072..48469cd 100644
--- a/ltdl/lt__dirent.c
+++ b/ltdl/lt__dirent.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/lt__strl.c b/ltdl/lt__strl.c
index c2cee58..e174463 100644
--- a/ltdl/lt__strl.c
+++ b/ltdl/lt__strl.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -37,7 +37,7 @@
  lt_strlcat appends the NULL-terminated string src to the end of dst.
  It will append at most dstsize - strlen(dst) - 1 bytes,
  NULL-terminating the result. The total length of the string which
- would have been created given sufficient buffer size (may be longer
+ would have been created given sufficient buffer size (may be ssize_ter
  than dstsize) is returned.  This function substitutes for strlcat()
  which is available under NetBSD, FreeBSD and Solaris 9.
 
@@ -85,7 +85,7 @@
   lt_strlcpy copies up to dstsize - 1 characters from the NULL-terminated
   string src to dst, NULL-terminating the result. The total length of
   the string which would have been created given sufficient buffer
-  size (may be longer than dstsize) is returned. This function
+  size (may be ssize_ter than dstsize) is returned. This function
   substitutes for strlcpy() which is available under OpenBSD, FreeBSD
   and Solaris 9.
 
diff --git a/ltdl/lt_dlloader.c b/ltdl/lt_dlloader.c
index 4e66a6c..3a52287 100644
--- a/ltdl/lt_dlloader.c
+++ b/ltdl/lt_dlloader.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/lt_error.c b/ltdl/lt_error.c
index d7af36d..7634ba7 100644
--- a/ltdl/lt_error.c
+++ b/ltdl/lt_error.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/ltdl.c b/ltdl/ltdl.c
index 7c42635..8c6aae5 100644
--- a/ltdl/ltdl.c
+++ b/ltdl/ltdl.c
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -1039,7 +1039,7 @@
 	}
 
       /* Handle the case where we occasionally need to read a line
-	 that is longer than the initial buffer size.
+	 that is ssize_ter than the initial buffer size.
 	 Behave even if the file contains NUL bytes due to corruption. */
       while (line[line_len-2] != '\0' && line[line_len-2] != '\n' && !feof (file))
 	{
@@ -1844,7 +1844,7 @@
 }
 
 
-/* Call FUNC for each unique extensionless file in SEARCH_PATH, along
+/* Call FUNC for each unique extensionless file in SEARCH_PATH, assize_t
    with DATA.  The filenames passed to FUNC would be suitable for
    passing to lt_dlopenext.  The extensions are stripped so that
    individual modules do not generate several entries (e.g. libfoo.la,
diff --git a/ltdl/ltdl.h b/ltdl/ltdl.h
index 8b516ad..9ea3ffd 100644
--- a/ltdl/ltdl.h
+++ b/ltdl/ltdl.h
@@ -23,7 +23,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
diff --git a/ltdl/slist.c b/ltdl/slist.c
index c99f399..1f66008 100644
--- a/ltdl/slist.c
+++ b/ltdl/slist.c
@@ -22,7 +22,7 @@
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public
-License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
+License assize_t with GNU Libltdl; see the file COPYING.LIB.  If not, a
 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
 or obtained by writing to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -185,7 +185,7 @@
 }
 
 /* Return a list starting at the Nth item of SLIST.  If SLIST is less
-   than N items long, NULL is returned.  Just to be confusing, list items
+   than N items ssize_t, NULL is returned.  Just to be confusing, list items
    are counted from 1, to get the 2nd element of slist:
 
    e.g. shared_list = slist_nth (slist, 2);  */
@@ -296,7 +296,7 @@
 }
 
 /* Perform a destructive quicksort on the items in SLIST, by repeatedly
-   calling COMPARE with a pair of items from SLIST along with USERDATA
+   calling COMPARE with a pair of items from SLIST assize_t with USERDATA
    at every iteration.  COMPARE is a function as defined above for
    slist_sort_merge().  The value of SLIST is undefined after calling
    this function.
@@ -315,7 +315,7 @@
   right = slist->next;
 
   /* Skip two items with RIGHT and one with SLIST, until RIGHT falls off
-     the end.  SLIST must be about half way along.  */
+     the end.  SLIST must be about half way assize_t.  */
   while (right && (right = right->next))
     {
       if (!right || !(right = right->next))
diff --git a/magick/PreRvIcccm.c b/magick/PreRvIcccm.c
index 2b0a2b5..5f714cc 100644
--- a/magick/PreRvIcccm.c
+++ b/magick/PreRvIcccm.c
@@ -156,7 +156,7 @@
   return((XWMHints *) AcquireAlignedMemory(1,sizeof(XWMHints)));
 }
 
-Status XGetGCValues(Display *display,GC gc,unsigned long mask,
+Status XGetGCValues(Display *display,GC gc,size_t mask,
   XGCValues *values)
 {
   return(MagickTrue);
@@ -181,7 +181,7 @@
     actual_format,
     status;
 
-  unsigned long
+  size_t
     leftover,
     number_items;
 
@@ -276,7 +276,7 @@
      protocol;
 
   number_bytes=0;
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
     number_bytes+=(unsigned int) ((argv[i] ? strlen(argv[i]) : 0)+1);
   protocol.encoding=XA_STRING;
   protocol.format=8;
@@ -301,7 +301,7 @@
       if (buffer == (char *) NULL)
         return(MagickFalse);
       protocol.value=(unsigned char *) buffer;
-      for (i=0; i < (long) argc; i++)
+      for (i=0; i < (ssize_t) argc; i++)
       {
         char
           *argument;
diff --git a/magick/PreRvIcccm.h b/magick/PreRvIcccm.h
index 3ec03e4..0b26400 100644
--- a/magick/PreRvIcccm.h
+++ b/magick/PreRvIcccm.h
@@ -65,7 +65,7 @@
   int
     format;
 
-  unsigned long
+  size_t
     nitems;
 } XTextProperty;
 
diff --git a/magick/accelerate.c b/magick/accelerate.c
index 1c2f456..10470c5 100644
--- a/magick/accelerate.c
+++ b/magick/accelerate.c
@@ -131,9 +131,9 @@
   "-DQuantumRange=%g -DMagickEpsilon=%g"
 #define CLPixelPacket  cl_uint4
 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
-#define CLOptions "-DCLQuantum=ulong -DCLPixelType=ulong4 " \
+#define CLOptions "-DCLQuantum=ussize_t -DCLPixelType=ussize_t4 " \
   "-DQuantumRange=%g -DMagickEpsilon=%g"
-#define CLPixelPacket  cl_ulong4
+#define CLPixelPacket  cl_ussize_t4
 #endif
 #endif
 
@@ -158,7 +158,7 @@
     pixels,
     convolve_pixels;
 
-  cl_ulong
+  cl_ussize_t
     width,
     height;
 
@@ -171,12 +171,12 @@
 
 static char
   *ConvolveKernel =
-    "static inline long ClampToCanvas(const long offset,const ulong range)\n"
+    "static inline ssize_t ClampToCanvas(const ssize_t offset,const ussize_t range)\n"
     "{\n"
     "  if (offset < 0L)\n"
     "    return(0L);\n"
     "  if (offset >= range)\n"
-    "    return((long) (range-1L));\n"
+    "    return((ssize_t) (range-1L));\n"
     "  return(offset);\n"
     "}\n"
     "\n"
@@ -194,21 +194,21 @@
     "}\n"
     "\n"
     "__kernel void Convolve(const __global CLPixelType *input,\n"
-    "  __constant double *filter,const ulong width,const ulong height,\n"
+    "  __constant double *filter,const ussize_t width,const ussize_t height,\n"
     "  const bool matte,__global CLPixelType *output)\n"
     "{\n"
-    "  const ulong columns = get_global_size(0);\n"
-    "  const ulong rows = get_global_size(1);\n"
+    "  const ussize_t columns = get_global_size(0);\n"
+    "  const ussize_t rows = get_global_size(1);\n"
     "\n"
-    "  const long x = get_global_id(0);\n"
-    "  const long y = get_global_id(1);\n"
+    "  const ssize_t x = get_global_id(0);\n"
+    "  const ssize_t y = get_global_id(1);\n"
     "\n"
     "  const double scale = (1.0/QuantumRange);\n"
-    "  const long mid_width = (width-1)/2;\n"
-    "  const long mid_height = (height-1)/2;\n"
+    "  const ssize_t mid_width = (width-1)/2;\n"
+    "  const ssize_t mid_height = (height-1)/2;\n"
     "  double4 sum = { 0.0, 0.0, 0.0, 0.0 };\n"
     "  double gamma = 0.0;\n"
-    "  register ulong i = 0;\n"
+    "  register ussize_t i = 0;\n"
     "\n"
     "  int method = 0;\n"
     "  if (matte != false)\n"
@@ -224,11 +224,11 @@
     "  {\n"
     "    case 0:\n"
     "    {\n"
-    "      for (long v=(-mid_height); v <= mid_height; v++)\n"
+    "      for (ssize_t v=(-mid_height); v <= mid_height; v++)\n"
     "      {\n"
-    "        for (long u=(-mid_width); u <= mid_width; u++)\n"
+    "        for (ssize_t u=(-mid_width); u <= mid_width; u++)\n"
     "        {\n"
-    "          const long index=ClampToCanvas(y+v,rows)*columns+\n"
+    "          const ssize_t index=ClampToCanvas(y+v,rows)*columns+\n"
     "            ClampToCanvas(x+u,columns);\n"
     "          sum.x+=filter[i]*input[index].x;\n"
     "          sum.y+=filter[i]*input[index].y;\n"
@@ -241,11 +241,11 @@
     "    }\n"
     "    case 1:\n"
     "    {\n"
-    "      for (long v=(-mid_height); v <= mid_height; v++)\n"
+    "      for (ssize_t v=(-mid_height); v <= mid_height; v++)\n"
     "      {\n"
-    "        for (long u=(-mid_width); u <= mid_width; u++)\n"
+    "        for (ssize_t u=(-mid_width); u <= mid_width; u++)\n"
     "        {\n"
-    "          const ulong index=ClampToCanvas(y+v,rows)*columns+\n"
+    "          const ussize_t index=ClampToCanvas(y+v,rows)*columns+\n"
     "            ClampToCanvas(x+u,columns);\n"
     "          const double alpha=scale*(QuantumRange-input[index].w);\n"
     "          sum.x+=alpha*filter[i]*input[index].x;\n"
@@ -260,11 +260,11 @@
     "    }\n"
     "    case 2:\n"
     "    {\n"
-    "      for (long v=(-mid_height); v <= mid_height; v++)\n"
+    "      for (ssize_t v=(-mid_height); v <= mid_height; v++)\n"
     "      {\n"
-    "        for (long u=(-mid_width); u <= mid_width; u++)\n"
+    "        for (ssize_t u=(-mid_width); u <= mid_width; u++)\n"
     "        {\n"
-    "          const ulong index=(y+v)*columns+(x+u);\n"
+    "          const ussize_t index=(y+v)*columns+(x+u);\n"
     "          sum.x+=filter[i]*input[index].x;\n"
     "          sum.y+=filter[i]*input[index].y;\n"
     "          sum.z+=filter[i]*input[index].z;\n"
@@ -276,11 +276,11 @@
     "    }\n"
     "    case 3:\n"
     "    {\n"
-    "      for (long v=(-mid_height); v <= mid_height; v++)\n"
+    "      for (ssize_t v=(-mid_height); v <= mid_height; v++)\n"
     "      {\n"
-    "        for (long u=(-mid_width); u <= mid_width; u++)\n"
+    "        for (ssize_t u=(-mid_width); u <= mid_width; u++)\n"
     "        {\n"
-    "          const ulong index=(y+v)*columns+(x+u);\n"
+    "          const ussize_t index=(y+v)*columns+(x+u);\n"
     "          const double alpha=scale*(QuantumRange-input[index].w);\n"
     "          sum.x+=alpha*filter[i]*input[index].x;\n"
     "          sum.y+=alpha*filter[i]*input[index].y;\n"
@@ -294,7 +294,7 @@
     "    }\n"
     "  }\n"
     "  gamma=1.0/(fabs(gamma) <= MagickEpsilon ? 1.0 : gamma);\n"
-    "  const ulong index = y*columns+x;\n"
+    "  const ussize_t index = y*columns+x;\n"
     "  output[index].x=ClampToQuantum(gamma*sum.x);\n"
     "  output[index].y=ClampToQuantum(gamma*sum.y);\n"
     "  output[index].z=ClampToQuantum(gamma*sum.z);\n"
@@ -319,7 +319,7 @@
 
 static MagickBooleanType BindConvolveParameters(ConvolveInfo *convolve_info,
   const Image *image,const void *pixels,double *filter,
-  const unsigned long width,const unsigned long height,void *convolve_pixels)
+  const size_t width,const size_t height,void *convolve_pixels)
 {
   cl_int
     status;
@@ -362,13 +362,13 @@
     &convolve_info->filter);
   if (status != CL_SUCCESS)
     return(MagickFalse);
-  convolve_info->width=(cl_ulong) width;
-  status=clSetKernelArg(convolve_info->kernel,i++,sizeof(cl_ulong),(void *)
+  convolve_info->width=(cl_ussize_t) width;
+  status=clSetKernelArg(convolve_info->kernel,i++,sizeof(cl_ussize_t),(void *)
     &convolve_info->width);
   if (status != CL_SUCCESS)
     return(MagickFalse);
-  convolve_info->height=(cl_ulong) height;
-  status=clSetKernelArg(convolve_info->kernel,i++,sizeof(cl_ulong),(void *)
+  convolve_info->height=(cl_ussize_t) height;
+  status=clSetKernelArg(convolve_info->kernel,i++,sizeof(cl_ussize_t),(void *)
     &convolve_info->height);
   if (status != CL_SUCCESS)
     return(MagickFalse);
@@ -419,7 +419,7 @@
 
 static MagickBooleanType EnqueueConvolveKernel(ConvolveInfo *convolve_info,
   const Image *image,const void *pixels,double *filter,
-  const unsigned long width,const unsigned long height,void *convolve_pixels)
+  const size_t width,const size_t height,void *convolve_pixels)
 {
   cl_int
     status;
diff --git a/magick/animate.c b/magick/animate.c
index 47376f8..c6c96da 100644
--- a/magick/animate.c
+++ b/magick/animate.c
@@ -630,7 +630,7 @@
     }
     case VersionCommand:
     {
-      XNoticeWidget(display,windows,GetMagickVersion((unsigned long *) NULL),
+      XNoticeWidget(display,windows,GetMagickVersion((size_t *) NULL),
         GetMagickCopyright());
       break;
     }
@@ -694,7 +694,7 @@
 %
 */
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
@@ -741,7 +741,7 @@
   RectangleInfo
     geometry_info;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -763,7 +763,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     delay;
 
   Window
@@ -829,7 +829,7 @@
         ThrowXWindowFatalException(ResourceLimitError,"MemoryAllocationFailed",
           images->filename);
       map_info->colormap=(Colormap) NULL;
-      pixel.pixels=(unsigned long *) NULL;
+      pixel.pixels=(size_t *) NULL;
       /*
         Initialize visual info.
       */
@@ -872,12 +872,12 @@
           next->matte=MagickFalse;
           if ((next->storage_class == DirectClass) ||
               (next->colors != images->colors) ||
-              (next->colors > (unsigned long) visual_info->colormap_size))
+              (next->colors > (size_t) visual_info->colormap_size))
             break;
-          for (i=0; i < (long) images->colors; i++)
+          for (i=0; i < (ssize_t) images->colors; i++)
             if (IsColorEqual(next->colormap+i,images->colormap+i) == MagickFalse)
               break;
-          if (i < (long) images->colors)
+          if (i < (ssize_t) images->colors)
             break;
           next=GetNextImageInList(next);
         }
@@ -892,10 +892,10 @@
   if (image_list == (Image **) NULL)
     ThrowXWindowFatalException(ResourceLimitFatalError,
       "MemoryAllocationFailed",images->filename);
-  for (i=0; i < (long) number_scenes; i++)
+  for (i=0; i < (ssize_t) number_scenes; i++)
     if (image_list[i]->scene == 0)
       break;
-  if (i == (long) number_scenes)
+  if (i == (ssize_t) number_scenes)
     qsort((void *) image_list,number_scenes,sizeof(Image *),SceneCompare);
   /*
     Initialize Standard Colormap.
@@ -924,7 +924,7 @@
   */
   context_values.background=pixel.background_color.pixel;
   context_values.foreground=pixel.foreground_color.pixel;
-  pixel.annotate_context=XCreateGC(display,window_info.id,(unsigned long)
+  pixel.annotate_context=XCreateGC(display,window_info.id,(size_t)
     GCBackground | GCForeground,&context_values);
   if (pixel.annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
@@ -1308,7 +1308,7 @@
   int
     status;
 
-  long
+  ssize_t
     first_scene,
     iterations,
     scene;
@@ -1326,13 +1326,13 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   static char
     working_directory[MaxTextExtent];
 
-  static unsigned long
+  static size_t
     number_windows;
 
   static XWindowInfo
@@ -1341,7 +1341,7 @@
   time_t
     timestamp;
 
-  unsigned long
+  size_t
     delay,
     number_scenes;
 
@@ -1443,7 +1443,7 @@
       magick_windows[number_windows++]=(&windows->command);
       magick_windows[number_windows++]=(&windows->widget);
       magick_windows[number_windows++]=(&windows->popup);
-      for (i=0; i < (long) number_windows; i++)
+      for (i=0; i < (ssize_t) number_windows; i++)
         magick_windows[i]->id=(Window) NULL;
     }
   /*
@@ -1489,12 +1489,12 @@
           next->matte=MagickFalse;
           if ((next->storage_class == DirectClass) ||
               (next->colors != images->colors) ||
-              (next->colors > (unsigned long) visual_info->colormap_size))
+              (next->colors > (size_t) visual_info->colormap_size))
             break;
-          for (i=0; i < (long) images->colors; i++)
+          for (i=0; i < (ssize_t) images->colors; i++)
             if (IsColorEqual(next->colormap+i,images->colormap+i) == MagickFalse)
               break;
-          if (i < (long) images->colors)
+          if (i < (ssize_t) images->colors)
             break;
           next=GetNextImageInList(next);
         }
@@ -1510,17 +1510,17 @@
   if (image_list == (Image **) NULL)
     ThrowXWindowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
       images->filename);
-  for (scene=0; scene < (long) number_scenes; scene++)
+  for (scene=0; scene < (ssize_t) number_scenes; scene++)
     if (image_list[scene]->scene == 0)
       break;
-  if (scene == (long) number_scenes)
+  if (scene == (ssize_t) number_scenes)
     qsort((void *) image_list,number_scenes,sizeof(Image *),SceneCompare);
   /*
     Initialize Standard Colormap.
   */
   nexus=NewImageList();
   display_image=image_list[0];
-  for (scene=0; scene < (long) number_scenes; scene++)
+  for (scene=0; scene < (ssize_t) number_scenes; scene++)
   {
     if ((resource_info->map_type != (char *) NULL) ||
         (visual_info->klass == TrueColor) ||
@@ -1589,7 +1589,7 @@
   if (pixel->highlight_context != (GC) NULL)
     (void) XFreeGC(display,pixel->highlight_context);
   pixel->highlight_context=XCreateGC(display,windows->context.id,
-    (unsigned long) (context_mask | GCPlaneMask),&context_values);
+    (size_t) (context_mask | GCPlaneMask),&context_values);
   if (pixel->highlight_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       images->filename);
@@ -1620,7 +1620,7 @@
   context_values.background=icon_pixel->background_color.pixel;
   context_values.foreground=icon_pixel->foreground_color.pixel;
   icon_pixel->annotate_context=XCreateGC(display,windows->icon.id,
-    (unsigned long) (GCBackground | GCForeground),&context_values);
+    (size_t) (GCBackground | GCForeground),&context_values);
   if (icon_pixel->annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       images->filename);
@@ -1687,7 +1687,7 @@
       windows->backdrop.x=0;
       windows->backdrop.y=0;
       (void) CloneString(&windows->backdrop.name,"ImageMagick Backdrop");
-      windows->backdrop.flags=(unsigned long) (USSize | USPosition);
+      windows->backdrop.flags=(size_t) (USSize | USPosition);
       windows->backdrop.width=(unsigned int)
         XDisplayWidth(display,visual_info->screen);
       windows->backdrop.height=(unsigned int)
@@ -1901,7 +1901,7 @@
       (windows->backdrop.id != (Window) NULL))
     (void) XMapWindow(display,windows->image.id);
   XSetCursorState(display,windows,MagickTrue);
-  for (scene=0; scene < (long) number_scenes; scene++)
+  for (scene=0; scene < (ssize_t) number_scenes; scene++)
   {
     unsigned int
       columns,
@@ -2011,12 +2011,12 @@
               /*
                 Forward animation:  increment scene number.
               */
-              if (scene < ((long) number_scenes-1))
+              if (scene < ((ssize_t) number_scenes-1))
                 scene++;
               else
                 {
                   iterations++;
-                  if (iterations == (long) image_list[0]->iterations)
+                  if (iterations == (ssize_t) image_list[0]->iterations)
                     {
                       iterations=0;
                       state|=ExitState;
@@ -2045,7 +2045,7 @@
               else
                 {
                   iterations++;
-                  if (iterations == (long) image_list[0]->iterations)
+                  if (iterations == (ssize_t) image_list[0]->iterations)
                     {
                       iterations=0;
                       state&=(~RepeatAnimationState);
@@ -2060,7 +2060,7 @@
                     {
                       if ((state & RepeatAnimationState) == MagickFalse)
                         state&=(~PlayAnimationState);
-                      scene=(long) number_scenes-1;
+                      scene=(ssize_t) number_scenes-1;
                     }
                 }
             }
@@ -2119,7 +2119,7 @@
             }
           state&=(~StepAnimationState);
           if (pause != MagickFalse)
-            for (i=0; i < (long) resource_info->pause; i++)
+            for (i=0; i < (ssize_t) resource_info->pause; i++)
             {
               int
                 status;
@@ -2244,16 +2244,16 @@
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
             "Client Message: 0x%lx 0x%lx %d 0x%lx",event.xclient.window,
-            event.xclient.message_type,event.xclient.format,(unsigned long)
+            event.xclient.message_type,event.xclient.format,(size_t)
             event.xclient.data.l[0]);
         if (event.xclient.message_type == windows->im_protocols)
           {
-            if (*event.xclient.data.l == (long) windows->im_update_colormap)
+            if (*event.xclient.data.l == (ssize_t) windows->im_update_colormap)
               {
                 /*
                   Update graphic context and window colormap.
                 */
-                for (i=0; i < (long) number_windows; i++)
+                for (i=0; i < (ssize_t) number_windows; i++)
                 {
                   if (magick_windows[i]->id == windows->icon.id)
                     continue;
@@ -2268,7 +2268,7 @@
                   context_values.plane_mask=
                     context_values.background ^ context_values.foreground;
                   (void) XChangeGC(display,magick_windows[i]->highlight_context,
-                    (unsigned long) (context_mask | GCPlaneMask),
+                    (size_t) (context_mask | GCPlaneMask),
                     &context_values);
                   magick_windows[i]->attributes.background_pixel=
                     pixel->background_color.pixel;
@@ -2282,7 +2282,7 @@
                   (void) XInstallColormap(display,map_info->colormap);
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_exit)
+            if (*event.xclient.data.l == (ssize_t) windows->im_exit)
               {
                 state|=ExitState;
                 break;
@@ -2302,7 +2302,7 @@
             unsigned char
               *data;
 
-            unsigned long
+            size_t
               after,
               length;
 
@@ -2350,13 +2350,13 @@
         */
         if (event.xclient.message_type != windows->wm_protocols)
           break;
-        if (*event.xclient.data.l == (long) windows->wm_take_focus)
+        if (*event.xclient.data.l == (ssize_t) windows->wm_take_focus)
           {
             (void) XSetInputFocus(display,event.xclient.window,RevertToParent,
               (Time) event.xclient.data.l[1]);
             break;
           }
-        if (*event.xclient.data.l != (long) windows->wm_delete_window)
+        if (*event.xclient.data.l != (ssize_t) windows->wm_delete_window)
           break;
         (void) XWithdrawWindow(display,event.xclient.window,
           visual_info->screen);
@@ -2493,7 +2493,7 @@
         *(command+length)='\0';
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key press: 0x%lx (%c)",(unsigned long) key_symbol,*command);
+            "Key press: 0x%lx (%c)",(size_t) key_symbol,*command);
         command_type=NullCommand;
         switch (key_symbol)
         {
@@ -2562,7 +2562,7 @@
           sizeof(command),&key_symbol,(XComposeStatus *) NULL);
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key release: 0x%lx (%c)",(unsigned long) key_symbol,*command);
+            "Key release: 0x%lx (%c)",(size_t) key_symbol,*command);
         break;
       }
       case LeaveNotify:
@@ -2660,7 +2660,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -2674,7 +2674,7 @@
           Display image named by the remote command protocol.
         */
         status=XGetWindowProperty(display,event.xproperty.window,
-          event.xproperty.atom,0L,(long) MaxTextExtent,MagickFalse,(Atom)
+          event.xproperty.atom,0L,(ssize_t) MaxTextExtent,MagickFalse,(Atom)
           AnyPropertyType,&type,&format,&length,&after,&data);
         if ((status != Success) || (length == 0))
           break;
@@ -2786,7 +2786,7 @@
       }
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
-  for (scene=1; scene < (long) number_scenes; scene++)
+  for (scene=1; scene < (ssize_t) number_scenes; scene++)
   {
     if (windows->image.pixmaps[scene] != (Pixmap) NULL)
       (void) XFreePixmap(display,windows->image.pixmaps[scene]);
diff --git a/magick/annotate.c b/magick/annotate.c
index 1da2627..be1bc44 100644
--- a/magick/annotate.c
+++ b/magick/annotate.c
@@ -181,7 +181,7 @@
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -190,7 +190,7 @@
   TypeMetric
     metrics;
 
-  unsigned long
+  size_t
     height,
     number_lines;
 
@@ -211,7 +211,7 @@
   for (i=1; textlist[i] != (char *) NULL; i++)
     if (strlen(textlist[i]) > length)
       length=strlen(textlist[i]);
-  number_lines=(unsigned long) i;
+  number_lines=(size_t) i;
   annotate=CloneDrawInfo((ImageInfo *) NULL,draw_info);
   annotate_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
   SetGeometry(image,&geometry);
@@ -234,7 +234,7 @@
     annotate_info->affine.ty=geometry_info.psi-image->page.y;
     (void) CloneString(&annotate->text,textlist[i]);
     (void) GetTypeMetrics(image,annotate,&metrics);
-    height=(long) (metrics.ascent-metrics.descent+
+    height=(ssize_t) (metrics.ascent-metrics.descent+
       draw_info->interline_spacing+0.5);
     switch (annotate->gravity)
     {
@@ -460,7 +460,7 @@
 %
 %  The format of the FormatMagickCaption method is:
 %
-%      long FormatMagickCaption(Image *image,DrawInfo *draw_info,
+%      ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
 %        TypeMetric *metrics,char **caption)
 %
 %  A description of each parameter follows.
@@ -474,7 +474,7 @@
 %    o metrics: Return the font metrics in this structure.
 %
 */
-MagickExport long FormatMagickCaption(Image *image,DrawInfo *draw_info,
+MagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
   TypeMetric *metrics,char **caption)
 {
   MagickBooleanType
@@ -485,10 +485,10 @@
     *q,
     *s;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   q=draw_info->text;
@@ -497,13 +497,13 @@
   {
     if (IsUTFSpace(GetUTFCode(p)) != MagickFalse)
       s=p;
-    for (i=0; i < (long) GetUTFOctets(p); i++)
+    for (i=0; i < (ssize_t) GetUTFOctets(p); i++)
       *q++=(*(p+i));
     *q='\0';
     status=GetTypeMetrics(image,draw_info,metrics);
     if (status == MagickFalse)
       break;
-    width=(unsigned long) floor(metrics->width+0.5);
+    width=(size_t) floor(metrics->width+0.5);
     if (GetUTFCode(p) != '\n')
       if (width <= image->columns)
         continue;
@@ -524,7 +524,7 @@
         char
           *target;
 
-        long
+        ssize_t
           n;
 
         /*
@@ -608,7 +608,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   TypeMetric
@@ -647,7 +647,7 @@
     if (extent.width > metrics->width)
       *metrics=extent;
   }
-  metrics->height=(double) (i*(unsigned long) (metrics->ascent-
+  metrics->height=(double) (i*(size_t) (metrics->ascent-
     metrics->descent+0.5)+(i-1)*draw_info->interline_spacing);
   /*
     Relinquish resources.
@@ -1008,7 +1008,7 @@
     glyph,
     last_glyph;
 
-  long
+  ssize_t
     code,
     y;
 
@@ -1283,9 +1283,9 @@
         status=MagickTrue;
         exception=(&image->exception);
         image_view=AcquireCacheView(image);
-        for (y=0; y < (long) bitmap->bitmap.rows; y++)
+        for (y=0; y < (ssize_t) bitmap->bitmap.rows; y++)
         {
-          long
+          ssize_t
             x_offset,
             y_offset;
 
@@ -1299,7 +1299,7 @@
           PixelPacket
             fill_color;
 
-          register long
+          register ssize_t
             x;
 
           register PixelPacket
@@ -1310,12 +1310,12 @@
 
           if (status == MagickFalse)
             continue;
-          x_offset=(long) ceil(point.x-0.5);
-          y_offset=(long) ceil(point.y+y-0.5);
-          if ((y_offset < 0) || (y_offset >= (long) image->rows))
+          x_offset=(ssize_t) ceil(point.x-0.5);
+          y_offset=(ssize_t) ceil(point.y+y-0.5);
+          if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
             continue;
           q=(PixelPacket *) NULL;
-          if ((x_offset < 0) || (x_offset >= (long) image->columns))
+          if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
             active=MagickFalse;
           else
             {
@@ -1324,11 +1324,11 @@
               active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
             }
           p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
-          for (x=0; x < (long) bitmap->bitmap.width; x++)
+          for (x=0; x < (ssize_t) bitmap->bitmap.width; x++)
           {
             x_offset++;
             if ((*p == 0) || (x_offset < 0) ||
-                (x_offset >= (long) image->columns))
+                (x_offset >= (ssize_t) image->columns))
               {
                 p++;
                 q++;
@@ -1499,7 +1499,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1508,7 +1508,7 @@
   escapes=0;
   buffer=AcquireString(text);
   p=buffer;
-  for (i=0; i < (long) MagickMin(strlen(text),MaxTextExtent-escapes-1); i++)
+  for (i=0; i < (ssize_t) MagickMin(strlen(text),MaxTextExtent-escapes-1); i++)
   {
     if ((text[i] == '(') || (text[i] == ')'))
       {
@@ -1541,7 +1541,7 @@
   int
     unique_file;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1552,7 +1552,7 @@
     point,
     resolution;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1589,7 +1589,7 @@
     MagickTrue : MagickFalse;
   extent.x=0.0;
   extent.y=0.0;
-  for (i=0; i <= (long) (strlen(draw_info->text)+2); i++)
+  for (i=0; i <= (ssize_t) (strlen(draw_info->text)+2); i++)
   {
     point.x=fabs(draw_info->affine.sx*i*draw_info->pointsize+
       draw_info->affine.ry*2.0*draw_info->pointsize);
@@ -1621,8 +1621,8 @@
   text=DestroyString(text);
   (void) fprintf(file,"showpage\n");
   (void) fclose(file);
-  (void) FormatMagickString(geometry,MaxTextExtent,"%ldx%ld+0+0!",(long)
-    floor(extent.x+0.5),(long) floor(extent.y+0.5));
+  (void) FormatMagickString(geometry,MaxTextExtent,"%ldx%ld+0+0!",(ssize_t)
+    floor(extent.x+0.5),(ssize_t) floor(extent.y+0.5));
   annotate_info=AcquireImageInfo();
   (void) FormatMagickString(annotate_info->filename,MaxTextExtent,"ps:%s",
     filename);
@@ -1660,9 +1660,9 @@
         crop_info;
 
       crop_info=GetImageBoundingBox(annotate_image,&annotate_image->exception);
-      crop_info.height=(unsigned long) ((resolution.y/DefaultResolution)*
+      crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
         ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
-      crop_info.y=(long) ceil((resolution.y/DefaultResolution)*extent.y/8.0-
+      crop_info.y=(ssize_t) ceil((resolution.y/DefaultResolution)*extent.y/8.0-
         0.5);
       (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
         crop_info.width,crop_info.height,crop_info.x,crop_info.y);
@@ -1712,9 +1712,9 @@
       fill_color=draw_info->fill;
       exception=(&image->exception);
       annotate_view=AcquireCacheView(annotate_image);
-      for (y=0; y < (long) annotate_image->rows; y++)
+      for (y=0; y < (ssize_t) annotate_image->rows; y++)
       {
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1724,7 +1724,7 @@
           1,exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) annotate_image->columns; x++)
+        for (x=0; x < (ssize_t) annotate_image->columns; x++)
         {
           (void) GetFillColor(draw_info,x,y,&fill_color);
           q->opacity=ClampToQuantum(QuantumRange-(((QuantumRange-
@@ -1741,7 +1741,7 @@
       }
       annotate_view=DestroyCacheView(annotate_view);
       (void) CompositeImage(image,OverCompositeOp,annotate_image,
-        (long) ceil(offset->x-0.5),(long) ceil(offset->y-(metrics->ascent+
+        (ssize_t) ceil(offset->x-0.5),(ssize_t) ceil(offset->y-(metrics->ascent+
         metrics->descent)-0.5));
     }
   annotate_image=DestroyImage(annotate_image);
@@ -1812,7 +1812,7 @@
   static XVisualInfo
     *visual_info;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -1865,7 +1865,7 @@
           return(MagickFalse);
         }
       map_info->colormap=(Colormap) NULL;
-      pixel.pixels=(unsigned long *) NULL;
+      pixel.pixels=(size_t *) NULL;
       /*
         Initialize Standard Colormap info.
       */
@@ -1956,8 +1956,8 @@
           atan2(draw_info->affine.rx,draw_info->affine.sx);
     }
   (void) FormatMagickString(annotate_info.geometry,MaxTextExtent,
-    "%lux%lu+%ld+%ld",width,height,(long) ceil(offset->x-0.5),
-    (long) ceil(offset->y-metrics->ascent-metrics->descent+
+    "%lux%lu+%ld+%ld",width,height,(ssize_t) ceil(offset->x-0.5),
+    (ssize_t) ceil(offset->y-metrics->ascent-metrics->descent+
     draw_info->interline_spacing-0.5));
   pixel.pen_color.red=ScaleQuantumToShort(draw_info->fill.red);
   pixel.pen_color.green=ScaleQuantumToShort(draw_info->fill.green);
diff --git a/magick/annotate.h b/magick/annotate.h
index 8e7a4cf..65356ac 100644
--- a/magick/annotate.h
+++ b/magick/annotate.h
@@ -24,7 +24,7 @@
 
 #include "magick/draw.h"
 
-extern MagickExport long
+extern MagickExport ssize_t
   FormatMagickCaption(Image *,DrawInfo *,TypeMetric *,char **);
 
 extern MagickExport MagickBooleanType
diff --git a/magick/attribute.c b/magick/attribute.c
index 6349d98..bd85ee4 100644
--- a/magick/attribute.c
+++ b/magick/attribute.c
@@ -123,7 +123,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -145,8 +145,8 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   bounds.width=0;
   bounds.height=0;
-  bounds.x=(long) image->columns;
-  bounds.y=(long) image->rows;
+  bounds.x=(ssize_t) image->columns;
+  bounds.y=(ssize_t) image->rows;
   GetMagickPixelPacket(image,&target[0]);
   image_view=AcquireCacheView(image);
   p=GetCacheViewVirtualPixels(image_view,0,0,1,1,exception);
@@ -158,12 +158,12 @@
   SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
     &target[0]);
   GetMagickPixelPacket(image,&target[1]);
-  p=GetCacheViewVirtualPixels(image_view,(long) image->columns-1,0,1,1,
+  p=GetCacheViewVirtualPixels(image_view,(ssize_t) image->columns-1,0,1,1,
     exception);
   SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
     &target[1]);
   GetMagickPixelPacket(image,&target[2]);
-  p=GetCacheViewVirtualPixels(image_view,0,(long) image->rows-1,1,1,exception);
+  p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-1,1,1,exception);
   SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
     &target[2]);
   status=MagickTrue;
@@ -171,7 +171,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -185,7 +185,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     if (status == MagickFalse)
@@ -202,21 +202,21 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     pixel=zero;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,p,indexes+x,&pixel);
       if ((x < bounding_box.x) &&
           (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
         bounding_box.x=x;
-      if ((x > (long) bounding_box.width) &&
+      if ((x > (ssize_t) bounding_box.width) &&
           (IsMagickColorSimilar(&pixel,&target[1]) == MagickFalse))
-        bounding_box.width=(unsigned long) x;
+        bounding_box.width=(size_t) x;
       if ((y < bounding_box.y) &&
           (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
         bounding_box.y=y;
-      if ((y > (long) bounding_box.height) &&
+      if ((y > (ssize_t) bounding_box.height) &&
           (IsMagickColorSimilar(&pixel,&target[2]) == MagickFalse))
-        bounding_box.height=(unsigned long) y;
+        bounding_box.height=(size_t) y;
       p++;
     }
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
@@ -260,8 +260,8 @@
 %
 %  The format of the GetImageChannelDepth method is:
 %
-%      unsigned long GetImageDepth(const Image *image,ExceptionInfo *exception)
-%      unsigned long GetImageChannelDepth(const Image *image,
+%      size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
+%      size_t GetImageChannelDepth(const Image *image,
 %        const ChannelType channel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -274,28 +274,28 @@
 %
 */
 
-MagickExport unsigned long GetImageDepth(const Image *image,
+MagickExport size_t GetImageDepth(const Image *image,
   ExceptionInfo *exception)
 {
   return(GetImageChannelDepth(image,AllChannels,exception));
 }
 
-MagickExport unsigned long GetImageChannelDepth(const Image *image,
+MagickExport size_t GetImageChannelDepth(const Image *image,
   const ChannelType channel,ExceptionInfo *exception)
 {
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     id;
 
-  unsigned long
+  size_t
     *current_depth,
     depth,
     number_threads;
@@ -308,26 +308,26 @@
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   number_threads=GetOpenMPMaximumThreads();
-  current_depth=(unsigned long *) AcquireQuantumMemory(number_threads,
+  current_depth=(size_t *) AcquireQuantumMemory(number_threads,
     sizeof(*current_depth));
-  if (current_depth == (unsigned long *) NULL)
+  if (current_depth == (size_t *) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   status=MagickTrue;
-  for (id=0; id < (long) number_threads; id++)
+  for (id=0; id < (ssize_t) number_threads; id++)
     current_depth[id]=1;
   if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         i;
 
       p=image->colormap;
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if (status == MagickFalse)
           continue;
@@ -358,17 +358,17 @@
         p++;
       }
       depth=current_depth[0];
-      for (id=1; id < (long) number_threads; id++)
+      for (id=1; id < (ssize_t) number_threads; id++)
         if (depth < current_depth[id])
           depth=current_depth[id];
-      current_depth=(unsigned long *) RelinquishMagickMemory(current_depth);
+      current_depth=(size_t *) RelinquishMagickMemory(current_depth);
       return(depth);
     }
   image_view=AcquireCacheView(image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -376,7 +376,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -387,7 +387,7 @@
     if (p == (const PixelPacket *) NULL)
       continue;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
       {
@@ -426,10 +426,10 @@
   }
   image_view=DestroyCacheView(image_view);
   depth=current_depth[0];
-  for (id=1; id < (long) number_threads; id++)
+  for (id=1; id < (ssize_t) number_threads; id++)
     if (depth < current_depth[id])
       depth=current_depth[id];
-  current_depth=(unsigned long *) RelinquishMagickMemory(current_depth);
+  current_depth=(size_t *) RelinquishMagickMemory(current_depth);
   return(depth);
 }
 
@@ -449,7 +449,7 @@
 %
 %  The format of the GetImageQuantumDepth method is:
 %
-%      unsigned long GetImageQuantumDepth(const Image *image,
+%      size_t GetImageQuantumDepth(const Image *image,
 %        const MagickBooleanType constrain)
 %
 %  A description of each parameter follows:
@@ -468,10 +468,10 @@
   return(y);
 }
 
-MagickExport unsigned long GetImageQuantumDepth(const Image *image,
+MagickExport size_t GetImageQuantumDepth(const Image *image,
   const MagickBooleanType constrain)
 {
-  unsigned long
+  size_t
     depth;
 
   depth=image->depth;
@@ -487,7 +487,7 @@
         if (depth <= 64)
           depth=64;
   if (constrain != MagickFalse)
-    depth=(unsigned long) MagickMin((double) depth,(double)
+    depth=(size_t) MagickMin((double) depth,(double)
       MAGICKCORE_QUANTUM_DEPTH);
   return(depth);
 }
@@ -590,13 +590,13 @@
   ImageType
     type;
 
-  long
+  ssize_t
     y;
 
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   assert(image != (Image *) NULL);
@@ -610,12 +610,12 @@
     return(MagickFalse);
   type=BilevelType;
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (IsGrayPixel(p) == MagickFalse)
         {
@@ -674,10 +674,10 @@
   ImageType
     type;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register const PixelPacket
@@ -693,12 +693,12 @@
     return(MagickFalse);
   type=BilevelType;
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (IsMonochromePixel(p) == MagickFalse)
         {
@@ -749,13 +749,13 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -768,22 +768,22 @@
   if (image->matte == MagickFalse)
     return(MagickTrue);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (p->opacity != OpaqueOpacity)
         break;
       p++;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
      break;
   }
   image_view=DestroyCacheView(image_view);
-  return(y < (long) image->rows ? MagickFalse : MagickTrue);
+  return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
 }
 
 /*
@@ -801,9 +801,9 @@
 %
 %  The format of the SetImageChannelDepth method is:
 %
-%      MagickBooleanType SetImageDepth(Image *image,const unsigned long depth)
+%      MagickBooleanType SetImageDepth(Image *image,const size_t depth)
 %      MagickBooleanType SetImageChannelDepth(Image *image,
-%        const ChannelType channel,const unsigned long depth)
+%        const ChannelType channel,const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -816,13 +816,13 @@
 */
 
 MagickExport MagickBooleanType SetImageDepth(Image *image,
-  const unsigned long depth)
+  const size_t depth)
 {
   return(SetImageChannelDepth(image,AllChannels,depth));
 }
 
 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
-  const ChannelType channel,const unsigned long depth)
+  const ChannelType channel,const size_t depth)
 {
   CacheView
     *image_view;
@@ -830,7 +830,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -843,7 +843,7 @@
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(image->signature == MagickSignature);
-  if (GetImageDepth(image,&image->exception) <= (unsigned long)
+  if (GetImageDepth(image,&image->exception) <= (size_t)
       MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
     {
       image->depth=depth;
@@ -859,12 +859,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -880,7 +880,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ScaleAnyToQuantum(ScaleQuantumToAny(q->red,range),range);
@@ -907,7 +907,7 @@
       QuantumAny
         range;
 
-      register long
+      register ssize_t
         i;
 
       register PixelPacket
@@ -918,7 +918,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((channel & RedChannel) != 0)
           p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range);
diff --git a/magick/attribute.h b/magick/attribute.h
index e119363..8f74a26 100644
--- a/magick/attribute.h
+++ b/magick/attribute.h
@@ -32,13 +32,13 @@
   IsGrayImage(const Image *,ExceptionInfo *),
   IsMonochromeImage(const Image *,ExceptionInfo *),
   IsOpaqueImage(const Image *,ExceptionInfo *),
-  SetImageChannelDepth(Image *,const ChannelType,const unsigned long),
-  SetImageDepth(Image *,const unsigned long);
+  SetImageChannelDepth(Image *,const ChannelType,const size_t),
+  SetImageDepth(Image *,const size_t);
 
 extern MagickExport RectangleInfo
   GetImageBoundingBox(const Image *,ExceptionInfo *exception);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetImageChannelDepth(const Image *,const ChannelType,ExceptionInfo *),
   GetImageDepth(const Image *,ExceptionInfo *),
   GetImageQuantumDepth(const Image *,const MagickBooleanType);
diff --git a/magick/blob.c b/magick/blob.c
index f3b5458..000bedb 100644
--- a/magick/blob.c
+++ b/magick/blob.c
@@ -140,10 +140,10 @@
   SemaphoreInfo
     *semaphore;
 
-  long
+  ssize_t
     reference_count;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -1777,7 +1777,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2416,7 +2416,7 @@
                   count=fread(magick,1,sizeof(magick),image->blob->file);
                   (void) rewind(image->blob->file);
                   (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                     "  read %ld magic header bytes",(long) count);
+                     "  read %ld magic header bytes",(ssize_t) count);
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
                   if (((int) magick[0] == 0x1F) && ((int) magick[1] == 0x8B) &&
                       ((int) magick[2] == 0x08))
@@ -2860,7 +2860,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  ReadBlobLong() reads a long value as a 32-bit quantity in the byte-order
+%  ReadBlobLong() reads a ssize_t value as a 32-bit quantity in the byte-order
 %  specified by the endian member of the image structure.
 %
 %  The format of the ReadBlobLong method is:
@@ -2918,7 +2918,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  ReadBlobLongLong() reads a long value as a 64-bit quantity in the byte-order
+%  ReadBlobLongLong() reads a ssize_t value as a 64-bit quantity in the byte-order
 %  specified by the endian member of the image structure.
 %
 %  The format of the ReadBlobLong method is:
@@ -3038,7 +3038,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  ReadBlobLSBLong() reads a long value as a 32-bit quantity in
+%  ReadBlobLSBLong() reads a ssize_t value as a 32-bit quantity in
 %  least-significant byte first order.
 %
 %  The format of the ReadBlobLSBLong method is:
@@ -3136,7 +3136,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  ReadBlobMSBLong() reads a long value as a 32-bit quantity in
+%  ReadBlobMSBLong() reads a ssize_t value as a 32-bit quantity in
 %  most-significant byte first order.
 %
 %  The format of the ReadBlobMSBLong method is:
@@ -3186,7 +3186,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  ReadBlobMSBLongLong() reads a long value as a 64-bit quantity in
+%  ReadBlobMSBLongLong() reads a ssize_t value as a 64-bit quantity in
 %  most-significant byte first order.
 %
 %  The format of the ReadBlobMSBLongLong method is:
@@ -3307,7 +3307,7 @@
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -4068,7 +4068,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WriteBlobLong() writes a long value as a 32-bit quantity in the byte-order
+%  WriteBlobLong() writes a ssize_t value as a 32-bit quantity in the byte-order
 %  specified by the endian member of the image structure.
 %
 %  The format of the WriteBlobLong method is:
@@ -4158,7 +4158,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WriteBlobLSBLong() writes a long value as a 32-bit quantity in
+%  WriteBlobLSBLong() writes a ssize_t value as a 32-bit quantity in
 %  least-significant byte first order.
 %
 %  The format of the WriteBlobLSBLong method is:
@@ -4197,7 +4197,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WriteBlobLSBShort() writes a long value as a 16-bit quantity in
+%  WriteBlobLSBShort() writes a ssize_t value as a 16-bit quantity in
 %  least-significant byte first order.
 %
 %  The format of the WriteBlobLSBShort method is:
@@ -4234,7 +4234,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WriteBlobMSBLong() writes a long value as a 32-bit quantity in
+%  WriteBlobMSBLong() writes a ssize_t value as a 32-bit quantity in
 %  most-significant byte first order.
 %
 %  The format of the WriteBlobMSBLong method is:
@@ -4317,7 +4317,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WriteBlobMSBShort() writes a long value as a 16-bit quantity in
+%  WriteBlobMSBShort() writes a ssize_t value as a 16-bit quantity in
 %  most-significant byte first order.
 %
 %  The format of the WriteBlobMSBShort method is:
diff --git a/magick/cache-private.h b/magick/cache-private.h
index dddd564..d3d8dbe 100644
--- a/magick/cache-private.h
+++ b/magick/cache-private.h
@@ -46,27 +46,27 @@
   *(*GetAuthenticIndexesFromHandler)(const Image *);
 
 typedef MagickBooleanType
-  (*GetOneAuthenticPixelFromHandler)(Image *,const long,const long,
+  (*GetOneAuthenticPixelFromHandler)(Image *,const ssize_t,const ssize_t,
     PixelPacket *,ExceptionInfo *),
   (*GetOneVirtualPixelFromHandler)(const Image *,const VirtualPixelMethod,
-    const long,const long,PixelPacket *,ExceptionInfo *),
+    const ssize_t,const ssize_t,PixelPacket *,ExceptionInfo *),
   (*SyncAuthenticPixelsHandler)(Image *,ExceptionInfo *);
 
 typedef const PixelPacket
-  *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,const long,
-    const long,const unsigned long,const unsigned long,ExceptionInfo *),
+  *(*GetVirtualPixelHandler)(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,const size_t,const size_t,ExceptionInfo *),
   *(*GetVirtualPixelsHandler)(const Image *);
 
 typedef PixelPacket
-  *(*GetAuthenticPixelsHandler)(Image *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *);
+  *(*GetAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *);
 
 typedef PixelPacket
   *(*GetAuthenticPixelsFromHandler)(const Image *);
 
 typedef PixelPacket
-  *(*QueueAuthenticPixelsHandler)(Image *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *);
+  *(*QueueAuthenticPixelsHandler)(Image *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *);
 
 typedef void
   (*DestroyPixelHandler)(Image *);
@@ -127,7 +127,7 @@
   MagickBooleanType
     mapped;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -143,7 +143,7 @@
   MagickPixelPacket
     virtual_pixel_color;
 
-  unsigned long
+  size_t
     number_threads;
 
   NexusInfo
@@ -177,7 +177,7 @@
   MagickThreadType
     id;
 
-  long
+  ssize_t
     reference_count;
 
   SemaphoreInfo
@@ -187,12 +187,12 @@
   time_t
     timestamp;
 
-  unsigned long
+  size_t
     signature;
 } CacheInfo;
 
 extern MagickExport Cache
-  AcquirePixelCache(const unsigned long),
+  AcquirePixelCache(const size_t),
   ClonePixelCache(const Cache),
   DestroyPixelCache(Cache),
   GetImagePixelCache(Image *,const MagickBooleanType,ExceptionInfo *),
@@ -211,8 +211,8 @@
   *GetVirtualIndexesFromNexus(const Cache,NexusInfo *);
 
 extern MagickExport const PixelPacket
-  *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,const long,
-    const long,const unsigned long,const unsigned long,NexusInfo *,
+  *GetVirtualPixelsFromNexus(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,const size_t,const size_t,NexusInfo *,
     ExceptionInfo *),
   *GetVirtualPixelsNexus(const Cache,NexusInfo *);
 
@@ -226,19 +226,19 @@
   GetPixelCacheNexusExtent(const Cache,NexusInfo *);
 
 extern MagickExport NexusInfo
-  **AcquirePixelCacheNexus(const unsigned long),
-  **DestroyPixelCacheNexus(NexusInfo **,const unsigned long);
+  **AcquirePixelCacheNexus(const size_t),
+  **DestroyPixelCacheNexus(NexusInfo **,const size_t);
 
 extern MagickExport PixelPacket
-  *GetAuthenticPixelCacheNexus(Image *,const long,const long,
-    const unsigned long,const unsigned long,NexusInfo *,ExceptionInfo *),
+  *GetAuthenticPixelCacheNexus(Image *,const ssize_t,const ssize_t,
+    const size_t,const size_t,NexusInfo *,ExceptionInfo *),
   *GetPixelCacheNexusPixels(const Cache,NexusInfo *),
-  *QueueAuthenticNexus(Image *,const long,const long,const unsigned long,
-    const unsigned long,NexusInfo *,ExceptionInfo *);
+  *QueueAuthenticNexus(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,NexusInfo *,ExceptionInfo *);
 
 extern MagickExport void
   ClonePixelCacheMethods(Cache,const Cache),
-  GetPixelCacheTileSize(const Image *,unsigned long *,unsigned long *),
+  GetPixelCacheTileSize(const Image *,size_t *,size_t *),
   GetPixelCacheMethods(CacheMethods *),
   SetPixelCacheMethods(Cache,CacheMethods *);
 
diff --git a/magick/cache-view.c b/magick/cache-view.c
index 8ebc071..8db4940 100644
--- a/magick/cache-view.c
+++ b/magick/cache-view.c
@@ -67,7 +67,7 @@
   VirtualPixelMethod
     virtual_pixel_method;
 
-  unsigned long
+  size_t
     number_threads;
 
   NexusInfo
@@ -76,7 +76,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -303,7 +303,7 @@
 */
 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
 {
-  long
+  ssize_t
     id;
 
   MagickSizeType
@@ -316,7 +316,7 @@
       cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   extent=GetPixelCacheNexusExtent(cache_view->image->cache,
     cache_view->nexus_info[id]);
   return(extent);
@@ -373,8 +373,8 @@
 %  The format of the GetCacheViewAuthenticPixels method is:
 %
 %      PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -385,13 +385,13 @@
 %
 */
 MagickExport PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
   Cache
     cache;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -406,7 +406,7 @@
   if (cache == (Cache) NULL)
     return((PixelPacket *) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
     cache_view->nexus_info[id],exception);
   return(pixels);
@@ -429,7 +429,7 @@
 %  The format of the GetOneCacheViewAuthenticPixel method is:
 %
 %      MagickBooleaNType GetOneCacheViewAuthenticPixel(
-%        const CacheView *cache_view,const long x,const long y,
+%        const CacheView *cache_view,const ssize_t x,const ssize_t y,
 %        Pixelpacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -444,13 +444,13 @@
 %
 */
 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
-  const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelPacket *pixel,
   ExceptionInfo *exception)
 {
   Cache
     cache;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -466,7 +466,7 @@
     return(MagickFalse);
   *pixel=cache_view->image->background_color;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
     cache_view->nexus_info[id],exception);
   if (pixels == (const PixelPacket *) NULL)
@@ -504,7 +504,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (CacheView *) NULL);
@@ -514,7 +514,7 @@
       cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   indexes=GetPixelCacheNexusIndexes(cache_view->image->cache,
     cache_view->nexus_info[id]);
   return(indexes);
@@ -547,7 +547,7 @@
 */
 MagickExport PixelPacket *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
 {
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -560,7 +560,7 @@
       cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
     cache_view->nexus_info[id]);
   return(pixels);
@@ -597,7 +597,7 @@
   const IndexPacket
     *indexes;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (const CacheView *) NULL);
@@ -607,7 +607,7 @@
       cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   indexes=GetVirtualIndexesFromNexus(cache_view->image->cache,
     cache_view->nexus_info[id]);
   return(indexes);
@@ -644,7 +644,7 @@
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (const CacheView *) NULL);
@@ -654,7 +654,7 @@
       cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetVirtualPixelsNexus(cache_view->image->cache,
     cache_view->nexus_info[id]);
   return(pixels);
@@ -679,8 +679,8 @@
 %  The format of the GetCacheViewVirtualPixels method is:
 %
 %      const PixelPacket *GetCacheViewVirtualPixels(
-%        const CacheView *cache_view,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows,
+%        const CacheView *cache_view,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -694,13 +694,13 @@
 %
 */
 MagickExport const PixelPacket *GetCacheViewVirtualPixels(
-  const CacheView *cache_view,const long x,const long y,
-  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows,ExceptionInfo *exception)
 {
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (CacheView *) NULL);
@@ -709,7 +709,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       cache_view->image->filename);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetVirtualPixelsFromNexus(cache_view->image,
     cache_view->virtual_pixel_method,x,y,columns,rows,
     cache_view->nexus_info[id],exception);
@@ -734,7 +734,7 @@
 %  The format of the GetOneCacheViewVirtualPixel method is:
 %
 %      MagickBooleanType GetOneCacheViewVirtualPixel(
-%        const CacheView *cache_view,const long x,const long y,
+%        const CacheView *cache_view,const ssize_t x,const ssize_t y,
 %        PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -749,13 +749,13 @@
 %
 */
 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
-  const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelPacket *pixel,
   ExceptionInfo *exception)
 {
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (CacheView *) NULL);
@@ -765,7 +765,7 @@
       cache_view->image->filename);
   *pixel=cache_view->image->background_color;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetVirtualPixelsFromNexus(cache_view->image,
     cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
     exception);
@@ -795,8 +795,8 @@
 %
 %      MagickBooleanType GetOneCacheViewVirtualMethodPixel(
 %        const CacheView *cache_view,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -813,12 +813,12 @@
 */
 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
   const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
-  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   assert(cache_view != (CacheView *) NULL);
@@ -828,7 +828,7 @@
       cache_view->image->filename);
   *pixel=cache_view->image->background_color;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,
     1,cache_view->nexus_info[id],exception);
   if (pixels == (const PixelPacket *) NULL)
@@ -856,8 +856,8 @@
 %  The format of the QueueCacheViewAuthenticPixels method is:
 %
 %      PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -870,13 +870,13 @@
 %
 */
 MagickExport PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
   Cache
     cache;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -891,7 +891,7 @@
   if (cache == (Cache) NULL)
     return((PixelPacket *) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   pixels=QueueAuthenticNexus(cache_view->image,x,y,columns,rows,
     cache_view->nexus_info[id],exception);
   return(pixels);
@@ -1002,7 +1002,7 @@
 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
   CacheView *cache_view,ExceptionInfo *exception)
 {
-  long
+  ssize_t
     id;
 
   MagickBooleanType
@@ -1014,7 +1014,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       cache_view->image->filename);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_view->number_threads);
+  assert(id < (ssize_t) cache_view->number_threads);
   status=SyncAuthenticPixelCacheNexus(cache_view->image,
     cache_view->nexus_info[id],exception);
   return(status);
diff --git a/magick/cache-view.h b/magick/cache-view.h
index 6175be8..e64f96a 100644
--- a/magick/cache-view.h
+++ b/magick/cache-view.h
@@ -59,8 +59,8 @@
   *GetCacheViewVirtualIndexQueue(const CacheView *);
 
 extern MagickExport const PixelPacket
-  *GetCacheViewVirtualPixels(const CacheView *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *),
+  *GetCacheViewVirtualPixels(const CacheView *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *),
   *GetCacheViewVirtualPixelQueue(const CacheView *);
 
 extern MagickExport ExceptionInfo
@@ -70,12 +70,12 @@
   *GetCacheViewAuthenticIndexQueue(CacheView *);
 
 extern MagickExport MagickBooleanType
-  GetOneCacheViewVirtualPixel(const CacheView *,const long,const long,
+  GetOneCacheViewVirtualPixel(const CacheView *,const ssize_t,const ssize_t,
     PixelPacket *,ExceptionInfo *),
   GetOneCacheViewVirtualMethodPixel(const CacheView *,
-    const VirtualPixelMethod,const long,const long,PixelPacket *,
+    const VirtualPixelMethod,const ssize_t,const ssize_t,PixelPacket *,
     ExceptionInfo *),
-  GetOneCacheViewAuthenticPixel(const CacheView *,const long,const long,
+  GetOneCacheViewAuthenticPixel(const CacheView *,const ssize_t,const ssize_t,
     PixelPacket *,ExceptionInfo *),
   SetCacheViewStorageClass(CacheView *,const ClassType),
   SetCacheViewVirtualPixelMethod(CacheView *,const VirtualPixelMethod),
@@ -86,10 +86,10 @@
 
 extern MagickExport PixelPacket
   *GetCacheViewAuthenticPixelQueue(CacheView *),
-  *GetCacheViewAuthenticPixels(CacheView *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *),
-  *QueueCacheViewAuthenticPixels(CacheView *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *);
+  *GetCacheViewAuthenticPixels(CacheView *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *),
+  *QueueCacheViewAuthenticPixels(CacheView *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *);
 
 extern MagickExport CacheView
   *AcquireCacheView(const Image *),
diff --git a/magick/cache.c b/magick/cache.c
index 4f39ee1..da5da6c 100644
--- a/magick/cache.c
+++ b/magick/cache.c
@@ -73,7 +73,7 @@
 */
 typedef struct _MagickModulo
 {
-  long
+  ssize_t
     quotient,
     remainder;
 } MagickModulo;
@@ -96,7 +96,7 @@
   IndexPacket
     *indexes;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -111,15 +111,15 @@
   *GetVirtualIndexesFromCache(const Image *);
 
 static const PixelPacket
-  *GetVirtualPixelCache(const Image *,const VirtualPixelMethod,const long,
-    const long,const unsigned long,const unsigned long,ExceptionInfo *),
+  *GetVirtualPixelCache(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,const size_t,const size_t,ExceptionInfo *),
   *GetVirtualPixelsCache(const Image *);
 
 static MagickBooleanType
-  GetOneAuthenticPixelFromCache(Image *,const long,const long,PixelPacket *,
+  GetOneAuthenticPixelFromCache(Image *,const ssize_t,const ssize_t,PixelPacket *,
     ExceptionInfo *),
   GetOneVirtualPixelFromCache(const Image *,const VirtualPixelMethod,
-    const long,const long,PixelPacket *,ExceptionInfo *),
+    const ssize_t,const ssize_t,PixelPacket *,ExceptionInfo *),
   OpenPixelCache(Image *,const MapMode,ExceptionInfo *),
   ReadPixelCacheIndexes(CacheInfo *,NexusInfo *,ExceptionInfo *),
   ReadPixelCachePixels(CacheInfo *,NexusInfo *,ExceptionInfo *),
@@ -128,10 +128,10 @@
   WritePixelCachePixels(CacheInfo *,NexusInfo *,ExceptionInfo *);
 
 static PixelPacket
-  *GetAuthenticPixelsCache(Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *),
-  *QueueAuthenticPixelsCache(Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *),
+  *GetAuthenticPixelsCache(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *),
+  *QueueAuthenticPixelsCache(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *),
   *SetPixelCacheNexusPixels(const Image *,const RectangleInfo *,NexusInfo *,
     ExceptionInfo *);
 
@@ -166,14 +166,14 @@
 %
 %  The format of the AcquirePixelCache() method is:
 %
-%      Cache AcquirePixelCache(const unsigned long number_threads)
+%      Cache AcquirePixelCache(const size_t number_threads)
 %
 %  A description of each parameter follows:
 %
 %    o number_threads: the number of nexus threads.
 %
 */
-MagickExport Cache AcquirePixelCache(const unsigned long number_threads)
+MagickExport Cache AcquirePixelCache(const size_t number_threads)
 {
   CacheInfo
     *cache_info;
@@ -233,7 +233,7 @@
 %
 %  The format of the AcquirePixelCacheNexus method is:
 %
-%      NexusInfo **AcquirePixelCacheNexus(const unsigned long number_threads)
+%      NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
 %
 %  A description of each parameter follows:
 %
@@ -241,9 +241,9 @@
 %
 */
 MagickExport NexusInfo **AcquirePixelCacheNexus(
-  const unsigned long number_threads)
+  const size_t number_threads)
 {
-  register long
+  register ssize_t
     i;
 
   NexusInfo
@@ -253,7 +253,7 @@
     sizeof(*nexus_info));
   if (nexus_info == (NexusInfo **) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     nexus_info[i]=(NexusInfo *) AcquireAlignedMemory(1,sizeof(**nexus_info));
     if (nexus_info[i] == (NexusInfo *) NULL)
@@ -417,7 +417,7 @@
     *restrict nexus_indexes,
     *restrict indexes;
 
-  register long
+  register ssize_t
     i;
 
   register PixelPacket
@@ -450,7 +450,7 @@
     nexus_info->region.height,clip_nexus[0],exception);
   number_pixels=(MagickSizeType) nexus_info->region.width*
     nexus_info->region.height;
-  for (i=0; i < (long) number_pixels; i++)
+  for (i=0; i < (ssize_t) number_pixels; i++)
   {
     if ((p == (PixelPacket *) NULL) || (r == (const PixelPacket *) NULL))
       break;
@@ -469,7 +469,7 @@
   }
   clip_nexus=DestroyPixelCacheNexus(clip_nexus,1);
   image_nexus=DestroyPixelCacheNexus(image_nexus,1);
-  if (i < (long) number_pixels)
+  if (i < (ssize_t) number_pixels)
     return(MagickFalse);
   return(MagickTrue);
 }
@@ -579,7 +579,7 @@
   MagickSizeType
     number_pixels;
 
-  register long
+  register ssize_t
     i;
 
   register const NexusInfo
@@ -589,7 +589,7 @@
     *q;
 
   status=MagickTrue;
-  for (i=0; i < (long) source->number_threads; i++)
+  for (i=0; i < (ssize_t) source->number_threads; i++)
   {
     p=source->nexus_info[i];
     q=destination->nexus_info[i];
@@ -873,13 +873,13 @@
   MagickSizeType
     length;
 
-  register long
+  register ssize_t
     y;
 
   register PixelPacket
     *restrict pixels;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -897,8 +897,8 @@
         cache_info->cache_filename);
       return(MagickFalse);
     }
-  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
-  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
+  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
+  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
   if ((clone_info->active_index_channel != MagickFalse) &&
       (cache_info->active_index_channel != MagickFalse))
     {
@@ -923,7 +923,7 @@
         sizeof(*pixels)+cache_info->columns*rows*sizeof(*indexes);
       offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
         sizeof(*pixels)+clone_info->columns*rows*sizeof(*indexes);
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         source_offset-=cache_info->columns*sizeof(*indexes);
         count=ReadPixelCacheRegion(cache_info,cache_info->offset+source_offset,
@@ -936,7 +936,7 @@
         if ((MagickSizeType) count != length)
           break;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
           ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -949,7 +949,7 @@
           (void) ResetMagickMemory(indexes,0,(size_t) length);
           offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
             sizeof(*pixels)+(clone_info->columns*rows+columns)*sizeof(*indexes);
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             offset-=clone_info->columns*sizeof(*indexes);
             count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,
@@ -957,7 +957,7 @@
             if ((MagickSizeType) count != length)
               break;
           }
-          if (y < (long) rows)
+          if (y < (ssize_t) rows)
             {
               indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
               ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -982,7 +982,7 @@
   length=columns*sizeof(*pixels);
   source_offset=(MagickOffsetType) cache_info->columns*rows*sizeof(*pixels);
   offset=(MagickOffsetType) clone_info->columns*rows*sizeof(*pixels);
-  for (y=0; y < (long) rows; y++)
+  for (y=0; y < (ssize_t) rows; y++)
   {
     source_offset-=cache_info->columns*sizeof(*pixels);
     count=ReadPixelCacheRegion(cache_info,cache_info->offset+source_offset,
@@ -995,7 +995,7 @@
     if ((MagickSizeType) count != length)
       break;
   }
-  if (y < (long) rows)
+  if (y < (ssize_t) rows)
     {
       pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
       ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1008,7 +1008,7 @@
         sizeof(*pixels);
       length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
       (void) ResetMagickMemory(pixels,0,(size_t) length);
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         offset-=clone_info->columns*sizeof(*pixels);
         count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,length,
@@ -1016,7 +1016,7 @@
         if ((MagickSizeType) count != length)
           break;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
           ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1038,14 +1038,14 @@
   MagickSizeType
     length;
 
-  register long
+  register ssize_t
     y;
 
   register PixelPacket
     *restrict pixels,
     *restrict q;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -1057,8 +1057,8 @@
         cache_info->cache_filename);
       return(MagickFalse);
     }
-  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
-  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
+  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
+  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
   if ((clone_info->active_index_channel != MagickFalse) &&
       (cache_info->active_index_channel != MagickFalse))
     {
@@ -1083,7 +1083,7 @@
       offset=(MagickOffsetType) cache_info->columns*cache_info->rows*
         sizeof(*pixels)+cache_info->columns*rows*sizeof(*indexes);
       q=clone_info->indexes+clone_info->columns*rows;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         offset-=cache_info->columns*sizeof(IndexPacket);
         count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset,
@@ -1095,7 +1095,7 @@
         if ((MagickSizeType) count != length)
           break;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
           ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1119,7 +1119,7 @@
   length=columns*sizeof(*pixels);
   offset=(MagickOffsetType) cache_info->columns*rows*sizeof(*pixels);
   q=clone_info->pixels+clone_info->columns*rows;
-  for (y=0; y < (long) rows; y++)
+  for (y=0; y < (ssize_t) rows; y++)
   {
     offset-=cache_info->columns*sizeof(*pixels);
     count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset,length,
@@ -1129,7 +1129,7 @@
     q-=clone_info->columns;
     (void) CopyMagickMemory(q,pixels,(size_t) length);
   }
-  if (y < (long) rows)
+  if (y < (ssize_t) rows)
     {
       pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
       ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1150,14 +1150,14 @@
   MagickSizeType
     length;
 
-  register long
+  register ssize_t
     y;
 
   register PixelPacket
     *restrict p,
     *restrict pixels;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
@@ -1169,8 +1169,8 @@
         clone_info->cache_filename);
       return(MagickFalse);
     }
-  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
-  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
+  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
+  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
   if ((clone_info->active_index_channel != MagickFalse) &&
       (cache_info->active_index_channel != MagickFalse))
     {
@@ -1195,7 +1195,7 @@
       p=cache_info->indexes+cache_info->columns*rows;
       offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
         sizeof(*pixels)+clone_info->columns*rows*sizeof(*indexes);
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p-=cache_info->columns;
         (void) CopyMagickMemory(indexes,p,(size_t) length);
@@ -1205,7 +1205,7 @@
         if ((MagickSizeType) count != length)
           break;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
           ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1218,7 +1218,7 @@
           (void) ResetMagickMemory(indexes,0,(size_t) length);
           offset=(MagickOffsetType) clone_info->columns*clone_info->rows*
             sizeof(*pixels)+(clone_info->columns*rows+columns)*sizeof(*indexes);
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             offset-=clone_info->columns*sizeof(*indexes);
             count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,
@@ -1226,7 +1226,7 @@
             if ((MagickSizeType) count != length)
               break;
           }
-          if (y < (long) rows)
+          if (y < (ssize_t) rows)
             {
               indexes=(IndexPacket *) RelinquishMagickMemory(indexes);
               ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1251,7 +1251,7 @@
   length=columns*sizeof(*pixels);
   p=cache_info->pixels+cache_info->columns*rows;
   offset=(MagickOffsetType) clone_info->columns*rows*sizeof(*pixels);
-  for (y=0; y < (long) rows; y++)
+  for (y=0; y < (ssize_t) rows; y++)
   {
     p-=cache_info->columns;
     (void) CopyMagickMemory(pixels,p,(size_t) length);
@@ -1261,7 +1261,7 @@
     if ((MagickSizeType) count != length)
       break;
   }
-  if (y < (long) rows)
+  if (y < (ssize_t) rows)
     {
       pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
       ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1274,7 +1274,7 @@
         sizeof(*pixels);
       length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
       (void) ResetMagickMemory(pixels,0,(size_t) length);
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         offset-=clone_info->columns*sizeof(*pixels);
         count=WritePixelCacheRegion(clone_info,clone_info->offset+offset,length,
@@ -1282,7 +1282,7 @@
         if ((MagickSizeType) count != length)
           break;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           pixels=(PixelPacket *) RelinquishMagickMemory(pixels);
           ThrowFileException(exception,CacheError,"UnableToCloneCache",
@@ -1297,7 +1297,7 @@
 static MagickBooleanType CloneMemoryToMemoryPixelCache(CacheInfo *clone_info,
   CacheInfo *cache_info,ExceptionInfo *magick_unused(exception))
 {
-  register long
+  register ssize_t
     y;
 
   register PixelPacket
@@ -1307,14 +1307,14 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     columns,
     rows;
 
   if (cache_info->debug != MagickFalse)
     (void) LogMagickEvent(CacheEvent,GetMagickModule(),"memory => memory");
-  columns=(unsigned long) MagickMin(clone_info->columns,cache_info->columns);
-  rows=(unsigned long) MagickMin(clone_info->rows,cache_info->rows);
+  columns=(size_t) MagickMin(clone_info->columns,cache_info->columns);
+  rows=(size_t) MagickMin(clone_info->rows,cache_info->rows);
   if ((clone_info->active_index_channel != MagickFalse) &&
       (cache_info->active_index_channel != MagickFalse))
     {
@@ -1333,7 +1333,7 @@
         {
           source_indexes=cache_info->indexes+cache_info->columns*rows;
           indexes=clone_info->indexes+clone_info->columns*rows;
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             source_indexes-=cache_info->columns;
             indexes-=clone_info->columns;
@@ -1345,7 +1345,7 @@
                 sizeof(*indexes);
               indexes=clone_info->indexes+clone_info->columns*rows+
                 cache_info->columns;
-              for (y=0; y < (long) rows; y++)
+              for (y=0; y < (ssize_t) rows; y++)
               {
                 indexes-=clone_info->columns;
                 (void) ResetMagickMemory(indexes,0,length);
@@ -1363,7 +1363,7 @@
     {
       source_pixels=cache_info->pixels+cache_info->columns*rows;
       pixels=clone_info->pixels+clone_info->columns*rows;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         source_pixels-=cache_info->columns;
         pixels-=clone_info->columns;
@@ -1374,7 +1374,7 @@
           length=(clone_info->columns-cache_info->columns)*sizeof(*pixels);
           pixels=clone_info->pixels+clone_info->columns*rows+
             cache_info->columns;
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             pixels-=clone_info->columns;
             (void) ResetMagickMemory(pixels,0,length);
@@ -1640,7 +1640,7 @@
 %  The format of the DestroyPixelCacheNexus() method is:
 %
 %      NexusInfo **DestroyPixelCacheNexus(NexusInfo *nexus_info,
-%        const unsigned long number_threads)
+%        const size_t number_threads)
 %
 %  A description of each parameter follows:
 %
@@ -1664,13 +1664,13 @@
 }
 
 MagickExport NexusInfo **DestroyPixelCacheNexus(NexusInfo **nexus_info,
-  const unsigned long number_threads)
+  const size_t number_threads)
 {
-  register long
+  register ssize_t
     i;
 
   assert(nexus_info != (NexusInfo **) NULL);
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     if (nexus_info[i]->cache != (PixelPacket *) NULL)
       RelinquishCacheNexusPixels(nexus_info[i]);
@@ -1712,14 +1712,14 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     id;
 
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   indexes=GetPixelCacheNexusIndexes(image->cache,cache_info->nexus_info[id]);
   return(indexes);
 }
@@ -1785,8 +1785,8 @@
 %
 %  The format of the GetAuthenticPixelCacheNexus() method is:
 %
-%      PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        NexusInfo *nexus_info,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1817,8 +1817,8 @@
   return(MagickTrue);
 }
 
-MagickExport PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+MagickExport PixelPacket *GetAuthenticPixelCacheNexus(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   NexusInfo *nexus_info,ExceptionInfo *exception)
 {
   CacheInfo
@@ -1877,7 +1877,7 @@
   CacheInfo
     *cache_info;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -1887,7 +1887,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   pixels=GetPixelCacheNexusPixels(image->cache,cache_info->nexus_info[id]);
   return(pixels);
 }
@@ -1965,8 +1965,8 @@
 %
 %  The format of the GetAuthenticPixels() method is:
 %
-%      PixelPacket *GetAuthenticPixels(Image *image,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows,
+%      PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1979,8 +1979,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport PixelPacket *GetAuthenticPixels(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+MagickExport PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
@@ -2021,8 +2021,8 @@
 %
 %  The format of the GetAuthenticPixelsCache() method is:
 %
-%      PixelPacket *GetAuthenticPixelsCache(Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      PixelPacket *GetAuthenticPixelsCache(Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2035,14 +2035,14 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static PixelPacket *GetAuthenticPixelsCache(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+static PixelPacket *GetAuthenticPixelsCache(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
     *cache_info;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -2052,7 +2052,7 @@
   if (cache_info == (Cache) NULL)
     return((PixelPacket *) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   pixels=GetAuthenticPixelCacheNexus(image,x,y,columns,rows,
     cache_info->nexus_info[id],exception);
   return(pixels);
@@ -2086,7 +2086,7 @@
   CacheInfo
     *cache_info;
 
-  long
+  ssize_t
     id;
 
   MagickSizeType
@@ -2100,7 +2100,7 @@
   cache_info=(CacheInfo *) image->cache;
   assert(cache_info->signature == MagickSignature);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   extent=GetPixelCacheNexusExtent(image->cache,cache_info->nexus_info[id]);
   return(extent);
 }
@@ -2258,8 +2258,8 @@
 %
 %  The format of the GetOneAuthenticPixel() method is:
 %
-%      MagickBooleanType GetOneAuthenticPixel(const Image image,const long x,
-%        const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%      MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
+%        const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2272,8 +2272,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport MagickBooleanType GetOneAuthenticPixel(Image *image,const long x,
-  const long y,PixelPacket *pixel,ExceptionInfo *exception)
+MagickExport MagickBooleanType GetOneAuthenticPixel(Image *image,const ssize_t x,
+  const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   CacheInfo
     *cache_info;
@@ -2319,7 +2319,7 @@
 %  The format of the GetOneAuthenticPixelFromCache() method is:
 %
 %      MagickBooleanType GetOneAuthenticPixelFromCache(const Image image,
-%        const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2333,7 +2333,7 @@
 %
 */
 static MagickBooleanType GetOneAuthenticPixelFromCache(Image *image,
-  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   PixelPacket
     *pixels;
@@ -2366,7 +2366,7 @@
 %  The format of the GetOneVirtualMagickPixel() method is:
 %
 %      MagickBooleanType GetOneVirtualMagickPixel(const Image image,
-%        const long x,const long y,MagickPixelPacket *pixel,
+%        const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,
 %        ExceptionInfo exception)
 %
 %  A description of each parameter follows:
@@ -2381,7 +2381,7 @@
 %
 */
 MagickExport MagickBooleanType GetOneVirtualMagickPixel(const Image *image,
-  const long x,const long y,MagickPixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,ExceptionInfo *exception)
 {
   CacheInfo
     *cache_info;
@@ -2426,8 +2426,8 @@
 %  The format of the GetOneVirtualMethodPixel() method is:
 %
 %      MagickBooleanType GetOneVirtualMethodPixel(const Image image,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,Pixelpacket *pixel,ExceptionInfo exception)
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,Pixelpacket *pixel,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -2443,7 +2443,7 @@
 %
 */
 MagickExport MagickBooleanType GetOneVirtualMethodPixel(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
   PixelPacket *pixel,ExceptionInfo *exception)
 {
   GetOneVirtualPixelFromHandler
@@ -2488,8 +2488,8 @@
 %
 %  The format of the GetOneVirtualPixel() method is:
 %
-%      MagickBooleanType GetOneVirtualPixel(const Image image,const long x,
-%        const long y,PixelPacket *pixel,ExceptionInfo exception)
+%      MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
+%        const ssize_t y,PixelPacket *pixel,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -2503,7 +2503,7 @@
 %
 */
 MagickExport MagickBooleanType GetOneVirtualPixel(const Image *image,
-  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   GetOneVirtualPixelFromHandler
     get_one_virtual_pixel_from_handler;
@@ -2548,7 +2548,7 @@
 %  The format of the GetOneVirtualPixelFromCache() method is:
 %
 %      MagickBooleanType GetOneVirtualPixelFromCache(const Image image,
-%        const VirtualPixelPacket method,const long x,const long y,
+%        const VirtualPixelPacket method,const ssize_t x,const ssize_t y,
 %        PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2565,7 +2565,7 @@
 %
 */
 static MagickBooleanType GetOneVirtualPixelFromCache(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
   PixelPacket *pixel,ExceptionInfo *exception)
 {
   const PixelPacket
@@ -2884,8 +2884,8 @@
 %
 %  The format of the GetPixelCacheTileSize() method is:
 %
-%      void GetPixelCacheTileSize(const Image *image,unsigned long *width,
-%        unsigned long *height)
+%      void GetPixelCacheTileSize(const Image *image,size_t *width,
+%        size_t *height)
 %
 %  A description of each parameter follows:
 %
@@ -2896,8 +2896,8 @@
 %    o height: the optimize cache tile height in pixels.
 %
 */
-MagickExport void GetPixelCacheTileSize(const Image *image,unsigned long *width,
-  unsigned long *height)
+MagickExport void GetPixelCacheTileSize(const Image *image,size_t *width,
+  size_t *height)
 {
   CacheInfo
     *cache_info;
@@ -3022,14 +3022,14 @@
   const IndexPacket
     *indexes;
 
-  long
+  ssize_t
     id;
 
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   indexes=GetVirtualIndexesFromNexus(image->cache,cache_info->nexus_info[id]);
   return(indexes);
 }
@@ -3136,8 +3136,8 @@
 %  The format of the GetVirtualPixelsFromNexus() method is:
 %
 %      PixelPacket *GetVirtualPixelsFromNexus(const Image *image,
-%        const VirtualPixelMethod method,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows,
+%        const VirtualPixelMethod method,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows,
 %        NexusInfo *nexus_info,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -3155,7 +3155,7 @@
 %
 */
 
-static long
+static ssize_t
   DitherMatrix[64] =
   {
      0,  48,  12,  60,   3,  51,  15,  63,
@@ -3168,58 +3168,58 @@
     42,  26,  38,  22,  41,  25,  37,  21
   };
 
-static inline long DitherX(const long x,const unsigned long columns)
+static inline ssize_t DitherX(const ssize_t x,const size_t columns)
 {
-  long
+  ssize_t
     index;
 
   index=x+DitherMatrix[x & 0x07]-32L;
   if (index < 0L)
     return(0L);
-  if (index >= (long) columns)
-    return((long) columns-1L);
+  if (index >= (ssize_t) columns)
+    return((ssize_t) columns-1L);
   return(index);
 }
 
-static inline long DitherY(const long y,const unsigned long rows)
+static inline ssize_t DitherY(const ssize_t y,const size_t rows)
 {
-  long
+  ssize_t
     index;
 
   index=y+DitherMatrix[y & 0x07]-32L;
   if (index < 0L)
     return(0L);
-  if (index >= (long) rows)
-    return((long) rows-1L);
+  if (index >= (ssize_t) rows)
+    return((ssize_t) rows-1L);
   return(index);
 }
 
-static inline long EdgeX(const long x,const unsigned long columns)
+static inline ssize_t EdgeX(const ssize_t x,const size_t columns)
 {
   if (x < 0L)
     return(0L);
-  if (x >= (long) columns)
-    return((long) (columns-1));
+  if (x >= (ssize_t) columns)
+    return((ssize_t) (columns-1));
   return(x);
 }
 
-static inline long EdgeY(const long y,const unsigned long rows)
+static inline ssize_t EdgeY(const ssize_t y,const size_t rows)
 {
   if (y < 0L)
     return(0L);
-  if (y >= (long) rows)
-    return((long) (rows-1));
+  if (y >= (ssize_t) rows)
+    return((ssize_t) (rows-1));
   return(y);
 }
 
-static inline long RandomX(RandomInfo *random_info,const unsigned long columns)
+static inline ssize_t RandomX(RandomInfo *random_info,const size_t columns)
 {
-  return((long) (columns*GetPseudoRandomValue(random_info)));
+  return((ssize_t) (columns*GetPseudoRandomValue(random_info)));
 }
 
-static inline long RandomY(RandomInfo *random_info,const unsigned long rows)
+static inline ssize_t RandomY(RandomInfo *random_info,const size_t rows)
 {
-  return((long) (rows*GetPseudoRandomValue(random_info)));
+  return((ssize_t) (rows*GetPseudoRandomValue(random_info)));
 }
 
 /*
@@ -3229,22 +3229,22 @@
   essentially a ldiv() using a floored modulo division rather than the normal
   default truncated modulo division.
 */
-static inline MagickModulo VirtualPixelModulo(const long offset,
-  const unsigned long extent)
+static inline MagickModulo VirtualPixelModulo(const ssize_t offset,
+  const size_t extent)
 {
   MagickModulo
     modulo;
 
-  modulo.quotient=offset/(long) extent;
+  modulo.quotient=offset/(ssize_t) extent;
   if (offset < 0L)
     modulo.quotient--;
-  modulo.remainder=offset-modulo.quotient*(long) extent;
+  modulo.remainder=offset-modulo.quotient*(ssize_t) extent;
   return(modulo);
 }
 
 MagickExport const PixelPacket *GetVirtualPixelsFromNexus(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
-  const unsigned long columns,const unsigned long rows,NexusInfo *nexus_info,
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows,NexusInfo *nexus_info,
   ExceptionInfo *exception)
 {
   CacheInfo
@@ -3279,7 +3279,7 @@
   register IndexPacket
     *restrict indexes;
 
-  register long
+  register ssize_t
     u,
     v;
 
@@ -3307,8 +3307,8 @@
     nexus_info->region.width-1L;
   number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
   if ((offset >= 0) && (((MagickSizeType) offset+length) < number_pixels))
-    if ((x >= 0) && ((long) (x+columns) <= (long) cache_info->columns) &&
-        (y >= 0) && ((long) (y+rows) <= (long) cache_info->rows))
+    if ((x >= 0) && ((ssize_t) (x+columns) <= (ssize_t) cache_info->columns) &&
+        (y >= 0) && ((ssize_t) (y+rows) <= (ssize_t) cache_info->rows))
       {
         MagickBooleanType
           status;
@@ -3384,13 +3384,13 @@
     }
   }
   virtual_index=0;
-  for (v=0; v < (long) rows; v++)
+  for (v=0; v < (ssize_t) rows; v++)
   {
-    for (u=0; u < (long) columns; u+=length)
+    for (u=0; u < (ssize_t) columns; u+=length)
     {
       length=(MagickSizeType) MagickMin(cache_info->columns-(x+u),columns-u);
-      if ((((x+u) < 0) || ((x+u) >= (long) cache_info->columns)) ||
-          (((y+v) < 0) || ((y+v) >= (long) cache_info->rows)) || (length == 0))
+      if ((((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns)) ||
+          (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows)) || (length == 0))
         {
           MagickModulo
             x_modulo,
@@ -3460,11 +3460,11 @@
             {
               x_modulo=VirtualPixelModulo(x+u,cache_info->columns);
               if ((x_modulo.quotient & 0x01) == 1L)
-                x_modulo.remainder=(long) cache_info->columns-
+                x_modulo.remainder=(ssize_t) cache_info->columns-
                   x_modulo.remainder-1L;
               y_modulo=VirtualPixelModulo(y+v,cache_info->rows);
               if ((y_modulo.quotient & 0x01) == 1L)
-                y_modulo.remainder=(long) cache_info->rows-
+                y_modulo.remainder=(ssize_t) cache_info->rows-
                   y_modulo.remainder-1L;
               p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,
                 x_modulo.remainder,y_modulo.remainder,1UL,1UL,virtual_nexus[0],
@@ -3492,7 +3492,7 @@
             }
             case HorizontalTileVirtualPixelMethod:
             {
-              if (((y+v) < 0) || ((y+v) >= (long) cache_info->rows))
+              if (((y+v) < 0) || ((y+v) >= (ssize_t) cache_info->rows))
                 {
                   p=(&virtual_pixel);
                   virtual_indexes=(&virtual_index);
@@ -3509,7 +3509,7 @@
             }
             case VerticalTileVirtualPixelMethod:
             {
-              if (((x+u) < 0) || ((x+u) >= (long) cache_info->columns))
+              if (((x+u) < 0) || ((x+u) >= (ssize_t) cache_info->columns))
                 {
                   p=(&virtual_pixel);
                   virtual_indexes=(&virtual_index);
@@ -3557,7 +3557,7 @@
         Transfer a run of pixels.
       */
       p=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x+u,y+v,
-        (unsigned long) length,1UL,virtual_nexus[0],exception);
+        (size_t) length,1UL,virtual_nexus[0],exception);
       if (p == (const PixelPacket *) NULL)
         break;
       virtual_indexes=GetVirtualIndexesFromNexus(cache_info,virtual_nexus[0]);
@@ -3594,8 +3594,8 @@
 %  The format of the GetVirtualPixelCache() method is:
 %
 %      const PixelPacket *GetVirtualPixelCache(const Image *image,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -3611,8 +3611,8 @@
 %
 */
 static const PixelPacket *GetVirtualPixelCache(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
-  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows,ExceptionInfo *exception)
 {
   CacheInfo
    *cache_info;
@@ -3620,14 +3620,14 @@
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   pixels=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x,y,columns,rows,
     cache_info->nexus_info[id],exception);
   return(pixels);
@@ -3708,8 +3708,8 @@
 %
 %  The format of the GetVirtualPixels() method is:
 %
-%      const PixelPacket *GetVirtualPixels(const Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      const PixelPacket *GetVirtualPixels(const Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -3723,8 +3723,8 @@
 %
 */
 MagickExport const PixelPacket *GetVirtualPixels(const Image *image,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
   CacheInfo
     *cache_info;
@@ -3778,14 +3778,14 @@
   const PixelPacket
     *pixels;
 
-  long
+  ssize_t
     id;
 
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   pixels=GetVirtualPixelsNexus(image->cache,cache_info->nexus_info[id]);
   return(pixels);
 }
@@ -3906,7 +3906,7 @@
     *restrict nexus_indexes,
     *restrict indexes;
 
-  register long
+  register ssize_t
     i;
 
   register PixelPacket
@@ -3941,7 +3941,7 @@
   GetMagickPixelPacket(image,&beta);
   number_pixels=(MagickSizeType) nexus_info->region.width*
     nexus_info->region.height;
-  for (i=0; i < (long) number_pixels; i++)
+  for (i=0; i < (ssize_t) number_pixels; i++)
   {
     if ((p == (PixelPacket *) NULL) || (r == (const PixelPacket *) NULL))
       break;
@@ -3961,7 +3961,7 @@
   }
   clip_nexus=DestroyPixelCacheNexus(clip_nexus,1);
   image_nexus=DestroyPixelCacheNexus(image_nexus,1);
-  if (i < (long) number_pixels)
+  if (i < (ssize_t) number_pixels)
     return(MagickFalse);
   return(MagickTrue);
 }
@@ -4066,7 +4066,7 @@
   size_t
     packet_size;
 
-  unsigned long
+  size_t
     columns;
 
   if (image->debug != MagickFalse)
@@ -4098,7 +4098,7 @@
   if (cache_info->active_index_channel != MagickFalse)
     packet_size+=sizeof(IndexPacket);
   length=number_pixels*packet_size;
-  columns=(unsigned long) (length/cache_info->rows/packet_size);
+  columns=(size_t) (length/cache_info->rows/packet_size);
   if (cache_info->columns != columns)
     ThrowBinaryException(ResourceLimitError,"PixelCacheAllocationFailed",
       image->filename);
@@ -4295,7 +4295,7 @@
   Image
     clone_image;
 
-  long
+  ssize_t
     page_size;
 
   MagickBooleanType
@@ -4401,8 +4401,8 @@
 %
 %  The format of the QueueAuthenticNexus() method is:
 %
-%      PixelPacket *QueueAuthenticNexus(Image *image,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows,
+%      PixelPacket *QueueAuthenticNexus(Image *image,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows,
 %        NexusInfo *nexus_info,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4417,8 +4417,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport PixelPacket *QueueAuthenticNexus(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+MagickExport PixelPacket *QueueAuthenticNexus(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   NexusInfo *nexus_info,ExceptionInfo *exception)
 {
   CacheInfo
@@ -4443,8 +4443,8 @@
         "NoPixelsDefinedInCache","`%s'",image->filename);
       return((PixelPacket *) NULL);
     }
-  if ((x < 0) || (y < 0) || (x >= (long) cache_info->columns) ||
-      (y >= (long) cache_info->rows))
+  if ((x < 0) || (y < 0) || (x >= (ssize_t) cache_info->columns) ||
+      (y >= (ssize_t) cache_info->rows))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
         "PixelsAreNotAuthentic","`%s'",image->filename);
@@ -4486,8 +4486,8 @@
 %
 %  The format of the QueueAuthenticPixelsCache() method is:
 %
-%      PixelPacket *QueueAuthenticPixelsCache(Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      PixelPacket *QueueAuthenticPixelsCache(Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4500,14 +4500,14 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static PixelPacket *QueueAuthenticPixelsCache(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+static PixelPacket *QueueAuthenticPixelsCache(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
     *cache_info;
 
-  long
+  ssize_t
     id;
 
   PixelPacket
@@ -4517,7 +4517,7 @@
   if (cache_info == (Cache) NULL)
     return((PixelPacket *) NULL);
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   pixels=QueueAuthenticNexus(image,x,y,columns,rows,cache_info->nexus_info[id],
     exception);
   return(pixels);
@@ -4565,8 +4565,8 @@
 %
 %  The format of the QueueAuthenticPixels() method is:
 %
-%      PixelPacket *QueueAuthenticPixels(Image *image,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows,
+%      PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4579,8 +4579,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport PixelPacket *QueueAuthenticPixels(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+MagickExport PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
@@ -4646,10 +4646,10 @@
   register IndexPacket
     *restrict q;
 
-  register long
+  register ssize_t
     y;
 
-  unsigned long
+  size_t
     rows;
 
   if (cache_info->debug != MagickFalse)
@@ -4683,7 +4683,7 @@
           rows=1UL;
         }
       p=cache_info->indexes+offset;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         (void) CopyMagickMemory(q,p,(size_t) length);
         p+=cache_info->columns;
@@ -4709,7 +4709,7 @@
           rows=1UL;
         }
       number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         count=ReadPixelCacheRegion(cache_info,cache_info->offset+number_pixels*
           sizeof(PixelPacket)+offset*sizeof(*q),length,(unsigned char *) q);
@@ -4718,7 +4718,7 @@
         offset+=cache_info->columns;
         q+=nexus_info->region.width;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           ThrowFileException(exception,CacheError,"UnableToReadPixelCache",
             cache_info->cache_filename);
@@ -4776,13 +4776,13 @@
     length,
     number_pixels;
 
-  register long
+  register ssize_t
     y;
 
   register PixelPacket
     *restrict q;
 
-  unsigned long
+  size_t
     rows;
 
   if (cache_info->debug != MagickFalse)
@@ -4814,7 +4814,7 @@
           rows=1UL;
         }
       p=cache_info->pixels+offset;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         (void) CopyMagickMemory(q,p,(size_t) length);
         p+=cache_info->columns;
@@ -4839,7 +4839,7 @@
           length=number_pixels;
           rows=1UL;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         count=ReadPixelCacheRegion(cache_info,cache_info->offset+offset*
           sizeof(*q),length,(unsigned char *) q);
@@ -4848,7 +4848,7 @@
         offset+=cache_info->columns;
         q+=nexus_info->region.width;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           ThrowFileException(exception,CacheError,"UnableToReadPixelCache",
             cache_info->cache_filename);
@@ -5051,14 +5051,14 @@
   if ((cache_info->type != DiskCache) && (cache_info->type != PingCache) &&
       (image->clip_mask == (Image *) NULL) && (image->mask == (Image *) NULL))
     {
-      long
+      ssize_t
         x,
         y;
 
       x=nexus_info->region.x+nexus_info->region.width-1;
       y=nexus_info->region.y+nexus_info->region.height-1;
-      if (((nexus_info->region.x >= 0) && (x < (long) cache_info->columns) &&
-           (nexus_info->region.y >= 0) && (y < (long) cache_info->rows)) &&
+      if (((nexus_info->region.x >= 0) && (x < (ssize_t) cache_info->columns) &&
+           (nexus_info->region.y >= 0) && (y < (ssize_t) cache_info->rows)) &&
           ((nexus_info->region.height == 1UL) ||
            ((nexus_info->region.x == 0) &&
            ((nexus_info->region.width == cache_info->columns) ||
@@ -5257,7 +5257,7 @@
   CacheInfo
     *cache_info;
 
-  long
+  ssize_t
     id;
 
   MagickBooleanType
@@ -5265,7 +5265,7 @@
 
   cache_info=(CacheInfo *) image->cache;
   id=GetOpenMPThreadId();
-  assert(id < (long) cache_info->number_threads);
+  assert(id < (ssize_t) cache_info->number_threads);
   status=SyncAuthenticPixelCacheNexus(image,cache_info->nexus_info[id],
     exception);
   return(status);
@@ -5359,10 +5359,10 @@
   register const IndexPacket
     *restrict p;
 
-  register long
+  register ssize_t
     y;
 
-  unsigned long
+  size_t
     rows;
 
   if (cache_info->debug != MagickFalse)
@@ -5396,7 +5396,7 @@
           rows=1UL;
         }
       q=cache_info->indexes+offset;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         (void) CopyMagickMemory(q,p,(size_t) length);
         p+=nexus_info->region.width;
@@ -5422,7 +5422,7 @@
           rows=1UL;
         }
       number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         count=WritePixelCacheRegion(cache_info,cache_info->offset+number_pixels*
           sizeof(PixelPacket)+offset*sizeof(*p),length,
@@ -5432,7 +5432,7 @@
         p+=nexus_info->region.width;
         offset+=cache_info->columns;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           ThrowFileException(exception,CacheError,"UnableToWritePixelCache",
             cache_info->cache_filename);
@@ -5493,10 +5493,10 @@
   register const PixelPacket
     *restrict p;
 
-  register long
+  register ssize_t
     y;
 
-  unsigned long
+  size_t
     rows;
 
   if (cache_info->debug != MagickFalse)
@@ -5528,7 +5528,7 @@
           rows=1UL;
         }
       q=cache_info->pixels+offset;
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         (void) CopyMagickMemory(q,p,(size_t) length);
         p+=nexus_info->region.width;
@@ -5553,7 +5553,7 @@
           length=number_pixels;
           rows=1UL;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         count=WritePixelCacheRegion(cache_info,cache_info->offset+offset*
           sizeof(*p),length,(const unsigned char *) p);
@@ -5562,7 +5562,7 @@
         p+=nexus_info->region.width;
         offset+=cache_info->columns;
       }
-      if (y < (long) rows)
+      if (y < (ssize_t) rows)
         {
           ThrowFileException(exception,CacheError,"UnableToWritePixelCache",
             cache_info->cache_filename);
diff --git a/magick/cache.h b/magick/cache.h
index 5533bda..a9dc07c 100644
--- a/magick/cache.h
+++ b/magick/cache.h
@@ -28,8 +28,8 @@
   *GetVirtualIndexQueue(const Image *);
 
 extern MagickExport const PixelPacket
-  *GetVirtualPixels(const Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *),
+  *GetVirtualPixels(const Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *),
   *GetVirtualPixelQueue(const Image *);
 
 extern MagickExport const void
@@ -40,13 +40,13 @@
 
 extern MagickExport MagickBooleanType
   CacheComponentGenesis(void),
-  GetOneVirtualMagickPixel(const Image *,const long,const long,
+  GetOneVirtualMagickPixel(const Image *,const ssize_t,const ssize_t,
     MagickPixelPacket *,ExceptionInfo *),
-  GetOneVirtualPixel(const Image *,const long,const long,PixelPacket *,
+  GetOneVirtualPixel(const Image *,const ssize_t,const ssize_t,PixelPacket *,
     ExceptionInfo *),
-  GetOneVirtualMethodPixel(const Image *,const VirtualPixelMethod,const long,
-    const long,PixelPacket *,ExceptionInfo *),
-  GetOneAuthenticPixel(Image *,const long,const long,PixelPacket *,
+  GetOneVirtualMethodPixel(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,PixelPacket *,ExceptionInfo *),
+  GetOneAuthenticPixel(Image *,const ssize_t,const ssize_t,PixelPacket *,
     ExceptionInfo *),
   PersistPixelCache(Image *,const char *,const MagickBooleanType,
     MagickOffsetType *,ExceptionInfo *),
@@ -56,11 +56,11 @@
   GetImageExtent(const Image *);
 
 extern MagickExport PixelPacket
-  *GetAuthenticPixels(Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *),
+  *GetAuthenticPixels(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *),
   *GetAuthenticPixelQueue(const Image *),
-  *QueueAuthenticPixels(Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *);
+  *QueueAuthenticPixels(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *);
 
 extern MagickExport VirtualPixelMethod
   GetPixelCacheVirtualMethod(const Image *),
diff --git a/magick/cipher.c b/magick/cipher.c
index 59468d5..bc01b2d 100644
--- a/magick/cipher.c
+++ b/magick/cipher.c
@@ -78,11 +78,11 @@
     *encipher_key,
     *decipher_key;
 
-  long
+  ssize_t
     rounds,
     timestamp;
 
-  unsigned long
+  size_t
     signature;
 } AESInfo;
 
@@ -204,7 +204,7 @@
       (aes_info->encipher_key == (unsigned int *) NULL) ||
       (aes_info->decipher_key == (unsigned int *) NULL))
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
-  aes_info->timestamp=(long) time(0);
+  aes_info->timestamp=(ssize_t) time(0);
   aes_info->signature=MagickSignature;
   return(aes_info);
 }
@@ -281,7 +281,7 @@
 static inline void AddRoundKey(const unsigned int *ciphertext,
   const unsigned int *key,unsigned int *plaintext)
 {
-  register long
+  register ssize_t
     i;
 
   /*
@@ -380,7 +380,7 @@
 static void EncipherAESBlock(AESInfo *aes_info,const unsigned char *plaintext,
   unsigned char *ciphertext)
 {
-  register long
+  register ssize_t
     i,
     j;
 
@@ -562,7 +562,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -645,9 +645,9 @@
   quantum_type=GetQuantumType(image,exception);
   pixels=GetQuantumPixels(quantum_info);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -660,7 +660,7 @@
     length=ExportQuantumPixels(image,image_view,quantum_info,quantum_type,
       pixels,exception);
     p=pixels;
-    for (x=0; x < (long) length; x++)
+    for (x=0; x < (ssize_t) length; x++)
     {
       (void) CopyMagickMemory(output_block,input_block,AESBlocksize*
         sizeof(*output_block));
@@ -674,7 +674,8 @@
       pixels,exception);
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       break;
-    proceed=SetImageProgress(image,DecipherImageTag,y,image->rows);
+    proceed=SetImageProgress(image,DecipherImageTag,(MagickOffsetType) y,
+      image->rows);
     if (proceed == MagickFalse)
       break;
   }
@@ -690,7 +691,7 @@
   aes_info=DestroyAESInfo(aes_info);
   (void) ResetMagickMemory(input_block,0,sizeof(input_block));
   (void) ResetMagickMemory(output_block,0,sizeof(output_block));
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -764,7 +765,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -854,9 +855,9 @@
   quantum_type=GetQuantumType(image,exception);
   pixels=GetQuantumPixels(quantum_info);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -869,7 +870,7 @@
     length=ExportQuantumPixels(image,image_view,quantum_info,quantum_type,
       pixels,exception);
     p=pixels;
-    for (x=0; x < (long) length; x++)
+    for (x=0; x < (ssize_t) length; x++)
     {
       (void) CopyMagickMemory(output_block,input_block,AESBlocksize*
         sizeof(*output_block));
@@ -883,7 +884,8 @@
       pixels,exception);
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       break;
-    proceed=SetImageProgress(image,EncipherImageTag,y,image->rows);
+    proceed=SetImageProgress(image,EncipherImageTag,(MagickOffsetType) y,
+      image->rows);
     if (proceed == MagickFalse)
       break;
   }
@@ -896,7 +898,7 @@
   aes_info=DestroyAESInfo(aes_info);
   (void) ResetMagickMemory(input_block,0,sizeof(input_block));
   (void) ResetMagickMemory(output_block,0,sizeof(output_block));
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -962,11 +964,11 @@
 
 static void SetAESKey(AESInfo *aes_info,const StringInfo *key)
 {
-  long
+  ssize_t
     bytes,
     n;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
diff --git a/magick/coder.c b/magick/coder.c
index 0152ff8..4fcf3c1 100644
--- a/magick/coder.c
+++ b/magick/coder.c
@@ -351,7 +351,7 @@
 %  The format of the GetCoderInfoList function is:
 %
 %      const CoderInfo **GetCoderInfoList(const char *pattern,
-%        unsigned long *number_coders,ExceptionInfo *exception)
+%        size_t *number_coders,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -377,7 +377,7 @@
 }
 
 MagickExport const CoderInfo **GetCoderInfoList(const char *pattern,
-  unsigned long *number_coders,ExceptionInfo *exception)
+  size_t *number_coders,ExceptionInfo *exception)
 {
   const CoderInfo
     **coder_map;
@@ -385,7 +385,7 @@
   register const CoderInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -393,7 +393,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_coders != (unsigned long *) NULL);
+  assert(number_coders != (size_t *) NULL);
   *number_coders=0;
   p=GetCoderInfo("*",exception);
   if (p == (const CoderInfo *) NULL)
@@ -418,7 +418,7 @@
   UnlockSemaphoreInfo(coder_semaphore);
   qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderInfoCompare);
   coder_map[i]=(CoderInfo *) NULL;
-  *number_coders=(unsigned long) i;
+  *number_coders=(size_t) i;
   return(coder_map);
 }
 
@@ -437,7 +437,7 @@
 %
 %  The format of the GetCoderList function is:
 %
-%      char **GetCoderList(const char *pattern,unsigned long *number_coders,
+%      char **GetCoderList(const char *pattern,size_t *number_coders,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -462,7 +462,7 @@
 }
 
 MagickExport char **GetCoderList(const char *pattern,
-  unsigned long *number_coders,ExceptionInfo *exception)
+  size_t *number_coders,ExceptionInfo *exception)
 {
   char
     **coder_map;
@@ -470,7 +470,7 @@
   register const CoderInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -478,7 +478,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_coders != (unsigned long *) NULL);
+  assert(number_coders != (size_t *) NULL);
   *number_coders=0;
   p=GetCoderInfo("*",exception);
   if (p == (const CoderInfo *) NULL)
@@ -503,7 +503,7 @@
   UnlockSemaphoreInfo(coder_semaphore);
   qsort((void *) coder_map,(size_t) i,sizeof(*coder_map),CoderCompare);
   coder_map[i]=(char *) NULL;
-  *number_coders=(unsigned long) i;
+  *number_coders=(size_t) i;
   return(coder_map);
 }
 
@@ -581,13 +581,13 @@
   const CoderInfo
     **coder_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_coders;
 
   if (file == (const FILE *) NULL)
@@ -596,7 +596,7 @@
   if (coder_info == (const CoderInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_coders; i++)
+  for (i=0; i < (ssize_t) number_coders; i++)
   {
     if (coder_info[i]->stealth != MagickFalse)
       continue;
@@ -611,7 +611,7 @@
       }
     path=coder_info[i]->path;
     (void) fprintf(file,"%s",coder_info[i]->magick);
-    for (j=(long) strlen(coder_info[i]->magick); j <= 11; j++)
+    for (j=(ssize_t) strlen(coder_info[i]->magick); j <= 11; j++)
       (void) fprintf(file," ");
     if (coder_info[i]->name != (char *) NULL)
       (void) fprintf(file,"%s",coder_info[i]->name);
@@ -639,7 +639,7 @@
 %  The format of the LoadCoderList coder is:
 %
 %      MagickBooleanType LoadCoderList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -672,7 +672,7 @@
 }
 
 static MagickBooleanType LoadCoderList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -886,7 +886,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -904,7 +904,7 @@
           return(MagickFalse);
         }
     }
-  for (i=0; i < (long) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
   {
     CoderInfo
       *coder_info;
diff --git a/magick/coder.h b/magick/coder.h
index b4ad19f..0c831a4 100644
--- a/magick/coder.h
+++ b/magick/coder.h
@@ -37,16 +37,16 @@
     *previous,
     *next;  /* deprecated, use GetCoderInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } CoderInfo;
 
 extern MagickExport char
-  **GetCoderList(const char *,unsigned long *,ExceptionInfo *);
+  **GetCoderList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const CoderInfo
   *GetCoderInfo(const char *,ExceptionInfo *),
-  **GetCoderInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetCoderInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
   CoderComponentGenesis(void),
diff --git a/magick/color.c b/magick/color.c
index 255049a..a98b06d 100644
--- a/magick/color.c
+++ b/magick/color.c
@@ -85,7 +85,7 @@
     blue,
     alpha;
 
-  const long
+  const ssize_t
     compliance;
 } ColorMapInfo;
 
@@ -1026,7 +1026,7 @@
       if (pixel->depth > 16)
         {
           (void) FormatMagickString(component,MaxTextExtent,"%10lu",
-            (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
+            (size_t) ScaleQuantumToLong(ClampToQuantum(color)));
           (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
           return;
         }
@@ -1085,7 +1085,7 @@
 %  The format of the GetColorInfoList function is:
 %
 %      const ColorInfo **GetColorInfoList(const char *pattern,
-%        unsigned long *number_colors,ExceptionInfo *exception)
+%        size_t *number_colors,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1119,7 +1119,7 @@
 #endif
 
 MagickExport const ColorInfo **GetColorInfoList(const char *pattern,
-  unsigned long *number_colors,ExceptionInfo *exception)
+  size_t *number_colors,ExceptionInfo *exception)
 {
   const ColorInfo
     **colors;
@@ -1127,7 +1127,7 @@
   register const ColorInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1135,7 +1135,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_colors != (unsigned long *) NULL);
+  assert(number_colors != (size_t *) NULL);
   *number_colors=0;
   p=GetColorInfo("*",exception);
   if (p == (const ColorInfo *) NULL)
@@ -1160,7 +1160,7 @@
   UnlockSemaphoreInfo(color_semaphore);
   qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
   colors[i]=(ColorInfo *) NULL;
-  *number_colors=(unsigned long) i;
+  *number_colors=(size_t) i;
   return(colors);
 }
 
@@ -1179,7 +1179,7 @@
 %
 %  The format of the GetColorList function is:
 %
-%      char **GetColorList(const char *pattern,unsigned long *number_colors,
+%      char **GetColorList(const char *pattern,size_t *number_colors,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1212,7 +1212,7 @@
 #endif
 
 MagickExport char **GetColorList(const char *pattern,
-  unsigned long *number_colors,ExceptionInfo *exception)
+  size_t *number_colors,ExceptionInfo *exception)
 {
   char
     **colors;
@@ -1220,7 +1220,7 @@
   register const ColorInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1228,7 +1228,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_colors != (unsigned long *) NULL);
+  assert(number_colors != (size_t *) NULL);
   *number_colors=0;
   p=GetColorInfo("*",exception);
   if (p == (const ColorInfo *) NULL)
@@ -1253,7 +1253,7 @@
   UnlockSemaphoreInfo(color_semaphore);
   qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
   colors[i]=(char *) NULL;
-  *number_colors=(unsigned long) i;
+  *number_colors=(size_t) i;
   return(colors);
 }
 
@@ -1404,7 +1404,7 @@
         color.depth=8;
     }
   (void) ConcatenateMagickString(tuple,MagickOptionToMnemonic(
-    MagickColorspaceOptions,(long) color.colorspace),MaxTextExtent);
+    MagickColorspaceOptions,(ssize_t) color.colorspace),MaxTextExtent);
   if (color.matte != MagickFalse)
     (void) ConcatenateMagickString(tuple,"a",MaxTextExtent);
   (void) ConcatenateMagickString(tuple,"(",MaxTextExtent);
@@ -1562,7 +1562,7 @@
 %  The format of the IsImageSimilar method is:
 %
 %      MagickBooleanType IsImageSimilar(const Image *image,
-%        const Image *target_image,long *x_offset,long *y_offset,
+%        const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1581,7 +1581,7 @@
 %
 */
 MagickExport MagickBooleanType IsImageSimilar(const Image *image,
-  const Image *target_image,long *x_offset,long *y_offset,
+  const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
   ExceptionInfo *exception)
 {
 #define SearchImageText  "  Searching image...  "
@@ -1590,7 +1590,7 @@
     *image_view,
     *target_view;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -1609,7 +1609,7 @@
     *indexes,
     *target_indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1619,21 +1619,21 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(target_image != (Image *) NULL);
   assert(target_image->signature == MagickSignature);
-  assert(x_offset != (long *) NULL);
-  assert(y_offset != (long *) NULL);
+  assert(x_offset != (ssize_t *) NULL);
+  assert(y_offset != (ssize_t *) NULL);
   assert(exception != (ExceptionInfo *) NULL);
   x=0;
   GetMagickPixelPacket(image,&pixel);
   GetMagickPixelPacket(image,&target);
   image_view=AcquireCacheView(image);
   target_view=AcquireCacheView(target_image);
-  for (y=(*y_offset); y < (long) image->rows; y++)
+  for (y=(*y_offset); y < (ssize_t) image->rows; y++)
   {
-    for (x=y == 0 ? *x_offset : 0; x < (long) image->columns; x++)
+    for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
     {
-      for (j=0; j < (long) target_image->rows; j++)
+      for (j=0; j < (ssize_t) target_image->rows; j++)
       {
-        for (i=0; i < (long) target_image->columns; i++)
+        for (i=0; i < (ssize_t) target_image->columns; i++)
         {
           p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
           indexes=GetCacheViewVirtualIndexQueue(image_view);
@@ -1644,20 +1644,21 @@
           if (IsMagickColorSimilar(&pixel,&target) == MagickFalse)
             break;
         }
-        if (i < (long) target_image->columns)
+        if (i < (ssize_t) target_image->columns)
           break;
       }
-      if (j == (long) target_image->rows)
+      if (j == (ssize_t) target_image->rows)
         break;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
       break;
     if (image->progress_monitor != (MagickProgressMonitor) NULL)
       {
         MagickBooleanType
           proceed;
 
-        proceed=SetImageProgress(image,SearchImageText,y,image->rows);
+        proceed=SetImageProgress(image,SearchImageText,(MagickOffsetType) y,
+          image->rows);
         if (proceed == MagickFalse)
           status=MagickFalse;
       }
@@ -1666,7 +1667,7 @@
   image_view=DestroyCacheView(image_view);
   *x_offset=x;
   *y_offset=y;
-  return(y < (long) image->rows ? MagickTrue : MagickFalse);
+  return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -1850,10 +1851,10 @@
   const ColorInfo
     **color_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_colors;
 
   /*
@@ -1865,7 +1866,7 @@
   if (color_info == (const ColorInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_colors; i++)
+  for (i=0; i < (ssize_t) number_colors; i++)
   {
     if (color_info[i]->stealth != MagickFalse)
       continue;
@@ -1913,7 +1914,7 @@
 %  The format of the LoadColorList method is:
 %
 %      MagickBooleanType LoadColorList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1927,7 +1928,7 @@
 %
 */
 static MagickBooleanType LoadColorList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -2073,7 +2074,7 @@
           }
         if (LocaleCompare((char *) keyword,"compliance") == 0)
           {
-            long
+            ssize_t
               compliance;
 
             compliance=color_info->compliance;
@@ -2157,7 +2158,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -2175,7 +2176,7 @@
         }
     }
   scale=(MagickRealType) ScaleCharToQuantum(1);
-  for (i=0; i < (long) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
   {
     ColorInfo
       *color_info;
@@ -2370,7 +2371,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     type;
 
   MagickRealType
@@ -2382,7 +2383,7 @@
   register const ColorInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -2407,7 +2408,7 @@
       QuantumAny
         range;
 
-      unsigned long
+      size_t
         depth,
         n;
 
@@ -2424,7 +2425,7 @@
             pixel.red=pixel.green;
             pixel.green=pixel.blue;
             pixel.blue=0;
-            for (i=(long) (n/3-1); i >= 0; i--)
+            for (i=(ssize_t) (n/3-1); i >= 0; i--)
             {
               c=(*name++);
               pixel.blue<<=4;
@@ -2456,7 +2457,7 @@
             pixel.green=pixel.blue;
             pixel.blue=pixel.opacity;
             pixel.opacity=0;
-            for (i=(long) (n/4-1); i >= 0; i--)
+            for (i=(ssize_t) (n/4-1); i >= 0; i--)
             {
               c=(*name++);
               pixel.opacity<<=4;
@@ -2656,7 +2657,7 @@
   if (compliance == XPMCompliance)
     {
       pixel.matte=MagickFalse;
-      pixel.depth=(unsigned long) MagickMin(1.0*image->depth,16.0);
+      pixel.depth=(size_t) MagickMin(1.0*image->depth,16.0);
       GetColorTuple(&pixel,MagickTrue,name);
       return(MagickTrue);
     }
diff --git a/magick/color.h b/magick/color.h
index 5e5590a..3fdab0e 100644
--- a/magick/color.h
+++ b/magick/color.h
@@ -55,7 +55,7 @@
     *previous,
     *next;  /* deprecated, use GetColorInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } ColorInfo;
 
@@ -68,17 +68,17 @@
 } ErrorInfo;
 
 extern MagickExport char
-  **GetColorList(const char *,unsigned long *,ExceptionInfo *);
+  **GetColorList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const ColorInfo
   *GetColorInfo(const char *,ExceptionInfo *),
-  **GetColorInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetColorInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
   ColorComponentGenesis(void),
   IsColorSimilar(const Image *,const PixelPacket *,const PixelPacket *),
   IsGrayImage(const Image *,ExceptionInfo *),
-  IsImageSimilar(const Image *,const Image *,long *x,long *y,ExceptionInfo *),
+  IsImageSimilar(const Image *,const Image *,ssize_t *x,ssize_t *y,ExceptionInfo *),
   IsMagickColorSimilar(const MagickPixelPacket *,const MagickPixelPacket *),
   IsMonochromeImage(const Image *,ExceptionInfo *),
   IsOpacitySimilar(const Image *,const PixelPacket *,const PixelPacket *),
diff --git a/magick/colormap-private.h b/magick/colormap-private.h
index 7a77961..4a63641 100644
--- a/magick/colormap-private.h
+++ b/magick/colormap-private.h
@@ -27,7 +27,7 @@
 #include <magick/exception-private.h>
 
 static inline IndexPacket ConstrainColormapIndex(Image *image,
-  const unsigned long index)
+  const size_t index)
 {
   if (index < image->colors)
     return((IndexPacket) index);
diff --git a/magick/colormap.c b/magick/colormap.c
index 0755631..a3d6082 100644
--- a/magick/colormap.c
+++ b/magick/colormap.c
@@ -87,7 +87,7 @@
 %  The format of the AcquireImageColormap method is:
 %
 %      MagickBooleanType AcquireImageColormap(Image *image,
-%        const unsigned long colors)
+%        const size_t colors)
 %
 %  A description of each parameter follows:
 %
@@ -97,16 +97,16 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline unsigned long MagickMin(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMin(const size_t x,
+  const size_t y)
 {
   if (x < y)
     return(x);
@@ -114,9 +114,9 @@
 }
 
 MagickExport MagickBooleanType AcquireImageColormap(Image *image,
-  const unsigned long colors)
+  const size_t colors)
 {
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -140,12 +140,12 @@
   if (image->colormap == (PixelPacket *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < (ssize_t) image->colors; i++)
   {
-    unsigned long
+    size_t
       pixel;
 
-    pixel=(unsigned long) (i*(QuantumRange/MagickMax(colors-1,1)));
+    pixel=(size_t) (i*(QuantumRange/MagickMax(colors-1,1)));
     image->colormap[i].red=(Quantum) pixel;
     image->colormap[i].green=(Quantum) pixel;
     image->colormap[i].blue=(Quantum) pixel;
@@ -171,7 +171,7 @@
 %
 %  The format of the CycleColormapImage method is:
 %
-%      MagickBooleanType CycleColormapImage(Image *image,const long displace)
+%      MagickBooleanType CycleColormapImage(Image *image,const ssize_t displace)
 %
 %  A description of each parameter follows:
 %
@@ -181,7 +181,7 @@
 %
 */
 MagickExport MagickBooleanType CycleColormapImage(Image *image,
-  const long displace)
+  const ssize_t displace)
 {
   CacheView
     *image_view;
@@ -189,7 +189,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -207,15 +207,15 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    long
+    ssize_t
       index;
 
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -230,9 +230,9 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      index=(long) (indexes[x]+displace) % image->colors;
+      index=(ssize_t) (indexes[x]+displace) % image->colors;
       if (index < 0)
         index+=image->colors;
       indexes[x]=(IndexPacket) index;
@@ -304,13 +304,13 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   unsigned short
@@ -336,7 +336,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < (ssize_t) image->colors; i++)
     image->colormap[i].opacity=(IndexPacket) i;
   /*
     Sort image colormap by decreasing color popularity.
@@ -349,17 +349,17 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (i=0; i < (long) image->colors; i++)
-    pixels[(long) image->colormap[i].opacity]=(unsigned short) i;
+  for (i=0; i < (ssize_t) image->colors; i++)
+    pixels[(ssize_t) image->colormap[i].opacity]=(unsigned short) i;
   status=MagickTrue;
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     IndexPacket
       index;
 
-    register long
+    register ssize_t
       x;
 
     register IndexPacket
@@ -375,11 +375,11 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      index=(IndexPacket) pixels[(long) indexes[x]];
+      index=(IndexPacket) pixels[(ssize_t) indexes[x]];
       indexes[x]=index;
-      *q++=image->colormap[(long) index];
+      *q++=image->colormap[(ssize_t) index];
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       status=MagickFalse;
diff --git a/magick/colormap.h b/magick/colormap.h
index 235960a..19912ea 100644
--- a/magick/colormap.h
+++ b/magick/colormap.h
@@ -23,8 +23,8 @@
 #endif
 
 extern MagickExport MagickBooleanType
-  AcquireImageColormap(Image *,const unsigned long),
-  CycleColormapImage(Image *,const long),
+  AcquireImageColormap(Image *,const size_t),
+  CycleColormapImage(Image *,const ssize_t),
   SortColormapByIntensity(Image *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/colorspace.c b/magick/colorspace.c
index 12d326f..ac036c6 100644
--- a/magick/colorspace.c
+++ b/magick/colorspace.c
@@ -185,7 +185,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -196,7 +196,7 @@
   PrimaryInfo
     primary_info;
 
-  register long
+  register ssize_t
     i;
 
   TransformPacket
@@ -248,9 +248,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -265,7 +265,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=ClampToQuantum((MagickRealType) (QuantumRange-q->red));
           q->green=ClampToQuantum((MagickRealType) (QuantumRange-q->green));
@@ -301,7 +301,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickPixelPacket
           pixel;
@@ -309,7 +309,7 @@
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -326,7 +326,7 @@
           }
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
         pixel=zero;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           SetMagickPixelPacket(image,q,indexes+x,&pixel);
           ConvertRGBToCMYK(&pixel);
@@ -358,14 +358,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           brightness,
           hue,
           saturation;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -383,7 +383,7 @@
         hue=0.0;
         saturation=0.0;
         brightness=0.0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           ConvertRGBToHSB(q->red,q->green,q->blue,&hue,&saturation,&brightness);
           q->red=ClampToQuantum((MagickRealType) QuantumRange*hue);
@@ -414,14 +414,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           hue,
           lightness,
           saturation;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -439,7 +439,7 @@
         hue=0.0;
         saturation=0.0;
         lightness=0.0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           ConvertRGBToHSL(q->red,q->green,q->blue,&hue,&saturation,&lightness);
           q->red=ClampToQuantum((MagickRealType) QuantumRange*hue);
@@ -470,14 +470,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           blackness,
           hue,
           whiteness;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -495,7 +495,7 @@
         hue=0.0;
         whiteness=0.0;
         blackness=0.0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           ConvertRGBToHWB(q->red,q->green,q->blue,&hue,&whiteness,&blackness);
           q->red=ClampToQuantum((MagickRealType) QuantumRange*hue);
@@ -526,7 +526,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           a,
@@ -536,7 +536,7 @@
           Y,
           Z;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -557,7 +557,7 @@
         X=0.0;
         Y=0.0;
         Z=0.0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           ConvertRGBToXYZ(q->red,q->green,q->blue,&X,&Y,&Z);
           ConvertXYZToLab(X,Y,Z,&L,&a,&b);
@@ -624,7 +624,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
         logmap[i]=ScaleMapToQuantum((MagickRealType) (MaxMap*(reference_white+
           log10(black+((MagickRealType) i/MaxMap)*(1.0-black))/((gamma/density)*
           0.002/film_gamma))/1024.0));
@@ -632,9 +632,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -649,7 +649,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=(long) image->columns; x != 0; x--)
+        for (x=(ssize_t) image->columns; x != 0; x--)
         {
           q->red=logmap[ScaleQuantumToMap(q->red)];
           q->green=logmap[ScaleQuantumToMap(q->green)];
@@ -701,7 +701,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.33333f*(MagickRealType) i;
         y_map[i].x=0.33334f*(MagickRealType) i;
@@ -726,7 +726,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.29900f*(MagickRealType) i;
         y_map[i].x=0.58700f*(MagickRealType) i;
@@ -759,7 +759,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.299000f*(MagickRealType) i;
         y_map[i].x=0.587000f*(MagickRealType) i;
@@ -783,7 +783,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.21260f*(MagickRealType) i;
         y_map[i].x=0.71520f*(MagickRealType) i;
@@ -814,7 +814,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.212600f*(MagickRealType) i;
         y_map[i].x=0.715200f*(MagickRealType) i;
@@ -840,7 +840,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         MagickRealType
           v;
@@ -874,7 +874,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.4124564f*(MagickRealType) i;
         y_map[i].x=0.3575761f*(MagickRealType) i;
@@ -901,7 +901,7 @@
       */
       primary_info.y=(double) ScaleQuantumToMap(ScaleCharToQuantum(156));
       primary_info.z=(double) ScaleQuantumToMap(ScaleCharToQuantum(137));
-      for (i=0; i <= (long) (0.018*MaxMap); i++)
+      for (i=0; i <= (ssize_t) (0.018*MaxMap); i++)
       {
         x_map[i].x=0.003962014134275617f*(MagickRealType) i;
         y_map[i].x=0.007778268551236748f*(MagickRealType) i;
@@ -913,7 +913,7 @@
         y_map[i].z=(-0.005800713697502058f)*(MagickRealType) i;
         z_map[i].z=(-0.0011265440570958f)*(MagickRealType) i;
       }
-      for ( ; i <= (long) MaxMap; i++)
+      for ( ; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.2201118963486454*(1.099f*(MagickRealType) i-0.099f);
         y_map[i].x=0.4321260306242638*(1.099f*(MagickRealType) i-0.099f);
@@ -944,7 +944,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.29900f*(MagickRealType) i;
         y_map[i].x=0.58700f*(MagickRealType) i;
@@ -975,7 +975,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.299000f*(MagickRealType) i;
         y_map[i].x=0.587000f*(MagickRealType) i;
@@ -1007,7 +1007,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=0.29900f*(MagickRealType) i;
         y_map[i].x=0.58700f*(MagickRealType) i;
@@ -1037,18 +1037,18 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickPixelPacket
           pixel;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
           *restrict q;
 
-        register unsigned long
+        register size_t
           blue,
           green,
           red;
@@ -1062,7 +1062,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           red=ScaleQuantumToMap(q->red);
           green=ScaleQuantumToMap(q->green);
@@ -1100,7 +1100,7 @@
     }
     case PseudoClass:
     {
-      register unsigned long
+      register size_t
         blue,
         green,
         red;
@@ -1109,7 +1109,7 @@
         Convert PseudoClass image.
       */
       image_view=AcquireCacheView(image);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         MagickPixelPacket
           pixel;
@@ -1401,14 +1401,14 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     progress,
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   TransformPacket
@@ -1453,12 +1453,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1473,7 +1473,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=ClampToQuantum((MagickRealType) (QuantumRange-q->red));
           q->green=ClampToQuantum((MagickRealType) (QuantumRange-q->green));
@@ -1509,7 +1509,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1520,7 +1520,7 @@
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1537,7 +1537,7 @@
           }
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
         pixel=zero;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           SetMagickPixelPacket(image,q,indexes+x,&pixel);
           ConvertCMYKToRGB(&pixel);
@@ -1569,7 +1569,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           brightness,
@@ -1579,7 +1579,7 @@
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1594,7 +1594,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           hue=(double) (QuantumScale*q->red);
           saturation=(double) (QuantumScale*q->green);
@@ -1627,7 +1627,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           hue,
@@ -1637,7 +1637,7 @@
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1652,7 +1652,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           hue=(double) (QuantumScale*q->red);
           saturation=(double) (QuantumScale*q->green);
@@ -1685,7 +1685,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           blackness,
@@ -1695,7 +1695,7 @@
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1710,7 +1710,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           hue=(double) (QuantumScale*q->red);
           whiteness=(double) (QuantumScale*q->green);
@@ -1743,7 +1743,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         double
           a,
@@ -1756,7 +1756,7 @@
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1774,7 +1774,7 @@
         X=0.0;
         Y=0.0;
         Z=0.0;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           L=QuantumScale*q->red;
           a=QuantumScale*q->green;
@@ -1835,13 +1835,13 @@
           image->filename);
       black=pow(10.0,(reference_black-reference_white)*(gamma/density)*
         0.002/film_gamma);
-      for (i=0; i <= (long) (reference_black*MaxMap/1024.0); i++)
+      for (i=0; i <= (ssize_t) (reference_black*MaxMap/1024.0); i++)
         logmap[i]=(Quantum) 0;
-      for ( ; i < (long) (reference_white*MaxMap/1024.0); i++)
+      for ( ; i < (ssize_t) (reference_white*MaxMap/1024.0); i++)
         logmap[i]=ClampToQuantum((MagickRealType) QuantumRange/(1.0-black)*
           (pow(10.0,(1024.0*i/MaxMap-reference_white)*
           (gamma/density)*0.002/film_gamma)-black));
-      for ( ; i <= (long) MaxMap; i++)
+      for ( ; i <= (ssize_t) MaxMap; i++)
         logmap[i]=(Quantum) QuantumRange;
       if (SetImageStorageClass(image,DirectClass) == MagickFalse)
         return(MagickFalse);
@@ -1849,12 +1849,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1869,7 +1869,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=(long) image->columns; x != 0; x--)
+        for (x=(ssize_t) image->columns; x != 0; x--)
         {
           q->red=logmap[ScaleQuantumToMap(q->red)];
           q->green=logmap[ScaleQuantumToMap(q->green)];
@@ -1928,7 +1928,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.500000f*(2.000000*(MagickRealType) i-(MagickRealType)
@@ -1963,7 +1963,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.000000f;
@@ -1996,7 +1996,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.000000f;
@@ -2026,7 +2026,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=1.0f*(MagickRealType) i;
         y_map[i].x=0.0f*(MagickRealType) i;
@@ -2052,7 +2052,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=3.2404542f*(MagickRealType) i;
         x_map[i].y=(-0.9692660f)*(MagickRealType) i;
@@ -2080,7 +2080,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=1.3584000f*(MagickRealType) i;
         y_map[i].x=0.0000000f;
@@ -2113,7 +2113,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.47810f*(2.00000f*(MagickRealType) i-(MagickRealType)
@@ -2148,7 +2148,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.000000f;
@@ -2182,7 +2182,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         x_map[i].x=(MagickRealType) i;
         y_map[i].x=0.00000f;
@@ -2216,7 +2216,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -2224,7 +2224,7 @@
         MagickPixelPacket
           pixel;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -2239,9 +2239,9 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
-          register unsigned long
+          register size_t
             blue,
             green,
             red;
@@ -2325,12 +2325,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         MagickPixelPacket
           pixel;
 
-        register unsigned long
+        register size_t
           blue,
           green,
           red;
diff --git a/magick/compare.c b/magick/compare.c
index 2fea579..51b43aa 100644
--- a/magick/compare.c
+++ b/magick/compare.c
@@ -129,7 +129,7 @@
     *difference_image,
     *highlight_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -200,7 +200,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -220,7 +220,7 @@
     register IndexPacket
       *restrict highlight_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -244,7 +244,7 @@
     highlight_indexes=GetCacheViewAuthenticIndexQueue(highlight_view);
     pixel=zero;
     reconstruct_pixel=zero;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickStatusType
         difference;
@@ -353,7 +353,7 @@
     *image_view,
     *reconstruct_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -372,7 +372,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       channel_distortion[AllChannels+1];
@@ -389,7 +389,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -408,7 +408,7 @@
     pixel=zero;
     reconstruct_pixel=pixel;
     (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,p,indexes+x,&pixel);
       SetMagickPixelPacket(reconstruct_image,q,reconstruct_indexes+x,
@@ -435,7 +435,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp critical (MagickCore_GetAbsoluteError)
 #endif
-    for (i=0; i <= (long) AllChannels; i++)
+    for (i=0; i <= (ssize_t) AllChannels; i++)
       distortion[i]+=channel_distortion[i];
   }
   reconstruct_view=DestroyCacheView(reconstruct_view);
@@ -443,10 +443,10 @@
   return(status);
 }
 
-static unsigned long GetNumberChannels(const Image *image,
+static size_t GetNumberChannels(const Image *image,
   const ChannelType channel)
 {
-  unsigned long
+  size_t
     channels;
 
   channels=0;
@@ -473,13 +473,13 @@
     *image_view,
     *reconstruct_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   status=MagickTrue;
@@ -488,7 +488,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       channel_distortion[AllChannels+1];
@@ -501,7 +501,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -518,7 +518,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
     (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         distance;
@@ -562,12 +562,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp critical (MagickCore_GetMeanAbsoluteError)
 #endif
-    for (i=0; i <= (long) AllChannels; i++)
+    for (i=0; i <= (ssize_t) AllChannels; i++)
       distortion[i]+=channel_distortion[i];
   }
   reconstruct_view=DestroyCacheView(reconstruct_view);
   image_view=DestroyCacheView(image_view);
-  for (i=0; i <= (long) AllChannels; i++)
+  for (i=0; i <= (ssize_t) AllChannels; i++)
     distortion[i]/=((double) image->columns*image->rows);
   distortion[AllChannels]/=(double) GetNumberChannels(image,channel);
   return(status);
@@ -581,7 +581,7 @@
     *image_view,
     *reconstruct_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -602,7 +602,7 @@
   mean_error=0.0;
   image_view=AcquireCacheView(image);
   reconstruct_view=AcquireCacheView(reconstruct_image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes,
@@ -612,7 +612,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -625,7 +625,7 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         distance;
@@ -710,13 +710,13 @@
     *image_view,
     *reconstruct_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   status=MagickTrue;
@@ -725,7 +725,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       channel_distortion[AllChannels+1];
@@ -738,7 +738,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -755,7 +755,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
     (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         distance;
@@ -800,12 +800,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp critical (MagickCore_GetMeanSquaredError)
 #endif
-    for (i=0; i <= (long) AllChannels; i++)
+    for (i=0; i <= (ssize_t) AllChannels; i++)
       distortion[i]+=channel_distortion[i];
   }
   reconstruct_view=DestroyCacheView(reconstruct_view);
   image_view=DestroyCacheView(image_view);
-  for (i=0; i <= (long) AllChannels; i++)
+  for (i=0; i <= (ssize_t) AllChannels; i++)
     distortion[i]/=((double) image->columns*image->rows);
   distortion[AllChannels]/=(double) GetNumberChannels(image,channel);
   return(status);
@@ -819,7 +819,7 @@
     *image_view,
     *reconstruct_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -831,7 +831,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       channel_distortion[AllChannels+1];
@@ -844,7 +844,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -861,7 +861,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
     (void) ResetMagickMemory(channel_distortion,0,sizeof(channel_distortion));
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         distance;
@@ -916,7 +916,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp critical (MagickCore_GetPeakAbsoluteError)
 #endif
-    for (i=0; i <= (long) AllChannels; i++)
+    for (i=0; i <= (ssize_t) AllChannels; i++)
       if (channel_distortion[i] > distortion[i])
         distortion[i]=channel_distortion[i];
   }
@@ -1244,7 +1244,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1270,7 +1270,7 @@
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
   reconstruct_view=AcquireCacheView(reconstruct_image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes,
@@ -1280,7 +1280,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -1290,7 +1290,7 @@
       break;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reconstruct_indexes=GetCacheViewVirtualIndexQueue(reconstruct_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         distance;
@@ -1382,7 +1382,7 @@
 */
 
 static double GetSimilarityMetric(const Image *image,const Image *reference,
-  const long x_offset,const long y_offset,ExceptionInfo *exception)
+  const ssize_t x_offset,const ssize_t y_offset,ExceptionInfo *exception)
 {
   CacheView
     *image_view,
@@ -1391,7 +1391,7 @@
   double
     similarity;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1407,7 +1407,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) reference->rows; y++)
+  for (y=0; y < (ssize_t) reference->rows; y++)
   {
     register const IndexPacket
       *restrict indexes,
@@ -1417,7 +1417,7 @@
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       x;
 
     if (status == MagickFalse)
@@ -1433,7 +1433,7 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
-    for (x=0; x < (long) reference->columns; x++)
+    for (x=0; x < (ssize_t) reference->columns; x++)
     {
       double
         thread_similarity;
@@ -1485,16 +1485,18 @@
   CacheView
     *similarity_view;
 
-  long
-    progress,
-    y;
-
   Image
     *similarity_image;
 
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -1526,12 +1528,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) (image->rows-reference->rows+1); y++)
+  for (y=0; y < (ssize_t) (image->rows-reference->rows+1); y++)
   {
     double
       similarity;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1546,7 +1548,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) (image->columns-reference->columns+1); x++)
+    for (x=0; x < (ssize_t) (image->columns-reference->columns+1); x++)
     {
       similarity=GetSimilarityMetric(image,reference,x,y,exception);
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
diff --git a/magick/composite.c b/magick/composite.c
index c811b08..ef1a75f 100644
--- a/magick/composite.c
+++ b/magick/composite.c
@@ -90,10 +90,10 @@
 %
 %      MagickBooleanType CompositeImage(Image *image,
 %        const CompositeOperator compose,Image *composite_image,
-%        const long x_offset,const long y_offset)
+%        const ssize_t x_offset,const ssize_t y_offset)
 %      MagickBooleanType CompositeImageChannel(Image *image,
 %        const ChannelType channel,const CompositeOperator compose,
-%        Image *composite_image,const long x_offset,const long y_offset)
+%        Image *composite_image,const ssize_t x_offset,const ssize_t y_offset)
 %
 %  A description of each parameter follows:
 %
@@ -1500,7 +1500,7 @@
 
 MagickExport MagickBooleanType CompositeImage(Image *image,
   const CompositeOperator compose,const Image *composite_image,
-  const long x_offset,const long y_offset)
+  const ssize_t x_offset,const ssize_t y_offset)
 {
   MagickBooleanType
     status;
@@ -1512,7 +1512,7 @@
 
 MagickExport MagickBooleanType CompositeImageChannel(Image *image,
   const ChannelType channel,const CompositeOperator compose,
-  const Image *composite_image,const long x_offset,const long y_offset)
+  const Image *composite_image,const ssize_t x_offset,const ssize_t y_offset)
 {
 #define CompositeImageTag  "Composite/Image"
 
@@ -1535,7 +1535,7 @@
   Image
     *destination_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1606,9 +1606,9 @@
     {
       if ((x_offset < 0) || (y_offset < 0))
         break;
-      if ((x_offset+(long) composite_image->columns) >= (long) image->columns)
+      if ((x_offset+(ssize_t) composite_image->columns) >= (ssize_t) image->columns)
         break;
-      if ((y_offset+(long) composite_image->rows) >= (long) image->rows)
+      if ((y_offset+(ssize_t) composite_image->rows) >= (ssize_t) image->rows)
         break;
       status=MagickTrue;
       exception=(&image->exception);
@@ -1617,7 +1617,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
 #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) composite_image->rows; y++)
+      for (y=0; y < (ssize_t) composite_image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1761,7 +1761,7 @@
       SetResampleFilter(resample_filter,GaussianFilter,1.0);
       destination_view=AcquireCacheView(destination_image);
       composite_view=AcquireCacheView(composite_image);
-      for (y=0; y < (long) composite_image->rows; y++)
+      for (y=0; y < (ssize_t) composite_image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1775,10 +1775,10 @@
         register IndexPacket
           *restrict destination_indexes;
 
-        register long
+        register ssize_t
           x;
 
-        if (((y+y_offset) < 0) || ((y+y_offset) >= (long) image->rows))
+        if (((y+y_offset) < 0) || ((y+y_offset) >= (ssize_t) image->rows))
           continue;
         p=GetCacheViewVirtualPixels(composite_view,0,y,composite_image->columns,
           1,exception);
@@ -1787,9 +1787,9 @@
         if ((p == (const PixelPacket *) NULL) || (r == (PixelPacket *) NULL))
           break;
         destination_indexes=GetCacheViewAuthenticIndexQueue(destination_view);
-        for (x=0; x < (long) composite_image->columns; x++)
+        for (x=0; x < (ssize_t) composite_image->columns; x++)
         {
-          if (((x_offset+x) < 0) || ((x_offset+x) >= (long) image->columns))
+          if (((x_offset+x) < 0) || ((x_offset+x) >= (ssize_t) image->columns))
             {
               p++;
               continue;
@@ -1943,7 +1943,7 @@
       resample_filter=AcquireResampleFilter(image,&image->exception);
       destination_view=AcquireCacheView(destination_image);
       composite_view=AcquireCacheView(composite_image);
-      for (y=0; y < (long) composite_image->rows; y++)
+      for (y=0; y < (ssize_t) composite_image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1951,10 +1951,10 @@
         register const PixelPacket
           *restrict p;
 
-        register long
+        register ssize_t
           x;
 
-        if (((y+y_offset) < 0) || ((y+y_offset) >= (long) image->rows))
+        if (((y+y_offset) < 0) || ((y+y_offset) >= (ssize_t) image->rows))
           continue;
         p=GetCacheViewVirtualPixels(composite_view,0,y,composite_image->columns,
           1,exception);
@@ -1963,9 +1963,9 @@
         if ((p == (const PixelPacket *) NULL) || (r == (PixelPacket *) NULL))
           break;
         destination_indexes=GetCacheViewAuthenticIndexQueue(destination_view);
-        for (x=0; x < (long) composite_image->columns; x++)
+        for (x=0; x < (ssize_t) composite_image->columns; x++)
         {
-          if (((x_offset+x) < 0) || ((x_offset+x) >= (long) image->columns))
+          if (((x_offset+x) < 0) || ((x_offset+x) >= (ssize_t) image->columns))
             {
               p++;
               continue;
@@ -2115,7 +2115,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     const PixelPacket
       *pixels;
@@ -2139,7 +2139,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2151,7 +2151,7 @@
       {
         if (y < y_offset)
           continue;
-        if ((y-y_offset) >= (long) composite_image->rows)
+        if ((y-y_offset) >= (ssize_t) composite_image->rows)
           continue;
       }
     /*
@@ -2159,7 +2159,7 @@
     */
     pixels=(PixelPacket *) NULL;
     p=(PixelPacket *) NULL;
-    if ((y >= y_offset) && ((y-y_offset) < (long) composite_image->rows))
+    if ((y >= y_offset) && ((y-y_offset) < (ssize_t) composite_image->rows))
       {
         p=GetCacheViewVirtualPixels(composite_view,0,y-y_offset,
           composite_image->columns,1,exception);
@@ -2186,7 +2186,7 @@
     hue=0.0;
     saturation=0.0;
     brightness=0.0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (modify_outside_overlay == MagickFalse)
         {
@@ -2195,7 +2195,7 @@
               q++;
               continue;
             }
-          if ((x-x_offset) >= (long) composite_image->columns)
+          if ((x-x_offset) >= (ssize_t) composite_image->columns)
             break;
         }
       destination.red=(MagickRealType) q->red;
@@ -2215,7 +2215,7 @@
       */
       composite=destination;
       if ((pixels == (PixelPacket *) NULL) || (x < x_offset) ||
-          ((x-x_offset) >= (long) composite_image->columns))
+          ((x-x_offset) >= (ssize_t) composite_image->columns))
         {
           switch (compose)
           {
@@ -2511,12 +2511,12 @@
         }
         case ModulateCompositeOp:
         {
-          long
+          ssize_t
             offset;
 
           if (source.opacity == TransparentOpacity)
             break;
-          offset=(long) (MagickPixelIntensityToQuantum(&source)-midpoint);
+          offset=(ssize_t) (MagickPixelIntensityToQuantum(&source)-midpoint);
           if (offset == 0)
             break;
           CompositeHSB(destination.red,destination.green,destination.blue,&hue,
@@ -2726,7 +2726,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2752,14 +2752,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y+=texture->rows)
+      for (y=0; y < (ssize_t) image->rows; y+=texture->rows)
       {
-        register long
+        register ssize_t
           x;
 
         if (status == MagickFalse)
           continue;
-        for (x=0; x < (long) image->columns; x+=texture->columns)
+        for (x=0; x < (ssize_t) image->columns; x+=texture->columns)
         {
           MagickBooleanType
             thread_status;
@@ -2799,7 +2799,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -2813,13 +2813,13 @@
     register IndexPacket
       *indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
       *q;
 
-    unsigned long
+    size_t
       width;
 
     if (status == MagickFalse)
@@ -2835,10 +2835,10 @@
       }
     texture_indexes=GetCacheViewVirtualIndexQueue(texture_view);
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x+=texture->columns)
+    for (x=0; x < (ssize_t) image->columns; x+=texture->columns)
     {
       width=texture->columns;
-      if ((x+(long) width) > (long) image->columns)
+      if ((x+(ssize_t) width) > (ssize_t) image->columns)
         width=image->columns-x;
       (void) CopyMagickMemory(q,p,width*sizeof(*p));
       if ((image->colorspace == CMYKColorspace) &&
diff --git a/magick/composite.h b/magick/composite.h
index 2f92e5c..3dca1df 100644
--- a/magick/composite.h
+++ b/magick/composite.h
@@ -95,10 +95,10 @@
 #define SubtractCompositeOp  ModulusSubtractCompositeOp
 
 extern MagickExport MagickBooleanType
-  CompositeImage(Image *,const CompositeOperator,const Image *,const long,
-    const long),
+  CompositeImage(Image *,const CompositeOperator,const Image *,const ssize_t,
+    const ssize_t),
   CompositeImageChannel(Image *,const ChannelType,const CompositeOperator,
-    const Image *,const long,const long),
+    const Image *,const ssize_t,const ssize_t),
   TextureImage(Image *,const Image *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/compress.c b/magick/compress.c
index 07b8422..f913ca3 100644
--- a/magick/compress.c
+++ b/magick/compress.c
@@ -75,7 +75,7 @@
 */
 struct _Ascii85Info
 {
-  long
+  ssize_t
     offset,
     line_break;
 
@@ -85,7 +85,7 @@
 
 typedef struct HuffmanTable
 {
-  unsigned long
+  size_t
     id,
     code,
     length,
@@ -222,7 +222,7 @@
 %
 %  The format of the ASCII85Encode method is:
 %
-%      void Ascii85Encode(Image *image,const unsigned long code)
+%      void Ascii85Encode(Image *image,const size_t code)
 %
 %  A description of each parameter follows:
 %
@@ -239,16 +239,16 @@
   static char
     tuple[6];
 
-  register long
+  register ssize_t
     i,
     x;
 
-  unsigned long
+  size_t
     code,
     quantum;
 
-  code=((((unsigned long) data[0] << 8) | (unsigned long) data[1]) << 16) |
-    ((unsigned long) data[2] << 8) | (unsigned long) data[3];
+  code=((((size_t) data[0] << 8) | (size_t) data[1]) << 16) |
+    ((size_t) data[2] << 8) | (size_t) data[3];
   if (code == 0L)
     {
       tuple[0]='z';
@@ -258,7 +258,7 @@
   quantum=85UL*85UL*85UL*85UL;
   for (i=0; i < 4; i++)
   {
-    x=(long) (code/quantum);
+    x=(ssize_t) (code/quantum);
     code-=quantum*x;
     tuple[i]=(char) (x+(int) '!');
     quantum/=85L;
@@ -308,7 +308,7 @@
 
 MagickExport void Ascii85Encode(Image *image,const unsigned char code)
 {
-  long
+  ssize_t
     n;
 
   register char
@@ -410,7 +410,7 @@
       mask=0x80;  \
     }  \
   runlength++;  \
-  bit=(unsigned long) ((byte & mask) != 0 ? 0x01 : 0x00); \
+  bit=(size_t) ((byte & mask) != 0 ? 0x01 : 0x00); \
   mask>>=1;  \
   if (bit != 0)  \
     runlength=0;  \
@@ -432,7 +432,7 @@
   int
     byte;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -441,7 +441,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -457,7 +457,7 @@
     bail,
     color;
 
-  unsigned long
+  size_t
     bit,
     code,
     mask,
@@ -509,9 +509,9 @@
   image->y_resolution=196.0;
   image->units=PixelsPerInchResolution;
   exception=(&image->exception);
-  for (y=0; ((y < (long) image->rows) && (null_lines < 3)); )
+  for (y=0; ((y < (ssize_t) image->rows) && (null_lines < 3)); )
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -521,7 +521,7 @@
       Initialize scanline to white.
     */
     p=scanline;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *p++=(unsigned char) 0;
     /*
       Decode Huffman encoded scanline.
@@ -536,7 +536,7 @@
     {
       if (byte == EOF)
         break;
-      if (x >= (long) image->columns)
+      if (x >= (ssize_t) image->columns)
         {
           while (runlength < 11)
             InputBit(bit);
@@ -560,7 +560,7 @@
                 break;
               }
           }
-        code=(code << 1)+(unsigned long) bit;
+        code=(code << 1)+(size_t) bit;
         length++;
       } while (code == 0);
       if (bail != MagickFalse)
@@ -594,7 +594,7 @@
         case TBId:
         {
           count+=entry->count;
-          if ((x+count) > (long) image->columns)
+          if ((x+count) > (ssize_t) image->columns)
             count=(ssize_t) image->columns-x;
           if (count > 0)
             {
@@ -632,11 +632,11 @@
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetAuthenticIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       index=(IndexPacket) (*p++);
       indexes[x]=index;
-      *q++=image->colormap[(long) index];
+      *q++=image->colormap[(ssize_t) index];
     }
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
@@ -645,7 +645,7 @@
       break;
     y++;
   }
-  image->rows=(unsigned long) MagickMax((size_t) y-3,1);
+  image->rows=(size_t) MagickMax((size_t) y-3,1);
   image->compression=FaxCompression;
   /*
     Free decoder memory.
@@ -722,7 +722,7 @@
     k,
     runlength;
 
-  long
+  ssize_t
     n,
     y;
 
@@ -732,7 +732,7 @@
   MagickBooleanType
     proceed;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -747,7 +747,7 @@
     bit,
     *scanline;
 
-  unsigned long
+  size_t
     mask,
     width;
 
@@ -764,7 +764,7 @@
   assert(inject_image->signature == MagickSignature);
   width=inject_image->columns;
   if (LocaleCompare(image_info->magick,"FAX") == 0)
-    width=(unsigned long) MagickMax(inject_image->columns,1728);
+    width=(size_t) MagickMax(inject_image->columns,1728);
   scanline=(unsigned char *) AcquireQuantumMemory((size_t) width+1UL,
     sizeof(*scanline));
   if (scanline == (unsigned char *) NULL)
@@ -796,12 +796,12 @@
   */
   exception=(&huffman_image->exception);
   q=scanline;
-  for (y=0; y < (long) huffman_image->rows; y++)
+  for (y=0; y < (ssize_t) huffman_image->rows; y++)
   {
     p=GetVirtualPixels(huffman_image,0,y,huffman_image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) huffman_image->columns; x++)
+    for (x=0; x < (ssize_t) huffman_image->columns; x++)
     {
       *q++=(unsigned char) (PixelIntensity(p) >= ((MagickRealType)
         QuantumRange/2.0) ? 0 : 1);
@@ -811,7 +811,7 @@
       Huffman encode scanline.
     */
     q=scanline;
-    for (n=(long) width; n > 0; )
+    for (n=(ssize_t) width; n > 0; )
     {
       /*
         Output white run.
@@ -943,22 +943,22 @@
 
   typedef struct _TableType
   {
-    long
+    ssize_t
       prefix,
       suffix,
       next;
   } TableType;
 
-  long
+  ssize_t
     index;
 
-  register long
+  register ssize_t
     i;
 
   TableType
     *table;
 
-  unsigned long
+  size_t
     accumulator,
     number_bits,
     code_width,
@@ -992,32 +992,32 @@
   }
   next_index=LZWEod+1;
   code_width=9;
-  last_code=(unsigned long) pixels[0];
-  for (i=1; i < (long) length; i++)
+  last_code=(size_t) pixels[0];
+  for (i=1; i < (ssize_t) length; i++)
   {
     /*
       Find string.
     */
-    index=(long) last_code;
+    index=(ssize_t) last_code;
     while (index != -1)
-      if ((table[index].prefix != (long) last_code) ||
-          (table[index].suffix != (long) pixels[i]))
+      if ((table[index].prefix != (ssize_t) last_code) ||
+          (table[index].suffix != (ssize_t) pixels[i]))
         index=table[index].next;
       else
         {
-          last_code=(unsigned long) index;
+          last_code=(size_t) index;
           break;
         }
-    if (last_code != (unsigned long) index)
+    if (last_code != (size_t) index)
       {
         /*
           Add string.
         */
         OutputCode(last_code);
-        table[next_index].prefix=(long) last_code;
+        table[next_index].prefix=(ssize_t) last_code;
         table[next_index].suffix=(short) pixels[i];
         table[next_index].next=table[last_code].next;
-        table[last_code].next=(long) next_index;
+        table[last_code].next=(ssize_t) next_index;
         next_index++;
         /*
           Did we just move up to next bit width?
@@ -1042,7 +1042,7 @@
                 code_width=9;
               }
             }
-          last_code=(unsigned long) pixels[i];
+          last_code=(size_t) pixels[i];
       }
   }
   /*
@@ -1092,7 +1092,7 @@
   int
     count;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -1111,7 +1111,7 @@
   if (packbits == (unsigned char *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
-  for (i=(long) length; i != 0; )
+  for (i=(ssize_t) length; i != 0; )
   {
     switch (i)
     {
@@ -1153,7 +1153,7 @@
               Packed run.
             */
             count=3;
-            while (((long) count < i) && (*pixels == *(pixels+count)))
+            while (((ssize_t) count < i) && (*pixels == *(pixels+count)))
             {
               count++;
               if (count >= 127)
@@ -1174,12 +1174,12 @@
         {
           packbits[count+1]=pixels[count];
           count++;
-          if (((long) count >= (i-3)) || (count >= 127))
+          if (((ssize_t) count >= (i-3)) || (count >= 127))
             break;
         }
         i-=count;
         *packbits=(unsigned char) (count-1);
-        for (j=0; j <= (long) count; j++)
+        for (j=0; j <= (ssize_t) count; j++)
           (void) WriteBlobByte(image,packbits[j]);
         pixels+=count;
         break;
@@ -1242,7 +1242,7 @@
   int
     status;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1285,7 +1285,7 @@
   if (status != Z_OK)
     ThrowBinaryException(CoderError,"UnableToZipCompressImage",image->filename)
   else
-    for (i=0; i < (long) compress_packets; i++)
+    for (i=0; i < (ssize_t) compress_packets; i++)
       (void) WriteBlobByte(image,compress_pixels[i]);
   compress_pixels=(unsigned char *) RelinquishMagickMemory(compress_pixels);
   return(status == Z_OK ? MagickTrue : MagickFalse);
diff --git a/magick/configure.c b/magick/configure.c
index a4c9cab..c2a0098 100644
--- a/magick/configure.c
+++ b/magick/configure.c
@@ -286,7 +286,7 @@
 %  The format of the GetConfigureInfoList function is:
 %
 %      const ConfigureInfo **GetConfigureInfoList(const char *pattern,
-%        unsigned long *number_options,ExceptionInfo *exception)
+%        size_t *number_options,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -321,7 +321,7 @@
 #endif
 
 MagickExport const ConfigureInfo **GetConfigureInfoList(const char *pattern,
-  unsigned long *number_options,ExceptionInfo *exception)
+  size_t *number_options,ExceptionInfo *exception)
 {
   const ConfigureInfo
     **options;
@@ -329,7 +329,7 @@
   register const ConfigureInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -337,7 +337,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_options != (unsigned long *) NULL);
+  assert(number_options != (size_t *) NULL);
   *number_options=0;
   p=GetConfigureInfo("*",exception);
   if (p == (const ConfigureInfo *) NULL)
@@ -362,7 +362,7 @@
   UnlockSemaphoreInfo(configure_semaphore);
   qsort((void *) options,(size_t) i,sizeof(*options),ConfigureInfoCompare);
   options[i]=(ConfigureInfo *) NULL;
-  *number_options=(unsigned long) i;
+  *number_options=(size_t) i;
   return(options);
 }
 
@@ -383,7 +383,7 @@
 %  The format of the GetConfigureList function is:
 %
 %      char **GetConfigureList(const char *pattern,
-%        unsigned long *number_options,ExceptionInfo *exception)
+%        size_t *number_options,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -415,7 +415,7 @@
 #endif
 
 MagickExport char **GetConfigureList(const char *pattern,
-  unsigned long *number_options,ExceptionInfo *exception)
+  size_t *number_options,ExceptionInfo *exception)
 {
   char
     **options;
@@ -423,7 +423,7 @@
   register const ConfigureInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -431,7 +431,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_options != (unsigned long *) NULL);
+  assert(number_options != (size_t *) NULL);
   *number_options=0;
   p=GetConfigureInfo("*",exception);
   if (p == (const ConfigureInfo *) NULL)
@@ -453,7 +453,7 @@
   UnlockSemaphoreInfo(configure_semaphore);
   qsort((void *) options,(size_t) i,sizeof(*options),ConfigureCompare);
   options[i]=(char *) NULL;
-  *number_options=(unsigned long) i;
+  *number_options=(size_t) i;
   return(options);
 }
 
@@ -916,13 +916,13 @@
   const ConfigureInfo
     **configure_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_options;
 
   if (file == (const FILE *) NULL)
@@ -931,7 +931,7 @@
   if (configure_info == (const ConfigureInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_options; i++)
+  for (i=0; i < (ssize_t) number_options; i++)
   {
     if (configure_info[i]->stealth != MagickFalse)
       continue;
@@ -949,7 +949,7 @@
     if (configure_info[i]->name != (char *) NULL)
       name=configure_info[i]->name;
     (void) fprintf(file,"%s",name);
-    for (j=(long) strlen(name); j <= 12; j++)
+    for (j=(ssize_t) strlen(name); j <= 12; j++)
       (void) fprintf(file," ");
     (void) fprintf(file," ");
     value="unknown";
@@ -981,7 +981,7 @@
 %  The format of the LoadConfigureList method is:
 %
 %      MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -995,7 +995,7 @@
 %
 */
 static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -1209,7 +1209,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1226,7 +1226,7 @@
           return(MagickFalse);
         }
     }
-  for (i=0; i < (long) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++)
   {
     ConfigureInfo
       *configure_info;
diff --git a/magick/configure.h b/magick/configure.h
index 98805d5..5b431ab 100644
--- a/magick/configure.h
+++ b/magick/configure.h
@@ -39,12 +39,12 @@
     *previous,
     *next;  /* deprecated, use GetConfigureInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } ConfigureInfo;
 
 extern MagickExport char
-  **GetConfigureList(const char *,unsigned long *,ExceptionInfo *),
+  **GetConfigureList(const char *,size_t *,ExceptionInfo *),
   *GetConfigureOption(const char *);
 
 extern MagickExport const char
@@ -52,7 +52,7 @@
 
 extern MagickExport const ConfigureInfo
   *GetConfigureInfo(const char *,ExceptionInfo *),
-  **GetConfigureInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetConfigureInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport LinkedListInfo
   *DestroyConfigureOptions(LinkedListInfo *),
diff --git a/magick/constitute.c b/magick/constitute.c
index 5e03300..ad2b1ec 100644
--- a/magick/constitute.c
+++ b/magick/constitute.c
@@ -146,8 +146,8 @@
 %
 %  The format of the ConstituteImage method is:
 %
-%      Image *ConstituteImage(const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType storage,
+%      Image *ConstituteImage(const size_t columns,
+%        const size_t rows,const char *map,const StorageType storage,
 %        const void *pixels,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -174,8 +174,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ConstituteImage(const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType storage,
+MagickExport Image *ConstituteImage(const size_t columns,
+  const size_t rows,const char *map,const StorageType storage,
   const void *pixels,ExceptionInfo *exception)
 {
   Image
@@ -333,7 +333,7 @@
       ExceptionInfo
         *sans;
 
-      long
+      ssize_t
         extent,
         scene;
 
@@ -346,8 +346,8 @@
       sans=DestroyExceptionInfo(sans);
       (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
       images=NewImageList();
-      extent=(long) (read_info->scene+read_info->number_scenes);
-      for (scene=(long) read_info->scene; scene < (long) extent; scene++)
+      extent=(ssize_t) (read_info->scene+read_info->number_scenes);
+      for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
       {
         (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
           scene,read_info->filename);
@@ -468,7 +468,7 @@
         if ((image_info->endian == UndefinedEndian) &&
             (GetMagickRawSupport(magick_info) != MagickFalse))
           {
-            unsigned long
+            size_t
               lsb_first;
 
             lsb_first=1;
@@ -832,7 +832,7 @@
       ExceptionInfo
         *sans;
 
-      long
+      ssize_t
         extent,
         scene;
 
@@ -845,8 +845,8 @@
       sans=DestroyExceptionInfo(sans);
       (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
       images=NewImageList();
-      extent=(long) (read_info->scene+read_info->number_scenes);
-      for (scene=(long) read_info->scene; scene < (long) extent; scene++)
+      extent=(ssize_t) (read_info->scene+read_info->number_scenes);
+      for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
       {
         (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
           scene,read_info->filename);
@@ -1036,7 +1036,7 @@
         if ((image_info->endian == UndefinedEndian) &&
             (GetMagickRawSupport(magick_info) != MagickFalse))
           {
-            unsigned long
+            size_t
               lsb_first;
 
             lsb_first=1;
@@ -1276,15 +1276,15 @@
   for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
     if (p->scene >= GetNextImageInList(p)->scene)
       {
-        register long
+        register ssize_t
           i;
 
         /*
           Generate consistent scene numbers.
         */
-        i=(long) images->scene;
+        i=(ssize_t) images->scene;
         for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
-          p->scene=(unsigned long) i++;
+          p->scene=(size_t) i++;
         break;
       }
   /*
diff --git a/magick/constitute.h b/magick/constitute.h
index ce910ce..eb37b05 100644
--- a/magick/constitute.h
+++ b/magick/constitute.h
@@ -35,7 +35,7 @@
 } StorageType;
 
 extern MagickExport Image
-  *ConstituteImage(const unsigned long,const unsigned long,const char *,
+  *ConstituteImage(const size_t,const size_t,const char *,
     const StorageType,const void *,ExceptionInfo *),
   *PingImage(const ImageInfo *,ExceptionInfo *),
   *PingImages(const ImageInfo *,ExceptionInfo *),
diff --git a/magick/decorate.c b/magick/decorate.c
index 0545af0..ff24b8b 100644
--- a/magick/decorate.c
+++ b/magick/decorate.c
@@ -112,8 +112,8 @@
   assert(border_info != (RectangleInfo *) NULL);
   frame_info.width=image->columns+(border_info->width << 1);
   frame_info.height=image->rows+(border_info->height << 1);
-  frame_info.x=(long) border_info->width;
-  frame_info.y=(long) border_info->height;
+  frame_info.x=(ssize_t) border_info->width;
+  frame_info.y=(ssize_t) border_info->height;
   frame_info.inner_bevel=0;
   frame_info.outer_bevel=0;
   clone_image=CloneImage(image,0,0,MagickTrue,exception);
@@ -170,13 +170,12 @@
   Image
     *frame_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     accentuate,
     border,
@@ -186,14 +185,17 @@
     shadow,
     trough;
 
-  register long
+  register ssize_t
     x;
 
-  unsigned long
+  size_t
     bevel_width,
     height,
     width;
 
+  ssize_t
+    y;
+
   /*
     Check frame geometry.
   */
@@ -204,7 +206,7 @@
   assert(frame_info != (FrameInfo *) NULL);
   if ((frame_info->outer_bevel < 0) || (frame_info->inner_bevel < 0))
     ThrowImageException(OptionError,"FrameIsLessThanImageSize");
-  bevel_width=(unsigned long) (frame_info->outer_bevel+frame_info->inner_bevel);
+  bevel_width=(size_t) (frame_info->outer_bevel+frame_info->inner_bevel);
   width=frame_info->width-frame_info->x-bevel_width;
   height=frame_info->height-frame_info->y-bevel_width;
   if ((width < image->columns) || (height < image->rows))
@@ -284,14 +286,14 @@
   progress=0;
   image_view=AcquireCacheView(image);
   frame_view=AcquireCacheView(frame_image);
-  height=(unsigned long) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
+  height=(size_t) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
     frame_info->inner_bevel);
   if (height != 0)
     {
       register IndexPacket
         *restrict frame_indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -308,9 +310,9 @@
           /*
             Draw top of ornamental border.
           */
-          for (y=0; y < (long) frame_info->outer_bevel; y++)
+          for (y=0; y < (ssize_t) frame_info->outer_bevel; y++)
           {
-            for (x=0; x < (long) (frame_image->columns-y); x++)
+            for (x=0; x < (ssize_t) (frame_image->columns-y); x++)
             {
               if (x < y)
                 SetPixelPacket(frame_image,&highlight,q,frame_indexes);
@@ -319,52 +321,52 @@
               q++;
               frame_indexes++;
             }
-            for ( ; x < (long) frame_image->columns; x++)
+            for ( ; x < (ssize_t) frame_image->columns; x++)
             {
               SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               q++;
               frame_indexes++;
             }
           }
-          for (y=0; y < (long) (frame_info->y-bevel_width); y++)
+          for (y=0; y < (ssize_t) (frame_info->y-bevel_width); y++)
           {
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               q++;
               frame_indexes++;
             }
             width=frame_image->columns-2*frame_info->outer_bevel;
-            for (x=0; x < (long) width; x++)
+            for (x=0; x < (ssize_t) width; x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               q++;
               frame_indexes++;
             }
           }
-          for (y=0; y < (long) frame_info->inner_bevel; y++)
+          for (y=0; y < (ssize_t) frame_info->inner_bevel; y++)
           {
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) (frame_info->x-bevel_width); x++)
+            for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            width=image->columns+((unsigned long) frame_info->inner_bevel << 1)-
+            width=image->columns+((size_t) frame_info->inner_bevel << 1)-
               y;
-            for (x=0; x < (long) width; x++)
+            for (x=0; x < (ssize_t) width; x++)
             {
               if (x < y)
                 SetPixelPacket(frame_image,&shadow,q,frame_indexes);
@@ -373,20 +375,20 @@
               q++;
               frame_indexes++;
             }
-            for ( ; x < (long) (image->columns+2*frame_info->inner_bevel); x++)
+            for ( ; x < (ssize_t) (image->columns+2*frame_info->inner_bevel); x++)
             {
               SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               q++;
               frame_indexes++;
             }
             width=frame_info->width-frame_info->x-image->columns-bevel_width;
-            for (x=0; x < (long) width; x++)
+            for (x=0; x < (ssize_t) width; x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               q++;
@@ -402,12 +404,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict frame_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -426,19 +428,19 @@
         continue;
       }
     frame_indexes=GetCacheViewAuthenticIndexQueue(frame_view);
-    for (x=0; x < (long) frame_info->outer_bevel; x++)
+    for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
     {
       SetPixelPacket(frame_image,&highlight,q,frame_indexes);
       q++;
       frame_indexes++;
     }
-    for (x=0; x < (long) (frame_info->x-bevel_width); x++)
+    for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
     {
       SetPixelPacket(frame_image,&matte,q,frame_indexes);
       q++;
       frame_indexes++;
     }
-    for (x=0; x < (long) frame_info->inner_bevel; x++)
+    for (x=0; x < (ssize_t) frame_info->inner_bevel; x++)
     {
       SetPixelPacket(frame_image,&shadow,q,frame_indexes);
       q++;
@@ -449,7 +451,7 @@
     */
     if ((image->compose != CopyCompositeOp) &&
         ((image->compose != OverCompositeOp) || (image->matte != MagickFalse)))
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         SetPixelPacket(frame_image,&interior,q,frame_indexes);
         q++;
@@ -480,20 +482,20 @@
           }
         q+=image->columns;
       }
-    for (x=0; x < (long) frame_info->inner_bevel; x++)
+    for (x=0; x < (ssize_t) frame_info->inner_bevel; x++)
     {
       SetPixelPacket(frame_image,&highlight,q,frame_indexes);
       q++;
       frame_indexes++;
     }
     width=frame_info->width-frame_info->x-image->columns-bevel_width;
-    for (x=0; x < (long) width; x++)
+    for (x=0; x < (ssize_t) width; x++)
     {
       SetPixelPacket(frame_image,&matte,q,frame_indexes);
       q++;
       frame_indexes++;
     }
-    for (x=0; x < (long) frame_info->outer_bevel; x++)
+    for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
     {
       SetPixelPacket(frame_image,&shadow,q,frame_indexes);
       q++;
@@ -514,14 +516,14 @@
           status=MagickFalse;
       }
   }
-  height=(unsigned long) (frame_info->inner_bevel+frame_info->height-
+  height=(size_t) (frame_info->inner_bevel+frame_info->height-
     frame_info->y-image->rows-bevel_width+frame_info->outer_bevel);
   if (height != 0)
     {
       register IndexPacket
         *restrict frame_indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -530,7 +532,7 @@
       /*
         Draw bottom of ornamental border.
       */
-      q=QueueCacheViewAuthenticPixels(frame_view,0,(long) (frame_image->rows-
+      q=QueueCacheViewAuthenticPixels(frame_view,0,(ssize_t) (frame_image->rows-
         height),frame_image->columns,height,exception);
       if (q != (PixelPacket *) NULL)
         {
@@ -540,13 +542,13 @@
           frame_indexes=GetCacheViewAuthenticIndexQueue(frame_view);
           for (y=frame_info->inner_bevel-1; y >= 0; y--)
           {
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) (frame_info->x-bevel_width); x++)
+            for (x=0; x < (ssize_t) (frame_info->x-bevel_width); x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
@@ -558,9 +560,9 @@
               q++;
               frame_indexes++;
             }
-            for ( ; x < (long) (image->columns+2*frame_info->inner_bevel); x++)
+            for ( ; x < (ssize_t) (image->columns+2*frame_info->inner_bevel); x++)
             {
-              if (x >= (long) (image->columns+2*frame_info->inner_bevel-y))
+              if (x >= (ssize_t) (image->columns+2*frame_info->inner_bevel-y))
                 SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               else
                 SetPixelPacket(frame_image,&accentuate,q,frame_indexes);
@@ -568,13 +570,13 @@
               frame_indexes++;
             }
             width=frame_info->width-frame_info->x-image->columns-bevel_width;
-            for (x=0; x < (long) width; x++)
+            for (x=0; x < (ssize_t) width; x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               q++;
@@ -582,22 +584,22 @@
             }
           }
           height=frame_info->height-frame_info->y-image->rows-bevel_width;
-          for (y=0; y < (long) height; y++)
+          for (y=0; y < (ssize_t) height; y++)
           {
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&highlight,q,frame_indexes);
               q++;
               frame_indexes++;
             }
             width=frame_image->columns-2*frame_info->outer_bevel;
-            for (x=0; x < (long) width; x++)
+            for (x=0; x < (ssize_t) width; x++)
             {
               SetPixelPacket(frame_image,&matte,q,frame_indexes);
               q++;
               frame_indexes++;
             }
-            for (x=0; x < (long) frame_info->outer_bevel; x++)
+            for (x=0; x < (ssize_t) frame_info->outer_bevel; x++)
             {
               SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               q++;
@@ -612,9 +614,9 @@
               q++;
               frame_indexes++;
             }
-            for ( ; x < (long) frame_image->columns; x++)
+            for ( ; x < (ssize_t) frame_image->columns; x++)
             {
-              if (x >= (long) (frame_image->columns-y))
+              if (x >= (ssize_t) (frame_image->columns-y))
                 SetPixelPacket(frame_image,&shadow,q,frame_indexes);
               else
                 SetPixelPacket(frame_image,&trough,q,frame_indexes);
@@ -630,9 +632,9 @@
   if ((image->compose != CopyCompositeOp) &&
       ((image->compose != OverCompositeOp) || (image->matte != MagickFalse)))
     {
-      x=(long) (frame_info->outer_bevel+(frame_info->x-bevel_width)+
+      x=(ssize_t) (frame_info->outer_bevel+(frame_info->x-bevel_width)+
         frame_info->inner_bevel);
-      y=(long) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
+      y=(ssize_t) (frame_info->outer_bevel+(frame_info->y-bevel_width)+
         frame_info->inner_bevel);
       (void) CompositeImage(frame_image,image->compose,image,x,y);
     }
@@ -685,17 +687,19 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   Quantum
     foreground,
     background;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -724,9 +728,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) raise_info->height; y++)
+  for (y=0; y < (ssize_t) raise_info->height; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -753,7 +757,7 @@
         HighlightFactor)));
       q++;
     }
-    for ( ; x < (long) (image->columns-y); x++)
+    for ( ; x < (ssize_t) (image->columns-y); x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*
         AccentuateFactor+(MagickRealType) foreground*(QuantumRange-
@@ -766,7 +770,7 @@
         AccentuateFactor)));
       q++;
     }
-    for ( ; x < (long) image->columns; x++)
+    for ( ; x < (ssize_t) image->columns; x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+
         (MagickRealType) background*(QuantumRange-ShadowFactor)));
@@ -791,9 +795,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=(long) raise_info->height; y < (long) (image->rows-raise_info->height); y++)
+  for (y=(ssize_t) raise_info->height; y < (ssize_t) (image->rows-raise_info->height); y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -807,7 +811,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) raise_info->width; x++)
+    for (x=0; x < (ssize_t) raise_info->width; x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*
         HighlightFactor+(MagickRealType) foreground*(QuantumRange-
@@ -820,9 +824,9 @@
         HighlightFactor)));
       q++;
     }
-    for ( ; x < (long) (image->columns-raise_info->width); x++)
+    for ( ; x < (ssize_t) (image->columns-raise_info->width); x++)
       q++;
-    for ( ; x < (long) image->columns; x++)
+    for ( ; x < (ssize_t) image->columns; x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+
         (MagickRealType) background*(QuantumRange-ShadowFactor)));
@@ -847,9 +851,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=(long) (image->rows-raise_info->height); y < (long) image->rows; y++)
+  for (y=(ssize_t) (image->rows-raise_info->height); y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -863,7 +867,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) (image->rows-y); x++)
+    for (x=0; x < (ssize_t) (image->rows-y); x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*
         HighlightFactor+(MagickRealType) foreground*(QuantumRange-
@@ -876,7 +880,7 @@
         HighlightFactor)));
       q++;
     }
-    for ( ; x < (long) (image->columns-(image->rows-y)); x++)
+    for ( ; x < (ssize_t) (image->columns-(image->rows-y)); x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*TroughFactor+
         (MagickRealType) background*(QuantumRange-TroughFactor)));
@@ -886,7 +890,7 @@
         TroughFactor+(MagickRealType) background*(QuantumRange-TroughFactor)));
       q++;
     }
-    for ( ; x < (long) image->columns; x++)
+    for ( ; x < (ssize_t) image->columns; x++)
     {
       q->red=ClampToQuantum(QuantumScale*((MagickRealType) q->red*ShadowFactor+
         (MagickRealType) background*(QuantumRange-ShadowFactor)));
diff --git a/magick/decorate.h b/magick/decorate.h
index 1575676..3ae9393 100644
--- a/magick/decorate.h
+++ b/magick/decorate.h
@@ -24,11 +24,11 @@
 
 typedef struct _FrameInfo
 {
-  unsigned long
+  size_t
     width,
     height;
 
-  long
+  ssize_t
     x,
     y,
     inner_bevel,
diff --git a/magick/delegate.c b/magick/delegate.c
index 22d5664..0812dff 100644
--- a/magick/delegate.c
+++ b/magick/delegate.c
@@ -265,7 +265,7 @@
   const DelegateInfo
     *delegate_info;
 
-  register long
+  register ssize_t
     i;
 
   assert(image_info != (ImageInfo *) NULL);
@@ -433,7 +433,7 @@
 %  The delegate of the GetDelegateInfoList function is:
 %
 %      const DelegateInfo **GetDelegateInfoList(const char *pattern,
-%        unsigned long *number_delegates,ExceptionInfo *exception)
+%        size_t *number_delegates,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -476,7 +476,7 @@
 #endif
 
 MagickExport const DelegateInfo **GetDelegateInfoList(const char *pattern,
-  unsigned long *number_delegates,ExceptionInfo *exception)
+  size_t *number_delegates,ExceptionInfo *exception)
 {
   const DelegateInfo
     **delegates;
@@ -484,7 +484,7 @@
   register const DelegateInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -492,7 +492,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_delegates != (unsigned long *) NULL);
+  assert(number_delegates != (size_t *) NULL);
   *number_delegates=0;
   p=GetDelegateInfo("*","*",exception);
   if (p == (const DelegateInfo *) NULL)
@@ -518,7 +518,7 @@
   UnlockSemaphoreInfo(delegate_semaphore);
   qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateInfoCompare);
   delegates[i]=(DelegateInfo *) NULL;
-  *number_delegates=(unsigned long) i;
+  *number_delegates=(size_t) i;
   return(delegates);
 }
 
@@ -539,7 +539,7 @@
 %  The format of the GetDelegateList function is:
 %
 %      char **GetDelegateList(const char *pattern,
-%        unsigned long *number_delegates,ExceptionInfo *exception)
+%        size_t *number_delegates,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -572,7 +572,7 @@
 #endif
 
 MagickExport char **GetDelegateList(const char *pattern,
-  unsigned long *number_delegates,ExceptionInfo *exception)
+  size_t *number_delegates,ExceptionInfo *exception)
 {
   char
     **delegates;
@@ -580,7 +580,7 @@
   register const DelegateInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -588,7 +588,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_delegates != (unsigned long *) NULL);
+  assert(number_delegates != (size_t *) NULL);
   *number_delegates=0;
   p=GetDelegateInfo("*","*",exception);
   if (p == (const DelegateInfo *) NULL)
@@ -613,7 +613,7 @@
   UnlockSemaphoreInfo(delegate_semaphore);
   qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateCompare);
   delegates[i]=(char *) NULL;
-  *number_delegates=(unsigned long) i;
+  *number_delegates=(size_t) i;
   return(delegates);
 }
 
@@ -632,14 +632,14 @@
 %
 %  The format of the GetDelegateMode method is:
 %
-%      long GetDelegateMode(const DelegateInfo *delegate_info)
+%      ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
 %
 %  A description of each parameter follows:
 %
 %    o delegate_info:  The delegate info.
 %
 */
-MagickExport long GetDelegateMode(const DelegateInfo *delegate_info)
+MagickExport ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
 {
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(delegate_info != (DelegateInfo *) NULL);
@@ -847,7 +847,7 @@
     status,
     temporary;
 
-  register long
+  register ssize_t
     i;
 
   PolicyRights
@@ -1114,13 +1114,13 @@
   const char
     *path;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_delegates;
 
   if (file == (const FILE *) NULL)
@@ -1129,7 +1129,7 @@
   if (delegate_info == (const DelegateInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_delegates; i++)
+  for (i=0; i < (ssize_t) number_delegates; i++)
   {
     if (delegate_info[i]->stealth != MagickFalse)
       continue;
@@ -1188,7 +1188,7 @@
 %  The format of the LoadDelegateList method is:
 %
 %      MagickBooleanType LoadDelegateList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1202,7 +1202,7 @@
 %
 */
 static MagickBooleanType LoadDelegateList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
diff --git a/magick/delegate.h b/magick/delegate.h
index 0aac2f9..487f349 100644
--- a/magick/delegate.h
+++ b/magick/delegate.h
@@ -30,7 +30,7 @@
     *encode,
     *commands;
                                                                                 
-  long
+  ssize_t
     mode;
                                                                                 
   MagickBooleanType
@@ -42,23 +42,23 @@
     *previous,
     *next;  /* deprecated, use GetDelegateInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } DelegateInfo;
 
 extern MagickExport char
   *GetDelegateCommand(const ImageInfo *,Image *,const char *,const char *,
     ExceptionInfo *),
-  **GetDelegateList(const char *,unsigned long *,ExceptionInfo *);
+  **GetDelegateList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const char
   *GetDelegateCommands(const DelegateInfo *);
 
 extern MagickExport const DelegateInfo
   *GetDelegateInfo(const char *,const char *,ExceptionInfo *exception),
-  **GetDelegateInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetDelegateInfoList(const char *,size_t *,ExceptionInfo *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   GetDelegateMode(const DelegateInfo *);
 
 extern MagickExport MagickBooleanType
diff --git a/magick/deprecate.c b/magick/deprecate.c
index f4715d4..6929160 100644
--- a/magick/deprecate.c
+++ b/magick/deprecate.c
@@ -151,8 +151,8 @@
 %  The format of the AcquireCacheViewPixels method is:
 %
 %      const PixelPacket *AcquireCacheViewPixels(const CacheView *cache_view,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -165,8 +165,8 @@
 %
 */
 MagickExport const PixelPacket *AcquireCacheViewPixels(
-  const CacheView *cache_view,const long x,const long y,
-  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows,ExceptionInfo *exception)
 {
   return(GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception));
 }
@@ -208,8 +208,8 @@
 %
 %  The format of the AcquireImagePixels() method is:
 %
-%      const PixelPacket *AcquireImagePixels(const Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      const PixelPacket *AcquireImagePixels(const Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -223,8 +223,8 @@
 %
 */
 MagickExport const PixelPacket *AcquireImagePixels(const Image *image,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
   return(GetVirtualPixels(image,x,y,columns,rows,exception));
 }
@@ -322,7 +322,7 @@
 %  The format of the AcquireOneCacheViewPixel method is:
 %
 %      MagickBooleanType AcquireOneCacheViewPixel(const CacheView *cache_view,
-%        const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -336,7 +336,7 @@
 %
 */
 MagickExport MagickBooleanType AcquireOneCacheViewPixel(
-  const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelPacket *pixel,
   ExceptionInfo *exception)
 {
   return(GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception));
@@ -366,8 +366,8 @@
 %
 %      MagickBooleanType AcquireOneCacheViewVirtualPixel(
 %        const CacheView *cache_view,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -384,7 +384,7 @@
 */
 MagickExport MagickBooleanType AcquireOneCacheViewVirtualPixel(
   const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
-  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   MagickBooleanType
     status;
@@ -416,8 +416,8 @@
 %
 %  The format of the AcquireOneMagickPixel() method is:
 %
-%      MagickPixelPacket AcquireOneMagickPixel(const Image image,const long x,
-%        const long y,ExceptionInfo exception)
+%      MagickPixelPacket AcquireOneMagickPixel(const Image image,const ssize_t x,
+%        const ssize_t y,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -429,7 +429,7 @@
 %
 */
 MagickExport MagickPixelPacket AcquireOneMagickPixel(const Image *image,
-  const long x,const long y,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,ExceptionInfo *exception)
 {
   MagickPixelPacket
     pixel;
@@ -460,8 +460,8 @@
 %
 %  The format of the AcquireOnePixel() method is:
 %
-%      PixelPacket AcquireOnePixel(const Image image,const long x,
-%        const long y,ExceptionInfo exception)
+%      PixelPacket AcquireOnePixel(const Image image,const ssize_t x,
+%        const ssize_t y,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -472,8 +472,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport PixelPacket AcquireOnePixel(const Image *image,const long x,
-  const long y,ExceptionInfo *exception)
+MagickExport PixelPacket AcquireOnePixel(const Image *image,const ssize_t x,
+  const ssize_t y,ExceptionInfo *exception)
 {
   PixelPacket
     pixel;
@@ -506,8 +506,8 @@
 %  The format of the AcquireOneVirtualPixel() method is:
 %
 %      PixelPacket AcquireOneVirtualPixel(const Image image,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,ExceptionInfo exception)
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,ExceptionInfo exception)
 %
 %  A description of each parameter follows:
 %
@@ -521,7 +521,7 @@
 %
 */
 MagickExport PixelPacket AcquireOneVirtualPixel(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
   ExceptionInfo *exception)
 {
   PixelPacket
@@ -697,7 +697,7 @@
 %  The format of the AllocateImageColormap method is:
 %
 %      MagickBooleanType AllocateImageColormap(Image *image,
-%        const unsigned long colors)
+%        const size_t colors)
 %
 %  A description of each parameter follows:
 %
@@ -707,7 +707,7 @@
 %
 */
 MagickExport MagickBooleanType AllocateImageColormap(Image *image,
-  const unsigned long colors)
+  const size_t colors)
 {
   return(AcquireImageColormap(image,colors));
 }
@@ -1037,7 +1037,7 @@
   register unsigned char
     *q;
 
-  register long
+  register ssize_t
     i;
 
   assert(destination != (void *) NULL);
@@ -1052,7 +1052,7 @@
   */
   p+=size;
   q+=size;
-  for (i=(long) (size-1); i >= 0; i--)
+  for (i=(ssize_t) (size-1); i >= 0; i--)
     *--q=(*--p);
   return(destination);
 }
@@ -1116,7 +1116,7 @@
 %
 %      MagickBooleanType ColorFloodfillImage(Image *image,
 %        const DrawInfo *draw_info,const PixelPacket target,
-%        const long x_offset,const long y_offset,const PaintMethod method)
+%        const ssize_t x_offset,const ssize_t y_offset,const PaintMethod method)
 %
 %  A description of each parameter follows:
 %
@@ -1139,7 +1139,7 @@
     ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
   else \
     { \
-      if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (long) image->rows)) \
+      if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (ssize_t) image->rows)) \
         { \
           s->x1=(double) (left); \
           s->y1=(double) (up); \
@@ -1151,13 +1151,13 @@
 }
 
 MagickExport MagickBooleanType ColorFloodfillImage(Image *image,
-  const DrawInfo *draw_info,const PixelPacket target,const long x_offset,
-  const long y_offset,const PaintMethod method)
+  const DrawInfo *draw_info,const PixelPacket target,const ssize_t x_offset,
+  const ssize_t y_offset,const PaintMethod method)
 {
   Image
     *floodplane_image;
 
-  long
+  ssize_t
     offset,
     start,
     x,
@@ -1186,9 +1186,9 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(draw_info != (DrawInfo *) NULL);
   assert(draw_info->signature == MagickSignature);
-  if ((x_offset < 0) || (x_offset >= (long) image->columns))
+  if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
     return(MagickFalse);
-  if ((y_offset < 0) || (y_offset >= (long) image->rows))
+  if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
     return(MagickFalse);
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
@@ -1224,7 +1224,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1234,15 +1234,15 @@
       Pop segment off stack.
     */
     s--;
-    x1=(long) s->x1;
-    x2=(long) s->x2;
-    offset=(long) s->y2;
-    y=(long) s->y1+offset;
+    x1=(ssize_t) s->x1;
+    x2=(ssize_t) s->x2;
+    offset=(ssize_t) s->y2;
+    y=(ssize_t) s->y1+offset;
     /*
       Recolor neighboring pixels.
     */
-    p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
-    q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
+    p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,&image->exception);
+    q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
       &image->exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
@@ -1278,7 +1278,7 @@
     {
       if (skip == MagickFalse)
         {
-          if (x < (long) image->columns)
+          if (x < (ssize_t) image->columns)
             {
               p=GetVirtualPixels(image,x,y,image->columns-x,1,
                 &image->exception);
@@ -1287,7 +1287,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for ( ; x < (long) image->columns; x++)
+              for ( ; x < (ssize_t) image->columns; x++)
               {
                 if (q->opacity == (Quantum) TransparentOpacity)
                   break;
@@ -1314,9 +1314,9 @@
       x++;
       if (x <= x2)
         {
-          p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
+          p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,
             &image->exception);
-          q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
+          q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
             &image->exception);
           if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
             break;
@@ -1339,12 +1339,12 @@
       start=x;
     } while (x <= x2);
   }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1358,7 +1358,7 @@
     q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (p->opacity != OpaqueOpacity)
         {
@@ -1374,7 +1374,7 @@
   }
   segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
   floodplane_image=DestroyImage(floodplane_image);
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -1426,7 +1426,7 @@
 %
 %  The format of the DeleteImageList method is:
 %
-%      unsigned int DeleteImageList(Image *images,const long offset)
+%      unsigned int DeleteImageList(Image *images,const ssize_t offset)
 %
 %  A description of each parameter follows:
 %
@@ -1435,9 +1435,9 @@
 %    o offset: the position within the list.
 %
 */
-MagickExport unsigned int DeleteImageList(Image *images,const long offset)
+MagickExport unsigned int DeleteImageList(Image *images,const ssize_t offset)
 {
-  register long
+  register ssize_t
     i;
 
   if (images->debug != MagickFalse)
@@ -1477,14 +1477,14 @@
 %
 %  The format of the DeleteMagickRegistry method is:
 %
-%      MagickBooleanType DeleteMagickRegistry(const long id)
+%      MagickBooleanType DeleteMagickRegistry(const ssize_t id)
 %
 %  A description of each parameter follows:
 %
 %    o id: the registry id.
 %
 */
-MagickExport MagickBooleanType DeleteMagickRegistry(const long id)
+MagickExport MagickBooleanType DeleteMagickRegistry(const ssize_t id)
 {
   char
     key[MaxTextExtent];
@@ -1668,7 +1668,7 @@
 %
 %  DispatchImage() extracts pixel data from an image and returns it to you.
 %  The method returns MagickFalse on success otherwise MagickTrue if an error is
-%  encountered.  The data is returned as char, short int, int, long, float,
+%  encountered.  The data is returned as char, short int, int, ssize_t, float,
 %  or double in the order specified by map.
 %
 %  Suppose you want to extract the first scanline of a 640x480 image as
@@ -1683,9 +1683,9 @@
 %
 %  The format of the DispatchImage method is:
 %
-%      unsigned int DispatchImage(const Image *image,const long x_offset,
-%        const long y_offset,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType type,
+%      unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
+%        const ssize_t y_offset,const size_t columns,
+%        const size_t rows,const char *map,const StorageType type,
 %        void *pixels,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1712,8 +1712,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport unsigned int DispatchImage(const Image *image,const long x_offset,
-  const long y_offset,const unsigned long columns,const unsigned long rows,
+MagickExport unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
+  const ssize_t y_offset,const size_t columns,const size_t rows,
   const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
 {
   unsigned int
@@ -1756,14 +1756,14 @@
 */
 
 static double GetSimilarityMetric(const Image *image,const Image *reference,
-  const long x_offset,const long y_offset,const double similarity_threshold,
+  const ssize_t x_offset,const ssize_t y_offset,const double similarity_threshold,
   ExceptionInfo *exception)
 {
   CacheView
     *image_view,
     *reference_view;
 
-  long
+  ssize_t
     y;
 
   double
@@ -1784,7 +1784,7 @@
     channels++;
   image_view=AcquireCacheView(image);
   reference_view=AcquireCacheView(reference);
-  for (y=0; y < (long) reference->rows; y++)
+  for (y=0; y < (ssize_t) reference->rows; y++)
   {
     register const IndexPacket
       *indexes,
@@ -1794,7 +1794,7 @@
       *p,
       *q;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset+y,
@@ -1805,7 +1805,7 @@
       continue;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
-    for (x=0; x < (long) reference->columns; x++)
+    for (x=0; x < (ssize_t) reference->columns; x++)
     {
       MagickRealType
         pixel;
@@ -1843,7 +1843,7 @@
 MagickExport Image *ExtractSubimageFromImage(Image *image,
   const Image *reference,ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
   double
@@ -1862,15 +1862,15 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-  for (y=0; y < (long) (image->rows-reference->rows); y++)
+  for (y=0; y < (ssize_t) (image->rows-reference->rows); y++)
   {
     double
       similarity;
 
-    register long
+    register ssize_t
       x;
 
-    for (x=0; x < (long) (image->columns-reference->columns); x++)
+    for (x=0; x < (ssize_t) (image->columns-reference->columns); x++)
     {
       similarity=GetSimilarityMetric(image,reference,x,y,similarity_threshold,
         exception);
@@ -2349,8 +2349,8 @@
 %
 %  The format of the GetCacheView method is:
 %
-%      PixelPacket *GetCacheView(CacheView *cache_view,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows)
+%      PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2360,8 +2360,8 @@
 %      pixels.
 %
 */
-MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const long x,
-  const long y,const unsigned long columns,const unsigned long rows)
+MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows)
 {
   PixelPacket
     *pixels;
@@ -2425,8 +2425,8 @@
 %
 %  The format of the GetCacheViewPixels method is:
 %
-%      PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows)
+%      PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2436,8 +2436,8 @@
 %      pixels.
 %
 */
-MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
-  const long y,const unsigned long columns,const unsigned long rows)
+MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows)
 {
   PixelPacket
     *pixels;
@@ -2578,7 +2578,7 @@
 %
 %  The format of the GetImageFromMagickRegistry method is:
 %
-%      Image *GetImageFromMagickRegistry(const char *name,long *id,
+%      Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2590,7 +2590,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *GetImageFromMagickRegistry(const char *name,long *id,
+MagickExport Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
   ExceptionInfo *exception)
 {
   *id=0L;
@@ -2613,7 +2613,7 @@
 %
 %  The format of the GetMagickRegistry method is:
 %
-%      const void *GetMagickRegistry(const long id,RegistryType *type,
+%      const void *GetMagickRegistry(const ssize_t id,RegistryType *type,
 %        size_t *length,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2627,7 +2627,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport void *GetMagickRegistry(const long id,RegistryType *type,
+MagickExport void *GetMagickRegistry(const ssize_t id,RegistryType *type,
   size_t *length,ExceptionInfo *exception)
 {
   char
@@ -2712,12 +2712,12 @@
 %
 %  Deprecated, replace with:
 %
-%    CloneImage(GetImageFromList(images,(long) offset),0,0,MagickTrue,
+%    CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
 %      exception);
 %
 %  The format of the GetImageList method is:
 %
-%      Image *GetImageList(const Image *images,const long offset,
+%      Image *GetImageList(const Image *images,const ssize_t offset,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2729,7 +2729,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *GetImageList(const Image *images,const long offset,
+MagickExport Image *GetImageList(const Image *images,const ssize_t offset,
   ExceptionInfo *exception)
 {
   Image
@@ -2737,7 +2737,7 @@
 
   if (images->debug != MagickFalse)
     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
-  image=CloneImage(GetImageFromList(images,(long) offset),0,0,MagickTrue,
+  image=CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
     exception);
   return(image);
 }
@@ -2762,14 +2762,14 @@
 %
 %  The format of the GetImageListIndex method is:
 %
-%      long GetImageListIndex(const Image *images)
+%      ssize_t GetImageListIndex(const Image *images)
 %
 %  A description of each parameter follows:
 %
 %    o images: the image list.
 %
 */
-MagickExport long GetImageListIndex(const Image *images)
+MagickExport ssize_t GetImageListIndex(const Image *images)
 {
   if (images->debug != MagickFalse)
     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
@@ -2795,14 +2795,14 @@
 %
 %  The format of the GetImageListSize method is:
 %
-%      unsigned long GetImageListSize(const Image *images)
+%      size_t GetImageListSize(const Image *images)
 %
 %  A description of each parameter follows:
 %
 %    o images: the image list.
 %
 */
-MagickExport unsigned long GetImageListSize(const Image *images)
+MagickExport size_t GetImageListSize(const Image *images)
 {
   if (images->debug != MagickFalse)
     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
@@ -2845,8 +2845,8 @@
 %
 %  The format of the GetImagePixels() method is:
 %
-%      PixelPacket *GetImagePixels(Image *image,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows)
+%      PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2856,8 +2856,8 @@
 %      pixels.
 %
 */
-MagickExport PixelPacket *GetImagePixels(Image *image,const long x,const long y,
-  const unsigned long columns,const unsigned long rows)
+MagickExport PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows)
 {
   return(GetAuthenticPixels(image,x,y,columns,rows,&image->exception));
 }
@@ -2919,8 +2919,8 @@
 %
 %  The format of the GetMagickGeometry method is:
 %
-%      unsigned int GetMagickGeometry(const char *geometry,long *x,long *y,
-%        unsigned long *width,unsigned long *height)
+%      unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,ssize_t *y,
+%        size_t *width,size_t *height)
 %
 %  A description of each parameter follows:
 %
@@ -2934,8 +2934,8 @@
 %      as determined by the geometry specification is returned here.
 %
 */
-MagickExport unsigned int GetMagickGeometry(const char *geometry,long *x,
-  long *y,unsigned long *width,unsigned long *height)
+MagickExport unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,
+  ssize_t *y,size_t *width,size_t *height)
 {
   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
   return(ParseMetaGeometry(geometry,x,y,width,height));
@@ -3067,7 +3067,7 @@
 %
 %  The format of the GetOnePixel() method is:
 %
-%      PixelPacket GetOnePixel(const Image image,const long x,const long y)
+%      PixelPacket GetOnePixel(const Image image,const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -3076,7 +3076,7 @@
 %    o x,y:  These values define the location of the pixel to return.
 %
 */
-MagickExport PixelPacket GetOnePixel(Image *image,const long x,const long y)
+MagickExport PixelPacket GetOnePixel(Image *image,const ssize_t x,const ssize_t y)
 {
   PixelPacket
     pixel;
@@ -3394,11 +3394,11 @@
   return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
 }
 
-static inline long NearestNeighbor(MagickRealType x)
+static inline ssize_t NearestNeighbor(MagickRealType x)
 {
   if (x >= 0.0)
-    return((long) (x+0.5));
-  return((long) (x-0.5));
+    return((ssize_t) (x+0.5));
+  return((ssize_t) (x-0.5));
 }
 
 MagickExport MagickPixelPacket InterpolatePixelColor(const Image *image,
@@ -3414,7 +3414,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   assert(image != (Image *) NULL);
@@ -3432,7 +3432,7 @@
         alpha[16],
         gamma;
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
         1,4,4,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -3475,7 +3475,7 @@
       PointInfo
         delta;
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
         1,4,4,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -3516,7 +3516,7 @@
       PointInfo
         delta;
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),2,
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),2,
         2,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -3574,8 +3574,8 @@
 
       geometry.width=4L;
       geometry.height=4L;
-      geometry.x=(long) floor(x)-1L;
-      geometry.y=(long) floor(y)-1L;
+      geometry.x=(ssize_t) floor(x)-1L;
+      geometry.y=(ssize_t) floor(y)-1L;
       excerpt_image=ExcerptImage(image,&geometry,exception);
       if (excerpt_image == (Image *) NULL)
         break;
@@ -3601,7 +3601,7 @@
       MagickPixelPacket
         pixels[1];
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),1,
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),1,
         1,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -3623,7 +3623,7 @@
         delta,
         luminance;
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),
         2,2,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -3758,7 +3758,7 @@
     }
     case SplineInterpolatePixel:
     {
-      long
+      ssize_t
         j,
         n;
 
@@ -3774,7 +3774,7 @@
       PointInfo
         delta;
 
-      p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
+      p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
         1,4,4,exception);
       if (p == (const PixelPacket *) NULL)
         break;
@@ -4238,8 +4238,8 @@
 %  The format of the MatteFloodfillImage method is:
 %
 %      MagickBooleanType MatteFloodfillImage(Image *image,
-%        const PixelPacket target,const Quantum opacity,const long x_offset,
-%        const long y_offset,const PaintMethod method)
+%        const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
+%        const ssize_t y_offset,const PaintMethod method)
 %
 %  A description of each parameter follows:
 %
@@ -4256,13 +4256,13 @@
 %
 */
 MagickExport MagickBooleanType MatteFloodfillImage(Image *image,
-  const PixelPacket target,const Quantum opacity,const long x_offset,
-  const long y_offset,const PaintMethod method)
+  const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
+  const ssize_t y_offset,const PaintMethod method)
 {
   Image
     *floodplane_image;
 
-  long
+  ssize_t
     offset,
     start,
     x,
@@ -4286,9 +4286,9 @@
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if ((x_offset < 0) || (x_offset >= (long) image->columns))
+  if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
     return(MagickFalse);
-  if ((y_offset < 0) || (y_offset >= (long) image->rows))
+  if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
     return(MagickFalse);
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
@@ -4324,7 +4324,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4334,15 +4334,15 @@
       Pop segment off stack.
     */
     s--;
-    x1=(long) s->x1;
-    x2=(long) s->x2;
-    offset=(long) s->y2;
-    y=(long) s->y1+offset;
+    x1=(ssize_t) s->x1;
+    x2=(ssize_t) s->x2;
+    offset=(ssize_t) s->y2;
+    y=(ssize_t) s->y1+offset;
     /*
       Recolor neighboring pixels.
     */
-    p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
-    q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
+    p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,&image->exception);
+    q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
       &image->exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
@@ -4378,7 +4378,7 @@
     {
       if (skip == MagickFalse)
         {
-          if (x < (long) image->columns)
+          if (x < (ssize_t) image->columns)
             {
               p=GetVirtualPixels(image,x,y,image->columns-x,1,
                 &image->exception);
@@ -4387,7 +4387,7 @@
               if ((p == (const PixelPacket *) NULL) ||
                   (q == (PixelPacket *) NULL))
                 break;
-              for ( ; x < (long) image->columns; x++)
+              for ( ; x < (ssize_t) image->columns; x++)
               {
                 if (q->opacity == (Quantum) TransparentOpacity)
                   break;
@@ -4414,9 +4414,9 @@
       x++;
       if (x <= x2)
         {
-          p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
+          p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,
             &image->exception);
-          q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
+          q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
             &image->exception);
           if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
             break;
@@ -4439,12 +4439,12 @@
       start=x;
     } while (x <= x2);
   }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4458,7 +4458,7 @@
     q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (p->opacity != OpaqueOpacity)
         q->opacity=opacity;
@@ -4470,7 +4470,7 @@
   }
   segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
   floodplane_image=DestroyImage(floodplane_image);
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -4611,13 +4611,13 @@
 {
 #define OpaqueImageTag  "Opaque/Image"
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     proceed;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -4636,9 +4636,9 @@
       /*
         Make DirectClass image opaque.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -4647,7 +4647,7 @@
         q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           if (IsColorSimilar(image,q,&target) != MagickFalse)
             *q=fill;
@@ -4666,16 +4666,16 @@
       /*
         Make PseudoClass image opaque.
       */
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if (IsColorSimilar(image,&image->colormap[i],&target) != MagickFalse)
           image->colormap[i]=fill;
       }
       if (fill.opacity != OpaqueOpacity)
         {
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -4684,7 +4684,7 @@
             q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (IsColorSimilar(image,q,&target) != MagickFalse)
                 q->opacity=fill.opacity;
@@ -4766,8 +4766,8 @@
 %  The format of the PaintFloodfillImage method is:
 %
 %      MagickBooleanType PaintFloodfillImage(Image *image,
-%        const ChannelType channel,const MagickPixelPacket target,const long x,
-%        const long y,const DrawInfo *draw_info,const PaintMethod method)
+%        const ChannelType channel,const MagickPixelPacket target,const ssize_t x,
+%        const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
 %
 %  A description of each parameter follows:
 %
@@ -4785,8 +4785,8 @@
 %
 */
 MagickExport MagickBooleanType PaintFloodfillImage(Image *image,
-  const ChannelType channel,const MagickPixelPacket *target,const long x,
-  const long y,const DrawInfo *draw_info,const PaintMethod method)
+  const ChannelType channel,const MagickPixelPacket *target,const ssize_t x,
+  const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
 {
   MagickBooleanType
     status;
@@ -4921,8 +4921,8 @@
 %
 %  The format of the ParseImageGeometry method is:
 %
-%      int ParseImageGeometry(char *geometry,long *x,long *y,
-%        unsigned long *width,unsigned long *height)
+%      int ParseImageGeometry(char *geometry,ssize_t *x,ssize_t *y,
+%        size_t *width,size_t *height)
 %
 %  A description of each parameter follows:
 %
@@ -4939,8 +4939,8 @@
 %      as determined by the geometry specification is returned here.
 %
 */
-MagickExport int ParseImageGeometry(const char *geometry,long *x,long *y,
-  unsigned long *width,unsigned long *height)
+MagickExport int ParseImageGeometry(const char *geometry,ssize_t *x,ssize_t *y,
+  size_t *width,size_t *height)
 {
   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
   return((int) ParseMetaGeometry(geometry,x,y,width,height));
@@ -5286,7 +5286,7 @@
     lower_threshold,
     upper_threshold;
 
-  long
+  ssize_t
     count,
     y;
 
@@ -5300,7 +5300,7 @@
       1.2f, 0.4f, 0.9f, 1.3f, 0.2f},
     threshold=128;
 
-  unsigned long
+  size_t
     order;
 
   /*
@@ -5351,9 +5351,9 @@
       ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
         image->filename);
   random_info=AcquireRandomInfo();
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register IndexPacket
@@ -5370,7 +5370,7 @@
         LocaleCompare(channel,"intensity") == 0)
       {
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           {
             MagickRealType
               intensity;
@@ -5396,7 +5396,7 @@
                threshold ? 0 : QuantumRange);
             index=(IndexPacket) (intensity <= threshold ? 0 : 1);
             *indexes++=index;
-            q->red=q->green=q->blue=image->colormap[(long) index].red;
+            q->red=q->green=q->blue=image->colormap[(ssize_t) index].red;
             q++;
           }
       }
@@ -5405,7 +5405,7 @@
         LocaleCompare(channel,"matte") == 0)
       {
         if (image->matte != MagickFalse)
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (order == 1)
                 {
@@ -5508,7 +5508,7 @@
 %
 %  The format of the RecolorImage method is:
 %
-%      Image *RecolorImage(const Image *image,const unsigned long order,
+%      Image *RecolorImage(const Image *image,const size_t order,
 %        const double *color_matrix,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -5522,7 +5522,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *RecolorImage(const Image *image,const unsigned long order,
+MagickExport Image *RecolorImage(const Image *image,const size_t order,
   const double *color_matrix,ExceptionInfo *exception)
 {
   KernelInfo
@@ -5598,8 +5598,8 @@
 %
 %  The format of the SetCacheViewPixels method is:
 %
-%      PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows)
+%      PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -5609,8 +5609,8 @@
 %      pixels.
 %
 */
-MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
-  const long y,const unsigned long columns,const unsigned long rows)
+MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows)
 {
   PixelPacket
     *pixels;
@@ -5645,7 +5645,7 @@
 %      cache.
 %
 */
-MagickExport void SetCacheThreshold(const unsigned long size)
+MagickExport void SetCacheThreshold(const size_t size)
 {
   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
   (void) SetMagickResourceLimit(MemoryResource,size*1024*1024);
@@ -5715,7 +5715,7 @@
 */
 MagickExport void SetImage(Image *image,const Quantum opacity)
 {
-  long
+  ssize_t
     y;
 
   PixelPacket
@@ -5740,12 +5740,12 @@
       /*
         Set colormapped or CMYK image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -5754,10 +5754,10 @@
         q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
         if (q == (PixelPacket *) NULL)
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           *q++=background_color;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           indexes[x]=(IndexPacket) 0;
         if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
           break;
@@ -5767,9 +5767,9 @@
   /*
     Set DirectClass image.
   */
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -5778,7 +5778,7 @@
     q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *q++=background_color;
     if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
       break;
@@ -5841,7 +5841,7 @@
 %  The format of the SetImageList method is:
 %
 %      unsigned int SetImageList(Image *images,const Image *image,
-%        const long offset,ExceptionInfo *exception)
+%        const ssize_t offset,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -5855,12 +5855,12 @@
 %
 */
 MagickExport unsigned int SetImageList(Image **images,const Image *image,
-  const long offset,ExceptionInfo *exception)
+  const ssize_t offset,ExceptionInfo *exception)
 {
   Image
     *clone;
 
-  register long
+  register ssize_t
     i;
 
   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
@@ -5923,8 +5923,8 @@
 %
 %  The format of the SetImagePixels() method is:
 %
-%      PixelPacket *SetImagePixels(Image *image,const long x,const long y,
-%        const unsigned long columns,const unsigned long rows)
+%      PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -5937,8 +5937,8 @@
 %      pixels.
 %
 */
-MagickExport PixelPacket *SetImagePixels(Image *image,const long x,const long y,
-  const unsigned long columns,const unsigned long rows)
+MagickExport PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+  const size_t columns,const size_t rows)
 {
   return(QueueAuthenticPixels(image,x,y,columns,rows,&image->exception));
 }
@@ -5959,7 +5959,7 @@
 %
 %  The format of the SetMagickRegistry method is:
 %
-%      long SetMagickRegistry(const RegistryType type,const void *blob,
+%      ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
 %        const size_t length,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -5974,7 +5974,7 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport long SetMagickRegistry(const RegistryType type,const void *blob,
+MagickExport ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
   const size_t magick_unused(length),ExceptionInfo *exception)
 {
   char
@@ -5983,7 +5983,7 @@
   MagickBooleanType
     status;
 
-  static long
+  static ssize_t
     id = 0;
 
   (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
@@ -6116,8 +6116,8 @@
 %
 %  The format of the SpliceImageList method is:
 %
-%      Image *SpliceImageList(Image *images,const long offset,
-%        const unsigned long length,const Image *splices,
+%      Image *SpliceImageList(Image *images,const ssize_t offset,
+%        const size_t length,const Image *splices,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -6133,13 +6133,13 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *SpliceImageList(Image *images,const long offset,
-  const unsigned long length,const Image *splices,ExceptionInfo *exception)
+MagickExport Image *SpliceImageList(Image *images,const ssize_t offset,
+  const size_t length,const Image *splices,ExceptionInfo *exception)
 {
   Image
     *clone;
 
-  register long
+  register ssize_t
     i;
 
   if (images->debug != MagickFalse)
@@ -6381,7 +6381,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   /*
@@ -6396,12 +6396,12 @@
   if (!AcquireImageColormap(image,2))
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       "UnableToThresholdImage");
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -6411,14 +6411,14 @@
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetAuthenticIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       index=(IndexPacket) ((MagickRealType)
         PixelIntensityToQuantum(q) <= threshold ? 0 : 1);
       indexes[x]=index;
-      q->red=image->colormap[(long) index].red;
-      q->green=image->colormap[(long) index].green;
-      q->blue=image->colormap[(long) index].blue;
+      q->red=image->colormap[(ssize_t) index].red;
+      q->green=image->colormap[(ssize_t) index].green;
+      q->blue=image->colormap[(ssize_t) index].blue;
       q++;
     }
     if (!SyncAuthenticPixels(image,&image->exception))
@@ -6466,7 +6466,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   unsigned int
@@ -6512,12 +6512,12 @@
       if (pixel.red == 0)
         (void) GetImageDynamicThreshold(image,2.0,2.0,&pixel,&image->exception);
     }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -6528,18 +6528,18 @@
       break;
     indexes=GetAuthenticIndexQueue(image);
     if (IsMagickGray(&pixel) != MagickFalse)
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         index=(IndexPacket) ((MagickRealType)
           PixelIntensityToQuantum(q) <= pixel.red ? 0 : 1);
         indexes[x]=index;
-        q->red=image->colormap[(long) index].red;
-        q->green=image->colormap[(long) index].green;
-        q->blue=image->colormap[(long) index].blue;
+        q->red=image->colormap[(ssize_t) index].red;
+        q->green=image->colormap[(ssize_t) index].green;
+        q->blue=image->colormap[(ssize_t) index].blue;
         q++;
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         q->red=(Quantum) ((MagickRealType)
           q->red <= pixel.red ? 0 : QuantumRange);
@@ -6759,7 +6759,7 @@
 {
 #define TransparentImageTag  "Transparent/Image"
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -6775,9 +6775,9 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->matte == MagickFalse)
     (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -6786,7 +6786,7 @@
     q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (IsColorSimilar(image,q,&target) != MagickFalse)
         q->opacity=opacity;
@@ -6874,7 +6874,7 @@
 %
 */
 MagickExport IndexPacket ValidateColormapIndex(Image *image,
-  const unsigned long index)
+  const size_t index)
 {
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.4");
diff --git a/magick/deprecate.h b/magick/deprecate.h
index 134a316..d5bc2ea 100644
--- a/magick/deprecate.h
+++ b/magick/deprecate.h
@@ -109,67 +109,67 @@
 
 extern MagickExport const PixelPacket
   *AcquirePixels(const Image *) magick_attribute((deprecated)),
-  *AcquireCacheViewPixels(const CacheView *,const long,const long,
-    const unsigned long,const unsigned long,ExceptionInfo *)
+  *AcquireCacheViewPixels(const CacheView *,const ssize_t,const ssize_t,
+    const size_t,const size_t,ExceptionInfo *)
     magick_attribute((deprecated)),
-  *AcquireImagePixels(const Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *) magick_attribute((deprecated));
+  *AcquireImagePixels(const Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *) magick_attribute((deprecated));
 
 extern MagickExport Image
   *AllocateImage(const ImageInfo *) magick_attribute((deprecated)),
   *ExtractSubimageFromImage(Image *,const Image *,ExceptionInfo *)
     magick_attribute((deprecated)),
-  *GetImageFromMagickRegistry(const char *,long *id,ExceptionInfo *)
+  *GetImageFromMagickRegistry(const char *,ssize_t *id,ExceptionInfo *)
     magick_attribute((deprecated)),
-  *GetImageList(const Image *,const long,ExceptionInfo *)
+  *GetImageList(const Image *,const ssize_t,ExceptionInfo *)
     magick_attribute((deprecated)),
   *GetNextImage(const Image *) magick_attribute((deprecated)),
   *GetPreviousImage(const Image *) magick_attribute((deprecated)),
   *FlattenImages(Image *,ExceptionInfo *) magick_attribute((deprecated)),
   *MosaicImages(Image *,ExceptionInfo *) magick_attribute((deprecated)),
   *PopImageList(Image **) magick_attribute((deprecated)),
-  *RecolorImage(const Image *,const unsigned long,const double *,
+  *RecolorImage(const Image *,const size_t,const double *,
     ExceptionInfo *) magick_attribute((deprecated)),
   *ShiftImageList(Image **) magick_attribute((deprecated)),
-  *SpliceImageList(Image *,const long,const unsigned long,const Image *,
+  *SpliceImageList(Image *,const ssize_t,const size_t,const Image *,
     ExceptionInfo *) magick_attribute((deprecated));
 
 extern MagickExport IndexPacket
   *GetCacheViewIndexes(CacheView *) magick_attribute((deprecated)),
   *GetIndexes(const Image *) magick_attribute((deprecated)),
-  ValidateColormapIndex(Image *,const unsigned long)
+  ValidateColormapIndex(Image *,const size_t)
     magick_attribute((deprecated));
 
 extern MagickExport int
   GetImageGeometry(Image *,const char *,const unsigned int,RectangleInfo *)
     magick_attribute((deprecated)),
-  ParseImageGeometry(const char *,long *,long *,unsigned long *,
-    unsigned long *) magick_attribute((deprecated));
+  ParseImageGeometry(const char *,ssize_t *,ssize_t *,size_t *,
+    size_t *) magick_attribute((deprecated));
 
-extern MagickExport long
+extern MagickExport ssize_t
   GetImageListIndex(const Image *) magick_attribute((deprecated)),
   SetMagickRegistry(const RegistryType,const void *,const size_t,
     ExceptionInfo *) magick_attribute((deprecated));
 
 extern MagickExport MagickBooleanType
-  AcquireOneCacheViewPixel(const CacheView *,const long,const long,
+  AcquireOneCacheViewPixel(const CacheView *,const ssize_t,const ssize_t,
     PixelPacket *,ExceptionInfo *) magick_attribute((deprecated)),
   AcquireOneCacheViewVirtualPixel(const CacheView *,const VirtualPixelMethod,
-    const long,const long,PixelPacket *,ExceptionInfo *)
+    const ssize_t,const ssize_t,PixelPacket *,ExceptionInfo *)
     magick_attribute((deprecated)),
   AffinityImage(const QuantizeInfo *,Image *,const Image *)
     magick_attribute((deprecated)),
   AffinityImages(const QuantizeInfo *,Image *,const Image *)
     magick_attribute((deprecated)),
-  AllocateImageColormap(Image *,const unsigned long)
+  AllocateImageColormap(Image *,const size_t)
     magick_attribute((deprecated)),
   ClipPathImage(Image *,const char *,const MagickBooleanType)
     magick_attribute((deprecated)),
   CloneImageAttributes(Image *,const Image *) magick_attribute((deprecated)),
-  ColorFloodfillImage(Image *,const DrawInfo *,const PixelPacket,const long,
-    const long,const PaintMethod) magick_attribute((deprecated)),
+  ColorFloodfillImage(Image *,const DrawInfo *,const PixelPacket,const ssize_t,
+    const ssize_t,const PaintMethod) magick_attribute((deprecated)),
   DeleteImageAttribute(Image *,const char *) magick_attribute((deprecated)),
-  DeleteMagickRegistry(const long) magick_attribute((deprecated)),
+  DeleteMagickRegistry(const ssize_t) magick_attribute((deprecated)),
   DescribeImage(Image *,FILE *,const MagickBooleanType)
     magick_attribute((deprecated)),
   FormatImageAttribute(Image *,const char *,const char *,...)
@@ -189,12 +189,12 @@
     magick_attribute((deprecated)),
   MapImages(Image *,const Image *,const MagickBooleanType)
     magick_attribute((deprecated)),
-  MatteFloodfillImage(Image *,const PixelPacket,const Quantum,const long,
-    const long,const PaintMethod) magick_attribute((deprecated)),
+  MatteFloodfillImage(Image *,const PixelPacket,const Quantum,const ssize_t,
+    const ssize_t,const PaintMethod) magick_attribute((deprecated)),
   OpaqueImage(Image *,const PixelPacket,const PixelPacket)
     magick_attribute((deprecated)),
   PaintFloodfillImage(Image *,const ChannelType,const MagickPixelPacket *,
-    const long,const long,const DrawInfo *,const PaintMethod)
+    const ssize_t,const ssize_t,const DrawInfo *,const PaintMethod)
     magick_attribute((deprecated)),
   PaintOpaqueImage(Image *,const MagickPixelPacket *,const MagickPixelPacket *)
     magick_attribute((deprecated)),
@@ -212,7 +212,7 @@
     magick_attribute((deprecated));
 
 extern MagickExport MagickPixelPacket
-  AcquireOneMagickPixel(const Image *,const long,const long,ExceptionInfo *)
+  AcquireOneMagickPixel(const Image *,const ssize_t,const ssize_t,ExceptionInfo *)
     magick_attribute((deprecated));
 
 extern MagickExport MonitorHandler
@@ -231,22 +231,22 @@
     magick_attribute((deprecated));
 
 extern MagickExport PixelPacket
-  AcquireOnePixel(const Image *,const long,const long,ExceptionInfo *)
+  AcquireOnePixel(const Image *,const ssize_t,const ssize_t,ExceptionInfo *)
     magick_attribute((deprecated)),
-  AcquireOneVirtualPixel(const Image *,const VirtualPixelMethod,const long,
-    const long,ExceptionInfo *) magick_attribute((deprecated)),
-  *GetCacheView(CacheView *,const long,const long,const unsigned long,
-    const unsigned long) magick_attribute((deprecated)),
-  *GetCacheViewPixels(CacheView *,const long,const long,const unsigned long,
-    const unsigned long) magick_attribute((deprecated)),
-  *GetImagePixels(Image *,const long,const long,const unsigned long,
-    const unsigned long) magick_attribute((deprecated)),
-  GetOnePixel(Image *,const long,const long) magick_attribute((deprecated)),
+  AcquireOneVirtualPixel(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,ExceptionInfo *) magick_attribute((deprecated)),
+  *GetCacheView(CacheView *,const ssize_t,const ssize_t,const size_t,
+    const size_t) magick_attribute((deprecated)),
+  *GetCacheViewPixels(CacheView *,const ssize_t,const ssize_t,const size_t,
+    const size_t) magick_attribute((deprecated)),
+  *GetImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t) magick_attribute((deprecated)),
+  GetOnePixel(Image *,const ssize_t,const ssize_t) magick_attribute((deprecated)),
   *GetPixels(const Image *) magick_attribute((deprecated)),
-  *SetCacheViewPixels(CacheView *,const long,const long,const unsigned long,
-    const unsigned long) magick_attribute((deprecated)),
-  *SetImagePixels(Image *,const long,const long,const unsigned long,
-    const unsigned long) magick_attribute((deprecated));
+  *SetCacheViewPixels(CacheView *,const ssize_t,const ssize_t,const size_t,
+    const size_t) magick_attribute((deprecated)),
+  *SetImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t) magick_attribute((deprecated));
 
 extern MagickExport size_t
   PopImagePixels(Image *,const QuantumType,unsigned char *)
@@ -257,13 +257,13 @@
 extern MagickExport unsigned int
   ChannelImage(Image *,const ChannelType) magick_attribute((deprecated)),
   ChannelThresholdImage(Image *,const char *) magick_attribute((deprecated)),
-  DispatchImage(const Image *,const long,const long,const unsigned long,
-    const unsigned long,const char *,const StorageType,void *,ExceptionInfo *)
+  DispatchImage(const Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,const char *,const StorageType,void *,ExceptionInfo *)
     magick_attribute((deprecated)),
   FuzzyColorMatch(const PixelPacket *,const PixelPacket *,const double)
     magick_attribute((deprecated)),
   GetNumberScenes(const Image *) magick_attribute((deprecated)),
-  GetMagickGeometry(const char *,long *,long *,unsigned long *,unsigned long *)
+  GetMagickGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *)
     magick_attribute((deprecated)),
   IsSubimage(const char *,const unsigned int) magick_attribute((deprecated)),
   PushImageList(Image **,const Image *,ExceptionInfo *)
@@ -271,7 +271,7 @@
   QuantizationError(Image *) magick_attribute((deprecated)),
   RandomChannelThresholdImage(Image *,const char *,const char *,
     ExceptionInfo *) magick_attribute((deprecated)),
-  SetImageList(Image **,const Image *,const long,ExceptionInfo *)
+  SetImageList(Image **,const Image *,const ssize_t,ExceptionInfo *)
     magick_attribute((deprecated)),
   TransformColorspace(Image *,const ColorspaceType)
     magick_attribute((deprecated)),
@@ -280,7 +280,7 @@
   UnshiftImageList(Image **,const Image *,ExceptionInfo *)
     magick_attribute((deprecated));
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetImageListSize(const Image *) magick_attribute((deprecated));
 
 extern MagickExport CacheView
@@ -297,7 +297,7 @@
   DestroyMagickRegistry(void) magick_attribute((deprecated)),
   *GetConfigureBlob(const char *,char *,size_t *,ExceptionInfo *)
     magick_attribute((deprecated)),
-  *GetMagickRegistry(const long,RegistryType *,size_t *,ExceptionInfo *)
+  *GetMagickRegistry(const ssize_t,RegistryType *,size_t *,ExceptionInfo *)
     magick_attribute((deprecated)),
   IdentityAffine(AffineMatrix *) magick_attribute((deprecated)),
   LiberateMemory(void **) magick_attribute((deprecated)),
@@ -312,7 +312,7 @@
   MagickIncarnate(const char *) magick_attribute((deprecated)),
   ReacquireMemory(void **,const size_t) magick_attribute((deprecated)),
   ResetImageAttributeIterator(const Image *) magick_attribute((deprecated)),
-  SetCacheThreshold(const unsigned long) magick_attribute((deprecated)),
+  SetCacheThreshold(const size_t) magick_attribute((deprecated)),
   SetImage(Image *,const Quantum) magick_attribute((deprecated)),
   Strip(char *) magick_attribute((deprecated)),
   TemporaryFilename(char *) magick_attribute((deprecated)),
diff --git a/magick/display-private.h b/magick/display-private.h
index 2d93fbe..c125ec1 100644
--- a/magick/display-private.h
+++ b/magick/display-private.h
@@ -27,7 +27,7 @@
 
 extern MagickExport Image
   *XDisplayImage(Display *,XResourceInfo *,char **,int,Image **,
-    unsigned long *);
+    size_t *);
 
 extern MagickExport MagickBooleanType XDisplayBackgroundImage(Display *,
   XResourceInfo *,Image *);
diff --git a/magick/display.c b/magick/display.c
index 1391837..65f0d85 100644
--- a/magick/display.c
+++ b/magick/display.c
@@ -931,7 +931,7 @@
     "",
     "  Meta-I    Press to implode image pixels about the center.",
     "",
-    "  Meta-W    Press to alter an image along a sine wave.",
+    "  Meta-W    Press to alter an image assize_t a sine wave.",
     "",
     "  Meta-P    Press to simulate an oil painting.",
     "",
@@ -1631,10 +1631,10 @@
   Image
     *image;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     state;
 
   XrmDatabase
@@ -1670,7 +1670,7 @@
   state=DefaultState;
   for (i=0; (state & ExitState) == 0; i++)
   {
-    if ((images->iterations != 0) && (i >= (long) images->iterations))
+    if ((images->iterations != 0) && (i >= (ssize_t) images->iterations))
       break;
     image=GetImageFromList(images,i % GetImageListLength(images));
     (void) XDisplayImage(display,&resource_info,argv,1,&image,&state);
@@ -1770,14 +1770,14 @@
 %
 */
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -1859,14 +1859,14 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XAnnotateInfo
@@ -2562,7 +2562,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -2572,7 +2572,7 @@
         if (event.xselection.property == (Atom) None)
           break;
         status=XGetWindowProperty(display,event.xselection.requestor,
-          event.xselection.property,0L,(long) MaxTextExtent,True,XA_STRING,
+          event.xselection.property,0L,(ssize_t) MaxTextExtent,True,XA_STRING,
           &type,&format,&length,&after,&data);
         if ((status != Success) || (type != XA_STRING) || (format == 32) ||
             (length == 0))
@@ -2580,7 +2580,7 @@
         /*
           Annotate Image window with primary selection.
         */
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           if ((char) data[i] != '\n')
             {
@@ -2673,7 +2673,7 @@
     */
     windows->pixel_info->box_color=windows->pixel_info->pen_colors[box_id];
     if (windows->pixel_info->colors != 0)
-      for (i=0; i < (long) windows->pixel_info->colors; i++)
+      for (i=0; i < (ssize_t) windows->pixel_info->colors; i++)
         if (windows->pixel_info->pixels[i] ==
             windows->pixel_info->pen_colors[box_id].pixel)
           {
@@ -2682,7 +2682,7 @@
           }
     windows->pixel_info->pen_color=windows->pixel_info->pen_colors[pen_id];
     if (windows->pixel_info->colors != 0)
-      for (i=0; i < (long) windows->pixel_info->colors; i++)
+      for (i=0; i < (ssize_t) windows->pixel_info->colors; i++)
         if (windows->pixel_info->pixels[i] ==
             windows->pixel_info->pen_colors[pen_id].pixel)
           {
@@ -2876,7 +2876,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -3145,25 +3145,25 @@
     */
     if (direction == HorizontalChopCommand)
       {
-        chop_info.width=(unsigned long) (segment_info.x2-segment_info.x1+1);
+        chop_info.width=(size_t) (segment_info.x2-segment_info.x1+1);
         chop_info.x=windows->image.x+segment_info.x1;
         chop_info.height=0;
         chop_info.y=0;
         if (segment_info.x1 > (int) segment_info.x2)
           {
-            chop_info.width=(unsigned long) (segment_info.x1-segment_info.x2+1);
+            chop_info.width=(size_t) (segment_info.x1-segment_info.x2+1);
             chop_info.x=windows->image.x+segment_info.x2;
           }
       }
     else
       {
         chop_info.width=0;
-        chop_info.height=(unsigned long) (segment_info.y2-segment_info.y1+1);
+        chop_info.height=(size_t) (segment_info.y2-segment_info.y1+1);
         chop_info.x=0;
         chop_info.y=windows->image.y+segment_info.y1;
         if (segment_info.y1 > segment_info.y2)
           {
-            chop_info.height=(unsigned long)
+            chop_info.height=(size_t)
               (segment_info.y1-segment_info.y2+1);
             chop_info.y=windows->image.y+segment_info.y2;
           }
@@ -3305,14 +3305,14 @@
   register PixelPacket
     *q;
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XColor
@@ -3685,8 +3685,8 @@
           (height*(windows->image.y+y_offset)/windows->image.ximage->height+y);
         if ((x_offset < 0) || (y_offset < 0))
           continue;
-        if ((x_offset >= (long) (*image)->columns) ||
-            (y_offset >= (long) (*image)->rows))
+        if ((x_offset >= (ssize_t) (*image)->columns) ||
+            (y_offset >= (ssize_t) (*image)->rows))
           continue;
         exception=(&(*image)->exception);
         switch (method)
@@ -3720,7 +3720,7 @@
               &(*image)->exception);
             if ((*image)->storage_class == DirectClass)
               {
-                for (y=0; y < (long) (*image)->rows; y++)
+                for (y=0; y < (ssize_t) (*image)->rows; y++)
                 {
                   q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
                     exception);
@@ -3795,7 +3795,7 @@
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
@@ -3913,7 +3913,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -4138,7 +4138,7 @@
         *(command+length)='\0';
         if (image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key press: 0x%lx (%s)",(unsigned long) key_symbol,command);
+            "Key press: 0x%lx (%s)",(size_t) key_symbol,command);
         switch ((int) key_symbol)
         {
           case XK_Escape:
@@ -4272,12 +4272,12 @@
       */
       (void) SetImageAlphaChannel(composite_image,OpaqueAlphaChannel);
       opacity=(Quantum) (ScaleQuantumToChar((Quantum) QuantumRange)-
-        ((long) ScaleQuantumToChar((Quantum) QuantumRange)*blend)/100);
+        ((ssize_t) ScaleQuantumToChar((Quantum) QuantumRange)*blend)/100);
       if (SetImageStorageClass(image,DirectClass) == MagickFalse)
         return(MagickFalse);
       image->matte=MagickTrue;
       exception=(&image->exception);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -4344,14 +4344,14 @@
   char
     geometry[MaxTextExtent];
 
-  long
+  ssize_t
     x,
     y;
 
   MagickStatusType
     status;
 
-  unsigned long
+  size_t
     mask,
     height,
     width;
@@ -4412,7 +4412,7 @@
   window_changes.height=(int) height;
   if (window_changes.height > XDisplayHeight(display,windows->image.screen))
     window_changes.height=XDisplayHeight(display,windows->image.screen);
-  mask=(unsigned long) (CWWidth | CWHeight);
+  mask=(size_t) (CWWidth | CWHeight);
   if (resource_info->backdrop)
     {
       mask|=CWX | CWY;
@@ -4577,7 +4577,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -5011,8 +5011,8 @@
               (y < (int) (crop_info.y+RoiDelta)) &&
               (y > (int) (crop_info.y-RoiDelta)))
             {
-              crop_info.x=(long) (crop_info.x+crop_info.width);
-              crop_info.y=(long) (crop_info.y+crop_info.height);
+              crop_info.x=(ssize_t) (crop_info.x+crop_info.width);
+              crop_info.y=(ssize_t) (crop_info.y+crop_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5021,7 +5021,7 @@
               (y < (int) (crop_info.y+crop_info.height+RoiDelta)) &&
               (y > (int) (crop_info.y+crop_info.height-RoiDelta)))
             {
-              crop_info.x=(long) (crop_info.x+crop_info.width);
+              crop_info.x=(ssize_t) (crop_info.x+crop_info.width);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5030,7 +5030,7 @@
               (y < (int) (crop_info.y+RoiDelta)) &&
               (y > (int) (crop_info.y-RoiDelta)))
             {
-              crop_info.y=(long) (crop_info.y+crop_info.height);
+              crop_info.y=(ssize_t) (crop_info.y+crop_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -5092,8 +5092,8 @@
             case XK_Home:
             case XK_KP_Home:
             {
-              crop_info.x=(long) (windows->image.width/2L-crop_info.width/2L);
-              crop_info.y=(long) (windows->image.height/2L-crop_info.height/2L);
+              crop_info.x=(ssize_t) (windows->image.width/2L-crop_info.width/2L);
+              crop_info.y=(ssize_t) (windows->image.height/2L-crop_info.height/2L);
               break;
             }
             case XK_Left:
@@ -5284,7 +5284,7 @@
     return(MagickFalse);
   image->matte=MagickTrue;
   exception=(&image->exception);
-  for (y=0; y < (long) crop_info.height; y++)
+  for (y=0; y < (ssize_t) crop_info.height; y++)
   {
     q=GetAuthenticPixels(image,crop_info.x,y+crop_info.y,crop_info.width,1,
       exception);
@@ -5407,7 +5407,7 @@
     max_coordinates,
     width;
 
-  unsigned long
+  size_t
     state;
 
   Window
@@ -6108,7 +6108,7 @@
             rectangle_info.x=0;
           else
             if (rectangle_info.x > (int) windows->image.width)
-              rectangle_info.x=(long) windows->image.width;
+              rectangle_info.x=(ssize_t) windows->image.width;
           if ((int) rectangle_info.x < x)
             rectangle_info.width=(unsigned int) (x-rectangle_info.x);
           else
@@ -6120,7 +6120,7 @@
             rectangle_info.y=0;
           else
             if (rectangle_info.y > (int) windows->image.height)
-              rectangle_info.y=(long) windows->image.height;
+              rectangle_info.y=(ssize_t) windows->image.height;
           if ((int) rectangle_info.y < y)
             rectangle_info.height=(unsigned int) (y-rectangle_info.y);
           else
@@ -6152,8 +6152,8 @@
           if (coordinate_info[i].y < rectangle_info.y)
             rectangle_info.y=MagickMax(coordinate_info[i].y,0);
         }
-        rectangle_info.width=(unsigned long) (x-rectangle_info.x);
-        rectangle_info.height=(unsigned long) (y-rectangle_info.y);
+        rectangle_info.width=(size_t) (x-rectangle_info.x);
+        rectangle_info.height=(size_t) (y-rectangle_info.y);
         for (i=0; i < number_coordinates; i++)
         {
           coordinate_info[i].x-=rectangle_info.x;
@@ -6232,9 +6232,9 @@
       }
     draw_info.rectangle_info=rectangle_info;
     if (draw_info.rectangle_info.x > (int) (line_width/2))
-      draw_info.rectangle_info.x=(long) line_width/2;
+      draw_info.rectangle_info.x=(ssize_t) line_width/2;
     if (draw_info.rectangle_info.y > (int) (line_width/2))
-      draw_info.rectangle_info.y=(long) line_width/2;
+      draw_info.rectangle_info.y=(ssize_t) line_width/2;
     draw_info.number_coordinates=(unsigned int) number_coordinates;
     draw_info.coordinate_info=coordinate_info;
     windows->pixel_info->pen_color=windows->pixel_info->pen_colors[pen_id];
@@ -6466,10 +6466,10 @@
       Image
         *previous_image;
 
-      long
+      ssize_t
         bytes;
 
-      bytes=(long) ((*image)->columns*(*image)->rows*sizeof(PixelPacket));
+      bytes=(ssize_t) ((*image)->columns*(*image)->rows*sizeof(PixelPacket));
       if (undo_image != (Image *) NULL)
         {
           /*
@@ -6480,7 +6480,7 @@
           {
             bytes+=previous_image->list->columns*previous_image->list->rows*
               sizeof(PixelPacket);
-            if (bytes <= (long) (resource_info->undo_cache << 20))
+            if (bytes <= (ssize_t) (resource_info->undo_cache << 20))
               {
                 previous_image=GetPreviousImageInList(previous_image);
                 continue;
@@ -6504,7 +6504,7 @@
             cache_image=DestroyImage(cache_image);
           }
         }
-      if (bytes > (long) (resource_info->undo_cache << 20))
+      if (bytes > (ssize_t) (resource_info->undo_cache << 20))
         break;
       /*
         Save image before transformations are applied.
@@ -6521,8 +6521,8 @@
           cache_image=DestroyImage(cache_image);
           break;
         }
-      cache_image->columns=(unsigned long) windows->image.ximage->width;
-      cache_image->rows=(unsigned long) windows->image.ximage->height;
+      cache_image->columns=(size_t) windows->image.ximage->width;
+      cache_image->rows=(size_t) windows->image.ximage->height;
       cache_image->geometry=windows->image.crop_geometry;
       if (windows->image.crop_geometry != (char *) NULL)
         {
@@ -6922,8 +6922,8 @@
           */
           crop_info.x=0;
           crop_info.y=0;
-          crop_info.width=(unsigned long) windows->image.ximage->width;
-          crop_info.height=(unsigned long) windows->image.ximage->height;
+          crop_info.width=(size_t) windows->image.ximage->width;
+          crop_info.height=(size_t) windows->image.ximage->height;
           if ((key_symbol == XK_Up) || (key_symbol == XK_KP_Up))
             {
               if (resource_info->quantum >= (int) crop_info.height)
@@ -7284,19 +7284,19 @@
       int
         status;
 
-      long
+      ssize_t
         x,
         y;
 
-      unsigned long
+      size_t
         height,
         width;
 
       /*
         Resize image.
       */
-      width=(unsigned long) windows->image.ximage->width;
-      height=(unsigned long) windows->image.ximage->height;
+      width=(size_t) windows->image.ximage->width;
+      height=(size_t) windows->image.ximage->height;
       x=0;
       y=0;
       (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu+0+0",
@@ -8517,7 +8517,7 @@
       if ((flags & PsiValue) == 0)
         geometry_info.psi=0.1*(*image)->rows;
       vignette_image=VignetteImage(*image,geometry_info.rho,geometry_info.sigma,
-        (long) ceil(geometry_info.xi-0.5),(long) ceil(geometry_info.psi-0.5),
+        (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),
         &(*image)->exception);
       if (vignette_image != (Image *) NULL)
         {
@@ -8548,7 +8548,7 @@
       if (*geometry == '\0')
         break;
       /*
-        Alter an image along a sine wave.
+        Alter an image assize_t a sine wave.
       */
       XSetCursorState(display,windows,MagickTrue);
       XCheckRefreshWindows(display,windows);
@@ -8793,8 +8793,8 @@
       frame_info.height=page_geometry.height;
       frame_info.outer_bevel=page_geometry.x;
       frame_info.inner_bevel=page_geometry.y;
-      frame_info.x=(long) frame_info.width;
-      frame_info.y=(long) frame_info.height;
+      frame_info.x=(ssize_t) frame_info.width;
+      frame_info.y=(ssize_t) frame_info.height;
       frame_info.width=(*image)->columns+2*frame_info.width;
       frame_info.height=(*image)->rows+2*frame_info.height;
       frame_image=FrameImage(*image,&frame_info,&(*image)->exception);
@@ -8957,7 +8957,7 @@
       XCheckRefreshWindows(display,windows);
       image_info->preview_type=(PreviewType)
         ParseMagickOption(MagickPreviewOptions,MagickFalse,preview_type);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Preview");
       (void) AcquireUniqueFilename(filename);
@@ -8990,7 +8990,7 @@
       */
       XSetCursorState(display,windows,MagickTrue);
       XCheckRefreshWindows(display,windows);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Histogram");
       (void) AcquireUniqueFilename(filename);
@@ -9029,7 +9029,7 @@
       */
       XSetCursorState(display,windows,MagickTrue);
       XCheckRefreshWindows(display,windows);
-      image_info->group=(long) windows->image.id;
+      image_info->group=(ssize_t) windows->image.id;
       (void) DeleteImageProperty(*image,"label");
       (void) SetImageProperty(*image,"label","Matte");
       (void) AcquireUniqueFilename(filename);
@@ -9153,7 +9153,7 @@
     }
     case VersionCommand:
     {
-      XNoticeWidget(display,windows,GetMagickVersion((unsigned long *) NULL),
+      XNoticeWidget(display,windows,GetMagickVersion((size_t *) NULL),
         GetMagickCopyright());
       break;
     }
@@ -9207,7 +9207,7 @@
     x,
     y;
 
-  unsigned long
+  size_t
     state;
 
   /*
@@ -9563,7 +9563,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -9964,7 +9964,7 @@
             */
             (void) GetOneVirtualPixel(*image,x_offset,y_offset,&target,
               exception);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=GetAuthenticPixels(*image,0,y,(*image)->columns,1,
                 &(*image)->exception);
@@ -10020,7 +10020,7 @@
             */
             if (SetImageStorageClass(*image,DirectClass) == MagickFalse)
               return(MagickFalse);
-            for (y=0; y < (long) (*image)->rows; y++)
+            for (y=0; y < (ssize_t) (*image)->rows; y++)
             {
               q=QueueAuthenticPixels(*image,0,y,(*image)->columns,1,exception);
               if (q == (PixelPacket *) NULL)
@@ -10164,7 +10164,7 @@
         seconds);
       if (*seconds == '\0')
         return((Image *) NULL);
-      XDelay(display,(unsigned long) (1000*StringToLong(seconds)));
+      XDelay(display,(size_t) (1000*StringToLong(seconds)));
     }
   magick_info=GetMagickInfo(image_info->magick,exception);
   if ((magick_info != (const MagickInfo *) NULL) &&
@@ -10274,7 +10274,7 @@
   RectangleInfo
     pan_info;
 
-  unsigned long
+  size_t
     state;
 
   /*
@@ -10351,18 +10351,18 @@
         else
           if ((int) (pan_info.x+windows->image.width) >
               windows->image.ximage->width)
-            pan_info.x=(long)
+            pan_info.x=(ssize_t)
               (windows->image.ximage->width-windows->image.width);
-        if (pan_info.y < (long) (pan_info.height/2))
+        if (pan_info.y < (ssize_t) (pan_info.height/2))
           pan_info.y=0;
         else
-          pan_info.y=(long) (y_factor*(pan_info.y-(pan_info.height/2)));
+          pan_info.y=(ssize_t) (y_factor*(pan_info.y-(pan_info.height/2)));
         if (pan_info.y < 0)
           pan_info.y=0;
         else
           if ((int) (pan_info.y+windows->image.height) >
               windows->image.ximage->height)
-            pan_info.y=(long)
+            pan_info.y=(ssize_t)
               (windows->image.ximage->height-windows->image.height);
         if ((windows->image.x != (int) pan_info.x) ||
             (windows->image.y != (int) pan_info.y))
@@ -10478,7 +10478,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -10661,7 +10661,7 @@
         *(command+length)='\0';
         if (image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key press: 0x%lx (%s)",(long) key_symbol,command);
+            "Key press: 0x%lx (%s)",(ssize_t) key_symbol,command);
         switch ((int) key_symbol)
         {
           case XK_Escape:
@@ -11123,7 +11123,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -11571,8 +11571,8 @@
               (y < (int) (roi_info.y+RoiDelta)) &&
               (y > (int) (roi_info.y-RoiDelta)))
             {
-              roi_info.x=(long) (roi_info.x+roi_info.width);
-              roi_info.y=(long) (roi_info.y+roi_info.height);
+              roi_info.x=(ssize_t) (roi_info.x+roi_info.width);
+              roi_info.y=(ssize_t) (roi_info.y+roi_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11581,7 +11581,7 @@
               (y < (int) (roi_info.y+roi_info.height+RoiDelta)) &&
               (y > (int) (roi_info.y+roi_info.height-RoiDelta)))
             {
-              roi_info.x=(long) (roi_info.x+roi_info.width);
+              roi_info.x=(ssize_t) (roi_info.x+roi_info.width);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11590,7 +11590,7 @@
               (y < (int) (roi_info.y+RoiDelta)) &&
               (y > (int) (roi_info.y-RoiDelta)))
             {
-              roi_info.y=(long) (roi_info.y+roi_info.height);
+              roi_info.y=(ssize_t) (roi_info.y+roi_info.height);
               state|=UpdateConfigurationState;
               break;
             }
@@ -11658,8 +11658,8 @@
             case XK_Home:
             case XK_KP_Home:
             {
-              roi_info.x=(long) (windows->image.width/2L-roi_info.width/2L);
-              roi_info.y=(long) (windows->image.height/2L-roi_info.height/2L);
+              roi_info.x=(ssize_t) (windows->image.width/2L-roi_info.width/2L);
+              roi_info.y=(ssize_t) (windows->image.height/2L-roi_info.height/2L);
               break;
             }
             case XK_Left:
@@ -11881,7 +11881,7 @@
       unsigned int
         distance;
 
-      unsigned long
+      size_t
         state;
 
       XEvent
@@ -12567,7 +12567,7 @@
       */
       if (event->xclient.message_type != windows->wm_protocols)
         break;
-      if (*event->xclient.data.l != (long) windows->wm_delete_window)
+      if (*event->xclient.data.l != (ssize_t) windows->wm_delete_window)
         break;
       if (event->xclient.window == windows->magnify.id)
         {
@@ -13241,7 +13241,7 @@
     x,
     y;
 
-  unsigned long
+  size_t
     background,
     pixel;
 
@@ -13254,7 +13254,7 @@
     Crop the left edge.
   */
   background=XGetPixel(windows->image.ximage,0,0);
-  trim_info.width=(unsigned long) windows->image.ximage->width;
+  trim_info.width=(size_t) windows->image.ximage->width;
   for (x=0; x < windows->image.ximage->width; x++)
   {
     for (y=0; y < windows->image.ximage->height; y++)
@@ -13287,12 +13287,12 @@
     if (y < windows->image.ximage->height)
       break;
   }
-  trim_info.width=(unsigned long) (x-trim_info.x+1);
+  trim_info.width=(size_t) (x-trim_info.x+1);
   /*
     Crop the top edge.
   */
   background=XGetPixel(windows->image.ximage,0,0);
-  trim_info.height=(unsigned long) windows->image.ximage->height;
+  trim_info.height=(size_t) windows->image.ximage->height;
   for (y=0; y < windows->image.ximage->height; y++)
   {
     for (x=0; x < windows->image.ximage->width; x++)
@@ -13320,7 +13320,7 @@
     if (x < windows->image.ximage->width)
       break;
   }
-  trim_info.height=(unsigned long) y-trim_info.y+1;
+  trim_info.height=(size_t) y-trim_info.y+1;
   if (((unsigned int) trim_info.width != windows->image.width) ||
       ((unsigned int) trim_info.height != windows->image.height))
     {
@@ -13462,7 +13462,7 @@
   exception=AcquireExceptionInfo();
   XSetCursorState(display,windows,MagickTrue);
   XCheckRefreshWindows(display,windows);
-  for (i=0; i < (long) number_files; i++)
+  for (i=0; i < (ssize_t) number_files; i++)
   {
     (void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
     filelist[i]=DestroyString(filelist[i]);
@@ -13585,7 +13585,7 @@
   static XWindowInfo
     window_info;
 
-  unsigned long
+  size_t
     delay;
 
   Window
@@ -13646,7 +13646,7 @@
         ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed",
           image->filename);
       map_info->colormap=(Colormap) NULL;
-      pixel.pixels=(unsigned long *) NULL;
+      pixel.pixels=(size_t *) NULL;
       /*
         Initialize visual info.
       */
@@ -13680,7 +13680,7 @@
   context_values.background=pixel.background_color.pixel;
   context_values.foreground=pixel.foreground_color.pixel;
   pixel.annotate_context=XCreateGC(display,window_info.id,
-    (unsigned long) (GCBackground | GCForeground),&context_values);
+    (size_t) (GCBackground | GCForeground),&context_values);
   if (pixel.annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       image->filename);
@@ -13822,7 +13822,7 @@
 %  The format of the XDisplayImage method is:
 %
 %      Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
-%        char **argv,int argc,Image **image,unsigned long *state)
+%        char **argv,int argc,Image **image,size_t *state)
 %
 %  A description of each parameter follows:
 %
@@ -13843,7 +13843,7 @@
 %
 */
 MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info,
-  char **argv,int argc,Image **image,unsigned long *state)
+  char **argv,int argc,Image **image,size_t *state)
 {
 #define MagnifySize  256  /* must be a power of 2 */
 #define MagickMenus  10
@@ -14248,7 +14248,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     delay;
 
   WarningHandler
@@ -14425,7 +14425,7 @@
   if (pixel->highlight_context != (GC) NULL)
     (void) XFreeGC(display,pixel->highlight_context);
   pixel->highlight_context=XCreateGC(display,windows->context.id,
-    (unsigned long) (context_mask | GCPlaneMask),&context_values);
+    (size_t) (context_mask | GCPlaneMask),&context_values);
   if (pixel->highlight_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       display_image->filename);
@@ -14456,7 +14456,7 @@
   context_values.background=icon_pixel->background_color.pixel;
   context_values.foreground=icon_pixel->foreground_color.pixel;
   icon_pixel->annotate_context=XCreateGC(display,windows->icon.id,
-    (unsigned long) (GCBackground | GCForeground),&context_values);
+    (size_t) (GCBackground | GCForeground),&context_values);
   if (icon_pixel->annotate_context == (GC) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToCreateGraphicContext",
       display_image->filename);
@@ -14527,7 +14527,7 @@
       windows->backdrop.x=0;
       windows->backdrop.y=0;
       (void) CloneString(&windows->backdrop.name,"Backdrop");
-      windows->backdrop.flags=(unsigned long) (USSize | USPosition);
+      windows->backdrop.flags=(size_t) (USSize | USPosition);
       windows->backdrop.width=(unsigned int)
         XDisplayWidth(display,visual_info->screen);
       windows->backdrop.height=(unsigned int)
@@ -15144,11 +15144,11 @@
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
             "Client Message: 0x%lx 0x%lx %d 0x%lx",event.xclient.window,
-            event.xclient.message_type,event.xclient.format,(unsigned long)
+            event.xclient.message_type,event.xclient.format,(size_t)
             event.xclient.data.l[0]);
         if (event.xclient.message_type == windows->im_protocols)
           {
-            if (*event.xclient.data.l == (long) windows->im_update_widget)
+            if (*event.xclient.data.l == (ssize_t) windows->im_update_widget)
               {
                 (void) CloneString(&windows->command.name,MagickTitle);
                 windows->command.data=MagickMenus;
@@ -15156,7 +15156,7 @@
                   (XEvent *) NULL);
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_update_colormap)
+            if (*event.xclient.data.l == (ssize_t) windows->im_update_colormap)
               {
                 /*
                   Update graphic context and window colormap.
@@ -15176,7 +15176,7 @@
                   context_values.plane_mask=context_values.background ^
                     context_values.foreground;
                   (void) XChangeGC(display,magick_windows[i]->highlight_context,
-                    (unsigned long) (context_mask | GCPlaneMask),
+                    (size_t) (context_mask | GCPlaneMask),
                     &context_values);
                   magick_windows[i]->attributes.background_pixel=
                     pixel->background_color.pixel;
@@ -15197,22 +15197,22 @@
                   (void) XInstallColormap(display,map_info->colormap);
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_former_image)
+            if (*event.xclient.data.l == (ssize_t) windows->im_former_image)
               {
                 *state|=FormerImageState | ExitState;
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_next_image)
+            if (*event.xclient.data.l == (ssize_t) windows->im_next_image)
               {
                 *state|=NextImageState | ExitState;
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_retain_colors)
+            if (*event.xclient.data.l == (ssize_t) windows->im_retain_colors)
               {
                 *state|=RetainColorsState;
                 break;
               }
-            if (*event.xclient.data.l == (long) windows->im_exit)
+            if (*event.xclient.data.l == (ssize_t) windows->im_exit)
               {
                 *state|=ExitState;
                 break;
@@ -15232,7 +15232,7 @@
             unsigned char
               *data;
 
-            unsigned long
+            size_t
               after,
               length;
 
@@ -15242,7 +15242,7 @@
             if ((*event.xclient.data.l != 2) && (*event.xclient.data.l != 128))
               break;
             selection=XInternAtom(display,"DndSelection",MagickFalse);
-            status=XGetWindowProperty(display,root_window,selection,0L,(long)
+            status=XGetWindowProperty(display,root_window,selection,0L,(ssize_t)
               MaxTextExtent,MagickFalse,(Atom) AnyPropertyType,&type,&format,
               &length,&after,&data);
             if ((status != Success) || (length == 0))
@@ -15281,7 +15281,7 @@
         */
         if (event.xclient.message_type != windows->wm_protocols)
           break;
-        if (*event.xclient.data.l != (long) windows->wm_delete_window)
+        if (*event.xclient.data.l != (ssize_t) windows->wm_delete_window)
           break;
         (void) XWithdrawWindow(display,event.xclient.window,
           visual_info->screen);
@@ -15377,8 +15377,8 @@
                         &window_changes);
                     }
               }
-            if ((event.xconfigure.width == (long) windows->image.width) &&
-                (event.xconfigure.height == (long) windows->image.height))
+            if ((event.xconfigure.width == (ssize_t) windows->image.width) &&
+                (event.xconfigure.height == (ssize_t) windows->image.height))
               break;
             windows->image.width=(unsigned int) event.xconfigure.width;
             windows->image.height=(unsigned int) event.xconfigure.height;
@@ -15553,7 +15553,7 @@
         *(command+length)='\0';
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key press: %d 0x%lx (%s)",event.xkey.state,(unsigned long)
+            "Key press: %d 0x%lx (%s)",event.xkey.state,(size_t)
             key_symbol,command);
         if (event.xkey.window == windows->image.id)
           {
@@ -15591,7 +15591,7 @@
           sizeof(command),&key_symbol,(XComposeStatus *) NULL);
         if (display_image->debug != MagickFalse)
           (void) LogMagickEvent(X11Event,GetMagickModule(),
-            "Key release: 0x%lx (%c)",(unsigned long) key_symbol,*command);
+            "Key release: 0x%lx (%c)",(size_t) key_symbol,*command);
         break;
       }
       case LeaveNotify:
@@ -15708,7 +15708,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -15722,7 +15722,7 @@
           Display image named by the remote command protocol.
         */
         status=XGetWindowProperty(display,event.xproperty.window,
-          event.xproperty.atom,0L,(long) MaxTextExtent,MagickFalse,(Atom)
+          event.xproperty.atom,0L,(ssize_t) MaxTextExtent,MagickFalse,(Atom)
           AnyPropertyType,&type,&format,&length,&after,&data);
         if ((status != Success) || (length == 0))
           break;
diff --git a/magick/distort.c b/magick/distort.c
index ad2d7f1..66f23b8 100644
--- a/magick/distort.c
+++ b/magick/distort.c
@@ -132,8 +132,8 @@
     Round the fraction to nearest integer.
   */
   if (x >= 0.0)
-    return((double) ((long) (x+0.5)));
-  return((double) ((long) (x-0.5)));
+    return((double) ((ssize_t) (x+0.5)));
+  return((double) ((ssize_t) (x-0.5)));
 }
 
 /*
@@ -155,16 +155,16 @@
  * which is to allow the use of a bi-linear (order=1.5) polynomial.
  * All the later polynomials are ordered simply from x^N to y^N
  */
-static unsigned long poly_number_terms(double order)
+static size_t poly_number_terms(double order)
 {
  /* Return the number of terms for a 2d polynomial */
   if ( order < 1 || order > 5 ||
        ( order != floor(order) && (order-1.5) > MagickEpsilon) )
     return 0; /* invalid polynomial order */
-  return((unsigned long) floor((order+1)*(order+2)/2));
+  return((size_t) floor((order+1)*(order+2)/2));
 }
 
-static double poly_basis_fn(long n, double x, double y)
+static double poly_basis_fn(ssize_t n, double x, double y)
 {
   /* Return the result for this polynomial term */
   switch(n) {
@@ -192,7 +192,7 @@
   }
   return( 0 ); /* should never happen */
 }
-static const char *poly_basis_str(long n)
+static const char *poly_basis_str(ssize_t n)
 {
   /* return the result for this polynomial term */
   switch(n) {
@@ -220,7 +220,7 @@
   }
   return( "UNKNOWN" ); /* should never happen */
 }
-static double poly_basis_dx(long n, double x, double y)
+static double poly_basis_dx(ssize_t n, double x, double y)
 {
   /* polynomial term for x derivative */
   switch(n) {
@@ -248,7 +248,7 @@
   }
   return( 0.0 ); /* should never happen */
 }
-static double poly_basis_dy(long n, double x, double y)
+static double poly_basis_dy(ssize_t n, double x, double y)
 {
   /* polynomial term for y derivative */
   switch(n) {
@@ -284,8 +284,8 @@
 %  The format of the GenerateCoefficients() method is:
 %
 %    Image *GenerateCoefficients(const Image *image,DistortImageMethod method,
-%        const unsigned long number_arguments,const double *arguments,
-%        unsigned long number_values, ExceptionInfo *exception)
+%        const size_t number_arguments,const double *arguments,
+%        size_t number_values, ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -316,16 +316,16 @@
 */
 
 static double *GenerateCoefficients(const Image *image,
-  DistortImageMethod *method,const unsigned long number_arguments,
-  const double *arguments,unsigned long number_values,ExceptionInfo *exception)
+  DistortImageMethod *method,const size_t number_arguments,
+  const double *arguments,size_t number_values,ExceptionInfo *exception)
 {
   double
     *coeff;
 
-  register unsigned long
+  register size_t
     i;
 
-  unsigned long
+  size_t
     number_coeff, /* number of coefficients to return (array size) */
     cp_size,      /* number floating point numbers per control point */
     cp_x,cp_y,    /* the x,y indexes for control point */
@@ -730,7 +730,7 @@
         *vectors[1],
         terms[8];
 
-      unsigned long
+      size_t
         cp_u = cp_values,
         cp_v = cp_values+1;
 
@@ -987,10 +987,10 @@
         **vectors,
         *terms;
 
-      unsigned long
+      size_t
         nterms;   /* number of polynomial terms per number_values */
 
-      register long
+      register ssize_t
         j;
 
       MagickBooleanType
@@ -999,7 +999,7 @@
       /* first two coefficients hold polynomial order information */
       coeff[0] = arguments[0];
       coeff[1] = (double) poly_number_terms(arguments[0]);
-      nterms = (unsigned long) coeff[1];
+      nterms = (size_t) coeff[1];
 
       /* create matrix, a fake vectors matrix, and least sqs terms */
       matrix = AcquireMagickMatrix(nterms,nterms);
@@ -1023,7 +1023,7 @@
         vectors[i] = &(coeff[2+i*nterms]);
       /* Add given control point pairs for least squares solving */
       for (i=1; i < number_arguments; i+=cp_size) { /* NB: start = 1 not 0 */
-        for (j=0; j < (long) nterms; j++)
+        for (j=0; j < (ssize_t) nterms; j++)
           terms[j] = poly_basis_fn(j,arguments[i+cp_x],arguments[i+cp_y]);
         LeastSquaresAddTerms(matrix,vectors,terms,
              &(arguments[i+cp_values]),nterms,number_values);
@@ -1341,7 +1341,7 @@
 %  The format of the DistortImage() method is:
 %
 %      Image *DistortImage(const Image *image,const DistortImageMethod method,
-%        const unsigned long number_arguments,const double *arguments,
+%        const size_t number_arguments,const double *arguments,
 %        MagickBooleanType bestfit, ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1402,7 +1402,7 @@
 %
 */
 MagickExport Image *DistortImage(const Image *image,DistortImageMethod method,
-  const unsigned long number_arguments,const double *arguments,
+  const size_t number_arguments,const double *arguments,
   MagickBooleanType bestfit,ExceptionInfo *exception)
 {
 #define DistortImageTag  "Distort/Image"
@@ -1555,7 +1555,7 @@
         d.x = (coeff[2]-coeff[3])*ca;
         d.y = (coeff[2]-coeff[3])*sa;
         ExpandBounds(d);
-        /* Orthogonal points along top of arc */
+        /* Orthogonal points assize_t top of arc */
         for( a=ceil((coeff[0]-coeff[1]/2.0)/MagickPI2)*MagickPI2;
                a<(coeff[0]+coeff[1]/2.0); a+=MagickPI2 ) {
           ca = cos(a); sa = sin(a);
@@ -1589,8 +1589,8 @@
         /* direct calculation as it needs to tile correctly
          * for reversibility in a DePolar-Polar cycle */
         geometry.x = geometry.y = 0;
-        geometry.height = (unsigned long) ceil(coeff[0]-coeff[1]);
-        geometry.width = (unsigned long)
+        geometry.height = (size_t) ceil(coeff[0]-coeff[1]);
+        geometry.width = (size_t)
                   ceil((coeff[0]-coeff[1])*(coeff[5]-coeff[4])*0.5);
         break;
       }
@@ -1614,10 +1614,10 @@
        Do not do this for DePolar which needs to be exact for virtual tiling.
     */
     if ( bestfit && method != DePolarDistortion ) {
-      geometry.x = (long) floor(min.x-0.5);
-      geometry.y = (long) floor(min.y-0.5);
-      geometry.width=(unsigned long) ceil(max.x-geometry.x+0.5);
-      geometry.height=(unsigned long) ceil(max.y-geometry.y+0.5);
+      geometry.x = (ssize_t) floor(min.x-0.5);
+      geometry.y = (ssize_t) floor(min.y-0.5);
+      geometry.width=(size_t) ceil(max.x-geometry.x+0.5);
+      geometry.height=(size_t) ceil(max.y-geometry.y+0.5);
     }
 
     /* Now that we have a new size lets some distortions to it exactly
@@ -1643,7 +1643,7 @@
 
   /* Verbose output */
   if ( GetImageArtifact(image,"verbose") != (const char *) NULL ) {
-    register long
+    register ssize_t
        i;
     char image_gen[MaxTextExtent];
     const char *lookup;
@@ -1787,19 +1787,19 @@
 
       case PolynomialDistortion:
       {
-        unsigned long nterms = (unsigned long) coeff[1];
+        size_t nterms = (size_t) coeff[1];
         fprintf(stderr, "Polynomial (order %lg, terms %lu), FX Equivelent\n",
                        coeff[0], nterms);
         fprintf(stderr, "%s", image_gen);
         fprintf(stderr, "  -fx 'ii=i+page.x+0.5; jj=j+page.y+0.5;\n");
         fprintf(stderr, "       xx =");
-        for (i=0; i<(long) nterms; i++) {
+        for (i=0; i<(ssize_t) nterms; i++) {
           if ( i != 0 && i%4 == 0 ) fprintf(stderr, "\n         ");
           fprintf(stderr, " %+lf%s", coeff[2+i],
                poly_basis_str(i));
         }
         fprintf(stderr, ";\n       yy =");
-        for (i=0; i<(long) nterms; i++) {
+        for (i=0; i<(ssize_t) nterms; i++) {
           if ( i != 0 && i%4 == 0 ) fprintf(stderr, "\n         ");
           fprintf(stderr, " %+lf%s", coeff[2+i+nterms],
                poly_basis_str(i));
@@ -1942,7 +1942,7 @@
     CacheView
       *distort_view;
 
-    long
+    ssize_t
       j,
       progress,
       status;
@@ -1962,7 +1962,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-    for (j=0; j < (long) distort_image->rows; j++)
+    for (j=0; j < (ssize_t) distort_image->rows; j++)
     {
       double
         validity;  /* how mathematically valid is this the mapping */
@@ -1981,7 +1981,7 @@
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         i,
         id;
 
@@ -2026,7 +2026,7 @@
       if (distort_image->colorspace == CMYKColorspace)
         ConvertRGBToCMYK(&invalid);   /* what about other color spaces? */
 
-      for (i=0; i < (long) distort_image->columns; i++)
+      for (i=0; i < (ssize_t) distort_image->columns; i++)
       {
         /* map pixel coordinate to distortion space coordinate */
         d.x = (double) (geometry.x+i+0.5)*output_scaling;
@@ -2130,10 +2130,10 @@
           case PolynomialDistortion:
           {
             /* multi-ordered polynomial */
-            register long
+            register ssize_t
               k;
-            long
-              nterms=(long)coeff[1];
+            ssize_t
+              nterms=(ssize_t)coeff[1];
 
             PointInfo
               du,dv; /* the du,dv vectors from unit dx,dy -- derivatives */
@@ -2258,7 +2258,7 @@
               This is more of a 'displacement' function rather than an
               absolute distortion function.
             */
-            unsigned long
+            size_t
               i;
             double
               denominator;
@@ -2371,7 +2371,7 @@
 %  The format of the SparseColorImage() method is:
 %
 %      Image *SparseColorImage(const Image *image,const ChannelType channel,
-%        const SparseColorMethod method,const unsigned long number_arguments,
+%        const SparseColorMethod method,const size_t number_arguments,
 %        const double *arguments,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -2398,7 +2398,7 @@
 */
 MagickExport Image *SparseColorImage(const Image *image,
   const ChannelType channel,const SparseColorMethod method,
-  const unsigned long number_arguments,const double *arguments,
+  const size_t number_arguments,const double *arguments,
   ExceptionInfo *exception)
 {
 #define SparseColorTag  "Distort/SparseColor"
@@ -2415,7 +2415,7 @@
   MagickPixelPacket
     zero;
 
-  unsigned long
+  size_t
     number_colors;
 
   assert(image != (Image *) NULL);
@@ -2449,7 +2449,7 @@
     switch (method) {
       case BarycentricColorInterpolate:
       {
-        register long x=0;
+        register ssize_t x=0;
         fprintf(stderr, "Barycentric Sparse Color:\n");
         if ( channel & RedChannel )
           fprintf(stderr, "  -channel R -fx '%+lf*i %+lf*j %+lf' \\\n",
@@ -2470,7 +2470,7 @@
       }
       case BilinearColorInterpolate:
       {
-        register long x=0;
+        register ssize_t x=0;
         fprintf(stderr, "Bilinear Sparse Color\n");
         if ( channel & RedChannel )
           fprintf(stderr, "   -channel R -fx '%+lf*i %+lf*j %+lf*i*j %+lf;\n",
@@ -2517,7 +2517,7 @@
       return((Image *) NULL);
     }
   { /* ----- MAIN CODE ----- */
-    long
+    ssize_t
       j,
       progress;
 
@@ -2534,7 +2534,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-    for (j=0; j < (long) sparse_image->rows; j++)
+    for (j=0; j < (ssize_t) sparse_image->rows; j++)
     {
       MagickBooleanType
         sync;
@@ -2545,7 +2545,7 @@
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         i;
 
       register PixelPacket
@@ -2561,13 +2561,13 @@
 /* FUTURE: get pixel from source image - so channel can replace parts */
       indexes=GetCacheViewAuthenticIndexQueue(sparse_view);
       pixel=zero;
-      for (i=0; i < (long) sparse_image->columns; i++)
+      for (i=0; i < (ssize_t) sparse_image->columns; i++)
       {
         switch (method)
         {
           case BarycentricColorInterpolate:
           {
-            register long x=0;
+            register ssize_t x=0;
             if ( channel & RedChannel )
               pixel.red     = coeff[x]*i +coeff[x+1]*j
                               +coeff[x+2], x+=3;
@@ -2587,7 +2587,7 @@
           }
           case BilinearColorInterpolate:
           {
-            register long x=0;
+            register ssize_t x=0;
             if ( channel & RedChannel )
               pixel.red     = coeff[x]*i     + coeff[x+1]*j +
                               coeff[x+2]*i*j + coeff[x+3], x+=4;
@@ -2608,7 +2608,7 @@
           case ShepardsColorInterpolate:
           { /* Shepards Method,uses its own input arguments as coefficients.
             */
-            unsigned long
+            size_t
               k;
             double
               denominator;
@@ -2620,7 +2620,7 @@
             if ( channel & OpacityChannel ) pixel.opacity = 0.0;
             denominator = 0.0;
             for(k=0; k<number_arguments; k+=2+number_colors) {
-              register long x=(long) k+2;
+              register ssize_t x=(ssize_t) k+2;
               double weight =
                   ((double)i-arguments[ k ])*((double)i-arguments[ k ])
                 + ((double)j-arguments[k+1])*((double)j-arguments[k+1]);
@@ -2650,7 +2650,7 @@
           case VoronoiColorInterpolate:
           default:
           { /* Just use the closest control point you can find! */
-            unsigned long
+            size_t
               k;
             double
               minimum = MagickHuge;
@@ -2660,7 +2660,7 @@
                   ((double)i-arguments[ k ])*((double)i-arguments[ k ])
                 + ((double)j-arguments[k+1])*((double)j-arguments[k+1]);
               if ( distance < minimum ) {
-                register long x=(long) k+2;
+                register ssize_t x=(ssize_t) k+2;
                 if ( channel & RedChannel     ) pixel.red     = arguments[x++];
                 if ( channel & GreenChannel   ) pixel.green   = arguments[x++];
                 if ( channel & BlueChannel    ) pixel.blue    = arguments[x++];
diff --git a/magick/distort.h b/magick/distort.h
index b94927c..29fdd4a 100644
--- a/magick/distort.h
+++ b/magick/distort.h
@@ -66,10 +66,10 @@
 } SparseColorMethod;
 
 extern MagickExport Image
-  *DistortImage(const Image *,const DistortImageMethod,const unsigned long,
+  *DistortImage(const Image *,const DistortImageMethod,const size_t,
     const double *,MagickBooleanType,ExceptionInfo *exception),
   *SparseColorImage(const Image *,const ChannelType,const SparseColorMethod,
-    const unsigned long,const double *,ExceptionInfo *);
+    const size_t,const double *,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
diff --git a/magick/draw-private.h b/magick/draw-private.h
index 13e518a..0a78452 100644
--- a/magick/draw-private.h
+++ b/magick/draw-private.h
@@ -27,7 +27,7 @@
 #include "magick/memory_.h"
 
 static inline MagickBooleanType GetFillColor(const DrawInfo *draw_info,
-  const long x,const long y,PixelPacket *pixel)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel)
 {
   Image
     *pattern;
@@ -53,7 +53,7 @@
 }
 
 static inline MagickBooleanType GetStrokeColor(const DrawInfo *draw_info,
-  const long x,const long y,PixelPacket *pixel)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel)
 {
   Image
     *pattern;
diff --git a/magick/draw.c b/magick/draw.c
index f8adfd2..af63295 100644
--- a/magick/draw.c
+++ b/magick/draw.c
@@ -99,16 +99,16 @@
   PointInfo
     *points;
 
-  unsigned long
+  size_t
     number_points;
 
-  long
+  ssize_t
     direction;
 
   MagickBooleanType
     ghostline;
 
-  unsigned long
+  size_t
     highwater;
 } EdgeInfo;
 
@@ -127,7 +127,7 @@
   EdgeInfo
     *edges;
 
-  unsigned long
+  size_t
     number_edges;
 } PolygonInfo;
 
@@ -158,21 +158,21 @@
 static PrimitiveInfo
   *TraceStrokePolygon(const DrawInfo *,const PrimitiveInfo *);
 
-static unsigned long
+static size_t
   TracePath(PrimitiveInfo *,const char *);
 
 static void
   TraceArc(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
   TraceArcPath(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo,
     const MagickRealType,const MagickBooleanType,const MagickBooleanType),
-  TraceBezier(PrimitiveInfo *,const unsigned long),
+  TraceBezier(PrimitiveInfo *,const size_t),
   TraceCircle(PrimitiveInfo *,const PointInfo,const PointInfo),
   TraceEllipse(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
   TraceLine(PrimitiveInfo *,const PointInfo,const PointInfo),
   TraceRectangle(PrimitiveInfo *,const PointInfo,const PointInfo),
   TraceRoundRectangle(PrimitiveInfo *,const PointInfo,const PointInfo,
     PointInfo),
-  TraceSquareLinecap(PrimitiveInfo *,const unsigned long,const MagickRealType);
+  TraceSquareLinecap(PrimitiveInfo *,const size_t,const MagickRealType);
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -300,7 +300,7 @@
     (void) CloneString(&clone_info->server_name,draw_info->server_name);
   if (draw_info->dash_pattern != (double *) NULL)
     {
-      register long
+      register ssize_t
         x;
 
       for (x=0; draw_info->dash_pattern[x] != 0.0; x++) ;
@@ -315,7 +315,7 @@
   clone_info->gradient=draw_info->gradient;
   if (draw_info->gradient.stops != (StopInfo *) NULL)
     {
-      unsigned long
+      size_t
         number_stops;
 
       number_stops=clone_info->gradient.number_stops;
@@ -408,13 +408,13 @@
   register EdgeInfo
     *p;
 
-  register long
+  register ssize_t
     i,
     j;
 
   (void) LogMagickEvent(DrawEvent,GetMagickModule(),"    begin active-edge");
   p=polygon_info->edges;
-  for (i=0; i < (long) polygon_info->number_edges; i++)
+  for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
   {
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"      edge %lu:",i);
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"      direction: %s",
@@ -424,7 +424,7 @@
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),
       "      bounds: %g,%g - %g,%g",p->bounds.x1,p->bounds.y1,
       p->bounds.x2,p->bounds.y2);
-    for (j=0; j < (long) p->number_points; j++)
+    for (j=0; j < (ssize_t) p->number_points; j++)
       (void) LogMagickEvent(DrawEvent,GetMagickModule(),"        %g,%g",
         p->points[j].x,p->points[j].y);
     p++;
@@ -432,15 +432,15 @@
   (void) LogMagickEvent(DrawEvent,GetMagickModule(),"    end active-edge");
 }
 
-static void ReversePoints(PointInfo *points,const unsigned long number_points)
+static void ReversePoints(PointInfo *points,const size_t number_points)
 {
   PointInfo
     point;
 
-  register long
+  register ssize_t
     i;
 
-  for (i=0; i < (long) (number_points >> 1); i++)
+  for (i=0; i < (ssize_t) (number_points >> 1); i++)
   {
     point=points[i];
     points[i]=points[number_points-(i+1)];
@@ -451,7 +451,7 @@
 static PolygonInfo *ConvertPathToPolygon(
   const DrawInfo *magick_unused(draw_info),const PathInfo *path_info)
 {
-  long
+  ssize_t
     direction,
     next_direction;
 
@@ -465,14 +465,14 @@
   SegmentInfo
     bounds;
 
-  register long
+  register ssize_t
     i,
     n;
 
   MagickBooleanType
     ghostline;
 
-  unsigned long
+  size_t
     edge,
     number_edges,
     number_points;
@@ -515,13 +515,13 @@
                 if (polygon_info->edges == (EdgeInfo *) NULL)
                   return((PolygonInfo *) NULL);
               }
-            polygon_info->edges[edge].number_points=(unsigned long) n;
+            polygon_info->edges[edge].number_points=(size_t) n;
             polygon_info->edges[edge].scanline=(-1.0);
             polygon_info->edges[edge].highwater=0;
             polygon_info->edges[edge].ghostline=ghostline;
-            polygon_info->edges[edge].direction=(long) (direction > 0);
+            polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
             if (direction < 0)
-              ReversePoints(points,(unsigned long) n);
+              ReversePoints(points,(size_t) n);
             polygon_info->edges[edge].points=points;
             polygon_info->edges[edge].bounds=bounds;
             polygon_info->edges[edge].bounds.y1=points[0].y;
@@ -568,13 +568,13 @@
             if (polygon_info->edges == (EdgeInfo *) NULL)
               return((PolygonInfo *) NULL);
           }
-        polygon_info->edges[edge].number_points=(unsigned long) n;
+        polygon_info->edges[edge].number_points=(size_t) n;
         polygon_info->edges[edge].scanline=(-1.0);
         polygon_info->edges[edge].highwater=0;
         polygon_info->edges[edge].ghostline=ghostline;
-        polygon_info->edges[edge].direction=(long) (direction > 0);
+        polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
         if (direction < 0)
-          ReversePoints(points,(unsigned long) n);
+          ReversePoints(points,(size_t) n);
         polygon_info->edges[edge].points=points;
         polygon_info->edges[edge].bounds=bounds;
         polygon_info->edges[edge].bounds.y1=points[0].y;
@@ -594,7 +594,7 @@
     direction=next_direction;
     if (points == (PointInfo *) NULL)
       continue;
-    if (n == (long) number_points)
+    if (n == (ssize_t) number_points)
       {
         number_points<<=1;
         points=(PointInfo *) ResizeQuantumMemory(points,(size_t) number_points,
@@ -625,13 +625,13 @@
               if (polygon_info->edges == (EdgeInfo *) NULL)
                 return((PolygonInfo *) NULL);
             }
-          polygon_info->edges[edge].number_points=(unsigned long) n;
+          polygon_info->edges[edge].number_points=(size_t) n;
           polygon_info->edges[edge].scanline=(-1.0);
           polygon_info->edges[edge].highwater=0;
           polygon_info->edges[edge].ghostline=ghostline;
-          polygon_info->edges[edge].direction=(long) (direction > 0);
+          polygon_info->edges[edge].direction=(ssize_t) (direction > 0);
           if (direction < 0)
-            ReversePoints(points,(unsigned long) n);
+            ReversePoints(points,(size_t) n);
           polygon_info->edges[edge].points=points;
           polygon_info->edges[edge].bounds=bounds;
           polygon_info->edges[edge].bounds.y1=points[0].y;
@@ -697,7 +697,7 @@
 static PathInfo *ConvertPrimitiveToPath(
   const DrawInfo *magick_unused(draw_info),const PrimitiveInfo *primitive_info)
 {
-  long
+  ssize_t
     coordinates,
     start;
 
@@ -711,7 +711,7 @@
     p,
     q;
 
-  register long
+  register ssize_t
     i,
     n;
 
@@ -746,7 +746,7 @@
     code=LineToCode;
     if (coordinates <= 0)
       {
-        coordinates=(long) primitive_info[i].coordinates;
+        coordinates=(ssize_t) primitive_info[i].coordinates;
         p=primitive_info[i].point;
         start=n;
         code=MoveToCode;
@@ -869,7 +869,7 @@
 %
 %  The format of the DestroyEdge method is:
 %
-%      long DestroyEdge(PolygonInfo *polygon_info,const int edge)
+%      ssize_t DestroyEdge(PolygonInfo *polygon_info,const int edge)
 %
 %  A description of each parameter follows:
 %
@@ -878,8 +878,8 @@
 %    o edge: the polygon edge number to destroy.
 %
 */
-static unsigned long DestroyEdge(PolygonInfo *polygon_info,
-  const unsigned long edge)
+static size_t DestroyEdge(PolygonInfo *polygon_info,
+  const size_t edge)
 {
   assert(edge < polygon_info->number_edges);
   polygon_info->edges[edge].points=(PointInfo *) RelinquishMagickMemory(
@@ -915,10 +915,10 @@
 */
 static PolygonInfo *DestroyPolygonInfo(PolygonInfo *polygon_info)
 {
-  register long
+  register ssize_t
     i;
 
-  for (i=0; i < (long) polygon_info->number_edges; i++)
+  for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
     polygon_info->edges[i].points=(PointInfo *)
       RelinquishMagickMemory(polygon_info->edges[i].points);
   polygon_info->edges=(EdgeInfo *) RelinquishMagickMemory(polygon_info->edges);
@@ -998,7 +998,7 @@
           inverse_edge.x2=x;
       }
     else
-      if ((z < 0.0) || ((unsigned long) floor(z+0.5) >= image->columns))
+      if ((z < 0.0) || ((size_t) floor(z+0.5) >= image->columns))
         {
           inverse_edge.x2=edge->x1;
           return(inverse_edge);
@@ -1031,7 +1031,7 @@
           inverse_edge.x2=x;
       }
     else
-      if ((z < 0.0) || ((unsigned long) floor(z+0.5) >= image->rows))
+      if ((z < 0.0) || ((size_t) floor(z+0.5) >= image->rows))
         {
           inverse_edge.x2=edge->x2;
           return(inverse_edge);
@@ -1059,7 +1059,7 @@
   return(inverse_affine);
 }
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -1093,7 +1093,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1108,7 +1108,7 @@
     max,
     point;
 
-  register long
+  register ssize_t
     i;
 
   ResampleFilter
@@ -1174,9 +1174,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=(long) ceil(edge.y1-0.5); y <= (long) floor(edge.y2+0.5); y++)
+  for (y=(ssize_t) ceil(edge.y1-0.5); y <= (ssize_t) floor(edge.y2+0.5); y++)
   {
-    long
+    ssize_t
       x_offset;
 
     MagickPixelPacket
@@ -1189,7 +1189,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -1202,8 +1202,8 @@
     inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
     if (inverse_edge.x2 < inverse_edge.x1)
       continue;
-    q=GetCacheViewAuthenticPixels(image_view,(long) ceil(inverse_edge.x1-0.5),y,
-      (unsigned long) ((long) floor(inverse_edge.x2+0.5)-(long) floor(
+    q=GetCacheViewAuthenticPixels(image_view,(ssize_t) ceil(inverse_edge.x1-0.5),y,
+      (size_t) ((ssize_t) floor(inverse_edge.x2+0.5)-(ssize_t) floor(
       inverse_edge.x1+0.5)+1),1,exception);
     if (q == (PixelPacket *) NULL)
       continue;
@@ -1212,7 +1212,7 @@
     pixel=zero;
     composite=zero;
     x_offset=0;
-    for (x=(long) ceil(inverse_edge.x1-0.5); x <= (long) floor(inverse_edge.x2+0.5); x++)
+    for (x=(ssize_t) ceil(inverse_edge.x1-0.5); x <= (ssize_t) floor(inverse_edge.x2+0.5); x++)
     {
       point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
         inverse_affine.tx;
@@ -1269,7 +1269,7 @@
   DrawInfo
     *clone_info;
 
-  long
+  ssize_t
     coordinates;
 
   MagickRealType
@@ -1283,7 +1283,7 @@
   PrimitiveInfo
     primitive_info[6];
 
-  register long
+  register ssize_t
     i;
 
   SegmentInfo
@@ -1316,7 +1316,7 @@
   if (polygon_info != (PolygonInfo *) NULL)
     {
       bounds=polygon_info->edges[0].bounds;
-      for (i=1; i < (long) polygon_info->number_edges; i++)
+      for (i=1; i < (ssize_t) polygon_info->number_edges; i++)
       {
         if (polygon_info->edges[i].bounds.x1 < (double) bounds.x1)
           bounds.x1=polygon_info->edges[i].bounds.x1;
@@ -1339,7 +1339,7 @@
       bounds.y2+=mid;
       bounds.y2=bounds.y2 < 0.0 ? 0.0 : bounds.y2 >= (double)
         image->rows ? (double) image->rows-1 : bounds.y2;
-      for (i=0; i < (long) polygon_info->number_edges; i++)
+      for (i=0; i < (ssize_t) polygon_info->number_edges; i++)
       {
         if (polygon_info->edges[i].direction != 0)
           (void) QueryColorDatabase("red",&clone_info->stroke,
@@ -1354,7 +1354,7 @@
         primitive_info[0].primitive=RectanglePrimitive;
         TraceRectangle(primitive_info,start,end);
         primitive_info[0].method=ReplaceMethod;
-        coordinates=(long) primitive_info[0].coordinates;
+        coordinates=(ssize_t) primitive_info[0].coordinates;
         primitive_info[coordinates].primitive=UndefinedPrimitive;
         (void) DrawPrimitive(image,clone_info,primitive_info);
       }
@@ -1367,7 +1367,7 @@
   primitive_info[0].primitive=RectanglePrimitive;
   TraceRectangle(primitive_info,start,end);
   primitive_info[0].method=ReplaceMethod;
-  coordinates=(long) primitive_info[0].coordinates;
+  coordinates=(ssize_t) primitive_info[0].coordinates;
   primitive_info[coordinates].primitive=UndefinedPrimitive;
   (void) DrawPrimitive(image,clone_info,primitive_info);
   clone_info=DestroyDrawInfo(clone_info);
@@ -1490,7 +1490,7 @@
   DrawInfo
     *clone_info;
 
-  long
+  ssize_t
     j,
     n;
 
@@ -1507,14 +1507,14 @@
   PrimitiveInfo
     *dash_polygon;
 
-  register long
+  register ssize_t
     i;
 
   register MagickRealType
     dx,
     dy;
 
-  unsigned long
+  size_t
     number_vertices;
 
   assert(draw_info != (const DrawInfo *) NULL);
@@ -1523,7 +1523,7 @@
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
   clone_info->miterlimit=0;
   for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++) ;
-  number_vertices=(unsigned long) i;
+  number_vertices=(size_t) i;
   dash_polygon=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
     (2UL*number_vertices+1UL),sizeof(*dash_polygon));
   if (dash_polygon == (PrimitiveInfo *) NULL)
@@ -1557,7 +1557,7 @@
   status=MagickTrue;
   maximum_length=0.0;
   total_length=0.0;
-  for (i=1; i < (long) number_vertices; i++)
+  for (i=1; i < (ssize_t) number_vertices; i++)
   {
     dx=primitive_info[i].point.x-primitive_info[i-1].point.x;
     dy=primitive_info[i].point.y-primitive_info[i-1].point.y;
@@ -1583,7 +1583,7 @@
         }
       else
         {
-          if ((j+1) > (long) (2*number_vertices))
+          if ((j+1) > (ssize_t) (2*number_vertices))
             break;
           dash_polygon[j]=primitive_info[i-1];
           dash_polygon[j].point.x=(double) (primitive_info[i-1].point.x+dx*
@@ -1592,7 +1592,7 @@
             total_length/maximum_length);
           dash_polygon[j].coordinates=1;
           j++;
-          dash_polygon[0].coordinates=(unsigned long) j;
+          dash_polygon[0].coordinates=(size_t) j;
           dash_polygon[j].primitive=UndefinedPrimitive;
           status|=DrawStrokePolygon(image,clone_info,dash_polygon);
         }
@@ -1615,7 +1615,7 @@
       dash_polygon[j].point.y+=MagickEpsilon;
       dash_polygon[j].coordinates=1;
       j++;
-      dash_polygon[0].coordinates=(unsigned long) j;
+      dash_polygon[0].coordinates=(size_t) j;
       dash_polygon[j].primitive=UndefinedPrimitive;
       status|=DrawStrokePolygon(image,clone_info,dash_polygon);
     }
@@ -1697,7 +1697,7 @@
   DrawInfo
     **graphic_context;
 
-  long
+  ssize_t
     j,
     k,
     n;
@@ -1726,7 +1726,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1736,7 +1736,7 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     number_points;
 
   /*
@@ -1895,7 +1895,7 @@
           }
         if (LocaleCompare("clip-rule",keyword) == 0)
           {
-            long
+            ssize_t
               fill_rule;
 
             GetMagickToken(q,&q,token);
@@ -1911,7 +1911,7 @@
           }
         if (LocaleCompare("clip-units",keyword) == 0)
           {
-            long
+            ssize_t
               clip_units;
 
             GetMagickToken(q,&q,token);
@@ -1952,7 +1952,7 @@
       {
         if (LocaleCompare("decorate",keyword) == 0)
           {
-            long
+            ssize_t
               decorate;
 
             GetMagickToken(q,&q,token);
@@ -2026,7 +2026,7 @@
           }
         if (LocaleCompare("fill-rule",keyword) == 0)
           {
-            long
+            ssize_t
               fill_rule;
 
             GetMagickToken(q,&q,token);
@@ -2063,7 +2063,7 @@
           }
         if (LocaleCompare("font-stretch",keyword) == 0)
           {
-            long
+            ssize_t
               stretch;
 
             GetMagickToken(q,&q,token);
@@ -2078,7 +2078,7 @@
           }
         if (LocaleCompare("font-style",keyword) == 0)
           {
-            long
+            ssize_t
               style;
 
             GetMagickToken(q,&q,token);
@@ -2122,7 +2122,7 @@
           }
         if (LocaleCompare("gravity",keyword) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             GetMagickToken(q,&q,token);
@@ -2143,7 +2143,7 @@
       {
         if (LocaleCompare("image",keyword) == 0)
           {
-            long
+            ssize_t
               compose;
 
             primitive_type=ImagePrimitive;
@@ -2393,19 +2393,19 @@
                 GetMagickToken(q,&q,token);
                 (void) CopyMagickString(name,token,MaxTextExtent);
                 GetMagickToken(q,&q,token);
-                bounds.x=(long) ceil(StringToDouble(token)-0.5);
+                bounds.x=(ssize_t) ceil(StringToDouble(token)-0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.y=(long) ceil(StringToDouble(token)-0.5);
+                bounds.y=(ssize_t) ceil(StringToDouble(token)-0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.width=(unsigned long) floor(StringToDouble(token)+0.5);
+                bounds.width=(size_t) floor(StringToDouble(token)+0.5);
                 GetMagickToken(q,&q,token);
                 if (*token == ',')
                   GetMagickToken(q,&q,token);
-                bounds.height=(unsigned long) floor(StringToDouble(token)+0.5);
+                bounds.height=(size_t) floor(StringToDouble(token)+0.5);
                 for (p=q; *q != '\0'; )
                 {
                   GetMagickToken(q,&q,token);
@@ -2606,7 +2606,7 @@
           }
         if (LocaleCompare("stroke-linecap",keyword) == 0)
           {
-            long
+            ssize_t
               linecap;
 
             GetMagickToken(q,&q,token);
@@ -2621,7 +2621,7 @@
           }
         if (LocaleCompare("stroke-linejoin",keyword) == 0)
           {
-            long
+            ssize_t
               linejoin;
 
             GetMagickToken(q,&q,token);
@@ -2667,7 +2667,7 @@
           }
         if (LocaleCompare("text-align",keyword) == 0)
           {
-            long
+            ssize_t
               align;
 
             GetMagickToken(q,&q,token);
@@ -2682,7 +2682,7 @@
           }
         if (LocaleCompare("text-anchor",keyword) == 0)
           {
-            long
+            ssize_t
               align;
 
             GetMagickToken(q,&q,token);
@@ -2728,22 +2728,22 @@
         if (LocaleCompare("viewbox",keyword) == 0)
           {
             GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.x=(long) ceil(StringToDouble(token)-
+            graphic_context[n]->viewbox.x=(ssize_t) ceil(StringToDouble(token)-
               0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.y=(long) ceil(StringToDouble(token)-
+            graphic_context[n]->viewbox.y=(ssize_t) ceil(StringToDouble(token)-
               0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.width=(unsigned long) floor(
+            graphic_context[n]->viewbox.width=(size_t) floor(
               StringToDouble(token)+0.5);
             GetMagickToken(q,&q,token);
             if (*token == ',')
               GetMagickToken(q,&q,token);
-            graphic_context[n]->viewbox.height=(unsigned long) floor(
+            graphic_context[n]->viewbox.height=(size_t) floor(
               StringToDouble(token)+0.5);
             break;
           }
@@ -2805,7 +2805,7 @@
       primitive_info[i].coordinates=0;
       primitive_info[i].method=FloodfillMethod;
       i++;
-      if (i < (long) number_points)
+      if (i < (ssize_t) number_points)
         continue;
       number_points<<=1;
       primitive_info=(PrimitiveInfo *) ResizeQuantumMemory(primitive_info,
@@ -2818,7 +2818,7 @@
         }
     }
     primitive_info[j].primitive=primitive_type;
-    primitive_info[j].coordinates=(unsigned long) x;
+    primitive_info[j].coordinates=(size_t) x;
     primitive_info[j].method=FloodfillMethod;
     primitive_info[j].text=(char *) NULL;
     /*
@@ -2828,7 +2828,7 @@
     bounds.y1=primitive_info[j].point.y;
     bounds.x2=primitive_info[j].point.x;
     bounds.y2=primitive_info[j].point.y;
-    for (k=1; k < (long) primitive_info[j].coordinates; k++)
+    for (k=1; k < (ssize_t) primitive_info[j].coordinates; k++)
     {
       point=primitive_info[j+k].point;
       if (point.x < bounds.x1)
@@ -2906,7 +2906,7 @@
       default:
         break;
     }
-    if ((unsigned long) (i+length) >= number_points)
+    if ((size_t) (i+length) >= number_points)
       {
         /*
           Resize based on speculative points required by primitive.
@@ -2933,7 +2933,7 @@
             break;
           }
         TracePoint(primitive_info+j,primitive_info[j].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case LinePrimitive:
@@ -2945,7 +2945,7 @@
           }
         TraceLine(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case RectanglePrimitive:
@@ -2957,7 +2957,7 @@
           }
         TraceRectangle(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case RoundRectanglePrimitive:
@@ -2969,7 +2969,7 @@
           }
         TraceRoundRectangle(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point,primitive_info[j+2].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case ArcPrimitive:
@@ -2981,7 +2981,7 @@
           }
         TraceArc(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point,primitive_info[j+2].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case EllipsePrimitive:
@@ -2993,7 +2993,7 @@
           }
         TraceEllipse(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point,primitive_info[j+2].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case CirclePrimitive:
@@ -3005,7 +3005,7 @@
           }
         TraceCircle(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case PolylinePrimitive:
@@ -3026,18 +3026,18 @@
             break;
           }
         TraceBezier(primitive_info+j,primitive_info[j].coordinates);
-        i=(long) (j+primitive_info[j].coordinates);
+        i=(ssize_t) (j+primitive_info[j].coordinates);
         break;
       }
       case PathPrimitive:
       {
-        i=(long) (j+TracePath(primitive_info+j,token));
+        i=(ssize_t) (j+TracePath(primitive_info+j,token));
         break;
       }
       case ColorPrimitive:
       case MattePrimitive:
       {
-        long
+        ssize_t
           method;
 
         if (primitive_info[j].coordinates != 1)
@@ -3109,7 +3109,7 @@
         graphic_context[n]->bounds.y2=point.y;
       if (primitive_info[i].primitive == ImagePrimitive)
         break;
-      if (i >= (long) number_points)
+      if (i >= (ssize_t) number_points)
         ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
     }
     if (graphic_context[n]->render != MagickFalse)
@@ -3174,7 +3174,7 @@
 */
 
 static inline MagickRealType GetStopColorOffset(const GradientInfo *gradient,
-  const long x,const long y)
+  const ssize_t x,const ssize_t y)
 {
   switch (gradient->type)
   {
@@ -3242,7 +3242,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -3281,9 +3281,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=bounding_box.y; y < (long) bounding_box.height; y++)
+  for (y=bounding_box.y; y < (ssize_t) bounding_box.height; y++)
   {
-    long
+    ssize_t
       j;
 
     MagickPixelPacket
@@ -3297,7 +3297,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -3318,7 +3318,7 @@
     offset=GetStopColorOffset(gradient,0,y);
     if (gradient->type != RadialGradient)
       offset/=length;
-    for (x=bounding_box.x; x < (long) bounding_box.width; x++)
+    for (x=bounding_box.x; x < (ssize_t) bounding_box.width; x++)
     {
       SetMagickPixelPacket(image,q,indexes+x,&pixel);
       switch (gradient->spread)
@@ -3326,20 +3326,20 @@
         case UndefinedSpread:
         case PadSpread:
         {
-          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
-              (y != (long) ceil(gradient_vector->y1-0.5)))
+          if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+              (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
                 offset/=length;
             }
-          for (i=0; i < (long) gradient->number_stops; i++)
+          for (i=0; i < (ssize_t) gradient->number_stops; i++)
             if (offset < gradient->stops[i].offset)
               break;
           if ((offset < 0.0) || (i == 0))
             composite=gradient->stops[0].color;
           else
-            if ((offset > 1.0) || (i == (long) gradient->number_stops))
+            if ((offset > 1.0) || (i == (ssize_t) gradient->number_stops))
               composite=gradient->stops[gradient->number_stops-1].color;
             else
               {
@@ -3354,8 +3354,8 @@
         }
         case ReflectSpread:
         {
-          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
-              (y != (long) ceil(gradient_vector->y1-0.5)))
+          if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+              (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type != RadialGradient)
@@ -3363,17 +3363,17 @@
             }
           if (offset < 0.0)
             offset=(-offset);
-          if ((long) fmod(offset,2.0) == 0)
+          if ((ssize_t) fmod(offset,2.0) == 0)
             offset=fmod(offset,1.0);
           else
             offset=1.0-fmod(offset,1.0);
-          for (i=0; i < (long) gradient->number_stops; i++)
+          for (i=0; i < (ssize_t) gradient->number_stops; i++)
             if (offset < gradient->stops[i].offset)
               break;
           if (i == 0)
             composite=gradient->stops[0].color;
           else
-            if (i == (long) gradient->number_stops)
+            if (i == (ssize_t) gradient->number_stops)
               composite=gradient->stops[gradient->number_stops-1].color;
             else
               {
@@ -3396,8 +3396,8 @@
 
           antialias=MagickFalse;
           repeat=0.0;
-          if ((x != (long) ceil(gradient_vector->x1-0.5)) ||
-              (y != (long) ceil(gradient_vector->y1-0.5)))
+          if ((x != (ssize_t) ceil(gradient_vector->x1-0.5)) ||
+              (y != (ssize_t) ceil(gradient_vector->y1-0.5)))
             {
               offset=GetStopColorOffset(gradient,x,y);
               if (gradient->type == LinearGradient)
@@ -3423,13 +3423,13 @@
                   offset=repeat/gradient->radius;
                 }
             }
-          for (i=0; i < (long) gradient->number_stops; i++)
+          for (i=0; i < (ssize_t) gradient->number_stops; i++)
             if (offset < gradient->stops[i].offset)
               break;
           if (i == 0)
             composite=gradient->stops[0].color;
           else
-            if (i == (long) gradient->number_stops)
+            if (i == (ssize_t) gradient->number_stops)
               composite=gradient->stops[gradient->number_stops-1].color;
             else
               {
@@ -3444,7 +3444,7 @@
                     else
                       alpha=gradient->radius-repeat;
                     i=0;
-                    j=(long) gradient->number_stops-1L;
+                    j=(ssize_t) gradient->number_stops-1L;
                   }
                 MagickPixelCompositeBlend(&gradient->stops[i].color,1.0-alpha,
                   &gradient->stops[j].color,alpha,&composite);
@@ -3579,11 +3579,11 @@
 
 static PolygonInfo **DestroyPolygonThreadSet(PolygonInfo **polygon_info)
 {
-  register long
+  register ssize_t
     i;
 
   assert(polygon_info != (PolygonInfo **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (polygon_info[i] != (PolygonInfo *) NULL)
       polygon_info[i]=DestroyPolygonInfo(polygon_info[i]);
   polygon_info=(PolygonInfo **) RelinquishAlignedMemory(polygon_info);
@@ -3596,13 +3596,13 @@
   PathInfo
     *restrict path_info;
 
-  register long
+  register ssize_t
     i;
 
   PolygonInfo
     **polygon_info;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -3615,7 +3615,7 @@
   path_info=ConvertPrimitiveToPath(draw_info,primitive_info);
   if (path_info == (PathInfo *) NULL)
     return(DestroyPolygonThreadSet(polygon_info));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     polygon_info[i]=ConvertPathToPolygon(draw_info,path_info);
     if (polygon_info[i] == (PolygonInfo *) NULL)
@@ -3633,7 +3633,7 @@
   int
     winding_number;
 
-  long
+  ssize_t
     j;
 
   MagickRealType
@@ -3651,7 +3651,7 @@
   register const PointInfo
     *q;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -3660,19 +3660,19 @@
   *stroke_opacity=0.0;
   subpath_opacity=0.0;
   p=polygon_info->edges;
-  for (j=0; j < (long) polygon_info->number_edges; j++, p++)
+  for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
   {
     if (y <= (p->bounds.y1-mid-0.5))
       break;
     if (y > (p->bounds.y2+mid+0.5))
       {
-        (void) DestroyEdge(polygon_info,(unsigned long) j);
+        (void) DestroyEdge(polygon_info,(size_t) j);
         continue;
       }
     if ((x <= (p->bounds.x1-mid-0.5)) || (x > (p->bounds.x2+mid+0.5)))
       continue;
-    i=(long) MagickMax((double) p->highwater,1.0);
-    for ( ; i < (long) p->number_points; i++)
+    i=(ssize_t) MagickMax((double) p->highwater,1.0);
+    for ( ; i < (ssize_t) p->number_points; i++)
     {
       if (y <= (p->points[i-1].y-mid-0.5))
         break;
@@ -3681,7 +3681,7 @@
       if (p->scanline != y)
         {
           p->scanline=y;
-          p->highwater=(unsigned long) i;
+          p->highwater=(size_t) i;
         }
       /*
         Compute distance between a point and an edge.
@@ -3768,7 +3768,7 @@
   */
   winding_number=0;
   p=polygon_info->edges;
-  for (j=0; j < (long) polygon_info->number_edges; j++, p++)
+  for (j=0; j < (ssize_t) polygon_info->number_edges; j++, p++)
   {
     if (y <= p->bounds.y1)
       break;
@@ -3779,8 +3779,8 @@
         winding_number+=p->direction ? 1 : -1;
         continue;
       }
-    i=(long) MagickMax((double) p->highwater,1.0);
-    for ( ; i < (long) p->number_points; i++)
+    i=(ssize_t) MagickMax((double) p->highwater,1.0);
+    for ( ; i < (ssize_t) p->number_points; i++)
       if (y <= p->points[i].y)
         break;
     q=p->points+i-1;
@@ -3807,7 +3807,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     start,
     stop,
     y;
@@ -3825,7 +3825,7 @@
   register EdgeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   SegmentInfo
@@ -3854,7 +3854,7 @@
     (primitive_info->method == FloodfillMethod) ? MagickTrue : MagickFalse;
   mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
   bounds=polygon_info[0]->edges[0].bounds;
-  for (i=1; i < (long) polygon_info[0]->number_edges; i++)
+  for (i=1; i < (ssize_t) polygon_info[0]->number_edges; i++)
   {
     p=polygon_info[0]->edges+i;
     if (p->bounds.x1 < bounds.x1)
@@ -3867,21 +3867,21 @@
       bounds.y2=p->bounds.y2;
   }
   bounds.x1-=(mid+1.0);
-  bounds.x1=bounds.x1 < 0.0 ? 0.0 : (unsigned long) ceil(bounds.x1-0.5) >=
+  bounds.x1=bounds.x1 < 0.0 ? 0.0 : (size_t) ceil(bounds.x1-0.5) >=
     image->columns ? (double) image->columns-1.0 : bounds.x1;
   bounds.y1-=(mid+1.0);
-  bounds.y1=bounds.y1 < 0.0 ? 0.0 : (unsigned long) ceil(bounds.y1-0.5) >=
+  bounds.y1=bounds.y1 < 0.0 ? 0.0 : (size_t) ceil(bounds.y1-0.5) >=
     image->rows ? (double) image->rows-1.0 : bounds.y1;
   bounds.x2+=(mid+1.0);
-  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (unsigned long) floor(bounds.x2+0.5) >=
+  bounds.x2=bounds.x2 < 0.0 ? 0.0 : (size_t) floor(bounds.x2+0.5) >=
     image->columns ? (double) image->columns-1.0 : bounds.x2;
   bounds.y2+=(mid+1.0);
-  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (unsigned long) floor(bounds.y2+0.5) >=
+  bounds.y2=bounds.y2 < 0.0 ? 0.0 : (size_t) floor(bounds.y2+0.5) >=
     image->rows ? (double) image->rows-1.0 : bounds.y2;
   status=MagickTrue;
   exception=(&image->exception);
-  start=(long) ceil(bounds.x1-0.5);
-  stop=(long) floor(bounds.x2+0.5);
+  start=(ssize_t) ceil(bounds.x1-0.5);
+  stop=(ssize_t) floor(bounds.x2+0.5);
   image_view=AcquireCacheView(image);
   if (primitive_info->coordinates == 1)
     {
@@ -3891,12 +3891,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=(long) ceil(bounds.y1-0.5); y <= (long) floor(bounds.y2+0.5); y++)
+      for (y=(ssize_t) ceil(bounds.y1-0.5); y <= (ssize_t) floor(bounds.y2+0.5); y++)
       {
         MagickBooleanType
           sync;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -3905,7 +3905,7 @@
         if (status == MagickFalse)
           continue;
         x=start;
-        q=GetCacheViewAuthenticPixels(image_view,x,y,(unsigned long) (stop-x+1),
+        q=GetCacheViewAuthenticPixels(image_view,x,y,(size_t) (stop-x+1),
           1,exception);
         if (q == (PixelPacket *) NULL)
           {
@@ -3914,8 +3914,8 @@
           }
         for ( ; x <= stop; x++)
         {
-          if ((x == (long) ceil(primitive_info->point.x-0.5)) &&
-              (y == (long) ceil(primitive_info->point.y-0.5)))
+          if ((x == (ssize_t) ceil(primitive_info->point.x-0.5)) &&
+              (y == (ssize_t) ceil(primitive_info->point.y-0.5)))
             (void) GetStrokeColor(draw_info,x,y,q);
           q++;
         }
@@ -3938,7 +3938,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=(long) ceil(bounds.y1-0.5); y <= (long) floor(bounds.y2+0.5); y++)
+  for (y=(ssize_t) ceil(bounds.y1-0.5); y <= (ssize_t) floor(bounds.y2+0.5); y++)
   {
     MagickRealType
       fill_opacity,
@@ -3948,7 +3948,7 @@
       fill_color,
       stroke_color;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -3957,7 +3957,7 @@
 
     if (status == MagickFalse)
       continue;
-    q=GetCacheViewAuthenticPixels(image_view,start,y,(unsigned long) (stop-
+    q=GetCacheViewAuthenticPixels(image_view,start,y,(size_t) (stop-
       start+1),1,exception);
     if (q == (PixelPacket *) NULL)
       {
@@ -4040,7 +4040,7 @@
       "?"
     };
 
-  long
+  ssize_t
     coordinates,
     y;
 
@@ -4049,12 +4049,12 @@
     q,
     point;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  x=(long) ceil(primitive_info->point.x-0.5);
-  y=(long) ceil(primitive_info->point.y-0.5);
+  x=(ssize_t) ceil(primitive_info->point.x-0.5);
+  y=(ssize_t) ceil(primitive_info->point.y-0.5);
   switch (primitive_info->primitive)
   {
     case PointPrimitive:
@@ -4099,7 +4099,7 @@
     point=primitive_info[i].point;
     if (coordinates <= 0)
       {
-        coordinates=(long) primitive_info[i].coordinates;
+        coordinates=(ssize_t) primitive_info[i].coordinates;
         (void) LogMagickEvent(DrawEvent,GetMagickModule(),
           "    begin open (%ld)",coordinates);
         p=point;
@@ -4135,13 +4135,13 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -4156,8 +4156,8 @@
     }
   status=MagickTrue;
   exception=(&image->exception);
-  x=(long) ceil(primitive_info->point.x-0.5);
-  y=(long) ceil(primitive_info->point.y-0.5);
+  x=(ssize_t) ceil(primitive_info->point.x-0.5);
+  y=(ssize_t) ceil(primitive_info->point.y-0.5);
   image_view=AcquireCacheView(image);
   switch (primitive_info->primitive)
   {
@@ -4169,9 +4169,9 @@
       PixelPacket
         *q;
 
-      if ((y < 0) || (y >= (long) image->rows))
+      if ((y < 0) || (y >= (ssize_t) image->rows))
         break;
-      if ((x < 0) || (x >= (long) image->columns))
+      if ((x < 0) || (x >= (ssize_t) image->columns))
         break;
       q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
       if (q == (PixelPacket *) NULL)
@@ -4208,7 +4208,7 @@
             target;
 
           (void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             register PixelPacket
               *restrict q;
@@ -4217,7 +4217,7 @@
               exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (IsColorSimilar(image,q,&target) == MagickFalse)
                 {
@@ -4256,9 +4256,9 @@
           MagickBooleanType
             sync;
 
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -4268,7 +4268,7 @@
               exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               (void) GetFillColor(draw_info,x,y,q);
               q++;
@@ -4315,9 +4315,9 @@
             target;
 
           (void) GetOneCacheViewVirtualPixel(image_view,x,y,&target,exception);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -4327,7 +4327,7 @@
               exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (IsColorSimilar(image,q,&target) == MagickFalse)
                 {
@@ -4370,9 +4370,9 @@
           PixelPacket
             pixel;
 
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -4382,7 +4382,7 @@
               exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               (void) GetFillColor(draw_info,x,y,&pixel);
               q->opacity=pixel.opacity;
@@ -4430,7 +4430,7 @@
       ImageInfo
         *clone_info;
 
-      long
+      ssize_t
         x1,
         y1;
 
@@ -4454,10 +4454,10 @@
         break;
       (void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
         NULL,(void *) NULL);
-      x1=(long) ceil(primitive_info[1].point.x-0.5);
-      y1=(long) ceil(primitive_info[1].point.y-0.5);
-      if (((x1 != 0L) && (x1 != (long) composite_image->columns)) ||
-          ((y1 != 0L) && (y1 != (long) composite_image->rows)))
+      x1=(ssize_t) ceil(primitive_info[1].point.x-0.5);
+      y1=(ssize_t) ceil(primitive_info[1].point.y-0.5);
+      if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
+          ((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
         {
           char
             geometry[MaxTextExtent];
@@ -4538,7 +4538,7 @@
             (primitive_info[i-1].point.x == primitive_info[0].point.x) &&
             (primitive_info[i-1].point.y == primitive_info[0].point.y) ?
             MagickTrue : MagickFalse;
-          i=(long) primitive_info[0].coordinates;
+          i=(ssize_t) primitive_info[0].coordinates;
           if ((((draw_info->linecap == RoundCap) ||
                 (closed_path != MagickFalse)) &&
                (draw_info->linejoin == RoundJoin)) ||
@@ -4601,7 +4601,7 @@
   PrimitiveInfo
     linecap[5];
 
-  register long
+  register ssize_t
     i;
 
   for (i=0; i < 4; i++)
@@ -4819,7 +4819,7 @@
 %
 %  The format of the Permutate method is:
 %
-%      void Permutate(long n,long k)
+%      void Permutate(ssize_t n,ssize_t k)
 %
 %  A description of each parameter follows:
 %
@@ -4829,12 +4829,12 @@
 %
 %
 */
-static inline MagickRealType Permutate(const long n,const long k)
+static inline MagickRealType Permutate(const ssize_t n,const ssize_t k)
 {
   MagickRealType
     r;
 
-  register long
+  register ssize_t
     i;
 
   r=1.0;
@@ -4899,10 +4899,10 @@
   register PrimitiveInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     arc_segments;
 
   if ((start.x == end.x) && (start.y == end.y))
@@ -4957,10 +4957,10 @@
   else
     if ((theta > 0.0) && (sweep == MagickFalse))
       theta-=(MagickRealType) (2.0*MagickPI);
-  arc_segments=(unsigned long) ceil(fabs((double) (theta/(0.5*MagickPI+
+  arc_segments=(size_t) ceil(fabs((double) (theta/(0.5*MagickPI+
     MagickEpsilon)))-0.5);
   p=primitive_info;
-  for (i=0; i < (long) arc_segments; i++)
+  for (i=0; i < (ssize_t) arc_segments; i++)
   {
     beta=0.5*((alpha+(i+1)*theta/arc_segments)-(alpha+i*theta/arc_segments));
     gamma=(8.0/3.0)*sin(fmod((double) (0.5*beta),DegreesToRadians(360.0)))*
@@ -4994,13 +4994,13 @@
       points[2].y);
     (p+3)->point.y=(double) (sine*radii.x*points[2].x+cosine*radii.y*
       points[2].y);
-    if (i == (long) (arc_segments-1))
+    if (i == (ssize_t) (arc_segments-1))
       (p+3)->point=end;
     TraceBezier(p,4);
     p+=p->coordinates;
   }
-  primitive_info->coordinates=(unsigned long) (p-primitive_info);
-  for (i=0; i < (long) primitive_info->coordinates; i++)
+  primitive_info->coordinates=(size_t) (p-primitive_info);
+  for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
@@ -5008,7 +5008,7 @@
 }
 
 static void TraceBezier(PrimitiveInfo *primitive_info,
-  const unsigned long number_coordinates)
+  const size_t number_coordinates)
 {
   MagickRealType
     alpha,
@@ -5020,14 +5020,14 @@
     point,
     *points;
 
-  register long
+  register ssize_t
     i,
     j;
 
   register PrimitiveInfo
     *p;
 
-  unsigned long
+  size_t
     control_points,
     quantum;
 
@@ -5035,19 +5035,19 @@
     Allocate coeficients.
   */
   quantum=number_coordinates;
-  for (i=0; i < (long) number_coordinates; i++)
+  for (i=0; i < (ssize_t) number_coordinates; i++)
   {
-    for (j=i+1; j < (long) number_coordinates; j++)
+    for (j=i+1; j < (ssize_t) number_coordinates; j++)
     {
       alpha=fabs(primitive_info[j].point.x-primitive_info[i].point.x);
       if (alpha > (MagickRealType) quantum)
-        quantum=(unsigned long) alpha;
+        quantum=(size_t) alpha;
       alpha=fabs(primitive_info[j].point.y-primitive_info[i].point.y);
       if (alpha > (MagickRealType) quantum)
-        quantum=(unsigned long) alpha;
+        quantum=(size_t) alpha;
     }
   }
-  quantum=(unsigned long) MagickMin((double) quantum/number_coordinates,
+  quantum=(size_t) MagickMin((double) quantum/number_coordinates,
     (double) BezierQuantum);
   control_points=quantum*number_coordinates;
   coefficients=(MagickRealType *) AcquireQuantumMemory((size_t)
@@ -5061,16 +5061,16 @@
     Compute bezier points.
   */
   end=primitive_info[number_coordinates-1].point;
-  for (i=0; i < (long) number_coordinates; i++)
-    coefficients[i]=Permutate((long) number_coordinates-1,i);
+  for (i=0; i < (ssize_t) number_coordinates; i++)
+    coefficients[i]=Permutate((ssize_t) number_coordinates-1,i);
   weight=0.0;
-  for (i=0; i < (long) control_points; i++)
+  for (i=0; i < (ssize_t) control_points; i++)
   {
     p=primitive_info;
     point.x=0.0;
     point.y=0.0;
     alpha=pow((double) (1.0-weight),(double) number_coordinates-1.0);
-    for (j=0; j < (long) number_coordinates; j++)
+    for (j=0; j < (ssize_t) number_coordinates; j++)
     {
       point.x+=alpha*coefficients[j]*p->point.x;
       point.y+=alpha*coefficients[j]*p->point.y;
@@ -5084,15 +5084,15 @@
     Bezier curves are just short segmented polys.
   */
   p=primitive_info;
-  for (i=0; i < (long) control_points; i++)
+  for (i=0; i < (ssize_t) control_points; i++)
   {
     TracePoint(p,points[i]);
     p+=p->coordinates;
   }
   TracePoint(p,end);
   p+=p->coordinates;
-  primitive_info->coordinates=(unsigned long) (p-primitive_info);
-  for (i=0; i < (long) primitive_info->coordinates; i++)
+  primitive_info->coordinates=(size_t) (p-primitive_info);
+  for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
@@ -5138,7 +5138,7 @@
   register PrimitiveInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -5169,8 +5169,8 @@
   point.y=sin(fmod(angle.y,DegreesToRadians(360.0)))*stop.y+start.y;
   TracePoint(p,point);
   p+=p->coordinates;
-  primitive_info->coordinates=(unsigned long) (p-primitive_info);
-  for (i=0; i < (long) primitive_info->coordinates; i++)
+  primitive_info->coordinates=(size_t) (p-primitive_info);
+  for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
@@ -5193,7 +5193,7 @@
   primitive_info->coordinates=2;
 }
 
-static unsigned long TracePath(PrimitiveInfo *primitive_info,const char *path)
+static size_t TracePath(PrimitiveInfo *primitive_info,const char *path)
 {
   char
     token[MaxTextExtent];
@@ -5221,10 +5221,10 @@
   register PrimitiveInfo
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_coordinates,
     z_count;
 
@@ -5372,7 +5372,7 @@
       {
         if (q != primitive_info)
           {
-            primitive_info->coordinates=(unsigned long) (q-primitive_info);
+            primitive_info->coordinates=(size_t) (q-primitive_info);
             number_coordinates+=primitive_info->coordinates;
             primitive_info=q;
           }
@@ -5534,7 +5534,7 @@
         point=start;
         TracePoint(q,point);
         q+=q->coordinates;
-        primitive_info->coordinates=(unsigned long) (q-primitive_info);
+        primitive_info->coordinates=(size_t) (q-primitive_info);
         number_coordinates+=primitive_info->coordinates;
         primitive_info=q;
         z_count++;
@@ -5548,9 +5548,9 @@
       }
     }
   }
-  primitive_info->coordinates=(unsigned long) (q-primitive_info);
+  primitive_info->coordinates=(size_t) (q-primitive_info);
   number_coordinates+=primitive_info->coordinates;
-  for (i=0; i < (long) number_coordinates; i++)
+  for (i=0; i < (ssize_t) number_coordinates; i++)
   {
     q--;
     q->primitive=primitive_type;
@@ -5570,7 +5570,7 @@
   register PrimitiveInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   p=primitive_info;
@@ -5588,8 +5588,8 @@
   p+=p->coordinates;
   TracePoint(p,start);
   p+=p->coordinates;
-  primitive_info->coordinates=(unsigned long) (p-primitive_info);
-  for (i=0; i < (long) primitive_info->coordinates; i++)
+  primitive_info->coordinates=(size_t) (p-primitive_info);
+  for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
@@ -5607,7 +5607,7 @@
   register PrimitiveInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   p=primitive_info;
@@ -5643,8 +5643,8 @@
   p+=p->coordinates;
   TracePoint(p,primitive_info->point);
   p+=p->coordinates;
-  primitive_info->coordinates=(unsigned long) (p-primitive_info);
-  for (i=0; i < (long) primitive_info->coordinates; i++)
+  primitive_info->coordinates=(size_t) (p-primitive_info);
+  for (i=0; i < (ssize_t) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
@@ -5652,24 +5652,24 @@
 }
 
 static void TraceSquareLinecap(PrimitiveInfo *primitive_info,
-  const unsigned long number_vertices,const MagickRealType offset)
+  const size_t number_vertices,const MagickRealType offset)
 {
   MagickRealType
     distance;
 
-  long
+  ssize_t
     j;
 
   register MagickRealType
     dx,
     dy;
 
-  register long
+  register ssize_t
     i;
 
   dx=0.0;
   dy=0.0;
-  for (i=1; i < (long) number_vertices; i++)
+  for (i=1; i < (ssize_t) number_vertices; i++)
   {
     dx=primitive_info[0].point.x-primitive_info[i].point.x;
     dy=primitive_info[0].point.y-primitive_info[i].point.y;
@@ -5677,14 +5677,14 @@
         (fabs((double) dy) >= MagickEpsilon))
       break;
   }
-  if (i == (long) number_vertices)
-    i=(long) number_vertices-1L;
+  if (i == (ssize_t) number_vertices)
+    i=(ssize_t) number_vertices-1L;
   distance=hypot((double) dx,(double) dy);
   primitive_info[0].point.x=(double) (primitive_info[i].point.x+
     dx*(distance+offset)/distance);
   primitive_info[0].point.y=(double) (primitive_info[i].point.y+
     dy*(distance+offset)/distance);
-  for (j=(long) number_vertices-2; j >= 0;  j--)
+  for (j=(ssize_t) number_vertices-2; j >= 0;  j--)
   {
     dx=primitive_info[number_vertices-1].point.x-primitive_info[j].point.x;
     dy=primitive_info[number_vertices-1].point.y-primitive_info[j].point.y;
@@ -5716,7 +5716,7 @@
     slope,
     theta;
 
-  long
+  ssize_t
     j,
     n,
     p,
@@ -5743,10 +5743,10 @@
     *polygon_primitive,
     *stroke_polygon;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     arc_segments,
     max_strokes,
     number_vertices;
@@ -5783,15 +5783,15 @@
   */
   dx.p=0.0;
   dy.p=0.0;
-  for (n=1; n < (long) number_vertices; n++)
+  for (n=1; n < (ssize_t) number_vertices; n++)
   {
     dx.p=polygon_primitive[n].point.x-polygon_primitive[0].point.x;
     dy.p=polygon_primitive[n].point.y-polygon_primitive[0].point.y;
     if ((fabs(dx.p) >= MagickEpsilon) || (fabs(dy.p) >= MagickEpsilon))
       break;
   }
-  if (n == (long) number_vertices)
-    n=(long) number_vertices-1L;
+  if (n == (ssize_t) number_vertices)
+    n=(ssize_t) number_vertices-1L;
   slope.p=0.0;
   inverse_slope.p=0.0;
   if (fabs(dx.p) <= MagickEpsilon)
@@ -5850,7 +5850,7 @@
   q=0;
   path_q[p++]=box_q[0];
   path_p[q++]=box_p[0];
-  for (i=(long) n+1; i < (long) number_vertices; i++)
+  for (i=(ssize_t) n+1; i < (ssize_t) number_vertices; i++)
   {
     /*
       Compute the slope for this line segment, q.
@@ -5921,7 +5921,7 @@
           box_q[3].y)/(slope.p-slope.q));
         box_q[4].y=(double) (slope.p*(box_q[4].x-box_q[0].x)+box_q[0].y);
       }
-    if (q >= (long) (max_strokes-6*BezierQuantum-360))
+    if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360))
       {
          max_strokes+=6*BezierQuantum+360;
          path_p=(PointInfo *) ResizeQuantumMemory(path_p,(size_t) max_strokes,
@@ -5988,12 +5988,12 @@
           theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
           if (theta.q < theta.p)
             theta.q+=(MagickRealType) (2.0*MagickPI);
-          arc_segments=(unsigned long) ceil((double) ((theta.q-theta.p)/
+          arc_segments=(size_t) ceil((double) ((theta.q-theta.p)/
             (2.0*sqrt((double) (1.0/mid)))));
           path_q[q].x=box_q[1].x;
           path_q[q].y=box_q[1].y;
           q++;
-          for (j=1; j < (long) arc_segments; j++)
+          for (j=1; j < (ssize_t) arc_segments; j++)
           {
             delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
             path_q[q].x=(double) (center.x+mid*cos(fmod((double)
@@ -6060,10 +6060,10 @@
           theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
           if (theta.p < theta.q)
             theta.p+=(MagickRealType) (2.0*MagickPI);
-          arc_segments=(unsigned long) ceil((double) ((theta.p-theta.q)/
+          arc_segments=(size_t) ceil((double) ((theta.p-theta.q)/
             (2.0*sqrt((double) (1.0/mid)))));
           path_p[p++]=box_p[1];
-          for (j=1; j < (long) arc_segments; j++)
+          for (j=1; j < (ssize_t) arc_segments; j++)
           {
             delta_theta=(MagickRealType) (j*(theta.q-theta.p)/arc_segments);
             path_p[p].x=(double) (center.x+mid*cos(fmod((double)
@@ -6097,7 +6097,7 @@
     (p+q+2UL*closed_path+2UL),sizeof(*stroke_polygon));
   if (stroke_polygon != (PrimitiveInfo *) NULL)
     {
-      for (i=0; i < (long) p; i++)
+      for (i=0; i < (ssize_t) p; i++)
       {
         stroke_polygon[i]=polygon_primitive[0];
         stroke_polygon[i].point=path_p[i];
@@ -6108,7 +6108,7 @@
           stroke_polygon[i].point=stroke_polygon[0].point;
           i++;
         }
-      for ( ; i < (long) (p+q+closed_path); i++)
+      for ( ; i < (ssize_t) (p+q+closed_path); i++)
       {
         stroke_polygon[i]=polygon_primitive[0];
         stroke_polygon[i].point=path_q[p+q+closed_path-(i+1)];
@@ -6123,7 +6123,7 @@
       stroke_polygon[i].point=stroke_polygon[0].point;
       i++;
       stroke_polygon[i].primitive=UndefinedPrimitive;
-      stroke_polygon[0].coordinates=(unsigned long) (p+q+2*closed_path+1);
+      stroke_polygon[0].coordinates=(size_t) (p+q+2*closed_path+1);
     }
   path_p=(PointInfo *) RelinquishMagickMemory(path_p);
   path_q=(PointInfo *) RelinquishMagickMemory(path_q);
diff --git a/magick/draw.h b/magick/draw.h
index 4ab22f1..550fbe2 100644
--- a/magick/draw.h
+++ b/magick/draw.h
@@ -164,7 +164,7 @@
   StopInfo
     *stops;
 
-  unsigned long
+  size_t
     number_stops;
 
   SpreadMethod
@@ -173,7 +173,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 
   PointInfo
@@ -194,7 +194,7 @@
   GradientInfo
     gradient;
 
-  unsigned long
+  size_t
     signature;
 
   struct _ElementReference
@@ -245,7 +245,7 @@
   LineJoin
     linejoin;
 
-  unsigned long
+  size_t
     miterlimit;
 
   double
@@ -260,7 +260,7 @@
   char
     *text;
 
-  unsigned long
+  size_t
     face;
 
   char
@@ -274,7 +274,7 @@
   StretchType
     stretch;
 
-  unsigned long
+  size_t
     weight;
 
   char
@@ -320,7 +320,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 
   double
@@ -337,7 +337,7 @@
   PointInfo
     point;
 
-  unsigned long
+  size_t
     coordinates;
 
   PrimitiveType
diff --git a/magick/effect.c b/magick/effect.c
index c4c37ff..6c66d3d 100644
--- a/magick/effect.c
+++ b/magick/effect.c
@@ -156,26 +156,28 @@
     *edge_image,
     *gaussian_image;
 
-  long
-    j,
-    k,
-    progress,
-    u,
-    v,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    j,
+    k,
+    u,
+    v,
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -222,14 +224,14 @@
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
   (void) ResetMagickMemory(kernel,0,(size_t) width*sizeof(*kernel));
-  for (i=0; i < (long) width; i+=2)
+  for (i=0; i < (ssize_t) width; i+=2)
   {
     kernel[i]=(double *) AcquireQuantumMemory((size_t) (width-i),(width-i)*
       sizeof(**kernel));
     if (kernel[i] == (double *) NULL)
       break;
     normalize=0.0;
-    j=(long) (width-i)/2;
+    j=(ssize_t) (width-i)/2;
     k=0;
     for (v=(-j); v <= j; v++)
     {
@@ -247,7 +249,7 @@
     for (k=0; k < (j*j); k++)
       kernel[i][k]=normalize*kernel[i][k];
   }
-  if (i < (long) width)
+  if (i < (ssize_t) width)
     {
       for (i-=2; i >= 0; i-=2)
         kernel[i]=(double *) RelinquishMagickMemory(kernel[i]);
@@ -269,7 +271,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) blur_image->rows; y++)
+  for (y=0; y < (ssize_t) blur_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -281,7 +283,7 @@
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -298,7 +300,7 @@
         continue;
       }
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (x=0; x < (long) blur_image->columns; x++)
+    for (x=0; x < (ssize_t) blur_image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -310,30 +312,30 @@
       register const double
         *restrict k;
 
-      register long
+      register ssize_t
         i,
         u,
         v;
 
       gamma=0.0;
-      i=(long) ceil((double) width*QuantumScale*PixelIntensity(r)-0.5);
+      i=(ssize_t) ceil((double) width*QuantumScale*PixelIntensity(r)-0.5);
       if (i < 0)
         i=0;
       else
-        if (i > (long) width)
-          i=(long) width;
+        if (i > (ssize_t) width)
+          i=(ssize_t) width;
       if ((i & 0x01) != 0)
         i--;
-      p=GetCacheViewVirtualPixels(image_view,x-((long) (width-i)/2L),y-(long)
+      p=GetCacheViewVirtualPixels(image_view,x-((ssize_t) (width-i)/2L),y-(ssize_t)
         ((width-i)/2L),width-i,width-i,exception);
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetCacheViewVirtualIndexQueue(image_view);
       pixel=bias;
       k=kernel[i];
-      for (v=0; v < (long) (width-i); v++)
+      for (v=0; v < (ssize_t) (width-i); v++)
       {
-        for (u=0; u < (long) (width-i); u++)
+        for (u=0; u < (ssize_t) (width-i); u++)
         {
           alpha=1.0;
           if (((channel & OpacityChannel) != 0) &&
@@ -391,7 +393,7 @@
   edge_view=DestroyCacheView(edge_view);
   image_view=DestroyCacheView(image_view);
   edge_image=DestroyImage(edge_image);
-  for (i=0; i < (long) width;  i+=2)
+  for (i=0; i < (ssize_t) width;  i+=2)
     kernel[i]=(double *) RelinquishMagickMemory(kernel[i]);
   kernel=(double **) RelinquishMagickMemory(kernel);
   if (status == MagickFalse)
@@ -471,26 +473,28 @@
     *edge_image,
     *gaussian_image;
 
-  long
-    j,
-    k,
-    progress,
-    u,
-    v,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    j,
+    k,
+    u,
+    v,
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -537,14 +541,14 @@
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
   (void) ResetMagickMemory(kernel,0,(size_t) width*sizeof(*kernel));
-  for (i=0; i < (long) width; i+=2)
+  for (i=0; i < (ssize_t) width; i+=2)
   {
     kernel[i]=(double *) AcquireQuantumMemory((size_t) (width-i),(width-i)*
       sizeof(**kernel));
     if (kernel[i] == (double *) NULL)
       break;
     normalize=0.0;
-    j=(long) (width-i)/2;
+    j=(ssize_t) (width-i)/2;
     k=0;
     for (v=(-j); v <= j; v++)
     {
@@ -562,7 +566,7 @@
     for (k=0; k < (j*j); k++)
       kernel[i][k]=normalize*kernel[i][k];
   }
-  if (i < (long) width)
+  if (i < (ssize_t) width)
     {
       for (i-=2; i >= 0; i-=2)
         kernel[i]=(double *) RelinquishMagickMemory(kernel[i]);
@@ -584,7 +588,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) sharp_image->rows; y++)
+  for (y=0; y < (ssize_t) sharp_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -596,7 +600,7 @@
     register IndexPacket
       *restrict sharp_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -613,7 +617,7 @@
         continue;
       }
     sharp_indexes=GetCacheViewAuthenticIndexQueue(sharp_view);
-    for (x=0; x < (long) sharp_image->columns; x++)
+    for (x=0; x < (ssize_t) sharp_image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -625,31 +629,31 @@
       register const double
         *restrict k;
 
-      register long
+      register ssize_t
         i,
         u,
         v;
 
       gamma=0.0;
-      i=(long) ceil((double) width*(QuantumRange-QuantumScale*
+      i=(ssize_t) ceil((double) width*(QuantumRange-QuantumScale*
         PixelIntensity(r))-0.5);
       if (i < 0)
         i=0;
       else
-        if (i > (long) width)
-          i=(long) width;
+        if (i > (ssize_t) width)
+          i=(ssize_t) width;
       if ((i & 0x01) != 0)
         i--;
-      p=GetCacheViewVirtualPixels(image_view,x-((long) (width-i)/2L),y-(long)
+      p=GetCacheViewVirtualPixels(image_view,x-((ssize_t) (width-i)/2L),y-(ssize_t)
         ((width-i)/2L),width-i,width-i,exception);
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetCacheViewVirtualIndexQueue(image_view);
       k=kernel[i];
       pixel=bias;
-      for (v=0; v < (long) (width-i); v++)
+      for (v=0; v < (ssize_t) (width-i); v++)
       {
-        for (u=0; u < (long) (width-i); u++)
+        for (u=0; u < (ssize_t) (width-i); u++)
         {
           alpha=1.0;
           if (((channel & OpacityChannel) != 0) &&
@@ -707,7 +711,7 @@
   edge_view=DestroyCacheView(edge_view);
   image_view=DestroyCacheView(image_view);
   edge_image=DestroyImage(edge_image);
-  for (i=0; i < (long) width;  i+=2)
+  for (i=0; i < (ssize_t) width;  i+=2)
     kernel[i]=(double *) RelinquishMagickMemory(kernel[i]);
   kernel=(double **) RelinquishMagickMemory(kernel);
   if (status == MagickFalse)
@@ -767,17 +771,17 @@
   return(blur_image);
 }
 
-static double *GetBlurKernel(const unsigned long width,const double sigma)
+static double *GetBlurKernel(const size_t width,const double sigma)
 {
   double
     *kernel,
     normalize;
 
-  long
+  ssize_t
     j,
     k;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -788,7 +792,7 @@
   if (kernel == (double *) NULL)
     return(0);
   normalize=0.0;
-  j=(long) width/2;
+  j=(ssize_t) width/2;
   i=0;
   for (k=(-j); k <= j; k++)
   {
@@ -797,7 +801,7 @@
     normalize+=kernel[i];
     i++;
   }
-  for (i=0; i < (long) width; i++)
+  for (i=0; i < (ssize_t) width; i++)
     kernel[i]/=normalize;
   return(kernel);
 }
@@ -818,23 +822,25 @@
   Image
     *blur_image;
 
-  long
-    progress,
-    x,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    x,
+    y;
+
   /*
     Initialize blur image attributes.
   */
@@ -875,7 +881,7 @@
         "  BlurImage with %ld kernel:",width);
       message=AcquireString("");
       k=kernel;
-      for (i=0; i < (long) width; i++)
+      for (i=0; i < (ssize_t) width; i++)
       {
         *message='\0';
         (void) FormatMagickString(format,MaxTextExtent,"%ld: ",i);
@@ -898,7 +904,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) blur_image->rows; y++)
+  for (y=0; y < (ssize_t) blur_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -909,7 +915,7 @@
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -917,7 +923,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y,image->columns+
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y,image->columns+
       width,1,exception);
     q=GetCacheViewAuthenticPixels(blur_view,0,y,blur_image->columns,1,
       exception);
@@ -928,7 +934,7 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (x=0; x < (long) blur_image->columns; x++)
+    for (x=0; x < (ssize_t) blur_image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -939,7 +945,7 @@
       register const PixelPacket
         *restrict kernel_pixels;
 
-      register long
+      register ssize_t
         i;
 
       pixel=bias;
@@ -947,7 +953,7 @@
       kernel_pixels=p;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             pixel.red+=(*k)*kernel_pixels->red;
             pixel.green+=(*k)*kernel_pixels->green;
@@ -965,7 +971,7 @@
             {
               k=kernel;
               kernel_pixels=p;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.opacity+=(*k)*kernel_pixels->opacity;
                 k++;
@@ -981,7 +987,7 @@
 
               k=kernel;
               kernel_indexes=indexes;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.index+=(*k)*(*kernel_indexes);
                 k++;
@@ -997,7 +1003,7 @@
             gamma;
 
           gamma=0.0;
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             alpha=(MagickRealType) (QuantumScale*
               GetAlphaPixelComponent(kernel_pixels));
@@ -1019,7 +1025,7 @@
             {
               k=kernel;
               kernel_pixels=p;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.opacity+=(*k)*kernel_pixels->opacity;
                 k++;
@@ -1036,7 +1042,7 @@
               k=kernel;
               kernel_pixels=p;
               kernel_indexes=indexes;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 alpha=(MagickRealType) (QuantumScale*
                   GetAlphaPixelComponent(kernel_pixels));
@@ -1078,7 +1084,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (x=0; x < (long) blur_image->columns; x++)
+  for (x=0; x < (ssize_t) blur_image->columns; x++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1089,7 +1095,7 @@
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       y;
 
     register PixelPacket
@@ -1097,7 +1103,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,x,-((long) width/2L),1,image->rows+
+    p=GetCacheViewVirtualPixels(image_view,x,-((ssize_t) width/2L),1,image->rows+
       width,exception);
     q=GetCacheViewAuthenticPixels(blur_view,x,0,1,blur_image->rows,exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
@@ -1107,7 +1113,7 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (y=0; y < (long) blur_image->rows; y++)
+    for (y=0; y < (ssize_t) blur_image->rows; y++)
     {
       MagickPixelPacket
         pixel;
@@ -1118,7 +1124,7 @@
       register const PixelPacket
         *restrict kernel_pixels;
 
-      register long
+      register ssize_t
         i;
 
       pixel=bias;
@@ -1126,7 +1132,7 @@
       kernel_pixels=p;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             pixel.red+=(*k)*kernel_pixels->red;
             pixel.green+=(*k)*kernel_pixels->green;
@@ -1144,7 +1150,7 @@
             {
               k=kernel;
               kernel_pixels=p;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.opacity+=(*k)*kernel_pixels->opacity;
                 k++;
@@ -1160,7 +1166,7 @@
 
               k=kernel;
               kernel_indexes=indexes;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.index+=(*k)*(*kernel_indexes);
                 k++;
@@ -1176,7 +1182,7 @@
             gamma;
 
           gamma=0.0;
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             alpha=(MagickRealType) (QuantumScale*
               GetAlphaPixelComponent(kernel_pixels));
@@ -1198,7 +1204,7 @@
             {
               k=kernel;
               kernel_pixels=p;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 pixel.opacity+=(*k)*kernel_pixels->opacity;
                 k++;
@@ -1215,7 +1221,7 @@
               k=kernel;
               kernel_pixels=p;
               kernel_indexes=indexes;
-              for (i=0; i < (long) width; i++)
+              for (i=0; i < (ssize_t) width; i++)
               {
                 alpha=(MagickRealType) (QuantumScale*
                   GetAlphaPixelComponent(kernel_pixels));
@@ -1271,10 +1277,10 @@
 %
 %  The format of the ConvolveImage method is:
 %
-%      Image *ConvolveImage(const Image *image,const unsigned long order,
+%      Image *ConvolveImage(const Image *image,const size_t order,
 %        const double *kernel,ExceptionInfo *exception)
 %      Image *ConvolveImageChannel(const Image *image,const ChannelType channel,
-%        const unsigned long order,const double *kernel,
+%        const size_t order,const double *kernel,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1291,7 +1297,7 @@
 %
 */
 
-MagickExport Image *ConvolveImage(const Image *image,const unsigned long order,
+MagickExport Image *ConvolveImage(const Image *image,const size_t order,
   const double *kernel,ExceptionInfo *exception)
 {
   Image
@@ -1303,7 +1309,7 @@
 }
 
 MagickExport Image *ConvolveImageChannel(const Image *image,
-  const ChannelType channel,const unsigned long order,const double *kernel,
+  const ChannelType channel,const size_t order,const double *kernel,
   ExceptionInfo *exception)
 {
 #define ConvolveImageTag  "Convolve/Image"
@@ -1318,25 +1324,27 @@
   Image
     *convolve_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
   MagickRealType
     gamma;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    y;
+
   /*
     Initialize convolve image attributes.
   */
@@ -1364,7 +1372,7 @@
         format[MaxTextExtent],
         *message;
 
-      long
+      ssize_t
         u,
         v;
 
@@ -1375,12 +1383,12 @@
         "  ConvolveImage with %ldx%ld kernel:",width,width);
       message=AcquireString("");
       k=kernel;
-      for (v=0; v < (long) width; v++)
+      for (v=0; v < (ssize_t) width; v++)
       {
         *message='\0';
         (void) FormatMagickString(format,MaxTextExtent,"%ld: ",v);
         (void) ConcatenateString(&message,format);
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
         {
           (void) FormatMagickString(format,MaxTextExtent,"%g ",*k++);
           (void) ConcatenateString(&message,format);
@@ -1400,10 +1408,10 @@
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
   gamma=0.0;
-  for (i=0; i < (long) (width*width); i++)
+  for (i=0; i < (ssize_t) (width*width); i++)
     gamma+=kernel[i];
   gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
-  for (i=0; i < (long) (width*width); i++)
+  for (i=0; i < (ssize_t) (width*width); i++)
     normal_kernel[i]=gamma*kernel[i];
   /*
     Convolve image.
@@ -1417,7 +1425,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -1431,7 +1439,7 @@
     register IndexPacket
       *restrict convolve_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1439,7 +1447,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) (width/
       2L),image->columns+width,width,exception);
     q=GetCacheViewAuthenticPixels(convolve_view,0,y,convolve_image->columns,1,
       exception);
@@ -1450,9 +1458,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     convolve_indexes=GetCacheViewAuthenticIndexQueue(convolve_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      long
+      ssize_t
         v;
 
       MagickPixelPacket
@@ -1464,7 +1472,7 @@
       register const PixelPacket
         *restrict kernel_pixels;
 
-      register long
+      register ssize_t
         u;
 
       pixel=bias;
@@ -1472,9 +1480,9 @@
       kernel_pixels=p;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (v=0; v < (long) width; v++)
+          for (v=0; v < (ssize_t) width; v++)
           {
-            for (u=0; u < (long) width; u++)
+            for (u=0; u < (ssize_t) width; u++)
             {
               pixel.red+=(*k)*kernel_pixels[u].red;
               pixel.green+=(*k)*kernel_pixels[u].green;
@@ -1493,9 +1501,9 @@
             {
               k=normal_kernel;
               kernel_pixels=p;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   pixel.opacity+=(*k)*kernel_pixels[u].opacity;
                   k++;
@@ -1512,9 +1520,9 @@
 
               k=normal_kernel;
               kernel_indexes=indexes;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   pixel.index+=(*k)*kernel_indexes[u];
                   k++;
@@ -1531,9 +1539,9 @@
             gamma;
 
           gamma=0.0;
-          for (v=0; v < (long) width; v++)
+          for (v=0; v < (ssize_t) width; v++)
           {
-            for (u=0; u < (long) width; u++)
+            for (u=0; u < (ssize_t) width; u++)
             {
               alpha=(MagickRealType) (QuantumScale*(QuantumRange-
                 kernel_pixels[u].opacity));
@@ -1556,9 +1564,9 @@
             {
               k=normal_kernel;
               kernel_pixels=p;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   pixel.opacity+=(*k)*kernel_pixels[u].opacity;
                   k++;
@@ -1576,9 +1584,9 @@
               k=normal_kernel;
               kernel_pixels=p;
               kernel_indexes=indexes;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   alpha=(MagickRealType) (QuantumScale*(QuantumRange-
                     kernel_pixels[u].opacity));
@@ -1648,11 +1656,11 @@
 
 static Quantum **DestroyPixelThreadSet(Quantum **pixels)
 {
-  register long
+  register ssize_t
     i;
 
   assert(pixels != (Quantum **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (pixels[i] != (Quantum *) NULL)
       pixels[i]=(Quantum *) RelinquishMagickMemory(pixels[i]);
   pixels=(Quantum **) RelinquishAlignedMemory(pixels);
@@ -1661,13 +1669,13 @@
 
 static Quantum **AcquirePixelThreadSet(const size_t count)
 {
-  register long
+  register ssize_t
     i;
 
   Quantum
     **pixels;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -1675,7 +1683,7 @@
   if (pixels == (Quantum **) NULL)
     return((Quantum **) NULL);
   (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     pixels[i]=(Quantum *) AcquireQuantumMemory(count,sizeof(**pixels));
     if (pixels[i] == (Quantum *) NULL)
@@ -1684,17 +1692,17 @@
   return(pixels);
 }
 
-static void Hull(const long x_offset,const long y_offset,
-  const unsigned long columns,const unsigned long rows,Quantum *f,Quantum *g,
+static void Hull(const ssize_t x_offset,const ssize_t y_offset,
+  const size_t columns,const size_t rows,Quantum *f,Quantum *g,
   const int polarity)
 {
-  long
+  ssize_t
     y;
 
   MagickRealType
     v;
 
-  register long
+  register ssize_t
     x;
 
   register Quantum
@@ -1707,14 +1715,14 @@
   assert(g != (Quantum *) NULL);
   p=f+(columns+2);
   q=g+(columns+2);
-  r=p+(y_offset*((long) columns+2)+x_offset);
-  for (y=0; y < (long) rows; y++)
+  r=p+(y_offset*((ssize_t) columns+2)+x_offset);
+  for (y=0; y < (ssize_t) rows; y++)
   {
     p++;
     q++;
     r++;
     if (polarity > 0)
-      for (x=(long) columns; x != 0; x--)
+      for (x=(ssize_t) columns; x != 0; x--)
       {
         v=(MagickRealType) (*p);
         if ((MagickRealType) *r >= (v+(MagickRealType) ScaleCharToQuantum(2)))
@@ -1725,11 +1733,11 @@
         r++;
       }
     else
-      for (x=(long) columns; x != 0; x--)
+      for (x=(ssize_t) columns; x != 0; x--)
       {
         v=(MagickRealType) (*p);
         if ((MagickRealType) *r <= (v-(MagickRealType) ScaleCharToQuantum(2)))
-          v-=(long) ScaleCharToQuantum(1);
+          v-=(ssize_t) ScaleCharToQuantum(1);
         *q=(Quantum) v;
         p++;
         q++;
@@ -1741,16 +1749,16 @@
   }
   p=f+(columns+2);
   q=g+(columns+2);
-  r=q+(y_offset*((long) columns+2)+x_offset);
-  s=q-(y_offset*((long) columns+2)+x_offset);
-  for (y=0; y < (long) rows; y++)
+  r=q+(y_offset*((ssize_t) columns+2)+x_offset);
+  s=q-(y_offset*((ssize_t) columns+2)+x_offset);
+  for (y=0; y < (ssize_t) rows; y++)
   {
     p++;
     q++;
     r++;
     s++;
     if (polarity > 0)
-      for (x=(long) columns; x != 0; x--)
+      for (x=(ssize_t) columns; x != 0; x--)
       {
         v=(MagickRealType) (*q);
         if (((MagickRealType) *s >=
@@ -1764,7 +1772,7 @@
         s++;
       }
     else
-      for (x=(long) columns; x != 0; x--)
+      for (x=(ssize_t) columns; x != 0; x--)
       {
         v=(MagickRealType) (*q);
         if (((MagickRealType) *s <=
@@ -1795,7 +1803,7 @@
   Image
     *despeckle_image;
 
-  long
+  ssize_t
     channel;
 
   MagickBooleanType
@@ -1808,7 +1816,7 @@
   size_t
     length;
 
-  static const int
+  static const ssize_t
     X[4] = {0, 1, 1,-1},
     Y[4] = {1, 0, 1, 1};
 
@@ -1857,11 +1865,11 @@
 #endif
   for (channel=0; channel <= 3; channel++)
   {
-    long
+    ssize_t
       j,
       y;
 
-    register long
+    register ssize_t
       i,
       id,
       x;
@@ -1876,8 +1884,8 @@
     pixel=pixels[id];
     (void) ResetMagickMemory(pixel,0,length*sizeof(*pixel));
     buffer=buffers[id];
-    j=(long) image->columns+2;
-    for (y=0; y < (long) image->rows; y++)
+    j=(ssize_t) image->columns+2;
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register const PixelPacket
         *restrict p;
@@ -1886,7 +1894,7 @@
       if (p == (const PixelPacket *) NULL)
         break;
       j++;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         switch (channel)
         {
@@ -1909,8 +1917,8 @@
       Hull(-X[i],-Y[i],image->columns,image->rows,pixel,buffer,-1);
       Hull(X[i],Y[i],image->columns,image->rows,pixel,buffer,-1);
     }
-    j=(long) image->columns+2;
-    for (y=0; y < (long) image->rows; y++)
+    j=(ssize_t) image->columns+2;
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       MagickBooleanType
         sync;
@@ -1923,7 +1931,7 @@
       if (q == (PixelPacket *) NULL)
         break;
       j++;
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         switch (channel)
         {
@@ -1952,7 +1960,8 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp critical (MagickCore_DespeckleImage)
 #endif
-        proceed=SetImageProgress(image,DespeckleImageTag,channel,3);
+        proceed=SetImageProgress(image,DespeckleImageTag,(MagickOffsetType)
+          channel,3);
         if (proceed == MagickFalse)
           status=MagickFalse;
       }
@@ -2005,10 +2014,10 @@
   double
     *kernel;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   assert(image != (const Image *) NULL);
@@ -2021,7 +2030,7 @@
   kernel=(double *) AcquireQuantumMemory((size_t) width,width*sizeof(*kernel));
   if (kernel == (double *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-  for (i=0; i < (long) (width*width); i++)
+  for (i=0; i < (ssize_t) (width*width); i++)
     kernel[i]=(-1.0);
   kernel[i/2]=(double) (width*width-1.0);
   edge_image=ConvolveImage(image,width,kernel,exception);
@@ -2071,16 +2080,16 @@
   Image
     *emboss_image;
 
-  long
+  ssize_t
     j,
     k,
     u,
     v;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   assert(image != (Image *) NULL);
@@ -2093,7 +2102,7 @@
   kernel=(double *) AcquireQuantumMemory((size_t) width,width*sizeof(*kernel));
   if (kernel == (double *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-  j=(long) width/2;
+  j=(ssize_t) width/2;
   k=j;
   i=0;
   for (v=(-j); v <= j; v++)
@@ -2170,16 +2179,18 @@
   Image
     *filter_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
+  ssize_t
+    y;
+
   /*
     Initialize filter image attributes.
   */
@@ -2206,7 +2217,7 @@
         format[MaxTextExtent],
         *message;
 
-      long
+      ssize_t
         u,
         v;
 
@@ -2217,12 +2228,12 @@
         "  FilterImage with %ldx%ld kernel:",kernel->width,kernel->height);
       message=AcquireString("");
       k=kernel->values;
-      for (v=0; v < (long) kernel->height; v++)
+      for (v=0; v < (ssize_t) kernel->height; v++)
       {
         *message='\0';
         (void) FormatMagickString(format,MaxTextExtent,"%ld: ",v);
         (void) ConcatenateString(&message,format);
-        for (u=0; u < (long) kernel->width; u++)
+        for (u=0; u < (ssize_t) kernel->width; u++)
         {
           (void) FormatMagickString(format,MaxTextExtent,"%g ",*k++);
           (void) ConcatenateString(&message,format);
@@ -2246,7 +2257,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -2260,7 +2271,7 @@
     register IndexPacket
       *restrict filter_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2268,8 +2279,8 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) kernel->width/2L),
-      y-(long) (kernel->height/2L),image->columns+kernel->width,kernel->height,
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) kernel->width/2L),
+      y-(ssize_t) (kernel->height/2L),image->columns+kernel->width,kernel->height,
       exception);
     q=GetCacheViewAuthenticPixels(filter_view,0,y,filter_image->columns,1,
       exception);
@@ -2280,9 +2291,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     filter_indexes=GetCacheViewAuthenticIndexQueue(filter_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      long
+      ssize_t
         v;
 
       MagickPixelPacket
@@ -2294,7 +2305,7 @@
       register const PixelPacket
         *restrict kernel_pixels;
 
-      register long
+      register ssize_t
         u;
 
       pixel=bias;
@@ -2302,9 +2313,9 @@
       kernel_pixels=p;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (v=0; v < (long) kernel->width; v++)
+          for (v=0; v < (ssize_t) kernel->width; v++)
           {
-            for (u=0; u < (long) kernel->height; u++)
+            for (u=0; u < (ssize_t) kernel->height; u++)
             {
               pixel.red+=(*k)*kernel_pixels[u].red;
               pixel.green+=(*k)*kernel_pixels[u].green;
@@ -2323,9 +2334,9 @@
             {
               k=kernel->values;
               kernel_pixels=p;
-              for (v=0; v < (long) kernel->width; v++)
+              for (v=0; v < (ssize_t) kernel->width; v++)
               {
-                for (u=0; u < (long) kernel->height; u++)
+                for (u=0; u < (ssize_t) kernel->height; u++)
                 {
                   pixel.opacity+=(*k)*kernel_pixels[u].opacity;
                   k++;
@@ -2342,9 +2353,9 @@
 
               k=kernel->values;
               kernel_indexes=indexes;
-              for (v=0; v < (long) kernel->width; v++)
+              for (v=0; v < (ssize_t) kernel->width; v++)
               {
-                for (u=0; u < (long) kernel->height; u++)
+                for (u=0; u < (ssize_t) kernel->height; u++)
                 {
                   pixel.index+=(*k)*kernel_indexes[u];
                   k++;
@@ -2361,9 +2372,9 @@
             gamma;
 
           gamma=0.0;
-          for (v=0; v < (long) kernel->width; v++)
+          for (v=0; v < (ssize_t) kernel->width; v++)
           {
-            for (u=0; u < (long) kernel->height; u++)
+            for (u=0; u < (ssize_t) kernel->height; u++)
             {
               alpha=(MagickRealType) (QuantumScale*(QuantumRange-
                 kernel_pixels[u].opacity));
@@ -2386,9 +2397,9 @@
             {
               k=kernel->values;
               kernel_pixels=p;
-              for (v=0; v < (long) kernel->width; v++)
+              for (v=0; v < (ssize_t) kernel->width; v++)
               {
-                for (u=0; u < (long) kernel->height; u++)
+                for (u=0; u < (ssize_t) kernel->height; u++)
                 {
                   pixel.opacity+=(*k)*kernel_pixels[u].opacity;
                   k++;
@@ -2406,9 +2417,9 @@
               k=kernel->values;
               kernel_pixels=p;
               kernel_indexes=indexes;
-              for (v=0; v < (long) kernel->width; v++)
+              for (v=0; v < (ssize_t) kernel->width; v++)
               {
-                for (u=0; u < (long) kernel->height; u++)
+                for (u=0; u < (ssize_t) kernel->height; u++)
                 {
                   alpha=(MagickRealType) (QuantumScale*(QuantumRange-
                     kernel_pixels[u].opacity));
@@ -2509,15 +2520,15 @@
   Image
     *blur_image;
 
-  long
+  ssize_t
     j,
     u,
     v;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   assert(image != (const Image *) NULL);
@@ -2530,7 +2541,7 @@
   kernel=(double *) AcquireQuantumMemory((size_t) width,width*sizeof(*kernel));
   if (kernel == (double *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-  j=(long) width/2;
+  j=(ssize_t) width/2;
   i=0;
   for (v=(-j); v <= j; v++)
   {
@@ -2582,7 +2593,7 @@
 
 typedef struct _MedianListNode
 {
-  unsigned long
+  size_t
     next[9],
     count,
     signature;
@@ -2590,7 +2601,7 @@
 
 typedef struct _MedianSkipList
 {
-  long
+  ssize_t
     level;
 
   MedianListNode
@@ -2599,7 +2610,7 @@
 
 typedef struct _MedianPixelList
 {
-  unsigned long
+  size_t
     center,
     seed,
     signature;
@@ -2610,7 +2621,7 @@
 
 static MedianPixelList *DestroyMedianPixelList(MedianPixelList *pixel_list)
 {
-  register long
+  register ssize_t
     i;
 
   if (pixel_list == (MedianPixelList *) NULL)
@@ -2626,23 +2637,23 @@
 static MedianPixelList **DestroyMedianPixelListThreadSet(
   MedianPixelList **pixel_list)
 {
-  register long
+  register ssize_t
     i;
 
   assert(pixel_list != (MedianPixelList **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (pixel_list[i] != (MedianPixelList *) NULL)
       pixel_list[i]=DestroyMedianPixelList(pixel_list[i]);
   pixel_list=(MedianPixelList **) RelinquishAlignedMemory(pixel_list);
   return(pixel_list);
 }
 
-static MedianPixelList *AcquireMedianPixelList(const unsigned long width)
+static MedianPixelList *AcquireMedianPixelList(const size_t width)
 {
   MedianPixelList
     *pixel_list;
 
-  register long
+  register ssize_t
     i;
 
   pixel_list=(MedianPixelList *) AcquireAlignedMemory(1,sizeof(*pixel_list));
@@ -2664,15 +2675,15 @@
 }
 
 static MedianPixelList **AcquireMedianPixelListThreadSet(
-  const unsigned long width)
+  const size_t width)
 {
-  register long
+  register ssize_t
     i;
 
   MedianPixelList
     **pixel_list;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -2681,7 +2692,7 @@
   if (pixel_list == (MedianPixelList **) NULL)
     return((MedianPixelList **) NULL);
   (void) ResetMagickMemory(pixel_list,0,number_threads*sizeof(*pixel_list));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     pixel_list[i]=AcquireMedianPixelList(width);
     if (pixel_list[i] == (MedianPixelList *) NULL)
@@ -2691,15 +2702,15 @@
 }
 
 static void AddNodeMedianPixelList(MedianPixelList *pixel_list,
-  const long channel,const unsigned long color)
+  const ssize_t channel,const size_t color)
 {
-  register long
+  register ssize_t
     level;
 
   register MedianSkipList
     *list;
 
-  unsigned long
+  size_t
     search,
     update[9];
 
@@ -2710,7 +2721,7 @@
   list->nodes[color].signature=pixel_list->signature;
   list->nodes[color].count=1;
   /*
-    Determine where it belongs in the list.
+    Determine where it bessize_ts in the list.
   */
   search=65536UL;
   for (level=list->level; level >= 0; level--)
@@ -2756,13 +2767,13 @@
   MagickPixelPacket
     pixel;
 
-  register long
+  register ssize_t
     channel;
 
   register MedianSkipList
     *list;
 
-  unsigned long
+  size_t
     center,
     color,
     count;
@@ -2800,7 +2811,7 @@
   const PixelPacket *pixel,const IndexPacket *indexes,
   MedianPixelList *pixel_list)
 {
-  unsigned long
+  size_t
     signature;
 
   unsigned short
@@ -2844,7 +2855,7 @@
   int
     level;
 
-  register long
+  register ssize_t
     channel;
 
   register MedianListNode
@@ -2879,19 +2890,21 @@
   Image
     *median_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MedianPixelList
     **restrict pixel_list;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    y;
+
   /*
     Initialize median image attributes.
   */
@@ -2930,7 +2943,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) median_image->rows; y++)
+  for (y=0; y < (ssize_t) median_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -2941,7 +2954,7 @@
     register IndexPacket
       *restrict median_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -2950,7 +2963,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) (width/
       2L),image->columns+width,width,exception);
     q=QueueCacheViewAuthenticPixels(median_view,0,y,median_image->columns,1,
       exception);
@@ -2962,7 +2975,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     median_indexes=GetCacheViewAuthenticIndexQueue(median_view);
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) median_image->columns; x++)
+    for (x=0; x < (ssize_t) median_image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -2973,16 +2986,16 @@
       register const IndexPacket
         *restrict s;
 
-      register long
+      register ssize_t
         u,
         v;
 
       r=p;
       s=indexes+x;
       ResetMedianPixelList(pixel_list[id]);
-      for (v=0; v < (long) width; v++)
+      for (v=0; v < (ssize_t) width; v++)
       {
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
           InsertMedianPixelList(image,r+u,s+u,pixel_list[id]);
         r+=image->columns+width;
         s+=image->columns+width;
@@ -3053,19 +3066,19 @@
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 %    o exception: return any errors or warnings in this structure.
 %
 */
 
-static double *GetMotionBlurKernel(const unsigned long width,const double sigma)
+static double *GetMotionBlurKernel(const size_t width,const double sigma)
 {
   double
     *kernel,
     normalize;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -3076,13 +3089,13 @@
   if (kernel == (double *) NULL)
     return(kernel);
   normalize=0.0;
-  for (i=0; i < (long) width; i++)
+  for (i=0; i < (ssize_t) width; i++)
   {
     kernel[i]=exp((-((double) i*i)/(double) (2.0*MagickSigma*MagickSigma)))/
       (MagickSQ2PI*MagickSigma);
     normalize+=kernel[i];
   }
-  for (i=0; i < (long) width; i++)
+  for (i=0; i < (ssize_t) width; i++)
     kernel[i]/=normalize;
   return(kernel);
 }
@@ -3112,13 +3125,12 @@
   Image
     *blur_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
@@ -3128,12 +3140,15 @@
   PointInfo
     point;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -3166,10 +3181,10 @@
     }
   point.x=(double) width*sin(DegreesToRadians(angle));
   point.y=(double) width*cos(DegreesToRadians(angle));
-  for (i=0; i < (long) width; i++)
+  for (i=0; i < (ssize_t) width; i++)
   {
-    offset[i].x=(long) ceil((double) (i*point.y)/hypot(point.x,point.y)-0.5);
-    offset[i].y=(long) ceil((double) (i*point.x)/hypot(point.x,point.y)-0.5);
+    offset[i].x=(ssize_t) ceil((double) (i*point.y)/hypot(point.x,point.y)-0.5);
+    offset[i].y=(ssize_t) ceil((double) (i*point.x)/hypot(point.x,point.y)-0.5);
   }
   /*
     Motion blur image.
@@ -3182,12 +3197,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3203,7 +3218,7 @@
         continue;
       }
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickPixelPacket
         qixel;
@@ -3214,7 +3229,7 @@
       register double
         *restrict k;
 
-      register long
+      register ssize_t
         i;
 
       register const IndexPacket
@@ -3224,7 +3239,7 @@
       qixel=bias;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             (void) GetOneCacheViewVirtualPixel(image_view,x+offset[i].x,y+
               offset[i].y,&pixel,exception);
@@ -3259,7 +3274,7 @@
 
           alpha=0.0;
           gamma=0.0;
-          for (i=0; i < (long) width; i++)
+          for (i=0; i < (ssize_t) width; i++)
           {
             (void) GetOneCacheViewVirtualPixel(image_view,x+offset[i].x,y+
               offset[i].y,&pixel,exception);
@@ -3374,7 +3389,7 @@
   ImageInfo
     *preview_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -3389,11 +3404,11 @@
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  unsigned long
+  size_t
     colors;
 
   /*
@@ -3451,8 +3466,8 @@
       }
       case RollPreview:
       {
-        x=(long) ((i+1)*thumbnail->columns)/NumberTiles;
-        y=(long) ((i+1)*thumbnail->rows)/NumberTiles;
+        x=(ssize_t) ((i+1)*thumbnail->columns)/NumberTiles;
+        y=(ssize_t) ((i+1)*thumbnail->rows)/NumberTiles;
         preview_image=RollImage(thumbnail,x,y,exception);
         (void) FormatMagickString(label,MaxTextExtent,"roll %ldx%ld",x,y);
         break;
@@ -3672,8 +3687,8 @@
         preview_image=CloneImage(thumbnail,0,0,MagickTrue,exception);
         if (preview_image == (Image *) NULL)
           break;
-        geometry.width=(unsigned long) (2*i+2);
-        geometry.height=(unsigned long) (2*i+2);
+        geometry.width=(size_t) (2*i+2);
+        geometry.height=(size_t) (2*i+2);
         geometry.x=i/2;
         geometry.y=i/2;
         (void) RaiseImage(preview_image,&geometry,MagickTrue);
@@ -3743,7 +3758,7 @@
         preview_image=CloneImage(thumbnail,0,0,MagickTrue,exception);
         if (preview_image == (Image *) NULL)
           break;
-        preview_info->quality=(unsigned long) percentage;
+        preview_info->quality=(size_t) percentage;
         (void) FormatMagickString(factor,MaxTextExtent,"%lu",
           preview_info->quality);
         file=AcquireUniqueFileResource(filename);
@@ -3778,7 +3793,7 @@
               GetBlobSize(preview_image))/1024.0);
           else
             (void) FormatMagickString(label,MaxTextExtent,"quality %s\n%lub ",
-              factor,(unsigned long) GetBlobSize(thumbnail));
+              factor,(size_t) GetBlobSize(thumbnail));
         break;
       }
     }
@@ -3791,7 +3806,8 @@
     (void) DeleteImageProperty(preview_image,"label");
     (void) SetImageProperty(preview_image,"label",label);
     AppendImageToList(&images,preview_image);
-    proceed=SetImageProgress(image,PreviewImageTag,i,NumberTiles);
+    proceed=SetImageProgress(image,PreviewImageTag,(MagickOffsetType) i,
+      NumberTiles);
     if (proceed == MagickFalse)
       break;
   }
@@ -3883,13 +3899,12 @@
   Image
     *blur_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
@@ -3903,12 +3918,15 @@
   PointInfo
     blur_center;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     n;
 
+  ssize_t
+    y;
+
   /*
     Allocate blur image.
   */
@@ -3930,7 +3948,7 @@
   blur_center.x=(double) image->columns/2.0;
   blur_center.y=(double) image->rows/2.0;
   blur_radius=hypot(blur_center.x,blur_center.y);
-  n=(unsigned long) fabs(4.0*DegreesToRadians(angle)*sqrt((double) blur_radius)+
+  n=(size_t) fabs(4.0*DegreesToRadians(angle)*sqrt((double) blur_radius)+
     2UL);
   theta=DegreesToRadians(angle)/(MagickRealType) (n-1);
   cos_theta=(MagickRealType *) AcquireQuantumMemory((size_t) n,
@@ -3944,7 +3962,7 @@
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
   offset=theta*(MagickRealType) (n-1)/2.0;
-  for (i=0; i < (long) n; i++)
+  for (i=0; i < (ssize_t) n; i++)
   {
     cos_theta[i]=cos((double) (theta*i-offset));
     sin_theta[i]=sin((double) (theta*i-offset));
@@ -3960,7 +3978,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) blur_image->rows; y++)
+  for (y=0; y < (ssize_t) blur_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -3968,7 +3986,7 @@
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3984,7 +4002,7 @@
         continue;
       }
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (x=0; x < (long) blur_image->columns; x++)
+    for (x=0; x < (ssize_t) blur_image->columns; x++)
     {
       MagickPixelPacket
         qixel;
@@ -3999,10 +4017,10 @@
       PointInfo
         center;
 
-      register long
+      register ssize_t
         i;
 
-      unsigned long
+      size_t
         step;
 
       center.x=(double) x-blur_center.x;
@@ -4012,7 +4030,7 @@
         step=1;
       else
         {
-          step=(unsigned long) (blur_radius/radius);
+          step=(size_t) (blur_radius/radius);
           if (step == 0)
             step=1;
           else
@@ -4023,10 +4041,10 @@
       qixel=bias;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (i=0; i < (long) n; i+=step)
+          for (i=0; i < (ssize_t) n; i+=step)
           {
-            (void) GetOneCacheViewVirtualPixel(image_view,(long) (blur_center.x+
-              center.x*cos_theta[i]-center.y*sin_theta[i]+0.5),(long) (
+            (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t) (blur_center.x+
+              center.x*cos_theta[i]-center.y*sin_theta[i]+0.5),(ssize_t) (
               blur_center.y+center.x*sin_theta[i]+center.y*cos_theta[i]+0.5),
               &pixel,exception);
             qixel.red+=pixel.red;
@@ -4062,10 +4080,10 @@
 
           alpha=1.0;
           gamma=0.0;
-          for (i=0; i < (long) n; i+=step)
+          for (i=0; i < (ssize_t) n; i+=step)
           {
-            (void) GetOneCacheViewVirtualPixel(image_view,(long) (blur_center.x+
-              center.x*cos_theta[i]-center.y*sin_theta[i]+0.5),(long) (
+            (void) GetOneCacheViewVirtualPixel(image_view,(ssize_t) (blur_center.x+
+              center.x*cos_theta[i]-center.y*sin_theta[i]+0.5),(ssize_t) (
               blur_center.y+center.x*sin_theta[i]+center.y*cos_theta[i]+0.5),
               &pixel,exception);
             alpha=(MagickRealType) (QuantumScale*
@@ -4159,13 +4177,13 @@
   MagickPixelPacket
     pixel;
 
-  register long
+  register ssize_t
     channel;
 
   register MedianSkipList
     *list;
 
-  unsigned long
+  size_t
     center,
     color,
     count,
@@ -4221,19 +4239,21 @@
   Image
     *noise_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MedianPixelList
     **restrict pixel_list;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    y;
+
   /*
     Initialize noise image attributes.
   */
@@ -4272,7 +4292,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) noise_image->rows; y++)
+  for (y=0; y < (ssize_t) noise_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -4283,7 +4303,7 @@
     register IndexPacket
       *restrict noise_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -4292,7 +4312,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) (width/
       2L),image->columns+width,width,exception);
     q=QueueCacheViewAuthenticPixels(noise_view,0,y,noise_image->columns,1,
       exception);
@@ -4304,7 +4324,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     noise_indexes=GetCacheViewAuthenticIndexQueue(noise_view);
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) noise_image->columns; x++)
+    for (x=0; x < (ssize_t) noise_image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -4315,16 +4335,16 @@
       register const IndexPacket
         *restrict s;
 
-      register long
+      register ssize_t
         u,
         v;
 
       r=p;
       s=indexes+x;
       ResetMedianPixelList(pixel_list[id]);
-      for (v=0; v < (long) width; v++)
+      for (v=0; v < (ssize_t) width; v++)
       {
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
           InsertMedianPixelList(image,r+u,s+u,pixel_list[id]);
         r+=image->columns+width;
         s+=image->columns+width;
@@ -4432,25 +4452,27 @@
   Image
     *blur_image;
 
-  long
-    j,
-    progress,
-    u,
-    v,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    j,
+    u,
+    v,
+    y;
+
   /*
     Initialize blur image attributes.
   */
@@ -4464,7 +4486,7 @@
   kernel=(double *) AcquireQuantumMemory((size_t) width,width*sizeof(*kernel));
   if (kernel == (double *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-  j=(long) width/2;
+  j=(ssize_t) width/2;
   i=0;
   for (v=(-j); v <= j; v++)
   {
@@ -4478,7 +4500,7 @@
         format[MaxTextExtent],
         *message;
 
-      long
+      ssize_t
         u,
         v;
 
@@ -4489,12 +4511,12 @@
         "  SelectiveBlurImage with %ldx%ld kernel:",width,width);
       message=AcquireString("");
       k=kernel;
-      for (v=0; v < (long) width; v++)
+      for (v=0; v < (ssize_t) width; v++)
       {
         *message='\0';
         (void) FormatMagickString(format,MaxTextExtent,"%ld: ",v);
         (void) ConcatenateString(&message,format);
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
         {
           (void) FormatMagickString(format,MaxTextExtent,"%+f ",*k++);
           (void) ConcatenateString(&message,format);
@@ -4524,7 +4546,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -4541,7 +4563,7 @@
     register IndexPacket
       *restrict blur_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4549,7 +4571,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) (width/
       2L),image->columns+width,width,exception);
     q=GetCacheViewAuthenticPixels(blur_view,0,y,blur_image->columns,1,
       exception);
@@ -4560,9 +4582,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     blur_indexes=GetCacheViewAuthenticIndexQueue(blur_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      long
+      ssize_t
         j,
         v;
 
@@ -4572,7 +4594,7 @@
       register const double
         *restrict k;
 
-      register long
+      register ssize_t
         u;
 
       pixel=bias;
@@ -4581,9 +4603,9 @@
       j=0;
       if (((channel & OpacityChannel) == 0) || (image->matte == MagickFalse))
         {
-          for (v=0; v < (long) width; v++)
+          for (v=0; v < (ssize_t) width; v++)
           {
-            for (u=0; u < (long) width; u++)
+            for (u=0; u < (ssize_t) width; u++)
             {
               if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                 {
@@ -4610,9 +4632,9 @@
             {
               gamma=0.0;
               j=0;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                     {
@@ -4636,9 +4658,9 @@
             {
               gamma=0.0;
               j=0;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                     {
@@ -4663,9 +4685,9 @@
           MagickRealType
             alpha;
 
-          for (v=0; v < (long) width; v++)
+          for (v=0; v < (ssize_t) width; v++)
           {
-            for (u=0; u < (long) width; u++)
+            for (u=0; u < (ssize_t) width; u++)
             {
               if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                 {
@@ -4695,9 +4717,9 @@
             {
               gamma=0.0;
               j=0;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                     {
@@ -4721,9 +4743,9 @@
             {
               gamma=0.0;
               j=0;
-              for (v=0; v < (long) width; v++)
+              for (v=0; v < (ssize_t) width; v++)
               {
-                for (u=0; u < (long) width; u++)
+                for (u=0; u < (ssize_t) width; u++)
                 {
                   if (SelectiveContrast(p+u+j,q,threshold) != MagickFalse)
                     {
@@ -4818,16 +4840,18 @@
   Image
     *shade_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   PrimaryInfo
     light;
 
+  ssize_t
+    y;
+
   /*
     Initialize shaded image attributes.
   */
@@ -4864,7 +4888,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickRealType
       distance,
@@ -4880,7 +4904,7 @@
       *restrict s1,
       *restrict s2;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4903,7 +4927,7 @@
     s0=p+1;
     s1=s0+image->columns+2;
     s2=s1+image->columns+2;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Determine the surface normal and compute shading.
@@ -5032,15 +5056,15 @@
   Image
     *sharp_image;
 
-  long
+  ssize_t
     j,
     u,
     v;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   assert(image != (const Image *) NULL);
@@ -5054,7 +5078,7 @@
   if (kernel == (double *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
   normalize=0.0;
-  j=(long) width/2;
+  j=(ssize_t) width/2;
   i=0;
   for (v=(-j); v <= j; v++)
   {
@@ -5111,13 +5135,12 @@
   Image
     *spread_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
@@ -5127,9 +5150,12 @@
   ResampleFilter
     **restrict resample_filter;
 
-  unsigned long
+  size_t
     width;
 
+  ssize_t
+    y;
+
   /*
     Initialize spread image attributes.
   */
@@ -5163,7 +5189,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) spread_image->rows; y++)
+  for (y=0; y < (ssize_t) spread_image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -5171,7 +5197,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -5190,7 +5216,7 @@
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     pixel=bias;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) spread_image->columns; x++)
+    for (x=0; x < (ssize_t) spread_image->columns; x++)
     {
       (void) ResamplePixelColor(resample_filter[id],(double) x+width*
         (GetPseudoRandomValue(random_info[id])-0.5),(double) y+width*
@@ -5289,19 +5315,21 @@
   Image
     *unsharp_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     bias;
 
   MagickRealType
     quantum_threshold;
 
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -5322,7 +5350,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -5336,7 +5364,7 @@
     register IndexPacket
       *restrict unsharp_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -5355,7 +5383,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     unsharp_indexes=GetCacheViewAuthenticIndexQueue(unsharp_view);
     pixel=bias;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
diff --git a/magick/effect.h b/magick/effect.h
index 2f6fc5a..e6f6833 100644
--- a/magick/effect.h
+++ b/magick/effect.h
@@ -69,9 +69,9 @@
   *BlurImage(const Image *,const double,const double,ExceptionInfo *),
   *BlurImageChannel(const Image *,const ChannelType,const double,const double,
     ExceptionInfo *),
-  *ConvolveImage(const Image *,const unsigned long,const double *,
+  *ConvolveImage(const Image *,const size_t,const double *,
     ExceptionInfo *),
-  *ConvolveImageChannel(const Image *,const ChannelType,const unsigned long,
+  *ConvolveImageChannel(const Image *,const ChannelType,const size_t,
     const double *,ExceptionInfo *),
   *DespeckleImage(const Image *,ExceptionInfo *),
   *EdgeImage(const Image *,const double,ExceptionInfo *),
diff --git a/magick/enhance.c b/magick/enhance.c
index 7ad27f1..a597339 100644
--- a/magick/enhance.c
+++ b/magick/enhance.c
@@ -384,19 +384,21 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   PixelPacket
     *cdl_map;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   XMLTreeInfo
     *cc,
     *ccc,
@@ -542,7 +544,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     cdl_map[i].red=ClampToQuantum((MagickRealType) ScaleMapToQuantum((
       MagickRealType) (MaxMap*(pow(color_correction.red.slope*i/MaxMap+
@@ -562,7 +564,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         double
           luma;
@@ -588,12 +590,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       luma;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -607,7 +609,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       luma=0.2126*q->red+0.7152*q->green+0.0722*q->blue;
       q->red=ClampToQuantum(luma+color_correction.saturation*
@@ -652,7 +654,7 @@
 %
 %  ClutImage() replaces each color value in the given image, by using it as an
 %  index to lookup a replacement color value in a Color Look UP Table in the
-%  form of an image.  The values are extracted along a diagonal of the CLUT
+%  form of an image.  The values are extracted assize_t a diagonal of the CLUT
 %  image so either a horizontal or vertial gradient image can be used.
 %
 %  Typically this is used to either re-color a gray-scale image according to a
@@ -700,20 +702,22 @@
   ExceptionInfo
     *exception;
 
-  long
-    adjust,
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
   ResampleFilter
     **restrict resample_filter;
 
+  ssize_t
+    adjust,
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -728,7 +732,7 @@
   status=MagickTrue;
   progress=0;
   GetMagickPixelPacket(clut_image,&zero);
-  adjust=clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1;
+  adjust=(ssize_t) (clut_image->interpolate == IntegerInterpolatePixel ? 0 : 1);
   exception=(&image->exception);
   resample_filter=AcquireResampleFilterThreadSet(clut_image,
     UndefinedVirtualPixelMethod,MagickTrue,exception);
@@ -736,7 +740,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -744,7 +748,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -762,7 +766,7 @@
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     pixel=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         PROGRAMMERS WARNING:
@@ -935,16 +939,18 @@
   int
     sign;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  MagickOffsetType
+    progress;
+
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -955,7 +961,7 @@
       /*
         Contrast enhance colormap.
       */
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         Contrast(sign,&image->colormap[i].red,&image->colormap[i].green,
           &image->colormap[i].blue);
     }
@@ -969,9 +975,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -985,7 +991,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       Contrast(sign,&q->red,&q->green,&q->blue);
       q++;
@@ -1032,7 +1038,7 @@
 %      MagickBooleanType ContrastStretchImage(Image *image,
 %        const char *levels)
 %      MagickBooleanType ContrastStretchImageChannel(Image *image,
-%        const unsigned long channel,const double black_point,
+%        const size_t channel,const double black_point,
 %        const double white_point)
 %
 %  A description of each parameter follows:
@@ -1103,22 +1109,24 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     black,
     *histogram,
     *stretch_map,
     white;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate histogram and stretch map.
   */
@@ -1141,7 +1149,7 @@
   exception=(&image->exception);
   (void) ResetMagickMemory(histogram,0,(MaxMap+1)*sizeof(*histogram));
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -1149,7 +1157,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     if (status == MagickFalse)
@@ -1162,7 +1170,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     if (channel == DefaultChannels)
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         Quantum
           intensity;
@@ -1175,7 +1183,7 @@
         p++;
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if ((channel & RedChannel) != 0)
           histogram[ScaleQuantumToMap(GetRedPixelComponent(p))].red++;
@@ -1199,7 +1207,7 @@
   if ((channel & RedChannel) != 0)
     {
       intensity=0.0;
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         intensity+=histogram[i].red;
         if (intensity > black_point)
@@ -1207,7 +1215,7 @@
       }
       black.red=(MagickRealType) i;
       intensity=0.0;
-      for (i=(long) MaxMap; i != 0; i--)
+      for (i=(ssize_t) MaxMap; i != 0; i--)
       {
         intensity+=histogram[i].red;
         if (intensity > ((double) image->columns*image->rows-white_point))
@@ -1220,7 +1228,7 @@
   if ((channel & GreenChannel) != 0)
     {
       intensity=0.0;
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         intensity+=histogram[i].green;
         if (intensity > black_point)
@@ -1228,7 +1236,7 @@
       }
       black.green=(MagickRealType) i;
       intensity=0.0;
-      for (i=(long) MaxMap; i != 0; i--)
+      for (i=(ssize_t) MaxMap; i != 0; i--)
       {
         intensity+=histogram[i].green;
         if (intensity > ((double) image->columns*image->rows-white_point))
@@ -1241,7 +1249,7 @@
   if ((channel & BlueChannel) != 0)
     {
       intensity=0.0;
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         intensity+=histogram[i].blue;
         if (intensity > black_point)
@@ -1249,7 +1257,7 @@
       }
       black.blue=(MagickRealType) i;
       intensity=0.0;
-      for (i=(long) MaxMap; i != 0; i--)
+      for (i=(ssize_t) MaxMap; i != 0; i--)
       {
         intensity+=histogram[i].blue;
         if (intensity > ((double) image->columns*image->rows-white_point))
@@ -1262,7 +1270,7 @@
   if ((channel & OpacityChannel) != 0)
     {
       intensity=0.0;
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         intensity+=histogram[i].opacity;
         if (intensity > black_point)
@@ -1270,7 +1278,7 @@
       }
       black.opacity=(MagickRealType) i;
       intensity=0.0;
-      for (i=(long) MaxMap; i != 0; i--)
+      for (i=(ssize_t) MaxMap; i != 0; i--)
       {
         intensity+=histogram[i].opacity;
         if (intensity > ((double) image->columns*image->rows-white_point))
@@ -1283,7 +1291,7 @@
   if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace))
     {
       intensity=0.0;
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
       {
         intensity+=histogram[i].index;
         if (intensity > black_point)
@@ -1291,7 +1299,7 @@
       }
       black.index=(MagickRealType) i;
       intensity=0.0;
-      for (i=(long) MaxMap; i != 0; i--)
+      for (i=(ssize_t) MaxMap; i != 0; i--)
       {
         intensity+=histogram[i].index;
         if (intensity > ((double) image->columns*image->rows-white_point))
@@ -1307,14 +1315,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     if ((channel & RedChannel) != 0)
       {
-        if (i < (long) black.red)
+        if (i < (ssize_t) black.red)
           stretch_map[i].red=0.0;
         else
-          if (i > (long) white.red)
+          if (i > (ssize_t) white.red)
             stretch_map[i].red=(MagickRealType) QuantumRange;
           else
             if (black.red != white.red)
@@ -1323,10 +1331,10 @@
       }
     if ((channel & GreenChannel) != 0)
       {
-        if (i < (long) black.green)
+        if (i < (ssize_t) black.green)
           stretch_map[i].green=0.0;
         else
-          if (i > (long) white.green)
+          if (i > (ssize_t) white.green)
             stretch_map[i].green=(MagickRealType) QuantumRange;
           else
             if (black.green != white.green)
@@ -1336,10 +1344,10 @@
       }
     if ((channel & BlueChannel) != 0)
       {
-        if (i < (long) black.blue)
+        if (i < (ssize_t) black.blue)
           stretch_map[i].blue=0.0;
         else
-          if (i > (long) white.blue)
+          if (i > (ssize_t) white.blue)
             stretch_map[i].blue=(MagickRealType) QuantumRange;
           else
             if (black.blue != white.blue)
@@ -1349,10 +1357,10 @@
       }
     if ((channel & OpacityChannel) != 0)
       {
-        if (i < (long) black.opacity)
+        if (i < (ssize_t) black.opacity)
           stretch_map[i].opacity=0.0;
         else
-          if (i > (long) white.opacity)
+          if (i > (ssize_t) white.opacity)
             stretch_map[i].opacity=(MagickRealType) QuantumRange;
           else
             if (black.opacity != white.opacity)
@@ -1363,10 +1371,10 @@
     if (((channel & IndexChannel) != 0) &&
         (image->colorspace == CMYKColorspace))
       {
-        if (i < (long) black.index)
+        if (i < (ssize_t) black.index)
           stretch_map[i].index=0.0;
         else
-          if (i > (long) white.index)
+          if (i > (ssize_t) white.index)
             stretch_map[i].index=(MagickRealType) QuantumRange;
           else
             if (black.index != white.index)
@@ -1389,7 +1397,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((channel & RedChannel) != 0)
           {
@@ -1425,12 +1433,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1445,7 +1453,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
@@ -1562,16 +1570,18 @@
   Image
     *enhance_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
+  ssize_t
+    y;
+
   /*
     Initialize enhanced image attributes.
   */
@@ -1604,12 +1614,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1628,7 +1638,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickPixelPacket
         aggregate;
@@ -1733,13 +1743,12 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     black,
     *equalize_map,
@@ -1748,9 +1757,12 @@
     *map,
     white;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate and initialize histogram arrays.
   */
@@ -1781,7 +1793,7 @@
   */
   (void) ResetMagickMemory(histogram,0,(MaxMap+1)*sizeof(*histogram));
   exception=(&image->exception);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1789,14 +1801,14 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         histogram[ScaleQuantumToMap(GetRedPixelComponent(p))].red++;
@@ -1816,7 +1828,7 @@
     Integrate the histogram to get the equalization map.
   */
   (void) ResetMagickMemory(&intensity,0,sizeof(intensity));
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     if ((channel & RedChannel) != 0)
       intensity.red+=histogram[i].red;
@@ -1837,7 +1849,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     if (((channel & RedChannel) != 0) && (white.red != black.red))
       equalize_map[i].red=(MagickRealType) ScaleMapToQuantum((MagickRealType)
@@ -1868,7 +1880,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if (((channel & RedChannel) != 0) && (white.red != black.red))
           image->colormap[i].red=ClampToQuantum(equalize_map[
@@ -1895,12 +1907,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1915,7 +1927,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (((channel & RedChannel) != 0) && (white.red != black.red))
         q->red=ClampToQuantum(equalize_map[ScaleQuantumToMap(q->red)].red);
@@ -2040,19 +2052,21 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   Quantum
     *gamma_map;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate and initialize gamma maps.
   */
@@ -2071,7 +2085,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-    for (i=0; i <= (long) MaxMap; i++)
+    for (i=0; i <= (ssize_t) MaxMap; i++)
       gamma_map[i]=ClampToQuantum((MagickRealType) ScaleMapToQuantum((
         MagickRealType) (MaxMap*pow((double) i/MaxMap,1.0/gamma))));
   if (image->storage_class == PseudoClass)
@@ -2082,7 +2096,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((channel & RedChannel) != 0)
           image->colormap[i].red=gamma_map[
@@ -2115,12 +2129,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2135,7 +2149,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (channel == DefaultChannels)
         {
@@ -2164,7 +2178,7 @@
     }
     if (((channel & IndexChannel) != 0) &&
         (image->colorspace == CMYKColorspace))
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
         indexes[x]=gamma_map[ScaleQuantumToMap(indexes[x])];
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       status=MagickFalse;
@@ -2257,13 +2271,12 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
@@ -2275,6 +2288,9 @@
     length,
     level;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -2303,7 +2319,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       offset;
@@ -2321,7 +2337,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -2343,7 +2359,7 @@
     pixel3=zero;
     pixel4=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       point.x=QuantumScale*(level-1.0)*q->red;
       point.y=QuantumScale*(level-1.0)*q->green;
@@ -2553,19 +2569,21 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  MagickOffsetType
+    progress;
+
+  register ssize_t
     i;
 
   register double
     scale;
 
+  ssize_t
+    y;
+
   /*
     Allocate and initialize levels map.
   */
@@ -2578,7 +2596,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       /*
         Level colormap.
@@ -2602,12 +2620,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2622,7 +2640,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=LevelQuantum(q->red);
@@ -2632,7 +2650,8 @@
         q->blue=LevelQuantum(q->blue);
       if (((channel & OpacityChannel) != 0) &&
           (image->matte == MagickTrue))
-        q->opacity=QuantumRange-LevelQuantum(QuantumRange-q->opacity);
+        q->opacity=(Quantum) (QuantumRange-LevelQuantum(QuantumRange-
+          q->opacity));
       if (((channel & IndexChannel) != 0) &&
           (image->colorspace == CMYKColorspace))
         indexes[x]=LevelQuantum(indexes[x]);
@@ -2714,16 +2733,18 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  MagickOffsetType
+    progress;
+
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate and initialize levels map.
   */
@@ -2735,7 +2756,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-    for (i=0; i < (long) image->colors; i++)
+    for (i=0; i < (ssize_t) image->colors; i++)
     {
       /*
         Level colormap.
@@ -2759,12 +2780,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2779,7 +2800,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=LevelizeValue(q->red);
@@ -2964,7 +2985,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     black,
     white,
     y;
@@ -2994,18 +3015,18 @@
   */
   (void) ResetMagickMemory(histogram,0,(MaxMap+1)*sizeof(*histogram));
   exception=(&image->exception);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=(long) image->columns-1; x >= 0; x--)
+    for (x=(ssize_t) image->columns-1; x >= 0; x--)
     {
       histogram[ScaleQuantumToMap(PixelIntensityToQuantum(p))]++;
       p++;
@@ -3016,14 +3037,14 @@
   */
   number_pixels=(MagickSizeType) image->columns*image->rows;
   intensity=0.0;
-  for (black=0; black < (long) MaxMap; black++)
+  for (black=0; black < (ssize_t) MaxMap; black++)
   {
     intensity+=histogram[black];
     if (intensity >= black_point)
       break;
   }
   intensity=0.0;
-  for (white=(long) MaxMap; white != 0; white--)
+  for (white=(ssize_t) MaxMap; white != 0; white--)
   {
     intensity+=histogram[white];
     if (intensity >= white_point)
@@ -3165,19 +3186,21 @@
   GeometryInfo
     geometry_info;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickStatusType
     flags;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Initialize modulate table.
   */
@@ -3208,7 +3231,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
         switch (colorspace)
         {
           case HSBColorspace:
@@ -3245,9 +3268,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3261,7 +3284,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       switch (colorspace)
       {
@@ -3358,16 +3381,18 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  MagickOffsetType
+    progress;
+
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -3380,7 +3405,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if (grayscale != MagickFalse)
           if ((image->colormap[i].red != image->colormap[i].green) ||
@@ -3409,7 +3434,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -3417,7 +3442,7 @@
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -3433,7 +3458,7 @@
             continue;
           }
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           if ((q->red != q->green) || (q->green != q->blue))
             {
@@ -3479,12 +3504,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3499,7 +3524,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=(Quantum) QuantumRange-q->red;
@@ -3659,19 +3684,21 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickRealType
     *sigmoidal_map;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate and initialize sigmoidal maps.
   */
@@ -3688,7 +3715,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     if (sharpen != MagickFalse)
       {
@@ -3718,7 +3745,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((channel & RedChannel) != 0)
           image->colormap[i].red=ClampToQuantum(sigmoidal_map[
@@ -3744,12 +3771,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3764,7 +3791,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ClampToQuantum(sigmoidal_map[ScaleQuantumToMap(q->red)]);
diff --git a/magick/exception.c b/magick/exception.c
index 666ee34..ae5e851 100644
--- a/magick/exception.c
+++ b/magick/exception.c
@@ -915,7 +915,7 @@
 %  The format of the ThrowMagickException method is:
 %
 %      MagickBooleanType ThrowFileException(ExceptionInfo *exception,
-%        const char *module,const char *function,const unsigned long line,
+%        const char *module,const char *function,const size_t line,
 %        const ExceptionType severity,const char *tag,const char *format,...)
 %
 %  A description of each parameter follows:
@@ -938,7 +938,7 @@
 
 MagickExport MagickBooleanType ThrowMagickExceptionList(
   ExceptionInfo *exception,const char *module,const char *function,
-  const unsigned long line,const ExceptionType severity,const char *tag,
+  const size_t line,const ExceptionType severity,const char *tag,
   const char *format,va_list operands)
 {
   char
@@ -988,7 +988,7 @@
 }
 
 MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception,
-  const char *module,const char *function,const unsigned long line,
+  const char *module,const char *function,const size_t line,
   const ExceptionType severity,const char *tag,const char *format,...)
 {
   MagickBooleanType
diff --git a/magick/exception.h b/magick/exception.h
index db61aa0..d3b3275 100644
--- a/magick/exception.h
+++ b/magick/exception.h
@@ -120,7 +120,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -153,10 +153,10 @@
   ThrowException(ExceptionInfo *,const ExceptionType,const char *,
     const char *),
   ThrowMagickException(ExceptionInfo *,const char *,const char *,
-    const unsigned long,const ExceptionType,const char *,const char *,...)
+    const size_t,const ExceptionType,const char *,const char *,...)
     magick_attribute((format (printf,7,8))),
   ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *,
-    const unsigned long,const ExceptionType,const char *,const char *,va_list)
+    const size_t,const ExceptionType,const char *,const char *,va_list)
     magick_attribute((format (printf,7,0)));
 
 extern MagickExport void
diff --git a/magick/feature.c b/magick/feature.c
index 71b3177..58e1d86 100644
--- a/magick/feature.c
+++ b/magick/feature.c
@@ -116,7 +116,7 @@
 %  The format of the GetImageChannelFeatures method is:
 %
 %      ChannelFeatures *GetImageChannelFeatures(const Image *image,
-%        const unsigned long distance,ExceptionInfo *exception)
+%        const size_t distance,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -128,7 +128,7 @@
 %
 */
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
@@ -136,7 +136,7 @@
 }
 
 MagickExport ChannelFeatures *GetImageChannelFeatures(const Image *image,
-  const unsigned long distance,ExceptionInfo *exception)
+  const size_t distance,ExceptionInfo *exception)
 {
   typedef struct _ChannelStatistics
   {
@@ -171,20 +171,20 @@
     gray,
     *grays;
 
-  long
+  ssize_t
     y,
     z;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   size_t
     length;
 
-  unsigned long
+  size_t
     number_grays;
 
   assert(image != (Image *) NULL);
@@ -212,7 +212,7 @@
         ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
       return(channel_features);
     }
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     grays[i].red=(~0UL);
     grays[i].green=(~0UL);
@@ -225,7 +225,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -233,7 +233,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     if (status == MagickFalse)
@@ -245,7 +245,7 @@
         continue;
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       grays[ScaleQuantumToMap(p->red)].red=ScaleQuantumToMap(p->red);
       grays[ScaleQuantumToMap(p->green)].green=ScaleQuantumToMap(p->green);
@@ -268,7 +268,7 @@
       return(channel_features);
     }
   (void) ResetMagickMemory(&gray,0,sizeof(gray));
-  for (i=0; i <= (long) MaxMap; i++)
+  for (i=0; i <= (ssize_t) MaxMap; i++)
   {
     if (grays[i].red != ~0UL)
       grays[gray.red++].red=grays[i].red;
@@ -316,7 +316,7 @@
     {
       if (Q != (ChannelStatistics **) NULL)
         {
-          for (i=0; i < (long) number_grays; i++)
+          for (i=0; i < (ssize_t) number_grays; i++)
             Q[i]=(ChannelStatistics *) RelinquishMagickMemory(Q[i]);
           Q=(ChannelStatistics **) RelinquishMagickMemory(Q);
         }
@@ -330,7 +330,7 @@
         density_x=(ChannelStatistics *) RelinquishMagickMemory(density_x);
       if (cooccurrence != (ChannelStatistics **) NULL)
         {
-          for (i=0; i < (long) number_grays; i++)
+          for (i=0; i < (ssize_t) number_grays; i++)
             cooccurrence[i]=(ChannelStatistics *)
               RelinquishMagickMemory(cooccurrence[i]);
           cooccurrence=(ChannelStatistics **) RelinquishMagickMemory(
@@ -357,7 +357,7 @@
   (void) ResetMagickMemory(&entropy_xy2,0,sizeof(entropy_xy2));
   (void) ResetMagickMemory(&entropy_y,0,sizeof(entropy_y));
   (void) ResetMagickMemory(&variance,0,sizeof(variance));
-  for (i=0; i < (long) number_grays; i++)
+  for (i=0; i < (ssize_t) number_grays; i++)
   {
     cooccurrence[i]=(ChannelStatistics *) AcquireQuantumMemory(number_grays,
       sizeof(**cooccurrence));
@@ -369,7 +369,7 @@
       sizeof(**cooccurrence));
     (void) ResetMagickMemory(Q[i],0,number_grays*sizeof(**Q));
   }
-  if (i < (long) number_grays)
+  if (i < (ssize_t) number_grays)
     {
       for (i--; i >= 0; i--)
       {
@@ -400,9 +400,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    long
+    ssize_t
       u,
       v;
 
@@ -412,7 +412,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     ssize_t
@@ -420,7 +420,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-(long) distance,y,image->columns+
+    p=GetCacheViewVirtualPixels(image_view,-(ssize_t) distance,y,image->columns+
       2*distance,distance+1,exception);
     if (p == (const PixelPacket *) NULL)
       {
@@ -430,7 +430,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     p+=distance;
     indexes+=distance;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       for (i=0; i < 4; i++)
       {
@@ -524,7 +524,7 @@
   image_view=DestroyCacheView(image_view);
   if (status == MagickFalse)
     {
-      for (i=0; i < (long) number_grays; i++)
+      for (i=0; i < (ssize_t) number_grays; i++)
         cooccurrence[i]=(ChannelStatistics *)
           RelinquishMagickMemory(cooccurrence[i]);
       cooccurrence=(ChannelStatistics **) RelinquishMagickMemory(cooccurrence);
@@ -581,12 +581,12 @@
         break;
       }
     }
-    for (y=0; y < (long) number_grays; y++)
+    for (y=0; y < (ssize_t) number_grays; y++)
     {
-      register long
+      register ssize_t
         x;
 
-      for (x=0; x < (long) number_grays; x++)
+      for (x=0; x < (ssize_t) number_grays; x++)
       {
         cooccurrence[x][y].direction[i].red/=normalize;
         cooccurrence[x][y].direction[i].green/=normalize;
@@ -606,15 +606,15 @@
 #endif
   for (i=0; i < 4; i++)
   {
-    register long
+    register ssize_t
       y;
 
-    for (y=0; y < (long) number_grays; y++)
+    for (y=0; y < (ssize_t) number_grays; y++)
     {
-      register long
+      register ssize_t
         x;
 
-      for (x=0; x < (long) number_grays; x++)
+      for (x=0; x < (ssize_t) number_grays; x++)
       {
         /*
           Angular second moment:  measure of homogeneity of the image.
@@ -790,10 +790,10 @@
 #endif
   for (i=0; i < 4; i++)
   {
-    register long
+    register ssize_t
       x;
 
-    for (x=2; x < (long) (2*number_grays); x++)
+    for (x=2; x < (ssize_t) (2*number_grays); x++)
     {
       /*
         Sum average.
@@ -865,15 +865,15 @@
 #endif
   for (i=0; i < 4; i++)
   {
-    register long
+    register ssize_t
       y;
 
-    for (y=0; y < (long) number_grays; y++)
+    for (y=0; y < (ssize_t) number_grays; y++)
     {
-      register long
+      register ssize_t
         x;
 
-      for (x=0; x < (long) number_grays; x++)
+      for (x=0; x < (ssize_t) number_grays; x++)
       {
         /*
           Sum of Squares: Variance
@@ -985,10 +985,10 @@
 #endif
   for (i=0; i < 4; i++)
   {
-    register long
+    register ssize_t
       x;
 
-    for (x=0; x < (long) number_grays; x++)
+    for (x=0; x < (ssize_t) number_grays; x++)
     {
       /*
         Difference variance.
@@ -1136,21 +1136,21 @@
 #endif
   for (i=0; i < 4; i++)
   {
-    for (z=0; z < (long) number_grays; z++)
+    for (z=0; z < (ssize_t) number_grays; z++)
     {
-      register long
+      register ssize_t
         y;
 
       ChannelStatistics
         pixel;
 
       (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
-      for (y=0; y < (long) number_grays; y++)
+      for (y=0; y < (ssize_t) number_grays; y++)
       {
-        register long
+        register ssize_t
           x;
 
-        for (x=0; x < (long) number_grays; x++)
+        for (x=0; x < (ssize_t) number_grays; x++)
         {
           /*
             Contrast:  amount of local variations present in an image.
@@ -1221,13 +1221,13 @@
     Relinquish resources.
   */
   sum=(ChannelStatistics *) RelinquishMagickMemory(sum);
-  for (i=0; i < (long) number_grays; i++)
+  for (i=0; i < (ssize_t) number_grays; i++)
     Q[i]=(ChannelStatistics *) RelinquishMagickMemory(Q[i]);
   Q=(ChannelStatistics **) RelinquishMagickMemory(Q);
   density_y=(ChannelStatistics *) RelinquishMagickMemory(density_y);
   density_xy=(ChannelStatistics *) RelinquishMagickMemory(density_xy);
   density_x=(ChannelStatistics *) RelinquishMagickMemory(density_x);
-  for (i=0; i < (long) number_grays; i++)
+  for (i=0; i < (ssize_t) number_grays; i++)
     cooccurrence[i]=(ChannelStatistics *)
       RelinquishMagickMemory(cooccurrence[i]);
   cooccurrence=(ChannelStatistics **) RelinquishMagickMemory(cooccurrence);
diff --git a/magick/feature.h b/magick/feature.h
index d647fa5..5e138ad 100644
--- a/magick/feature.h
+++ b/magick/feature.h
@@ -45,7 +45,7 @@
 } ChannelFeatures;
 
 extern MagickExport ChannelFeatures
-  *GetImageChannelFeatures(const Image *,const unsigned long,ExceptionInfo *);
+  *GetImageChannelFeatures(const Image *,const size_t,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
diff --git a/magick/fourier.c b/magick/fourier.c
index 3723e97..063c075 100644
--- a/magick/fourier.c
+++ b/magick/fourier.c
@@ -77,11 +77,11 @@
   MagickBooleanType
     modulus;
 
-  unsigned long
+  size_t
     width,
     height;
 
-  long
+  ssize_t
     center;
 } FourierInfo;
 
@@ -118,19 +118,19 @@
 
 #if defined(MAGICKCORE_FFTW_DELEGATE)
 
-static MagickBooleanType RollFourier(const unsigned long width,
-  const unsigned long height,const long x_offset,const long y_offset,
+static MagickBooleanType RollFourier(const size_t width,
+  const size_t height,const ssize_t x_offset,const ssize_t y_offset,
   double *fourier)
 {
   double
     *roll;
 
-  long
+  ssize_t
     u,
     v,
     y;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -141,19 +141,19 @@
   if (roll == (double *) NULL)
     return(MagickFalse);
   i=0L;
-  for (y=0L; y < (long) height; y++)
+  for (y=0L; y < (ssize_t) height; y++)
   {
     if (y_offset < 0L)
-      v=((y+y_offset) < 0L) ? y+y_offset+(long) height : y+y_offset;
+      v=((y+y_offset) < 0L) ? y+y_offset+(ssize_t) height : y+y_offset;
     else
-      v=((y+y_offset) > ((long) height-1L)) ? y+y_offset-(long) height :
+      v=((y+y_offset) > ((ssize_t) height-1L)) ? y+y_offset-(ssize_t) height :
         y+y_offset;
-    for (x=0L; x < (long) width; x++)
+    for (x=0L; x < (ssize_t) width; x++)
     {
       if (x_offset < 0L)
-        u=((x+x_offset) < 0L) ? x+x_offset+(long) width : x+x_offset;
+        u=((x+x_offset) < 0L) ? x+x_offset+(ssize_t) width : x+x_offset;
       else
-        u=((x+x_offset) > ((long) width-1L)) ? x+x_offset-(long) width :
+        u=((x+x_offset) > ((ssize_t) width-1L)) ? x+x_offset-(ssize_t) width :
           x+x_offset;
       roll[v*width+u]=fourier[i++];
    }
@@ -163,48 +163,48 @@
   return(MagickTrue);
 }
 
-static MagickBooleanType ForwardQuadrantSwap(const unsigned long width,
-  const unsigned long height,double *source,double *destination)
+static MagickBooleanType ForwardQuadrantSwap(const size_t width,
+  const size_t height,double *source,double *destination)
 {
-  long
+  ssize_t
     center,
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   /*
     Swap quadrants.
   */
-  center=(long) floor((double) width/2L)+1L;
-  status=RollFourier((unsigned long) center,height,0L,(long) height/2L,source);
+  center=(ssize_t) floor((double) width/2L)+1L;
+  status=RollFourier((size_t) center,height,0L,(ssize_t) height/2L,source);
   if (status == MagickFalse)
     return(MagickFalse);
-  for (y=0L; y < (long) height; y++)
-    for (x=0L; x < (long) (width/2L-1L); x++)
+  for (y=0L; y < (ssize_t) height; y++)
+    for (x=0L; x < (ssize_t) (width/2L-1L); x++)
       destination[width*y+x+width/2L]=source[center*y+x];
-  for (y=1; y < (long) height; y++)
-    for (x=0L; x < (long) (width/2L-1L); x++)
+  for (y=1; y < (ssize_t) height; y++)
+    for (x=0L; x < (ssize_t) (width/2L-1L); x++)
       destination[width*(height-y)+width/2L-x-1L]=source[center*y+x+1L];
-  for (x=0L; x < (long) (width/2L); x++)
+  for (x=0L; x < (ssize_t) (width/2L); x++)
     destination[-x+width/2L-1L]=destination[x+width/2L+1L];
   return(MagickTrue);
 }
 
-static void CorrectPhaseLHS(const unsigned long width,
-  const unsigned long height,double *fourier)
+static void CorrectPhaseLHS(const size_t width,
+  const size_t height,double *fourier)
 {
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
-  for (y=0L; y < (long) height; y++)
-    for (x=0L; x < (long) (width/2L); x++)
+  for (y=0L; y < (ssize_t) height; y++)
+    for (x=0L; x < (ssize_t) (width/2L); x++)
       fourier[y*width+x]*=(-1.0);
 }
 
@@ -223,7 +223,7 @@
     *magnitude_image,
     *phase_image;
 
-  long
+  ssize_t
     i,
     y;
 
@@ -233,7 +233,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -274,8 +274,8 @@
   if (fourier_info->modulus != MagickFalse)
     {
       i=0L;
-      for (y=0L; y < (long) fourier_info->height; y++)
-        for (x=0L; x < (long) fourier_info->width; x++)
+      for (y=0L; y < (ssize_t) fourier_info->height; y++)
+        for (x=0L; x < (ssize_t) fourier_info->width; x++)
         {
           phase_source[i]/=(2.0*MagickPI);
           phase_source[i]+=0.5;
@@ -285,14 +285,14 @@
   magnitude_view=AcquireCacheView(magnitude_image);
   phase_view=AcquireCacheView(phase_image);
   i=0L;
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     q=GetCacheViewAuthenticPixels(magnitude_view,0L,y,fourier_info->height,1UL,
       exception);
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(magnitude_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -338,14 +338,14 @@
       break;
   }
   i=0L;
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     q=GetCacheViewAuthenticPixels(phase_view,0L,y,fourier_info->height,1UL,
       exception);
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(phase_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -413,7 +413,7 @@
   fftw_plan
     fftw_r2c_plan;
 
-  long
+  ssize_t
     y;
 
   register const IndexPacket
@@ -422,7 +422,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -441,14 +441,14 @@
     sizeof(*source));
   i=0L;
   image_view=AcquireCacheView(image);
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0L,y,fourier_info->width,1UL,
       exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -511,8 +511,8 @@
   */
   n=(double) fourier_info->width*(double) fourier_info->width;
   i=0L;
-  for (y=0L; y < (long) fourier_info->height; y++)
-    for (x=0L; x < (long) fourier_info->center; x++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
+    for (x=0L; x < (ssize_t) fourier_info->center; x++)
     {
 #if defined(MAGICKCORE_HAVE_COMPLEX_H)
       fourier[i]/=n;
@@ -527,16 +527,16 @@
   */
   i=0L;
   if (fourier_info->modulus != MagickFalse)
-    for (y=0L; y < (long) fourier_info->height; y++)
-      for (x=0L; x < (long) fourier_info->center; x++)
+    for (y=0L; y < (ssize_t) fourier_info->height; y++)
+      for (x=0L; x < (ssize_t) fourier_info->center; x++)
       {
         magnitude[i]=cabs(fourier[i]);
         phase[i]=carg(fourier[i]);
         i++;
       }
   else
-    for (y=0L; y < (long) fourier_info->height; y++)
-      for (x=0L; x < (long) fourier_info->center; x++)
+    for (y=0L; y < (ssize_t) fourier_info->height; y++)
+      for (x=0L; x < (ssize_t) fourier_info->center; x++)
       {
         magnitude[i]=creal(fourier[i]);
         phase[i]=cimag(fourier[i]);
@@ -574,7 +574,7 @@
       fourier_info.width=(extent & 0x01) == 1 ? extent+1UL : extent;
     }
   fourier_info.height=fourier_info.width;
-  fourier_info.center=(long) floor((double) fourier_info.width/2.0)+1L;
+  fourier_info.center=(ssize_t) floor((double) fourier_info.width/2.0)+1L;
   fourier_info.channel=channel;
   fourier_info.modulus=modulus;
   magnitude=(double *) AcquireQuantumMemory((size_t) fourier_info.height,
@@ -632,7 +632,7 @@
     Image
       *magnitude_image;
 
-    unsigned long
+    size_t
       extent,
       width;
 
@@ -660,7 +660,7 @@
               is_gray,
               status;
 
-            register long
+            register ssize_t
               i;
 
             phase_image->storage_class=DirectClass;
@@ -769,28 +769,28 @@
 */
 
 #if defined(MAGICKCORE_FFTW_DELEGATE)
-static MagickBooleanType InverseQuadrantSwap(const unsigned long width,
-  const unsigned long height,const double *source,double *destination)
+static MagickBooleanType InverseQuadrantSwap(const size_t width,
+  const size_t height,const double *source,double *destination)
 {
-  long
+  ssize_t
     center,
     y;
 
-  register long
+  register ssize_t
     x;
 
   /*
     Swap quadrants.
   */
-  center=(long) floor((double) width/2.0)+1L;
-  for (y=1L; y < (long) height; y++)
-    for (x=0L; x < (long) (width/2L+1L); x++)
+  center=(ssize_t) floor((double) width/2.0)+1L;
+  for (y=1L; y < (ssize_t) height; y++)
+    for (x=0L; x < (ssize_t) (width/2L+1L); x++)
       destination[center*(height-y)-x+width/2L]=source[y*width+x];
-  for (y=0L; y < (long) height; y++)
+  for (y=0L; y < (ssize_t) height; y++)
     destination[center*y]=source[y*width+width/2L];
   for (x=0L; x < center; x++)
     destination[x]=source[center-x-1L];
-  return(RollFourier(center,height,0L,(long) height/-2L,destination));
+  return(RollFourier(center,height,0L,(ssize_t) height/-2L,destination));
 }
 
 static MagickBooleanType InverseFourier(FourierInfo *fourier_info,
@@ -807,7 +807,7 @@
     *magnitude_source,
     *phase_source;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -819,7 +819,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -847,14 +847,14 @@
     }
   i=0L;
   magnitude_view=AcquireCacheView(magnitude_image);
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     p=GetCacheViewVirtualPixels(magnitude_view,0L,y,fourier_info->width,1UL,
       exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(magnitude_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -896,14 +896,14 @@
   }
   i=0L;
   phase_view=AcquireCacheView(phase_image);
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     p=GetCacheViewVirtualPixels(phase_view,0,y,fourier_info->width,1,
       exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(phase_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -946,8 +946,8 @@
   if (fourier_info->modulus != MagickFalse)
     {
       i=0L;
-      for (y=0L; y < (long) fourier_info->height; y++)
-        for (x=0L; x < (long) fourier_info->width; x++)
+      for (y=0L; y < (ssize_t) fourier_info->height; y++)
+        for (x=0L; x < (ssize_t) fourier_info->width; x++)
         {
           phase_source[i]-=0.5;
           phase_source[i]*=(2.0*MagickPI);
@@ -990,8 +990,8 @@
   */
   i=0L;
   if (fourier_info->modulus != MagickFalse)
-    for (y=0L; y < (long) fourier_info->height; y++)
-       for (x=0L; x < (long) fourier_info->center; x++)
+    for (y=0L; y < (ssize_t) fourier_info->height; y++)
+       for (x=0L; x < (ssize_t) fourier_info->center; x++)
        {
 #if defined(MAGICKCORE_HAVE_COMPLEX_H)
          fourier[i]=magnitude[i]*cos(phase[i])+I*magnitude[i]*sin(phase[i]);
@@ -1002,8 +1002,8 @@
          i++;
       }
   else
-    for (y=0L; y < (long) fourier_info->height; y++)
-      for (x=0L; x < (long) fourier_info->center; x++)
+    for (y=0L; y < (ssize_t) fourier_info->height; y++)
+      for (x=0L; x < (ssize_t) fourier_info->center; x++)
       {
 #if defined(MAGICKCORE_HAVE_COMPLEX_H)
         fourier[i]=magnitude[i]+I*phase[i];
@@ -1030,13 +1030,13 @@
   fftw_plan
     fftw_c2r_plan;
 
-  long
+  ssize_t
     y;
 
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1060,14 +1060,14 @@
   fftw_destroy_plan(fftw_c2r_plan);
   i=0L;
   image_view=AcquireCacheView(image);
-  for (y=0L; y < (long) fourier_info->height; y++)
+  for (y=0L; y < (ssize_t) fourier_info->height; y++)
   {
     q=GetCacheViewAuthenticPixels(image_view,0L,y,fourier_info->width,1UL,
       exception);
     if (q == (PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0L; x < (long) fourier_info->width; x++)
+    for (x=0L; x < (ssize_t) fourier_info->width; x++)
     {
       switch (fourier_info->channel)
       {
@@ -1147,7 +1147,7 @@
       fourier_info.width=(extent & 0x01) == 1 ? extent+1UL : extent;
     }
   fourier_info.height=fourier_info.width;
-  fourier_info.center=(long) floor((double) fourier_info.width/2.0)+1L;
+  fourier_info.center=(ssize_t) floor((double) fourier_info.width/2.0)+1L;
   fourier_info.channel=channel;
   fourier_info.modulus=modulus;
   magnitude=(double *) AcquireQuantumMemory((size_t) fourier_info.height,
@@ -1226,7 +1226,7 @@
           is_gray,
           status;
 
-        register long
+        register ssize_t
           i;
 
         status=MagickTrue;
diff --git a/magick/fx-private.h b/magick/fx-private.h
index 036c633..5f8577a 100644
--- a/magick/fx-private.h
+++ b/magick/fx-private.h
@@ -31,7 +31,7 @@
 
 extern MagickExport MagickBooleanType
   FxEvaluateExpression(FxInfo *,MagickRealType *,ExceptionInfo *),
-  FxEvaluateChannelExpression(FxInfo *,const ChannelType,const long,const long,
+  FxEvaluateChannelExpression(FxInfo *,const ChannelType,const ssize_t,const ssize_t,
     MagickRealType *,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/fx.c b/magick/fx.c
index a1756d0..91930b3 100644
--- a/magick/fx.c
+++ b/magick/fx.c
@@ -158,7 +158,7 @@
   FxInfo
     *fx_info;
 
-  register long
+  register ssize_t
     i;
 
   fx_info=(FxInfo *) AcquireAlignedMemory(1,sizeof(*fx_info));
@@ -176,7 +176,7 @@
     GetImageListLength(fx_info->images),sizeof(*fx_info->resample_filter));
   if (fx_info->resample_filter == (ResampleFilter **) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
-  for (i=0; i < (long) GetImageListLength(fx_info->images); i++)
+  for (i=0; i < (ssize_t) GetImageListLength(fx_info->images); i++)
   {
     fx_info->resample_filter[i]=AcquireResampleFilter(GetImageFromList(
       fx_info->images,i),fx_info->exception);
@@ -293,19 +293,21 @@
   Image
     *noise_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickRealType
     attenuate;
 
   RandomInfo
     **restrict random_info;
 
+  ssize_t
+    y;
+
   /*
     Initialize noise image attributes.
   */
@@ -339,7 +341,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -353,7 +355,7 @@
     register IndexPacket
       *restrict noise_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -373,7 +375,7 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     noise_indexes=GetCacheViewAuthenticIndexQueue(noise_view);
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ClampToQuantum(GenerateDifferentialNoise(random_info[id],
@@ -459,13 +461,15 @@
   Image
     *shift_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   /*
     Allocate blue shift image.
   */
@@ -495,7 +499,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -509,7 +513,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -525,7 +529,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       quantum=GetRedPixelComponent(p);
       if (p->green < quantum)
@@ -684,19 +688,21 @@
   Image
     *colorize_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     pixel;
 
   MagickStatusType
     flags;
 
+  ssize_t
+    y;
+
   /*
     Allocate colorized image.
   */
@@ -742,7 +748,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -750,7 +756,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -766,7 +772,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->red=(Quantum) ((p->red*(100.0-pixel.red)+
         colorize.red*pixel.red)/100.0);
@@ -858,18 +864,20 @@
   Image
     *color_image;
 
-  long
-    progress,
-    u,
-    v,
-    y;
-
   MagickBooleanType
     status;
 
-  register long
+  MagickOffsetType
+    progress;
+
+  register ssize_t
     i;
 
+  ssize_t
+    u,
+    v,
+    y;
+
   /*
     Create color matrix.
   */
@@ -880,8 +888,8 @@
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   i=0;
-  for (v=0; v < (long) color_matrix->height; v++)
-    for (u=0; u < (long) color_matrix->width; u++)
+  for (v=0; v < (ssize_t) color_matrix->height; v++)
+    for (u=0; u < (ssize_t) color_matrix->width; u++)
     {
       if ((v < 6) && (u < 6))
         ColorMatrix[v][u]=color_matrix->values[i];
@@ -933,7 +941,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickRealType
       pixel;
@@ -944,7 +952,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register IndexPacket
@@ -965,16 +973,16 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     color_indexes=GetCacheViewAuthenticIndexQueue(color_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      register long
+      register ssize_t
         v;
 
-      unsigned long
+      size_t
         height;
 
       height=color_matrix->height > 6 ? 6UL : color_matrix->height;
-      for (v=0; v < (long) height; v++)
+      for (v=0; v < (ssize_t) height; v++)
       {
         pixel=ColorMatrix[v][0]*p->red+ColorMatrix[v][1]*p->green+
           ColorMatrix[v][2]*p->blue;
@@ -1052,14 +1060,14 @@
 */
 MagickExport FxInfo *DestroyFxInfo(FxInfo *fx_info)
 {
-  register long
+  register ssize_t
     i;
 
   fx_info->exception=DestroyExceptionInfo(fx_info->exception);
   fx_info->expression=DestroyString(fx_info->expression);
   fx_info->symbols=DestroySplayTree(fx_info->symbols);
   fx_info->colors=DestroySplayTree(fx_info->colors);
-  for (i=0; i < (long) GetImageListLength(fx_info->images); i++)
+  for (i=0; i < (ssize_t) GetImageListLength(fx_info->images); i++)
     fx_info->resample_filter[i]=DestroyResampleFilter(
       fx_info->resample_filter[i]);
   fx_info->resample_filter=(ResampleFilter **) RelinquishMagickMemory(
@@ -1086,7 +1094,7 @@
 %  The format of the FxEvaluateExpression method is:
 %
 %      MagickRealType FxEvaluateChannelExpression(FxInfo *fx_info,
-%        const ChannelType channel,const long x,const long y,
+%        const ChannelType channel,const ssize_t x,const ssize_t y,
 %        MagickRealType *alpha,Exceptioninfo *exception)
 %      MagickRealType FxEvaluateExpression(FxInfo *fx_info,
 %        MagickRealType *alpha,Exceptioninfo *exception)
@@ -1146,14 +1154,14 @@
       default: break;
     }
   (void) FormatMagickString(key,MaxTextExtent,"%p.%ld.%s",(void *) image,
-    (long) channel,symbol);
+    (ssize_t) channel,symbol);
   value=(const char *) GetValueFromSplayTree(fx_info->symbols,key);
   if (value != (const char *) NULL)
     return(QuantumScale*StringToDouble(value));
   (void) DeleteNodeFromSplayTree(fx_info->symbols,key);
   if (LocaleNCompare(symbol,"depth",5) == 0)
     {
-      unsigned long
+      size_t
         depth;
 
       depth=GetImageChannelDepth(image,channel,exception);
@@ -1224,11 +1232,11 @@
 }
 
 static MagickRealType
-  FxEvaluateSubexpression(FxInfo *,const ChannelType,const long,const long,
+  FxEvaluateSubexpression(FxInfo *,const ChannelType,const ssize_t,const ssize_t,
     const char *,MagickRealType *,ExceptionInfo *);
 
 static inline MagickRealType FxMax(FxInfo *fx_info,const ChannelType channel,
-  const long x,const long y,const char *expression,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const char *expression,ExceptionInfo *exception)
 {
   MagickRealType
     alpha,
@@ -1239,7 +1247,7 @@
 }
 
 static inline MagickRealType FxMin(FxInfo *fx_info,ChannelType channel,
-  const long x,const long y,const char *expression,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const char *expression,ExceptionInfo *exception)
 {
   MagickRealType
     alpha,
@@ -1255,7 +1263,7 @@
   const char
     *subexpression;
 
-  register long
+  register ssize_t
     level;
 
   level=0;
@@ -1277,7 +1285,7 @@
 }
 
 static MagickRealType FxGetSymbol(FxInfo *fx_info,const ChannelType channel,
-  const long x,const long y,const char *expression,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,const char *expression,ExceptionInfo *exception)
 {
   char
     *q,
@@ -1301,13 +1309,13 @@
   PointInfo
     point;
 
-  register long
+  register ssize_t
     i;
 
   size_t
     length;
 
-  unsigned long
+  size_t
     level;
 
   p=expression;
@@ -1351,7 +1359,7 @@
               *q='\0';
               alpha=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,
                 &beta,exception);
-              i=(long) (alpha+0.5);
+              i=(ssize_t) (alpha+0.5);
               p++;
             }
           if (*p == '.')
@@ -1415,7 +1423,7 @@
     }
   length=GetImageListLength(fx_info->images);
   while (i < 0)
-    i+=(long) length;
+    i+=(ssize_t) length;
   i%=length;
   image=GetImageFromList(fx_info->images,i);
   if (image == (Image *) NULL)
@@ -1862,7 +1870,7 @@
   register int
     c;
 
-  unsigned long
+  size_t
     level;
 
   c=0;
@@ -2041,7 +2049,7 @@
 }
 
 static MagickRealType FxEvaluateSubexpression(FxInfo *fx_info,
-  const ChannelType channel,const long x,const long y,const char *expression,
+  const ChannelType channel,const ssize_t x,const ssize_t y,const char *expression,
   MagickRealType *beta,ExceptionInfo *exception)
 {
   char
@@ -2079,7 +2087,7 @@
         case '~':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) (~(unsigned long) *beta);
+          *beta=(MagickRealType) (~(size_t) *beta);
           return(*beta);
         }
         case '!':
@@ -2135,14 +2143,14 @@
         case LeftShiftOperator:
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((unsigned long) (alpha+0.5) << (unsigned long)
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) << (size_t)
             (gamma+0.5));
           return(*beta);
         }
         case RightShiftOperator:
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((unsigned long) (alpha+0.5) >> (unsigned long)
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) >> (size_t)
             (gamma+0.5));
           return(*beta);
         }
@@ -2179,14 +2187,14 @@
         case '&':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((unsigned long) (alpha+0.5) & (unsigned long)
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) & (size_t)
             (gamma+0.5));
           return(*beta);
         }
         case '|':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,beta,exception);
-          *beta=(MagickRealType) ((unsigned long) (alpha+0.5) | (unsigned long)
+          *beta=(MagickRealType) ((size_t) (alpha+0.5) | (size_t)
             (gamma+0.5));
           return(*beta);
         }
@@ -2289,7 +2297,7 @@
     {
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,beta,
         exception);
-      return((MagickRealType) (~(unsigned long) (gamma+0.5)));
+      return((MagickRealType) (~(size_t) (gamma+0.5)));
     }
     case 'A':
     case 'a':
@@ -2327,7 +2335,7 @@
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,beta,
             exception);
-          return(((long) alpha) & 0x01 ? -1.0 : 1.0);
+          return(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
         }
       if (LocaleNCompare(expression,"atan2",5) == 0)
         {
@@ -2411,7 +2419,7 @@
             subexpression[strlen(subexpression)-1]='\0';
           if (fx_info->file != (FILE *) NULL)
             (void) fprintf(fx_info->file,"%s[%ld,%ld].%s: %s=%.*g\n",
-              fx_info->images->filename,x,y,type,subexpression,
+              fx_info->images->filename,(long) x,(long) y,type,subexpression,
               GetMagickPrecision(),(double) alpha);
           return(0.0);
         }
@@ -2763,7 +2771,7 @@
 }
 
 MagickExport MagickBooleanType FxEvaluateChannelExpression(FxInfo *fx_info,
-  const ChannelType channel,const long x,const long y,MagickRealType *alpha,
+  const ChannelType channel,const ssize_t x,const ssize_t y,MagickRealType *alpha,
   ExceptionInfo *exception)
 {
   MagickRealType
@@ -2809,11 +2817,11 @@
 
 static FxInfo **DestroyFxThreadSet(FxInfo **fx_info)
 {
-  register long
+  register ssize_t
     i;
 
   assert(fx_info != (FxInfo **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (fx_info[i] != (FxInfo *) NULL)
       fx_info[i]=DestroyFxInfo(fx_info[i]);
   fx_info=(FxInfo **) RelinquishAlignedMemory(fx_info);
@@ -2832,10 +2840,10 @@
   MagickRealType
     alpha;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -2847,7 +2855,7 @@
     fx_expression=ConstantString(expression);
   else
     fx_expression=FileToString(expression+1,~0,exception);
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     fx_info[i]=AcquireFxInfo(image,fx_expression);
     if (fx_info[i] == (FxInfo *) NULL)
@@ -2882,16 +2890,18 @@
   Image
     *fx_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickRealType
     alpha;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -2927,7 +2937,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) fx_image->rows; y++)
+  for (y=0; y < (ssize_t) fx_image->rows; y++)
   {
     MagickRealType
       alpha;
@@ -2935,7 +2945,7 @@
     register IndexPacket
       *restrict fx_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -2953,7 +2963,7 @@
     fx_indexes=GetCacheViewAuthenticIndexQueue(fx_view);
     id=GetOpenMPThreadId();
     alpha=0.0;
-    for (x=0; x < (long) fx_image->columns; x++)
+    for (x=0; x < (ssize_t) fx_image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
@@ -3062,13 +3072,12 @@
   Image
     *implode_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
@@ -3082,6 +3091,9 @@
   ResampleFilter
     **restrict resample_filter;
 
+  ssize_t
+    y;
+
   /*
     Initialize implode image attributes.
   */
@@ -3131,7 +3143,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -3145,7 +3157,7 @@
     register IndexPacket
       *restrict implode_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -3165,7 +3177,7 @@
     delta.y=scale.y*(double) (y-center.y);
     pixel=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Determine if the pixel is within an ellipse.
@@ -3231,7 +3243,7 @@
 %
 %  The format of the MorphImage method is:
 %
-%      Image *MorphImages(const Image *image,const unsigned long number_frames,
+%      Image *MorphImages(const Image *image,const size_t number_frames,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -3245,7 +3257,7 @@
 %
 */
 MagickExport Image *MorphImages(const Image *image,
-  const unsigned long number_frames,ExceptionInfo *exception)
+  const size_t number_frames,ExceptionInfo *exception)
 {
 #define MorphImageTag  "Morph/Image"
 
@@ -3253,7 +3265,7 @@
     *morph_image,
     *morph_images;
 
-  long
+  ssize_t
     y;
 
   MagickOffsetType
@@ -3266,7 +3278,7 @@
   register const Image
     *next;
 
-  register long
+  register ssize_t
     i;
 
   MagickBooleanType
@@ -3289,7 +3301,7 @@
       /*
         Morph single image.
       */
-      for (i=1; i < (long) number_frames; i++)
+      for (i=1; i < (ssize_t) number_frames; i++)
       {
         morph_image=CloneImage(image,0,0,MagickTrue,exception);
         if (morph_image == (Image *) NULL)
@@ -3303,7 +3315,8 @@
             MagickBooleanType
               proceed;
 
-            proceed=SetImageProgress(image,MorphImageTag,i,number_frames);
+            proceed=SetImageProgress(image,MorphImageTag,(MagickOffsetType) i,
+              number_frames);
             if (proceed == MagickFalse)
               status=MagickFalse;
           }
@@ -3318,7 +3331,7 @@
   next=image;
   for ( ; GetNextImageInList(next) != (Image *) NULL; next=GetNextImageInList(next))
   {
-    for (i=0; i < (long) number_frames; i++)
+    for (i=0; i < (ssize_t) number_frames; i++)
     {
       CacheView
         *image_view,
@@ -3326,8 +3339,8 @@
 
       beta=(MagickRealType) (i+1.0)/(MagickRealType) (number_frames+1.0);
       alpha=1.0-beta;
-      morph_image=ZoomImage(next,(unsigned long) (alpha*next->columns+beta*
-        GetNextImageInList(next)->columns+0.5),(unsigned long) (alpha*
+      morph_image=ZoomImage(next,(size_t) (alpha*next->columns+beta*
+        GetNextImageInList(next)->columns+0.5),(size_t) (alpha*
         next->rows+beta*GetNextImageInList(next)->rows+0.5),exception);
       if (morph_image == (Image *) NULL)
         {
@@ -3354,7 +3367,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) morph_images->rows; y++)
+      for (y=0; y < (ssize_t) morph_images->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -3362,7 +3375,7 @@
         register const PixelPacket
           *restrict p;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -3379,7 +3392,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) morph_images->columns; x++)
+        for (x=0; x < (ssize_t) morph_images->columns; x++)
         {
           q->red=ClampToQuantum(alpha*q->red+beta*GetRedPixelComponent(p));
           q->green=ClampToQuantum(alpha*q->green+beta*
@@ -3398,7 +3411,7 @@
       image_view=DestroyCacheView(image_view);
       morph_image=DestroyImage(morph_image);
     }
-    if (i < (long) number_frames)
+    if (i < (ssize_t) number_frames)
       break;
     /*
       Clone last frame in sequence.
@@ -3452,7 +3465,7 @@
 %  The format of the PlasmaImage method is:
 %
 %      MagickBooleanType PlasmaImage(Image *image,const SegmentInfo *segment,
-%        unsigned long attenuate,unsigned long depth)
+%        size_t attenuate,size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -3478,13 +3491,13 @@
 }
 
 MagickExport MagickBooleanType PlasmaImageProxy(Image *image,
-  RandomInfo *random_info,const SegmentInfo *segment,unsigned long attenuate,
-  unsigned long depth)
+  RandomInfo *random_info,const SegmentInfo *segment,size_t attenuate,
+  size_t depth)
 {
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     x,
     x_mid,
     y,
@@ -3509,8 +3522,8 @@
       */
       depth--;
       attenuate++;
-      x_mid=(long) ceil((segment->x1+segment->x2)/2-0.5);
-      y_mid=(long) ceil((segment->y1+segment->y2)/2-0.5);
+      x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
+      y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
       local_info=(*segment);
       local_info.x2=(double) x_mid;
       local_info.y2=(double) y_mid;
@@ -3530,8 +3543,8 @@
     }
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
-  x_mid=(long) ceil((segment->x1+segment->x2)/2-0.5);
-  y_mid=(long) ceil((segment->y1+segment->y2)/2-0.5);
+  x_mid=(ssize_t) ceil((segment->x1+segment->x2)/2-0.5);
+  y_mid=(ssize_t) ceil((segment->y1+segment->y2)/2-0.5);
   if ((segment->x1 == (double) x_mid) && (segment->x2 == (double) x_mid) &&
       (segment->y1 == (double) y_mid) && (segment->y2 == (double) y_mid))
     return(MagickFalse);
@@ -3548,10 +3561,10 @@
       /*
         Left pixel.
       */
-      x=(long) ceil(segment->x1-0.5);
-      (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y1-0.5),&u,
+      x=(ssize_t) ceil(segment->x1-0.5);
+      (void) GetOneVirtualPixel(image,x,(ssize_t) ceil(segment->y1-0.5),&u,
         exception);
-      (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y2-0.5),&v,
+      (void) GetOneVirtualPixel(image,x,(ssize_t) ceil(segment->y2-0.5),&v,
         exception);
       q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
       if (q == (PixelPacket *) NULL)
@@ -3568,10 +3581,10 @@
           /*
             Right pixel.
           */
-          x=(long) ceil(segment->x2-0.5);
-          (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y1-0.5),&u,
+          x=(ssize_t) ceil(segment->x2-0.5);
+          (void) GetOneVirtualPixel(image,x,(ssize_t) ceil(segment->y1-0.5),&u,
             exception);
-          (void) GetOneVirtualPixel(image,x,(long) ceil(segment->y2-0.5),&v,
+          (void) GetOneVirtualPixel(image,x,(ssize_t) ceil(segment->y2-0.5),&v,
             exception);
           q=QueueAuthenticPixels(image,x,y_mid,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3595,10 +3608,10 @@
           /*
             Bottom pixel.
           */
-          y=(long) ceil(segment->y2-0.5);
-          (void) GetOneVirtualPixel(image,(long) ceil(segment->x1-0.5),y,&u,
+          y=(ssize_t) ceil(segment->y2-0.5);
+          (void) GetOneVirtualPixel(image,(ssize_t) ceil(segment->x1-0.5),y,&u,
             exception);
-          (void) GetOneVirtualPixel(image,(long) ceil(segment->x2-0.5),y,&v,
+          (void) GetOneVirtualPixel(image,(ssize_t) ceil(segment->x2-0.5),y,&v,
             exception);
           q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3619,10 +3632,10 @@
           /*
             Top pixel.
           */
-          y=(long) ceil(segment->y1-0.5);
-          (void) GetOneVirtualPixel(image,(long) ceil(segment->x1-0.5),y,&u,
+          y=(ssize_t) ceil(segment->y1-0.5);
+          (void) GetOneVirtualPixel(image,(ssize_t) ceil(segment->x1-0.5),y,&u,
             exception);
-          (void) GetOneVirtualPixel(image,(long) ceil(segment->x2-0.5),y,&v,
+          (void) GetOneVirtualPixel(image,(ssize_t) ceil(segment->x2-0.5),y,&v,
             exception);
           q=QueueAuthenticPixels(image,x_mid,y,1,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -3644,11 +3657,11 @@
       /*
         Middle pixel.
       */
-      x=(long) ceil(segment->x1-0.5);
-      y=(long) ceil(segment->y1-0.5);
+      x=(ssize_t) ceil(segment->x1-0.5);
+      y=(ssize_t) ceil(segment->y1-0.5);
       (void) GetOneVirtualPixel(image,x,y,&u,exception);
-      x=(long) ceil(segment->x2-0.5);
-      y=(long) ceil(segment->y2-0.5);
+      x=(ssize_t) ceil(segment->x2-0.5);
+      y=(ssize_t) ceil(segment->y2-0.5);
       (void) GetOneVirtualPixel(image,x,y,&v,exception);
       q=QueueAuthenticPixels(image,x_mid,y_mid,1,1,exception);
       if (q == (PixelPacket *) NULL)
@@ -3667,7 +3680,7 @@
 }
 
 MagickExport MagickBooleanType PlasmaImage(Image *image,
-  const SegmentInfo *segment,unsigned long attenuate,unsigned long depth)
+  const SegmentInfo *segment,size_t attenuate,size_t depth)
 {
   MagickBooleanType
     status;
@@ -3711,7 +3724,7 @@
 %
 %    o draw_info: the draw info.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 %    o exception: return any errors or warnings in this structure.
 %
@@ -3722,7 +3735,7 @@
   const char
     *value;
 
-  long
+  ssize_t
     quantum;
 
   Image
@@ -3734,7 +3747,7 @@
     *rotate_image,
     *trim_image;
 
-  unsigned long
+  size_t
     height;
 
   /*
@@ -3746,7 +3759,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  quantum=(long) MagickMax(MagickMax((double) image->columns,(double)
+  quantum=(ssize_t) MagickMax(MagickMax((double) image->columns,(double)
     image->rows)/25.0,10.0);
   height=image->rows+2*quantum;
   caption_image=(Image *) NULL;
@@ -3760,7 +3773,7 @@
       DrawInfo
         *annotate_info;
 
-      long
+      ssize_t
         count;
 
       MagickBooleanType
@@ -3780,7 +3793,7 @@
         value);
       (void) CloneString(&annotate_info->text,caption);
       count=FormatMagickCaption(caption_image,annotate_info,&metrics,&caption);
-      status=SetImageExtent(caption_image,image->columns,(unsigned long)
+      status=SetImageExtent(caption_image,image->columns,(size_t)
         ((count+1)*(metrics.ascent-metrics.descent)+0.5));
       if (status == MagickFalse)
         caption_image=DestroyImage(caption_image);
@@ -3814,7 +3827,7 @@
   if (caption_image != (Image *) NULL)
     {
       (void) CompositeImage(picture_image,OverCompositeOp,caption_image,
-        quantum,(long) (image->rows+3*quantum/2));
+        quantum,(ssize_t) (image->rows+3*quantum/2));
       caption_image=DestroyImage(caption_image);
     }
   (void) QueryColorDatabase("none",&picture_image->background_color,exception);
@@ -3853,7 +3866,7 @@
     }
   polaroid_image=flop_image;
   (void) CompositeImage(polaroid_image,OverCompositeOp,picture_image,
-    (long) (-0.01*picture_image->columns/2.0),0L);
+    (ssize_t) (-0.01*picture_image->columns/2.0),0L);
   picture_image=DestroyImage(picture_image);
   (void) QueryColorDatabase("none",&polaroid_image->background_color,exception);
   rotate_image=RotateImage(polaroid_image,angle,exception);
@@ -3911,13 +3924,15 @@
   Image
     *sepia_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   /*
     Initialize sepia-toned image attributes.
   */
@@ -3946,12 +3961,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3967,7 +3982,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickRealType
         intensity,
@@ -4031,7 +4046,7 @@
 %  The format of the ShadowImage method is:
 %
 %      Image *ShadowImage(const Image *image,const double opacity,
-%        const double sigma,const long x_offset,const long y_offset,
+%        const double sigma,const ssize_t x_offset,const ssize_t y_offset,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4050,7 +4065,7 @@
 %
 */
 MagickExport Image *ShadowImage(const Image *image,const double opacity,
-  const double sigma,const long x_offset,const long y_offset,
+  const double sigma,const ssize_t x_offset,const ssize_t y_offset,
   ExceptionInfo *exception)
 {
 #define ShadowImageTag  "Shadow/Image"
@@ -4063,16 +4078,18 @@
     *clone_image,
     *shadow_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   RectangleInfo
     border_info;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -4084,8 +4101,8 @@
     return((Image *) NULL);
   (void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod);
   clone_image->compose=OverCompositeOp;
-  border_info.width=(unsigned long) floor(2.0*sigma+0.5);
-  border_info.height=(unsigned long) floor(2.0*sigma+0.5);
+  border_info.width=(size_t) floor(2.0*sigma+0.5);
+  border_info.height=(size_t) floor(2.0*sigma+0.5);
   border_info.x=0;
   border_info.y=0;
   (void) QueryColorDatabase("none",&clone_image->border_color,exception);
@@ -4104,9 +4121,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) border_image->rows; y++)
+  for (y=0; y < (ssize_t) border_image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4121,7 +4138,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) border_image->columns; x++)
+    for (x=0; x < (ssize_t) border_image->columns; x++)
     {
       q->red=border_image->background_color.red;
       q->green=border_image->background_color.green;
@@ -4158,10 +4175,10 @@
     shadow_image->page.width=shadow_image->columns;
   if (shadow_image->page.height == 0)
     shadow_image->page.height=shadow_image->rows;
-  shadow_image->page.width+=x_offset-(long) border_info.width;
-  shadow_image->page.height+=y_offset-(long) border_info.height;
-  shadow_image->page.x+=x_offset-(long) border_info.width;
-  shadow_image->page.y+=y_offset-(long) border_info.height;
+  shadow_image->page.width+=x_offset-(ssize_t) border_info.width;
+  shadow_image->page.height+=y_offset-(ssize_t) border_info.height;
+  shadow_image->page.x+=x_offset-(ssize_t) border_info.width;
+  shadow_image->page.y+=y_offset-(ssize_t) border_info.height;
   return(shadow_image);
 }
 
@@ -4196,7 +4213,7 @@
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 %    o exception: return any errors or warnings in this structure.
 %
@@ -4214,7 +4231,7 @@
     *random_image,
     *sketch_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -4240,7 +4257,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) random_image->rows; y++)
+  for (y=0; y < (ssize_t) random_image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -4248,7 +4265,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -4267,7 +4284,7 @@
     indexes=GetCacheViewAuthenticIndexQueue(random_view);
     pixel=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) random_image->columns; x++)
+    for (x=0; x < (ssize_t) random_image->columns; x++)
     {
       pixel.red=(MagickRealType) (QuantumRange*
         GetPseudoRandomValue(random_info[id]));
@@ -4357,26 +4374,28 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->storage_class == PseudoClass)
     {
-      register long
+      register ssize_t
         i;
 
       /*
         Solarize colormap.
       */
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         if ((MagickRealType) image->colormap[i].red > threshold)
           image->colormap[i].red=(Quantum) QuantumRange-image->colormap[i].red;
@@ -4398,9 +4417,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4415,7 +4434,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((MagickRealType) q->red > threshold)
         q->red=(Quantum) QuantumRange-q->red;
@@ -4476,11 +4495,11 @@
 MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
   ExceptionInfo *exception)
 {
-#define GetBit(alpha,i) ((((unsigned long) (alpha) >> (unsigned long) \
+#define GetBit(alpha,i) ((((size_t) (alpha) >> (size_t) \
   (i)) & 0x01) != 0)
-#define SetBit(alpha,i,set) (alpha)=(Quantum) ((set) ? (unsigned long) (alpha) \
-  | (1UL << (unsigned long) (i)) : (unsigned long) (alpha) & \
-  ~(1UL << (unsigned long) (i)))
+#define SetBit(alpha,i,set) (alpha)=(Quantum) ((set) ? (size_t) (alpha) \
+  | (1UL << (size_t) (i)) : (size_t) (alpha) & \
+  ~(1UL << (size_t) (i)))
 #define SteganoImageTag  "Stegano/Image"
 
   Image
@@ -4489,7 +4508,7 @@
   int
     c;
 
-  long
+  ssize_t
     i,
     j,
     k,
@@ -4501,13 +4520,13 @@
   PixelPacket
     pixel;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
     *q;
 
-  unsigned long
+  size_t
     depth;
 
   /*
@@ -4539,17 +4558,17 @@
   j=0;
   depth=stegano_image->depth;
   k=image->offset;
-  for (i=(long) depth-1; (i >= 0) && (j < (long) depth); i--)
+  for (i=(ssize_t) depth-1; (i >= 0) && (j < (ssize_t) depth); i--)
   {
-    for (y=0; (y < (long) watermark->rows) && (j < (long) depth); y++)
+    for (y=0; (y < (ssize_t) watermark->rows) && (j < (ssize_t) depth); y++)
     {
-      for (x=0; (x < (long) watermark->columns) && (j < (long) depth); x++)
+      for (x=0; (x < (ssize_t) watermark->columns) && (j < (ssize_t) depth); x++)
       {
         (void) GetOneVirtualPixel(watermark,x,y,&pixel,exception);
-        if ((k/(long) stegano_image->columns) >= (long) stegano_image->rows)
+        if ((k/(ssize_t) stegano_image->columns) >= (ssize_t) stegano_image->rows)
           break;
-        q=GetAuthenticPixels(stegano_image,k % (long) stegano_image->columns,
-          k/(long) stegano_image->columns,1,1,exception);
+        q=GetAuthenticPixels(stegano_image,k % (ssize_t) stegano_image->columns,
+          k/(ssize_t) stegano_image->columns,1,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         switch (c)
@@ -4576,7 +4595,7 @@
         if (c == 3)
           c=0;
         k++;
-        if (k == (long) (stegano_image->columns*stegano_image->columns))
+        if (k == (ssize_t) (stegano_image->columns*stegano_image->columns))
           k=0;
         if (k == image->offset)
           j++;
@@ -4618,7 +4637,7 @@
 %      Image *StereoImage(const Image *left_image,const Image *right_image,
 %        ExceptionInfo *exception)
 %      Image *StereoAnaglyphImage(const Image *left_image,
-%        const Image *right_image,const long x_offset,const long y_offset,
+%        const Image *right_image,const ssize_t x_offset,const ssize_t y_offset,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4644,7 +4663,7 @@
 }
 
 MagickExport Image *StereoAnaglyphImage(const Image *left_image,
-  const Image *right_image,const long x_offset,const long y_offset,
+  const Image *right_image,const ssize_t x_offset,const ssize_t y_offset,
   ExceptionInfo *exception)
 {
 #define StereoImageTag  "Stereo/Image"
@@ -4655,7 +4674,7 @@
   Image
     *stereo_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -4691,13 +4710,13 @@
   /*
     Copy left image to red channel and right image to blue channel.
   */
-  for (y=0; y < (long) stereo_image->rows; y++)
+  for (y=0; y < (ssize_t) stereo_image->rows; y++)
   {
     register const PixelPacket
       *restrict p,
       *restrict q;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -4710,7 +4729,7 @@
     if ((p == (PixelPacket *) NULL) || (q == (PixelPacket *) NULL) ||
         (r == (PixelPacket *) NULL))
       break;
-    for (x=0; x < (long) stereo_image->columns; x++)
+    for (x=0; x < (ssize_t) stereo_image->columns; x++)
     {
       r->red=GetRedPixelComponent(p);
       r->green=q->green;
@@ -4727,7 +4746,8 @@
         MagickBooleanType
           proceed;
 
-        proceed=SetImageProgress(image,StereoImageTag,y,stereo_image->rows);
+        proceed=SetImageProgress(image,StereoImageTag,(MagickOffsetType) y,
+          stereo_image->rows);
         if (proceed == MagickFalse)
           status=MagickFalse;
       }
@@ -4776,13 +4796,12 @@
   Image
     *swirl_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
@@ -4796,6 +4815,9 @@
   ResampleFilter
     **restrict resample_filter;
 
+  ssize_t
+    y;
+
   /*
     Initialize swirl image attributes.
   */
@@ -4843,7 +4865,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -4857,7 +4879,7 @@
     register IndexPacket
       *restrict swirl_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -4877,7 +4899,7 @@
     delta.y=scale.y*(double) (y-center.y);
     pixel=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Determine if the pixel is within an ellipse.
@@ -4973,20 +4995,22 @@
   Image
     *tint_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  MagickStatusType
-    flags;
+  MagickOffsetType
+    progress;
 
   MagickPixelPacket
     color_vector,
     pixel;
 
+  MagickStatusType
+    flags;
+
+  ssize_t
+    y;
+
   /*
     Allocate tint image.
   */
@@ -5040,12 +5064,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -5061,7 +5085,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       MagickPixelPacket
         pixel;
@@ -5123,7 +5147,7 @@
 %  The format of the VignetteImage method is:
 %
 %      Image *VignetteImage(const Image *image,const double radius,
-%        const double sigma,const long x,const long y,ExceptionInfo *exception)
+%        const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -5139,7 +5163,7 @@
 %
 */
 MagickExport Image *VignetteImage(const Image *image,const double radius,
-  const double sigma,const long x,const long y,ExceptionInfo *exception)
+  const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
 {
   char
     ellipse[MaxTextExtent];
@@ -5214,7 +5238,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  WaveImage() creates a "ripple" effect in the image by shifting the pixels
-%  vertically along a sine wave whose amplitude and wavelength is specified
+%  vertically assize_t a sine wave whose amplitude and wavelength is specified
 %  by the given parameters.
 %
 %  The format of the WaveImage method is:
@@ -5243,25 +5267,27 @@
   Image
     *wave_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
   MagickRealType
     *sine_map;
 
-  register long
+  register ssize_t
     i;
 
   ResampleFilter
     **restrict resample_filter;
 
+  ssize_t
+    y;
+
   /*
     Initialize wave image attributes.
   */
@@ -5271,7 +5297,7 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  wave_image=CloneImage(image,image->columns,(unsigned long) (image->rows+2.0*
+  wave_image=CloneImage(image,image->columns,(size_t) (image->rows+2.0*
     fabs(amplitude)),MagickTrue,exception);
   if (wave_image == (Image *) NULL)
     return((Image *) NULL);
@@ -5293,7 +5319,7 @@
       wave_image=DestroyImage(wave_image);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
-  for (i=0; i < (long) wave_image->columns; i++)
+  for (i=0; i < (ssize_t) wave_image->columns; i++)
     sine_map[i]=fabs(amplitude)+amplitude*sin((2*MagickPI*i)/wave_length);
   /*
     Wave image.
@@ -5307,7 +5333,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) wave_image->rows; y++)
+  for (y=0; y < (ssize_t) wave_image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -5315,7 +5341,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -5334,7 +5360,7 @@
     indexes=GetCacheViewAuthenticIndexQueue(wave_view);
     pixel=zero;
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) wave_image->columns; x++)
+    for (x=0; x < (ssize_t) wave_image->columns; x++)
     {
       (void) ResamplePixelColor(resample_filter[id],(double) x,(double) (y-
         sine_map[x]),&pixel);
diff --git a/magick/fx.h b/magick/fx.h
index 68eccbb..1d7b224 100644
--- a/magick/fx.h
+++ b/magick/fx.h
@@ -47,25 +47,25 @@
   *FxImage(const Image *,const char *,ExceptionInfo *),
   *FxImageChannel(const Image *,const ChannelType,const char *,ExceptionInfo *),
   *ImplodeImage(const Image *,const double,ExceptionInfo *),
-  *MorphImages(const Image *,const unsigned long,ExceptionInfo *),
+  *MorphImages(const Image *,const size_t,ExceptionInfo *),
   *PolaroidImage(const Image *,const DrawInfo *,const double,ExceptionInfo *),
   *SepiaToneImage(const Image *,const double,ExceptionInfo *),
-  *ShadowImage(const Image *,const double,const double,const long,const long,
+  *ShadowImage(const Image *,const double,const double,const ssize_t,const ssize_t,
     ExceptionInfo *),
   *SketchImage(const Image *,const double,const double,const double,
     ExceptionInfo *),
   *SteganoImage(const Image *,const Image *,ExceptionInfo *),
   *StereoImage(const Image *,const Image *,ExceptionInfo *),
-  *StereoAnaglyphImage(const Image *,const Image *,const long,const long,
+  *StereoAnaglyphImage(const Image *,const Image *,const ssize_t,const ssize_t,
      ExceptionInfo *),
   *SwirlImage(const Image *,double,ExceptionInfo *),
   *TintImage(const Image *,const char *,const PixelPacket,ExceptionInfo *),
-  *VignetteImage(const Image *,const double,const double,const long,
-    const long,ExceptionInfo *),
+  *VignetteImage(const Image *,const double,const double,const ssize_t,
+    const ssize_t,ExceptionInfo *),
   *WaveImage(const Image *,const double,const double,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
-  PlasmaImage(Image *,const SegmentInfo *,unsigned long,unsigned long),
+  PlasmaImage(Image *,const SegmentInfo *,size_t,size_t),
   SolarizeImage(Image *,const double);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/gem.c b/magick/gem.c
index 60111eb..b67fb1d 100644
--- a/magick/gem.c
+++ b/magick/gem.c
@@ -276,7 +276,7 @@
     r,
     v;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -293,7 +293,7 @@
       *blue=ClampToQuantum((MagickRealType) QuantumRange*v);
       return;
     }
-  i=(long) floor(6.0*hue);
+  i=(ssize_t) floor(6.0*hue);
   f=6.0*hue-i;
   if ((i & 0x01) != 0)
     f=1.0-f;
@@ -508,14 +508,14 @@
 MagickExport void ConvertRGBToHWB(const Quantum red,const Quantum green,
   const Quantum blue,double *hue,double *whiteness,double *blackness)
 {
+  long
+    i;
+
   MagickRealType
     f,
     v,
     w;
 
-  register long
-    i;
-
   /*
     Convert RGB to HWB colorspace.
   */
@@ -693,7 +693,7 @@
       double
         poisson;
 
-      register long
+      register ssize_t
         i;
 
       poisson=exp(-SigmaPoisson*ScaleQuantumToChar(pixel));
@@ -731,7 +731,7 @@
 %
 %  The format of the GetOptimalKernelWidth method is:
 %
-%      unsigned long GetOptimalKernelWidth(const double radius,
+%      size_t GetOptimalKernelWidth(const double radius,
 %        const double sigma)
 %
 %  A description of each parameter follows:
@@ -745,7 +745,7 @@
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
 */
-MagickExport unsigned long GetOptimalKernelWidth1D(const double radius,
+MagickExport size_t GetOptimalKernelWidth1D(const double radius,
   const double sigma)
 {
   double
@@ -755,18 +755,18 @@
     normalize,
     value;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     width;
 
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   if (radius > MagickEpsilon)
-    return((unsigned long) (2.0*ceil(radius)+1.0));
+    return((size_t) (2.0*ceil(radius)+1.0));
   gamma=fabs(sigma);
   if (gamma <= MagickEpsilon)
     return(3UL);
@@ -775,7 +775,7 @@
   for (width=5; ; )
   {
     normalize=0.0;
-    j=(long) width/2;
+    j=(ssize_t) width/2;
     for (i=(-j); i <= j; i++)
       normalize+=exp(-((double) (i*i))*alpha)*beta;
     value=exp(-((double) (j*j))*alpha)*beta/normalize;
@@ -783,10 +783,10 @@
       break;
     width+=2;
   }
-  return((unsigned long) (width-2));
+  return((size_t) (width-2));
 }
 
-MagickExport unsigned long GetOptimalKernelWidth2D(const double radius,
+MagickExport size_t GetOptimalKernelWidth2D(const double radius,
   const double sigma)
 {
   double
@@ -796,17 +796,17 @@
     normalize,
     value;
 
-  long
+  ssize_t
     j,
     u,
     v;
 
-  unsigned long
+  size_t
     width;
 
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   if (radius > MagickEpsilon)
-    return((unsigned long) (2.0*ceil(radius)+1.0));
+    return((size_t) (2.0*ceil(radius)+1.0));
   gamma=fabs(sigma);
   if (gamma <= MagickEpsilon)
     return(3UL);
@@ -815,7 +815,7 @@
   for (width=5; ; )
   {
     normalize=0.0;
-    j=(long) width/2;
+    j=(ssize_t) width/2;
     for (v=(-j); v <= j; v++)
       for (u=(-j); u <= j; u++)
         normalize+=exp(-((double) (u*u+v*v))*alpha)*beta;
@@ -824,10 +824,10 @@
       break;
     width+=2;
   }
-  return((unsigned long) (width-2));
+  return((size_t) (width-2));
 }
 
-MagickExport unsigned long  GetOptimalKernelWidth(const double radius,
+MagickExport size_t  GetOptimalKernelWidth(const double radius,
   const double sigma)
 {
   return(GetOptimalKernelWidth1D(radius,sigma));
diff --git a/magick/gem.h b/magick/gem.h
index d525b63..8d0f116 100644
--- a/magick/gem.h
+++ b/magick/gem.h
@@ -30,7 +30,7 @@
   GenerateDifferentialNoise(RandomInfo *,const Quantum,const NoiseType,
     const MagickRealType);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetOptimalKernelWidth(const double,const double),
   GetOptimalKernelWidth1D(const double,const double),
   GetOptimalKernelWidth2D(const double,const double);
diff --git a/magick/geometry.c b/magick/geometry.c
index 7c11756..fa0e109 100644
--- a/magick/geometry.c
+++ b/magick/geometry.c
@@ -69,8 +69,8 @@
 %
 %  The format of the GetGeometry method is:
 %
-%      MagickStatusType GetGeometry(const char *geometry,long *x,long *y,
-%        unsigned long *width,unsigned long *height)
+%      MagickStatusType GetGeometry(const char *geometry,ssize_t *x,ssize_t *y,
+%        size_t *width,size_t *height)
 %
 %  A description of each parameter follows:
 %
@@ -82,8 +82,8 @@
 %      specification.
 %
 */
-MagickExport MagickStatusType GetGeometry(const char *geometry,long *x,long *y,
-  unsigned long *width,unsigned long *height)
+MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,ssize_t *y,
+  size_t *width,size_t *height)
 {
   char
     *p,
@@ -198,9 +198,9 @@
       */
       q=p;
       if (LocaleNCompare(p,"0x",2) == 0)
-        *width=(unsigned long) strtol(p,&p,10);
+        *width=(size_t) strtol(p,&p,10);
       else
-        *width=(unsigned long) floor(strtod(p,&p)+0.5);
+        *width=(size_t) floor(strtod(p,&p)+0.5);
       if (p != q)
         flags|=WidthValue;
     }
@@ -213,7 +213,7 @@
             Parse height.
           */
           q=p;
-          *height=(unsigned long) floor(strtod(p,&p)+0.5);
+          *height=(size_t) floor(strtod(p,&p)+0.5);
           if (p != q)
             flags|=HeightValue;
         }
@@ -226,7 +226,7 @@
       if (*p == '-')
         flags|=XNegative;
       q=p;
-      *x=(long) ceil(strtod(p,&p)-0.5);
+      *x=(ssize_t) ceil(strtod(p,&p)-0.5);
       if (p != q)
         flags|=XValue;
       if ((*p == '+') || (*p == '-'))
@@ -237,7 +237,7 @@
           if (*p == '-')
             flags|=YNegative;
           q=p;
-          *y=(long) ceil(strtod(p,&p)-0.5);
+          *y=(ssize_t) ceil(strtod(p,&p)-0.5);
           if (p != q)
             flags|=YValue;
         }
@@ -356,7 +356,7 @@
   char
     *page;
 
-  register long
+  register ssize_t
     i;
 
   assert(page_geometry != (char *) NULL);
@@ -405,8 +405,8 @@
 %
 %  The format of the GravityAdjustGeometry method is:
 %
-%      void GravityAdjustGeometry(const unsigned long width,
-%        const unsigned long height,const GravityType gravity,
+%      void GravityAdjustGeometry(const size_t width,
+%        const size_t height,const GravityType gravity,
 %        RectangleInfo *region);
 %
 %  A description of each parameter follows:
@@ -418,8 +418,8 @@
 %    o region:  The region requiring a offset adjustment relative to gravity
 %
 */
-MagickExport void GravityAdjustGeometry(const unsigned long width,
-  const unsigned long height,const GravityType gravity,RectangleInfo *region)
+MagickExport void GravityAdjustGeometry(const size_t width,
+  const size_t height,const GravityType gravity,RectangleInfo *region)
 {
   if (region->height == 0)
     region->height=height;
@@ -431,7 +431,7 @@
     case EastGravity:
     case SouthEastGravity:
     {
-      region->x=(long) (width-region->width-region->x);
+      region->x=(ssize_t) (width-region->width-region->x);
       break;
     }
     case NorthGravity:
@@ -439,7 +439,7 @@
     case CenterGravity:
     case StaticGravity:
     {
-      region->x+=(long) (width/2-region->width/2);
+      region->x+=(ssize_t) (width/2-region->width/2);
       break;
     }
     case ForgetGravity:
@@ -455,7 +455,7 @@
     case SouthGravity:
     case SouthEastGravity:
     {
-      region->y=(long) (height-region->height-region->y);
+      region->y=(ssize_t) (height-region->height-region->y);
       break;
     }
     case EastGravity:
@@ -463,7 +463,7 @@
     case CenterGravity:
     case StaticGravity:
     {
-      region->y+=(long) (height/2-region->height/2);
+      region->y+=(ssize_t) (height/2-region->height/2);
       break;
     }
     case ForgetGravity:
@@ -643,7 +643,7 @@
   MagickStatusType
     flags;
 
-  register long
+  register ssize_t
     i;
 
   GetAffineMatrix(affine_matrix);
@@ -975,7 +975,7 @@
   MagickStatusType
     flags;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -1014,9 +1014,9 @@
       scale.y=geometry_info.sigma;
       if ((status & SigmaValue) == 0)
         scale.y=scale.x;
-      region_info->width=(unsigned long) floor((scale.x*image->columns/100.0)+
+      region_info->width=(size_t) floor((scale.x*image->columns/100.0)+
         0.5);
-      region_info->height=(unsigned long) floor((scale.y*image->rows/100.0)+
+      region_info->height=(size_t) floor((scale.y*image->rows/100.0)+
         0.5);
     }
   /*
@@ -1051,8 +1051,8 @@
 %
 %  The format of the ParseMetaGeometry method is:
 %
-%      MagickStatusType ParseMetaGeometry(const char *geometry,long *x,long *y,
-%        unsigned long *width,unsigned long *height)
+%      MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,ssize_t *y,
+%        size_t *width,size_t *height)
 %
 %  A description of each parameter follows:
 %
@@ -1065,16 +1065,16 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,long *x,
-  long *y,unsigned long *width,unsigned long *height)
+MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
+  ssize_t *y,size_t *width,size_t *height)
 {
   GeometryInfo
     geometry_info;
@@ -1082,17 +1082,17 @@
   MagickStatusType
     flags;
 
-  unsigned long
+  size_t
     former_height,
     former_width;
 
   /*
     Ensure the image geometry is valid.
   */
-  assert(x != (long *) NULL);
-  assert(y != (long *) NULL);
-  assert(width != (unsigned long *) NULL);
-  assert(height != (unsigned long *) NULL);
+  assert(x != (ssize_t *) NULL);
+  assert(y != (ssize_t *) NULL);
+  assert(width != (size_t *) NULL);
+  assert(height != (size_t *) NULL);
   if ((geometry == (char *) NULL) || (*geometry == '\0'))
     return(NoValue);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",geometry);
@@ -1121,10 +1121,10 @@
       scale.y=geometry_info.sigma;
       if ((flags & SigmaValue) == 0)
         scale.y=scale.x;
-      *width=(unsigned long) floor(scale.x*former_width/100.0+0.5);
+      *width=(size_t) floor(scale.x*former_width/100.0+0.5);
       if (*width == 0)
         *width=1;
-      *height=(unsigned long) floor(scale.y*former_height/100.0+0.5);
+      *height=(size_t) floor(scale.y*former_height/100.0+0.5);
       if (*height == 0)
         *height=1;
       former_width=(*width);
@@ -1179,9 +1179,9 @@
                 scale_factor=(MagickRealType) *height/(MagickRealType)
                   former_width;
             }
-      *width=MagickMax((unsigned long) floor(scale_factor*former_width+0.5),
+      *width=MagickMax((size_t) floor(scale_factor*former_width+0.5),
         1UL);
-      *height=MagickMax((unsigned long) floor(scale_factor*former_height+0.5),
+      *height=MagickMax((size_t) floor(scale_factor*former_height+0.5),
         1UL);
     }
   if ((flags & GreaterValue) != 0)
@@ -1217,8 +1217,8 @@
       scale.y=(double) former_height/(double) (distance/sqrt((double) area));
       if ((scale.x < (double) *width) || (scale.y < (double) *height))
         {
-          *width=(unsigned long) (former_width/(distance/sqrt((double) area)));
-          *height=(unsigned long) (former_height/(distance/
+          *width=(size_t) (former_width/(distance/sqrt((double) area)));
+          *height=(size_t) (former_height/(distance/
             sqrt((double) area)));
         }
       former_width=(*width);
diff --git a/magick/geometry.h b/magick/geometry.h
index 5c07eb4..5d31386 100644
--- a/magick/geometry.h
+++ b/magick/geometry.h
@@ -112,18 +112,18 @@
 
 typedef struct _OffsetInfo
 {
-  long
+  ssize_t
     x,
     y;
 } OffsetInfo;
 
 typedef struct _RectangleInfo
 {
-  unsigned long
+  size_t
     width,
     height;
 
-  long
+  ssize_t
     x,
     y;
 } RectangleInfo;
@@ -136,19 +136,19 @@
   IsSceneGeometry(const char *,const MagickBooleanType);
 
 extern MagickExport MagickStatusType
-  GetGeometry(const char *,long *,long *,unsigned long *,unsigned long *),
+  GetGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
   ParseAbsoluteGeometry(const char *,RectangleInfo *),
   ParseAffineGeometry(const char *,AffineMatrix *,ExceptionInfo *),
   ParseGeometry(const char *,GeometryInfo *),
   ParseGravityGeometry(const Image *,const char *,RectangleInfo *,
     ExceptionInfo *),
-  ParseMetaGeometry(const char *,long *,long *,unsigned long *,unsigned long *),
+  ParseMetaGeometry(const char *,ssize_t *,ssize_t *,size_t *,size_t *),
   ParsePageGeometry(const Image *,const char *,RectangleInfo *,ExceptionInfo *),
   ParseRegionGeometry(const Image *,const char *,RectangleInfo *,
     ExceptionInfo *);
 
 extern MagickExport void
-  GravityAdjustGeometry(const unsigned long,const unsigned long,
+  GravityAdjustGeometry(const size_t,const size_t,
     const GravityType,RectangleInfo *),
   SetGeometry(const Image *,RectangleInfo *),
   SetGeometryInfo(GeometryInfo *);
diff --git a/magick/hashmap.c b/magick/hashmap.c
index c9f87a8..5b99457 100644
--- a/magick/hashmap.c
+++ b/magick/hashmap.c
@@ -75,7 +75,7 @@
 
 struct _LinkedListInfo
 {
-  unsigned long
+  size_t
     capacity,
     elements;
 
@@ -90,7 +90,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -106,7 +106,7 @@
     *(*relinquish_key)(void *),
     *(*relinquish_value)(void *);
 
-  unsigned long
+  size_t
     capacity,
     entries,
     next;
@@ -123,7 +123,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -345,7 +345,7 @@
   register EntryInfo
     *entry;
 
-  register long
+  register ssize_t
     i;
 
   assert(hashmap_info != (HashmapInfo *) NULL);
@@ -353,7 +353,7 @@
   if (hashmap_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   LockSemaphoreInfo(hashmap_info->semaphore);
-  for (i=0; i < (long) hashmap_info->capacity; i++)
+  for (i=0; i < (ssize_t) hashmap_info->capacity; i++)
   {
     list_info=hashmap_info->map[i];
     if (list_info != (LinkedListInfo *) NULL)
@@ -659,14 +659,14 @@
 %
 %  The format of the GetNumberOfEntriesInHashmap method is:
 %
-%      unsigned long GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
+%      size_t GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
 %
 %  A description of each parameter follows:
 %
 %    o hashmap_info: the hashmap info.
 %
 */
-MagickExport unsigned long GetNumberOfEntriesInHashmap(
+MagickExport size_t GetNumberOfEntriesInHashmap(
   const HashmapInfo *hashmap_info)
 {
   assert(hashmap_info != (HashmapInfo *) NULL);
@@ -692,7 +692,7 @@
 %
 %  The format of the GetNumberOfElementsInLinkedList method is:
 %
-%      unsigned long GetNumberOfElementsInLinkedList(
+%      size_t GetNumberOfElementsInLinkedList(
 %        const LinkedListInfo *list_info)
 %
 %  A description of each parameter follows:
@@ -700,7 +700,7 @@
 %    o list_info: the linked-list info.
 %
 */
-MagickExport unsigned long GetNumberOfElementsInLinkedList(
+MagickExport size_t GetNumberOfElementsInLinkedList(
   const LinkedListInfo *list_info)
 {
   assert(list_info != (LinkedListInfo *) NULL);
@@ -804,7 +804,7 @@
 %  The format of the GetValueFromLinkedList method is:
 %
 %      void *GetValueFromLinkedList(LinkedListInfo *list_info,
-%        const unsigned long index)
+%        const size_t index)
 %
 %  A description of each parameter follows:
 %
@@ -814,12 +814,12 @@
 %
 */
 MagickExport void *GetValueFromLinkedList(LinkedListInfo *list_info,
-  const unsigned long index)
+  const size_t index)
 {
   register ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
   void
@@ -845,7 +845,7 @@
       return(value);
     }
   next=list_info->head;
-  for (i=0; i < (long) index; i++)
+  for (i=0; i < (ssize_t) index; i++)
     next=next->next;
   value=next->value;
   UnlockSemaphoreInfo(list_info->semaphore);
@@ -916,7 +916,7 @@
   const unsigned char
     *digest;
 
-  register long
+  register ssize_t
     i;
 
   SignatureInfo
@@ -969,7 +969,7 @@
   const unsigned char
     *digest;
 
-  register long
+  register ssize_t
     i;
 
   SignatureInfo
@@ -1006,7 +1006,7 @@
 %  The format of the InsertValueInLinkedList method is:
 %
 %      MagickBooleanType InsertValueInLinkedList(ListInfo *list_info,
-%        const unsigned long index,const void *value)
+%        const size_t index,const void *value)
 %
 %  A description of each parameter follows:
 %
@@ -1018,12 +1018,12 @@
 %
 */
 MagickExport MagickBooleanType InsertValueInLinkedList(
-  LinkedListInfo *list_info,const unsigned long index,const void *value)
+  LinkedListInfo *list_info,const size_t index,const void *value)
 {
   register ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
   assert(list_info != (LinkedListInfo *) NULL);
@@ -1072,7 +1072,7 @@
 
             element=list_info->head;
             next->next=element->next;
-            for (i=1; i < (long) index; i++)
+            for (i=1; i < (ssize_t) index; i++)
             {
               element=element->next;
               next->next=element->next;
@@ -1130,7 +1130,7 @@
   register ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
   assert(list_info != (LinkedListInfo *) NULL);
@@ -1279,7 +1279,7 @@
   register ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
   assert(list_info != (LinkedListInfo *) NULL);
@@ -1316,7 +1316,7 @@
 %
 %  The format of the NewHashmap method is:
 %
-%      HashmapInfo *NewHashmap(const unsigned long capacity,
+%      HashmapInfo *NewHashmap(const size_t capacity,
 %        size_t (*hash)(const void *),
 %        MagickBooleanType (*compare)(const void *,const void *),
 %        void *(*relinquish_key)(void *),void *(*relinquish_value)(void *))
@@ -1342,7 +1342,7 @@
 %      the hash-map.
 %
 */
-MagickExport HashmapInfo *NewHashmap(const unsigned long capacity,
+MagickExport HashmapInfo *NewHashmap(const size_t capacity,
   size_t (*hash)(const void *),
   MagickBooleanType (*compare)(const void *,const void *),
   void *(*relinquish_key)(void *),void *(*relinquish_value)(void *))
@@ -1394,14 +1394,14 @@
 %
 %  The format of the NewLinkedList method is:
 %
-%      LinkedListInfo *NewLinkedList(const unsigned long capacity)
+%      LinkedListInfo *NewLinkedList(const size_t capacity)
 %
 %  A description of each parameter follows:
 %
 %    o capacity: the maximum number of elements in the list.
 %
 */
-MagickExport LinkedListInfo *NewLinkedList(const unsigned long capacity)
+MagickExport LinkedListInfo *NewLinkedList(const size_t capacity)
 {
   LinkedListInfo
     *list_info;
@@ -1410,7 +1410,7 @@
   if (list_info == (LinkedListInfo *) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   (void) ResetMagickMemory(list_info,0,sizeof(*list_info));
-  list_info->capacity=capacity == 0 ? (unsigned long) (~0) : capacity;
+  list_info->capacity=capacity == 0 ? (size_t) (~0) : capacity;
   list_info->elements=0;
   list_info->head=(ElementInfo *) NULL;
   list_info->tail=(ElementInfo *) NULL;
@@ -1454,7 +1454,7 @@
 {
 #define MaxCapacities  20
 
-  const unsigned long
+  const size_t
     capacities[MaxCapacities] =
     {
       17, 31, 61, 131, 257, 509, 1021, 2053, 4099, 8191, 16381, 32771,
@@ -1475,10 +1475,10 @@
   register ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     capacity;
 
   /*
@@ -1498,7 +1498,7 @@
   /*
     Copy entries to new hashmap with increased capacity.
   */
-  for (i=0; i < (long) hashmap_info->capacity; i++)
+  for (i=0; i < (ssize_t) hashmap_info->capacity; i++)
   {
     list_info=hashmap_info->map[i];
     if (list_info == (LinkedListInfo *) NULL)
@@ -1542,7 +1542,7 @@
   LinkedListInfo
     *list_info;
 
-  register unsigned long
+  register size_t
     i;
 
   assert(hashmap_info != (HashmapInfo *) NULL);
@@ -1701,7 +1701,7 @@
 %  The format of the RemoveElementFromLinkedList method is:
 %
 %      void *RemoveElementFromLinkedList(LinkedListInfo *list_info,
-%        const unsigned long index)
+%        const size_t index)
 %
 %  A description of each parameter follows:
 %
@@ -1711,12 +1711,12 @@
 %
 */
 MagickExport void *RemoveElementFromLinkedList(LinkedListInfo *list_info,
-  const unsigned long index)
+  const size_t index)
 {
   ElementInfo
     *next;
 
-  register long
+  register ssize_t
     i;
 
   void
@@ -1744,7 +1744,7 @@
         *element;
 
       next=list_info->head;
-      for (i=1; i < (long) index; i++)
+      for (i=1; i < (ssize_t) index; i++)
         next=next->next;
       element=next->next;
       next->next=element->next;
@@ -1793,7 +1793,7 @@
   LinkedListInfo
     *list_info;
 
-  register unsigned long
+  register size_t
     i;
 
   size_t
diff --git a/magick/hashmap.h b/magick/hashmap.h
index b3b4c52..84812e5 100644
--- a/magick/hashmap.h
+++ b/magick/hashmap.h
@@ -35,19 +35,19 @@
 
 extern MagickExport HashmapInfo
   *DestroyHashmap(HashmapInfo *),
-  *NewHashmap(const unsigned long,size_t (*)(const void *),
+  *NewHashmap(const size_t,size_t (*)(const void *),
     MagickBooleanType (*)(const void *,const void *),void *(*)(void *),
     void *(*)(void *));
 
 extern MagickExport LinkedListInfo
   *DestroyLinkedList(LinkedListInfo *,void *(*)(void *)),
-  *NewLinkedList(const unsigned long);
+  *NewLinkedList(const size_t);
 
 extern MagickExport MagickBooleanType
   AppendValueToLinkedList(LinkedListInfo *,const void *),
   CompareHashmapString(const void *,const void *),
   CompareHashmapStringInfo(const void *,const void *),
-  InsertValueInLinkedList(LinkedListInfo *,const unsigned long,const void *),
+  InsertValueInLinkedList(LinkedListInfo *,const size_t,const void *),
   InsertValueInSortedLinkedList(LinkedListInfo *,
     int (*)(const void *,const void *),void **,const void *),
   IsHashmapEmpty(const HashmapInfo *),
@@ -60,7 +60,7 @@
   HashStringType(const void *),
   HashStringInfoType(const void *);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetNumberOfElementsInLinkedList(const LinkedListInfo *),
   GetNumberOfEntriesInHashmap(const HashmapInfo *);
 
@@ -71,9 +71,9 @@
   *GetNextValueInHashmap(HashmapInfo *),
   *GetNextValueInLinkedList(LinkedListInfo *),
   *GetValueFromHashmap(HashmapInfo *,const void *),
-  *GetValueFromLinkedList(LinkedListInfo *,const unsigned long),
+  *GetValueFromLinkedList(LinkedListInfo *,const size_t),
   *RemoveElementByValueFromLinkedList(LinkedListInfo *,const void *),
-  *RemoveElementFromLinkedList(LinkedListInfo *,const unsigned long),
+  *RemoveElementFromLinkedList(LinkedListInfo *,const size_t),
   *RemoveEntryFromHashmap(HashmapInfo *,const void *),
   *RemoveLastElementFromLinkedList(LinkedListInfo *),
   ResetHashmapIterator(HashmapInfo *),
diff --git a/magick/histogram.c b/magick/histogram.c
index dd42ad3..645f416 100644
--- a/magick/histogram.c
+++ b/magick/histogram.c
@@ -81,7 +81,7 @@
   MagickSizeType
     number_unique;
 
-  unsigned long
+  size_t
     level;
 } NodeInfo;
 
@@ -99,11 +99,11 @@
   NodeInfo
     *root;
 
-  long
+  ssize_t
     x,
     progress;
 
-  unsigned long
+  size_t
     colors,
     free_nodes;
 
@@ -121,7 +121,7 @@
   *GetCubeInfo(void);
 
 static NodeInfo
-  *GetNodeInfo(CubeInfo *,const unsigned long);
+  *GetNodeInfo(CubeInfo *,const size_t);
 
 static void
   DestroyColorCube(const Image *,NodeInfo *);
@@ -139,7 +139,7 @@
 %
 %  ClassifyImageColors() builds a populated CubeInfo tree for the specified
 %  image.  The returned tree should be deallocated using DestroyCubeInfo()
-%  once it is no longer needed.
+%  once it is no ssize_ter needed.
 %
 %  The format of the ClassifyImageColors() method is:
 %
@@ -154,13 +154,13 @@
 %
 */
 
-static inline unsigned long ColorToNodeId(const Image *image,
-  const MagickPixelPacket *pixel,unsigned long index)
+static inline size_t ColorToNodeId(const Image *image,
+  const MagickPixelPacket *pixel,size_t index)
 {
-  unsigned long
+  size_t
     id;
 
-  id=(unsigned long) (
+  id=(size_t) (
     ((ScaleQuantumToChar(ClampToQuantum(pixel->red)) >> index) & 0x01) |
     ((ScaleQuantumToChar(ClampToQuantum(pixel->green)) >> index) & 0x01) << 1 |
     ((ScaleQuantumToChar(ClampToQuantum(pixel->blue)) >> index) & 0x01) << 2);
@@ -181,7 +181,7 @@
   CubeInfo
     *cube_info;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -200,11 +200,11 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  register unsigned long
+  register size_t
     id,
     index,
     level;
@@ -226,13 +226,13 @@
   GetMagickPixelPacket(image,&pixel);
   GetMagickPixelPacket(image,&target);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Start at the root and proceed level by level.
@@ -257,14 +257,14 @@
         node_info=node_info->child[id];
         index--;
       }
-      for (i=0; i < (long) node_info->number_unique; i++)
+      for (i=0; i < (ssize_t) node_info->number_unique; i++)
       {
         SetMagickPixelPacket(image,&node_info->list[i].pixel,
           &node_info->list[i].index,&target);
         if (IsMagickColorEqual(&pixel,&target) != MagickFalse)
           break;
       }
-      if (i < (long) node_info->number_unique)
+      if (i < (ssize_t) node_info->number_unique)
         node_info->list[i].count++;
       else
         {
@@ -332,17 +332,17 @@
 static void DefineImageHistogram(const Image *image,NodeInfo *node_info,
   ColorPacket **histogram)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=image->matte == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       DefineImageHistogram(image,node_info->child[i],histogram);
   if (node_info->level == (MaxTreeDepth-1))
@@ -351,7 +351,7 @@
         *p;
 
       p=node_info->list;
-      for (i=0; i < (long) node_info->number_unique; i++)
+      for (i=0; i < (ssize_t) node_info->number_unique; i++)
       {
         (*histogram)->pixel=p->pixel;
         (*histogram)->index=p->index;
@@ -433,17 +433,17 @@
 */
 static void DestroyColorCube(const Image *image,NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=image->matte == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       DestroyColorCube(image,node_info->child[i]);
   if (node_info->list != (ColorPacket *) NULL)
@@ -508,8 +508,8 @@
 %
 %  The format of the GetImageHistogram method is:
 %
-%      unsigned long GetImageHistogram(const Image *image,
-%        unsigned long *number_colors,ExceptionInfo *exception)
+%      size_t GetImageHistogram(const Image *image,
+%        size_t *number_colors,ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
 %
@@ -521,7 +521,7 @@
 %
 */
 MagickExport ColorPacket *GetImageHistogram(const Image *image,
-  unsigned long *number_colors,ExceptionInfo *exception)
+  size_t *number_colors,ExceptionInfo *exception)
 {
   ColorPacket
     *histogram;
@@ -569,7 +569,7 @@
 %
 %  The format of the GetNodeInfo method is:
 %
-%      NodeInfo *GetNodeInfo(CubeInfo *cube_info,const unsigned long level)
+%      NodeInfo *GetNodeInfo(CubeInfo *cube_info,const size_t level)
 %
 %  A description of each parameter follows.
 %
@@ -578,7 +578,7 @@
 %    o level: Specifies the level in the storage_class the node resides.
 %
 */
-static NodeInfo *GetNodeInfo(CubeInfo *cube_info,const unsigned long level)
+static NodeInfo *GetNodeInfo(CubeInfo *cube_info,const size_t level)
 {
   NodeInfo
     *node_info;
@@ -643,7 +643,7 @@
   CubeInfo
     *cube_info;
 
-  long
+  ssize_t
     y;
 
   MagickPixelPacket
@@ -656,16 +656,16 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register NodeInfo
     *node_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     id,
     index,
     level;
@@ -691,13 +691,13 @@
   GetMagickPixelPacket(image,&pixel);
   GetMagickPixelPacket(image,&target);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Start at the root and proceed level by level.
@@ -724,14 +724,14 @@
       }
       if (level < MaxTreeDepth)
         break;
-      for (i=0; i < (long) node_info->number_unique; i++)
+      for (i=0; i < (ssize_t) node_info->number_unique; i++)
       {
         SetMagickPixelPacket(image,&node_info->list[i].pixel,
           &node_info->list[i].index,&target);
         if (IsMagickColorEqual(&pixel,&target) != MagickFalse)
           break;
       }
-      if (i < (long) node_info->number_unique)
+      if (i < (ssize_t) node_info->number_unique)
         node_info->list[i].count++;
       else
         {
@@ -763,12 +763,12 @@
         }
       p++;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
       break;
   }
   image_view=DestroyCacheView(image_view);
   cube_info=DestroyCubeInfo(image,cube_info);
-  return(y < (long) image->rows ? MagickFalse : MagickTrue);
+  return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
 }
 
 /*
@@ -806,7 +806,7 @@
   CubeInfo
     *cube_info;
 
-  long
+  ssize_t
     y;
 
   MagickPixelPacket
@@ -819,16 +819,16 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     x;
 
   register NodeInfo
     *node_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     id,
     index,
     level;
@@ -854,13 +854,13 @@
   GetMagickPixelPacket(image,&pixel);
   GetMagickPixelPacket(image,&target);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       /*
         Start at the root and proceed level by level.
@@ -887,14 +887,14 @@
       }
       if (level < MaxTreeDepth)
         break;
-      for (i=0; i < (long) node_info->number_unique; i++)
+      for (i=0; i < (ssize_t) node_info->number_unique; i++)
       {
         SetMagickPixelPacket(image,&node_info->list[i].pixel,
           &node_info->list[i].index,&target);
         if (IsMagickColorEqual(&pixel,&target) != MagickFalse)
           break;
       }
-      if (i < (long) node_info->number_unique)
+      if (i < (ssize_t) node_info->number_unique)
         node_info->list[i].count++;
       else
         {
@@ -926,12 +926,12 @@
         }
       p++;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
       break;
   }
   image_view=DestroyCacheView(image_view);
   cube_info=DestroyCubeInfo(image,cube_info);
-  return(y < (long) image->rows ? MagickFalse : MagickTrue);
+  return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
 }
 
 /*
@@ -1073,7 +1073,7 @@
 %
 %  The format of the GetNumberColors method is:
 %
-%      unsigned long GetNumberColors(const Image *image,FILE *file,
+%      size_t GetNumberColors(const Image *image,FILE *file,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
@@ -1111,7 +1111,7 @@
 }
 #endif
 
-MagickExport unsigned long GetNumberColors(const Image *image,FILE *file,
+MagickExport size_t GetNumberColors(const Image *image,FILE *file,
   ExceptionInfo *exception)
 {
 #define HistogramImageTag  "Histogram/Image"
@@ -1133,10 +1133,10 @@
   register ColorPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_colors;
 
   number_colors=0;
@@ -1158,7 +1158,7 @@
     HistogramCompare);
   GetMagickPixelPacket(image,&pixel);
   p=histogram;
-  for (i=0; i < (long) number_colors; i++)
+  for (i=0; i < (ssize_t) number_colors; i++)
   {
     SetMagickPixelPacket(image,&p->pixel,&p->index,&pixel);
     (void) CopyMagickString(tuple,"(",MaxTextExtent);
@@ -1231,17 +1231,17 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=image->matte == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       UniqueColorsToImage(image,cube_info,node_info->child[i],exception);
   if (node_info->level == (MaxTreeDepth-1))
@@ -1256,7 +1256,7 @@
         *restrict q;
 
       p=node_info->list;
-      for (i=0; i < (long) node_info->number_unique; i++)
+      for (i=0; i < (ssize_t) node_info->number_unique; i++)
       {
         q=QueueAuthenticPixels(image,cube_info->x,0,1,1,exception);
         if (q == (PixelPacket *) NULL)
diff --git a/magick/histogram.h b/magick/histogram.h
index 81f9300..c8b9dab 100644
--- a/magick/histogram.h
+++ b/magick/histogram.h
@@ -35,7 +35,7 @@
 } ColorPacket;
 
 extern MagickExport ColorPacket
-  *GetImageHistogram(const Image *,unsigned long *,ExceptionInfo *);
+  *GetImageHistogram(const Image *,size_t *,ExceptionInfo *);
 
 extern MagickExport Image
   *UniqueImageColors(const Image *,ExceptionInfo *);
@@ -45,7 +45,7 @@
   IsPaletteImage(const Image *,ExceptionInfo *),
   MinMaxStretchImage(Image *,const ChannelType,const double,const double);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetNumberColors(const Image *,FILE *,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/identify.c b/magick/identify.c
index 15856cd..c8faa82 100644
--- a/magick/identify.c
+++ b/magick/identify.c
@@ -284,17 +284,17 @@
   ImageType
     type;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     ping;
 
-  register long
+  register ssize_t
     i,
     x;
 
-  unsigned long
+  size_t
     distance,
     scale;
 
@@ -336,7 +336,7 @@
       (void) fprintf(file,"%lu-bit ",image->depth);
       if (image->type != UndefinedType)
         (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
-          (long) image->type));
+          (ssize_t) image->type));
       if (image->storage_class == DirectClass)
         {
           (void) fprintf(file,"DirectClass ");
@@ -353,7 +353,7 @@
           (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
             image->colors);
       if (image->error.mean_error_per_pixel != 0.0)
-        (void) fprintf(file,"%ld/%f/%fdb ",(long)
+        (void) fprintf(file,"%ld/%f/%fdb ",(ssize_t)
           (image->error.mean_error_per_pixel+0.5),
           image->error.normalized_mean_error,
           image->error.normalized_maximum_error);
@@ -362,9 +362,9 @@
           (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
           (void) fprintf(file,"%sB ",format);
         }
-      (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
-        (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
-        (long) (1000.0*(elapsed_time-floor(elapsed_time))));
+      (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(ssize_t)
+        (elapsed_time/60.0),(ssize_t) floor(fmod(elapsed_time,60.0)),
+        (ssize_t) (1000.0*(elapsed_time-floor(elapsed_time))));
       (void) fprintf(file,"\n");
       (void) fflush(file);
       return(ferror(file) != 0 ? MagickFalse : MagickTrue);
@@ -396,7 +396,7 @@
     (void) fprintf(file,"  Format: %s (%s)\n",image->magick,
       GetMagickDescription(magick_info));
   (void) fprintf(file,"  Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
-    (long) image->storage_class));
+    (ssize_t) image->storage_class));
   (void) fprintf(file,"  Geometry: %lux%lu%+ld%+ld\n",image->columns,
     image->rows,image->tile_offset.x,image->tile_offset.y);
   if ((image->magick_columns != 0) || (image->magick_rows != 0))
@@ -412,25 +412,25 @@
         image->x_resolution,(double) image->rows/image->y_resolution);
     }
   (void) fprintf(file,"  Units: %s\n",MagickOptionToMnemonic(
-    MagickResolutionOptions,(long) image->units));
+    MagickResolutionOptions,(ssize_t) image->units));
   (void) fprintf(file,"  Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
-    (long) type));
+    (ssize_t) type));
   if (image->type != UndefinedType)
     (void) fprintf(file,"  Base type: %s\n",MagickOptionToMnemonic(
-      MagickTypeOptions,(long) image->type));
+      MagickTypeOptions,(ssize_t) image->type));
   (void) fprintf(file,"  Endianess: %s\n",MagickOptionToMnemonic(
-    MagickEndianOptions,(long) image->endian));
+    MagickEndianOptions,(ssize_t) image->endian));
   /*
     Detail channel depth and extrema.
   */
   (void) fprintf(file,"  Colorspace: %s\n",MagickOptionToMnemonic(
-    MagickColorspaceOptions,(long) image->colorspace));
+    MagickColorspaceOptions,(ssize_t) image->colorspace));
   channel_statistics=(ChannelStatistics *) NULL;
   channel_features=(ChannelFeatures *) NULL;
   colorspace=image->colorspace;
   if (ping == MagickFalse)
     {
-      unsigned long
+      size_t
         depth;
 
       channel_statistics=GetImageChannelStatistics(image,&image->exception);
@@ -492,7 +492,7 @@
       }
       scale=1;
       if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
-        scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long)
+        scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
           MAGICKCORE_QUANTUM_DEPTH-image->depth));
     }
   if (channel_statistics != (ChannelStatistics *) NULL)
@@ -594,22 +594,22 @@
 
           p=(PixelPacket *) NULL;
           indexes=(IndexPacket *) NULL;
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < (ssize_t) image->rows; y++)
           {
             p=GetVirtualPixels(image,0,y,image->columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
             indexes=GetVirtualIndexQueue(image);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               if (p->opacity == (Quantum) TransparentOpacity)
                 break;
               p++;
             }
-            if (x < (long) image->columns)
+            if (x < (ssize_t) image->columns)
               break;
           }
-          if ((x < (long) image->columns) || (y < (long) image->rows))
+          if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
             {
               char
                 tuple[MaxTextExtent];
@@ -655,7 +655,7 @@
 
           GetMagickPixelPacket(image,&pixel);
           p=image->colormap;
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
             (void) CopyMagickString(tuple,"(",MaxTextExtent);
@@ -695,7 +695,7 @@
     (void) fprintf(file,"  Normalized maximum error: %g\n",
       image->error.normalized_maximum_error);
   (void) fprintf(file,"  Rendering intent: %s\n",MagickOptionToMnemonic(
-    MagickIntentOptions,(long) image->rendering_intent));
+    MagickIntentOptions,(ssize_t) image->rendering_intent));
   if (image->gamma != 0.0)
     (void) fprintf(file,"  Gamma: %g\n",image->gamma);
   if ((image->chromaticity.red_primary.x != 0.0) ||
@@ -722,7 +722,7 @@
       image->extract_info.width,image->extract_info.height,
       image->extract_info.x,image->extract_info.y);
   (void) fprintf(file,"  Interlace: %s\n",MagickOptionToMnemonic(
-    MagickInterlaceOptions,(long) image->interlace));
+    MagickInterlaceOptions,(ssize_t) image->interlace));
   (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
     &image->exception);
   (void) fprintf(file,"  Background color: %s\n",color);
@@ -736,7 +736,7 @@
     &image->exception);
   (void) fprintf(file,"  Transparent color: %s\n",color);
   (void) fprintf(file,"  Compose: %s\n",MagickOptionToMnemonic(
-    MagickComposeOptions,(long) image->compose));
+    MagickComposeOptions,(ssize_t) image->compose));
   if ((image->page.width != 0) || (image->page.height != 0) ||
       (image->page.x != 0) || (image->page.y != 0))
     (void) fprintf(file,"  Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
@@ -745,7 +745,7 @@
     (void) fprintf(file,"  Origin geometry: %+ld%+ld\n",image->page.x,
       image->page.y);
   (void) fprintf(file,"  Dispose: %s\n",MagickOptionToMnemonic(
-    MagickDisposeOptions,(long) image->dispose));
+    MagickDisposeOptions,(ssize_t) image->dispose));
   if (image->delay != 0)
     (void) fprintf(file,"  Delay: %lux%ld\n",image->delay,
       image->ticks_per_second);
@@ -758,11 +758,11 @@
     if (image->scene != 0)
       (void) fprintf(file,"  Scene: %lu\n",image->scene);
   (void) fprintf(file,"  Compression: %s\n",MagickOptionToMnemonic(
-    MagickCompressOptions,(long) image->compression));
+    MagickCompressOptions,(ssize_t) image->compression));
   if (image->quality != UndefinedCompressionQuality)
     (void) fprintf(file,"  Quality: %lu\n",image->quality);
   (void) fprintf(file,"  Orientation: %s\n",MagickOptionToMnemonic(
-    MagickOrientationOptions,(long) image->orientation));
+    MagickOrientationOptions,(ssize_t) image->orientation));
   if (image->montage != (char *) NULL)
     (void) fprintf(file,"  Montage: %s\n",image->montage);
   if (image->directory != (char *) NULL)
@@ -869,7 +869,7 @@
         profile=GetImageProfile(image,name);
         if (profile == (StringInfo *) NULL)
           continue;
-        (void) fprintf(file,"    Profile-%s: %lu bytes\n",name,(unsigned long)
+        (void) fprintf(file,"    Profile-%s: %lu bytes\n",name,(size_t)
           GetStringInfoLength(profile));
 #if defined(MAGICKCORE_LCMS_DELEGATE)
         if ((LocaleCompare(name,"icc") == 0) ||
@@ -919,12 +919,12 @@
             const char
               *tag;
 
-            long
+            ssize_t
               dataset,
               record,
               sentinel;
 
-            register long
+            register ssize_t
               j;
 
             size_t
@@ -932,7 +932,7 @@
               profile_length;
 
             profile_length=GetStringInfoLength(profile);
-            for (i=0; i < (long) profile_length; i+=(long) length)
+            for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
             {
               length=1;
               sentinel=GetStringInfoDatum(profile)[i++];
@@ -1073,7 +1073,7 @@
       }
     }
   (void) fprintf(file,"  Tainted: %s\n",MagickOptionToMnemonic(
-    MagickBooleanOptions,(long) image->taint));
+    MagickBooleanOptions,(ssize_t) image->taint));
   (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
   (void) fprintf(file,"  Filesize: %sB\n",format);
   (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
@@ -1083,10 +1083,10 @@
     elapsed_time+0.5),MagickFalse,format);
   (void) fprintf(file,"  Pixels per second: %s\n",format);
   (void) fprintf(file,"  User time: %0.3fu\n",user_time);
-  (void) fprintf(file,"  Elapsed time: %ld:%02ld.%03ld\n",(long)
-    (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
+  (void) fprintf(file,"  Elapsed time: %ld:%02ld.%03ld\n",(ssize_t)
+    (elapsed_time/60.0),(ssize_t) ceil(fmod(elapsed_time,60.0)),(ssize_t)
     (1000.0*(elapsed_time-floor(elapsed_time))));
-  (void) fprintf(file,"  Version: %s\n",GetMagickVersion((unsigned long *)
+  (void) fprintf(file,"  Version: %s\n",GetMagickVersion((size_t *)
     NULL));
   (void) fflush(file);
   return(ferror(file) != 0 ? MagickFalse : MagickTrue);
diff --git a/magick/image-private.h b/magick/image-private.h
index 3e68204..463aef8 100644
--- a/magick/image-private.h
+++ b/magick/image-private.h
@@ -60,24 +60,24 @@
   return(180.0*radians/MagickPI);
 }
 
-static inline unsigned char ScaleColor5to8(const unsigned long color)
+static inline unsigned char ScaleColor5to8(const size_t color)
 {
   return((unsigned char) (((color) << 3) | ((color) >> 2)));
 }
 
-static inline unsigned char ScaleColor6to8(const unsigned long color)
+static inline unsigned char ScaleColor6to8(const size_t color)
 {
   return((unsigned char) (((color) << 2) | ((color) >> 4)));
 }
 
-static inline unsigned long ScaleColor8to5(const unsigned char color)
+static inline size_t ScaleColor8to5(const unsigned char color)
 {
-  return((unsigned long) (((color) & ~0x07) >> 3));
+  return((size_t) (((color) & ~0x07) >> 3));
 }
 
-static inline unsigned long ScaleColor8to6(const unsigned char color)
+static inline size_t ScaleColor8to6(const unsigned char color)
 {
-  return((unsigned long) (((color) & ~0x03) >> 2));
+  return((size_t) (((color) & ~0x03) >> 2));
 }
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/image.c b/magick/image.c
index 3938347..0f8e44d 100644
--- a/magick/image.c
+++ b/magick/image.c
@@ -389,28 +389,30 @@
   Image
     *append_image;
 
-  long
-    n,
-    x_offset,
-    y,
-    y_offset;
-
   MagickBooleanType
     matte,
     proceed,
     status;
 
+  MagickOffsetType
+    n;
+
   RectangleInfo
     geometry;
 
   register const Image
     *next;
 
-  unsigned long
+  size_t
     height,
     number_images,
     width;
 
+  ssize_t
+    x_offset,
+    y,
+    y_offset;
+
   /*
     Ensure the image have the same column width.
   */
@@ -459,7 +461,7 @@
   x_offset=0;
   y_offset=0;
   append_view=AcquireCacheView(append_image);
-  for (n=0; n < (long) number_images; n++)
+  for (n=0; n < (MagickOffsetType) number_images; n++)
   {
     SetGeometry(append_image,&geometry);
     GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
@@ -471,7 +473,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
     #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       MagickBooleanType
         sync;
@@ -485,7 +487,7 @@
       register IndexPacket
         *restrict append_indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -503,7 +505,7 @@
         }
       indexes=GetCacheViewVirtualIndexQueue(image_view);
       append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         SetRedPixelComponent(q,GetRedPixelComponent(p));
         SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -697,8 +699,8 @@
 %
 %  The format of the CloneImage method is:
 %
-%      Image *CloneImage(const Image *image,const unsigned long columns,
-%        const unsigned long rows,const MagickBooleanType orphan,
+%      Image *CloneImage(const Image *image,const size_t columns,
+%        const size_t rows,const MagickBooleanType orphan,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -715,8 +717,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
-  const unsigned long rows,const MagickBooleanType detach,
+MagickExport Image *CloneImage(const Image *image,const size_t columns,
+  const size_t rows,const MagickBooleanType detach,
   ExceptionInfo *exception)
 {
   Image
@@ -807,13 +809,13 @@
       return(clone_image);
     }
   scale=(MagickRealType) columns/(MagickRealType) image->columns;
-  clone_image->page.width=(unsigned long) floor(scale*image->page.width+0.5);
-  clone_image->page.x=(long) ceil(scale*image->page.x-0.5);
-  clone_image->tile_offset.x=(long) ceil(scale*image->tile_offset.x-0.5);
+  clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
+  clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
+  clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
   scale=(MagickRealType) rows/(MagickRealType) image->rows;
-  clone_image->page.height=(unsigned long) floor(scale*image->page.height+0.5);
-  clone_image->page.y=(long) ceil(scale*image->page.y-0.5);
-  clone_image->tile_offset.y=(long) ceil(scale*image->tile_offset.y-0.5);
+  clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
+  clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
+  clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
   clone_image->columns=columns;
   clone_image->rows=rows;
   clone_image->cache=ClonePixelCache(image->cache);
@@ -971,13 +973,15 @@
   Image
     *combine_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   /*
     Ensure the image are the same size.
   */
@@ -1013,7 +1017,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) combine_image->rows; y++)
+  for (y=0; y < (ssize_t) combine_image->rows; y++)
   {
     CacheView
       *image_view;
@@ -1027,7 +1031,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1050,7 +1054,7 @@
         if (p == (const PixelPacket *) NULL)
           continue;
         q=pixels;
-        for (x=0; x < (long) combine_image->columns; x++)
+        for (x=0; x < (ssize_t) combine_image->columns; x++)
         {
           SetRedPixelComponent(q,PixelIntensityToQuantum(p));
           p++;
@@ -1066,7 +1070,7 @@
         if (p == (const PixelPacket *) NULL)
           continue;
         q=pixels;
-        for (x=0; x < (long) combine_image->columns; x++)
+        for (x=0; x < (ssize_t) combine_image->columns; x++)
         {
           SetGreenPixelComponent(q,PixelIntensityToQuantum(p));
           p++;
@@ -1082,7 +1086,7 @@
         if (p == (const PixelPacket *) NULL)
           continue;
         q=pixels;
-        for (x=0; x < (long) combine_image->columns; x++)
+        for (x=0; x < (ssize_t) combine_image->columns; x++)
         {
           SetBluePixelComponent(q,PixelIntensityToQuantum(p));
           p++;
@@ -1098,7 +1102,7 @@
         if (p == (const PixelPacket *) NULL)
           continue;
         q=pixels;
-        for (x=0; x < (long) combine_image->columns; x++)
+        for (x=0; x < (ssize_t) combine_image->columns; x++)
         {
           SetOpacityPixelComponent(q,PixelIntensityToQuantum(p));
           p++;
@@ -1118,7 +1122,7 @@
         if (p == (const PixelPacket *) NULL)
           continue;
         indexes=GetCacheViewAuthenticIndexQueue(combine_view);
-        for (x=0; x < (long) combine_image->columns; x++)
+        for (x=0; x < (ssize_t) combine_image->columns; x++)
         {
           indexes[x]=PixelIntensityToQuantum(p);
           p++;
@@ -1557,16 +1561,16 @@
 %
 %  The format of the GetReferenceCount method is:
 %
-%      long GetImageReferenceCount(Image *image)
+%      ssize_t GetImageReferenceCount(Image *image)
 %
 %  A description of each parameter follows:
 %
 %    o image: the image.
 %
 */
-MagickExport long GetImageReferenceCount(Image *image)
+MagickExport ssize_t GetImageReferenceCount(Image *image)
 {
-  long
+  ssize_t
     reference_count;
 
   assert(image != (Image *) NULL);
@@ -1672,10 +1676,10 @@
       }
     if (*q == '0')
       {
-        long
+        ssize_t
           value;
 
-        value=strtol(q,&q,10);
+        value=(ssize_t) strtol(q,&q,10);
       }
     switch (*q)
     {
@@ -1704,13 +1708,13 @@
         const char
           *value;
 
-        long
+        ssize_t
           depth;
 
         register char
           *r;
 
-        register long
+        register ssize_t
           i;
 
         /*
@@ -1808,7 +1812,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1827,7 +1831,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -1838,7 +1842,7 @@
     register const PixelPacket
       *p;
 
-    register long
+    register ssize_t
       x;
 
     if (status == MagickFalse)
@@ -1851,7 +1855,7 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     pixel=zero;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,p,indexes+x,&pixel);
       if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
@@ -1877,7 +1881,7 @@
         }
       p++;
     }
-    if (x < (long) image->columns)
+    if (x < (ssize_t) image->columns)
       status=MagickFalse;
   }
   image_view=DestroyCacheView(image_view);
@@ -2036,7 +2040,7 @@
 %  The format of the NewMagickImage method is:
 %
 %      Image *NewMagickImage(const ImageInfo *image_info,
-%        const unsigned long width,const unsigned long height,
+%        const size_t width,const size_t height,
 %        const MagickPixelPacket *background)
 %
 %  A description of each parameter follows:
@@ -2051,7 +2055,7 @@
 %
 */
 MagickExport Image *NewMagickImage(const ImageInfo *image_info,
-  const unsigned long width,const unsigned long height,
+  const size_t width,const size_t height,
   const MagickPixelPacket *background)
 {
   CacheView
@@ -2063,7 +2067,7 @@
   Image
     *image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2087,12 +2091,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2107,7 +2111,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetPixelPacket(image,background,q,indexes+x);
       q++;
@@ -2265,13 +2269,15 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -2290,12 +2296,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2314,7 +2320,7 @@
     {
       case RedChannel:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->green=q->red;
           q->blue=q->red;
@@ -2324,7 +2330,7 @@
       }
       case GreenChannel:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=q->green;
           q->blue=q->green;
@@ -2334,7 +2340,7 @@
       }
       case BlueChannel:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=q->blue;
           q->green=q->blue;
@@ -2344,7 +2350,7 @@
       }
       case OpacityChannel:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=q->opacity;
           q->green=q->opacity;
@@ -2358,7 +2364,7 @@
         if ((image->storage_class != PseudoClass) &&
             (image->colorspace != CMYKColorspace))
           break;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=indexes[x];
           q->green=indexes[x];
@@ -2369,7 +2375,7 @@
       }
       case TrueAlphaChannel:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=(Quantum) GetAlphaPixelComponent(q);
           q->green=(Quantum) GetAlphaPixelComponent(q);
@@ -2380,7 +2386,7 @@
       }
       case GrayChannels:
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->opacity=(Quantum) (QuantumRange-PixelIntensityToQuantum(q));
           q++;
@@ -2545,7 +2551,7 @@
       IndexPacket
         index;
 
-      long
+      ssize_t
         y;
 
       MagickBooleanType
@@ -2577,12 +2583,12 @@
       #if defined(MAGICKCORE_OPENMP_SUPPORT)
         #pragma omp parallel for schedule(dynamic,4) shared(status)
       #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -2597,7 +2603,7 @@
             status=MagickFalse;
             continue;
           }
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           if (q->opacity == TransparentOpacity)
             {
@@ -2610,7 +2616,7 @@
         if (image->colorspace == CMYKColorspace)
           {
             indexes=GetCacheViewAuthenticIndexQueue(image_view);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
               indexes[x]=index;
           }
         if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -2717,7 +2723,7 @@
   IndexPacket
     index;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2753,12 +2759,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2772,12 +2778,12 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *q++=pixel;
     if (image->colorspace == CMYKColorspace)
       {
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           indexes[x]=index;
       }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -2821,7 +2827,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2842,12 +2848,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2862,7 +2868,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetPixelPacket(image,color,q,indexes+x);
       q++;
@@ -2980,7 +2986,7 @@
 %  The format of the SetImageExtent method is:
 %
 %      MagickBooleanType SetImageExtent(Image *image,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2992,7 +2998,7 @@
 %
 */
 MagickExport MagickBooleanType SetImageExtent(Image *image,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Cache
     cache;
@@ -3098,7 +3104,7 @@
             }
           else
             {
-              unsigned long
+              size_t
                 first,
                 last;
 
@@ -3111,12 +3117,12 @@
                 while ((isspace((int) ((unsigned char) *p)) != 0) ||
                        (*p == ','))
                   p++;
-                first=(unsigned long) strtol(p,&q,10);
+                first=(size_t) strtol(p,&q,10);
                 last=first;
                 while (isspace((int) ((unsigned char) *q)) != 0)
                   q++;
                 if (*q == '-')
-                  last=(unsigned long) strtol(q+1,&q,10);
+                  last=(size_t) strtol(q+1,&q,10);
                 if (first > last)
                   Swap(first,last);
                 if (first < image_info->scene)
@@ -3166,7 +3172,7 @@
       MagickFormatType
         format_type;
 
-      register long
+      register ssize_t
         i;
 
       static const char
@@ -3501,7 +3507,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -3518,9 +3524,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3534,7 +3540,7 @@
         status=MagickFalse;
         continue;
       }
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetOpacityPixelComponent(q,opacity);
       q++;
@@ -3818,7 +3824,7 @@
 */
 
 static inline IndexPacket PushColormapIndex(Image *image,
-  const unsigned long index,MagickBooleanType *range_exception)
+  const size_t index,MagickBooleanType *range_exception)
 {
   if (index < image->colors)
     return((IndexPacket) index);
@@ -3834,7 +3840,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -3854,7 +3860,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     IndexPacket
       index;
@@ -3865,7 +3871,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -3880,11 +3886,11 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      index=PushColormapIndex(image,(unsigned long) indexes[x],
+      index=PushColormapIndex(image,(size_t) indexes[x],
         &range_exception);
-      pixel=image->colormap[(long) index];
+      pixel=image->colormap[(ssize_t) index];
       q->red=pixel.red;
       q->green=pixel.green;
       q->blue=pixel.blue;
@@ -4024,19 +4030,19 @@
       flags=ParseGeometry(option,&geometry_info);
       if ((flags & GreaterValue) != 0)
         {
-          if (image->delay > (unsigned long) floor(geometry_info.rho+0.5))
-            image->delay=(unsigned long) floor(geometry_info.rho+0.5);
+          if (image->delay > (size_t) floor(geometry_info.rho+0.5))
+            image->delay=(size_t) floor(geometry_info.rho+0.5);
         }
       else
         if ((flags & LessValue) != 0)
           {
-            if (image->delay < (unsigned long) floor(geometry_info.rho+0.5))
-              image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
+            if (image->delay < (size_t) floor(geometry_info.rho+0.5))
+              image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
           }
         else
-          image->delay=(unsigned long) floor(geometry_info.rho+0.5);
+          image->delay=(size_t) floor(geometry_info.rho+0.5);
       if ((flags & SigmaValue) != 0)
-        image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
+        image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
     }
   option=GetImageOption(image_info,"density");
   if (option != (const char *) NULL)
@@ -4181,9 +4187,9 @@
           {
             if (units == PixelsPerInchResolution)
               {
-                image->x_resolution=(double) ((unsigned long) (100.0*2.54*
+                image->x_resolution=(double) ((size_t) (100.0*2.54*
                   image->x_resolution+0.5))/100.0;
-                image->y_resolution=(double) ((unsigned long) (100.0*2.54*
+                image->y_resolution=(double) ((size_t) (100.0*2.54*
                   image->y_resolution+0.5))/100.0;
               }
             break;
diff --git a/magick/image.h b/magick/image.h
index d373149..444efd2 100644
--- a/magick/image.h
+++ b/magick/image.h
@@ -155,7 +155,7 @@
   CompressionType
     compression;
 
-  unsigned long
+  size_t
     quality;
 
   OrientationType
@@ -165,7 +165,7 @@
     taint,
     matte;
 
-  unsigned long
+  size_t
     columns,
     rows,
     depth,
@@ -197,7 +197,7 @@
     *directory,
     *geometry;
 
-  long
+  ssize_t
     offset;
 
   double
@@ -235,18 +235,18 @@
   struct _Image
     *clip_mask;
 
-  unsigned long
+  size_t
     scene,
     delay;
 
-  long
+  ssize_t
     ticks_per_second;
 
-  unsigned long
+  size_t
     iterations,
     total_colors;
 
-  long
+  ssize_t
     start_loop;
 
   ErrorInfo
@@ -274,7 +274,7 @@
     magick_filename[MaxTextExtent],
     magick[MaxTextExtent];
 
-  unsigned long
+  size_t
     magick_columns,
     magick_rows;
 
@@ -284,7 +284,7 @@
   MagickBooleanType
     debug;
 
-  volatile long
+  volatile ssize_t
     reference_count;
 
   SemaphoreInfo
@@ -295,10 +295,10 @@
     iptc_profile,
     *generic_profile;
 
-  unsigned long
+  size_t
     generic_profiles;  /* this & ProfileInfo is deprecated */
 
-  unsigned long
+  size_t
     signature;
 
   struct _Image
@@ -358,7 +358,7 @@
     *page,
     *scenes;
 
-  unsigned long
+  size_t
     scene,
     number_scenes,
     depth;
@@ -372,7 +372,7 @@
   ResolutionType
     units;
 
-  unsigned long
+  size_t
     quality;
 
   char
@@ -395,7 +395,7 @@
     dither,
     monochrome;
 
-  unsigned long
+  size_t
     colors;
 
   ColorspaceType
@@ -407,7 +407,7 @@
   PreviewType
     preview_type;
 
-  long
+  ssize_t
     group;
 
   MagickBooleanType
@@ -458,14 +458,14 @@
   char
     *tile;  /* deprecated */
 
-  unsigned long
+  size_t
     subimage,  /* deprecated */
     subrange;  /* deprecated */
 
   PixelPacket
     pen;  /* deprecated */
 
-  unsigned long
+  size_t
     signature;
 
   VirtualPixelMethod
@@ -490,13 +490,13 @@
 extern MagickExport Image
   *AcquireImage(const ImageInfo *),
   *AppendImages(const Image *,const MagickBooleanType,ExceptionInfo *),
-  *CloneImage(const Image *,const unsigned long,const unsigned long,
+  *CloneImage(const Image *,const size_t,const size_t,
     const MagickBooleanType,ExceptionInfo *),
   *CombineImages(const Image *,const ChannelType,ExceptionInfo *),
   *DestroyImage(Image *),
   *GetImageClipMask(const Image *,ExceptionInfo *),
   *GetImageMask(const Image *,ExceptionInfo *),
-  *NewMagickImage(const ImageInfo *,const unsigned long,const unsigned long,
+  *NewMagickImage(const ImageInfo *,const size_t,const size_t,
     const MagickPixelPacket *),
   *ReferenceImage(Image *),
   *SeparateImages(const Image *,const ChannelType,ExceptionInfo *);
@@ -506,7 +506,7 @@
   *CloneImageInfo(const ImageInfo *),
   *DestroyImageInfo(ImageInfo *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   GetImageReferenceCount(Image *);
 
 extern MagickExport MagickBooleanType
@@ -525,7 +525,7 @@
   SetImageBackgroundColor(Image *),
   SetImageClipMask(Image *,const Image *),
   SetImageColor(Image *,const MagickPixelPacket *),
-  SetImageExtent(Image *,const unsigned long,const unsigned long),
+  SetImageExtent(Image *,const size_t,const size_t),
   SetImageInfo(ImageInfo *,const unsigned int,ExceptionInfo *),
   SetImageMask(Image *,const Image *),
   SetImageOpacity(Image *,const Quantum),
diff --git a/magick/layer.c b/magick/layer.c
index f049bc9..cfd5783 100644
--- a/magick/layer.c
+++ b/magick/layer.c
@@ -97,7 +97,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   if (bounds->x < 0)
@@ -105,9 +105,9 @@
   if (image->matte == MagickFalse)
     (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
   exception=(&image->exception);
-  for (y=0; y < (long) bounds->height; y++)
+  for (y=0; y < (ssize_t) bounds->height; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -116,7 +116,7 @@
     q=GetAuthenticPixels(image,bounds->x,bounds->y+y,bounds->width,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) bounds->width; x++)
+    for (x=0; x < (ssize_t) bounds->width; x++)
     {
       q->opacity=(Quantum) TransparentOpacity;
       q++;
@@ -163,10 +163,10 @@
 static MagickBooleanType IsBoundsCleared(const Image *image1,
   const Image *image2,RectangleInfo *bounds,ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register const PixelPacket
@@ -175,7 +175,7 @@
 
   if ( bounds->x< 0 ) return(MagickFalse);
 
-  for (y=0; y < (long) bounds->height; y++)
+  for (y=0; y < (ssize_t) bounds->height; y++)
   {
     p=GetVirtualPixels(image1,bounds->x,bounds->y+y,bounds->width,1,
       exception);
@@ -183,18 +183,18 @@
       exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
-    for (x=0; x < (long) bounds->width; x++)
+    for (x=0; x < (ssize_t) bounds->width; x++)
     {
-      if ((p->opacity <= (long) (QuantumRange/2)) &&
-          (q->opacity > (long) (QuantumRange/2)))
+      if ((p->opacity <= (ssize_t) (QuantumRange/2)) &&
+          (q->opacity > (ssize_t) (QuantumRange/2)))
         break;
       p++;
       q++;
     }
-    if (x < (long) bounds->width)
+    if (x < (ssize_t) bounds->width)
       break;
   }
-  return(y < (long) bounds->height ? MagickTrue : MagickFalse);
+  return(y < (ssize_t) bounds->height ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -295,14 +295,14 @@
         bounds.width+=bounds.x;
         bounds.x=0;
       }
-    if ((long) (bounds.x+bounds.width) > (long) coalesce_image->columns)
+    if ((ssize_t) (bounds.x+bounds.width) > (ssize_t) coalesce_image->columns)
       bounds.width=coalesce_image->columns-bounds.x;
     if (bounds.y < 0)
       {
         bounds.height+=bounds.y;
         bounds.y=0;
       }
-    if ((long) (bounds.y+bounds.height) > (long) coalesce_image->rows)
+    if ((ssize_t) (bounds.y+bounds.height) > (ssize_t) coalesce_image->rows)
       bounds.height=coalesce_image->rows-bounds.y;
     /*
       Replace the dispose image with the new coalesced image.
@@ -438,14 +438,14 @@
             bounds.width+=bounds.x;
             bounds.x=0;
           }
-        if ((long) (bounds.x+bounds.width) > (long) current_image->columns)
+        if ((ssize_t) (bounds.x+bounds.width) > (ssize_t) current_image->columns)
           bounds.width=current_image->columns-bounds.x;
         if (bounds.y < 0)
           {
             bounds.height+=bounds.y;
             bounds.y=0;
           }
-        if ((long) (bounds.y+bounds.height) > (long) current_image->rows)
+        if ((ssize_t) (bounds.y+bounds.height) > (ssize_t) current_image->rows)
           bounds.height=current_image->rows-bounds.y;
         ClearBounds(current_image,&bounds);
       }
@@ -605,10 +605,10 @@
     *p,
     *q;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -616,7 +616,7 @@
   */
   GetMagickPixelPacket(image1,&pixel1);
   GetMagickPixelPacket(image2,&pixel2);
-  for (x=0; x < (long) image1->columns; x++)
+  for (x=0; x < (ssize_t) image1->columns; x++)
   {
     p=GetVirtualPixels(image1,x,0,1,image1->rows,exception);
     q=GetVirtualPixels(image2,x,0,1,image2->rows,exception);
@@ -625,7 +625,7 @@
       break;
     indexes1=GetVirtualIndexQueue(image1);
     indexes2=GetVirtualIndexQueue(image2);
-    for (y=0; y < (long) image1->rows; y++)
+    for (y=0; y < (ssize_t) image1->rows; y++)
     {
       SetMagickPixelPacket(image1,p,indexes1+x,&pixel1);
       SetMagickPixelPacket(image2,q,indexes2+x,&pixel2);
@@ -634,10 +634,10 @@
       p++;
       q++;
     }
-    if (y < (long) image1->rows)
+    if (y < (ssize_t) image1->rows)
       break;
   }
-  if (x >= (long) image1->columns)
+  if (x >= (ssize_t) image1->columns)
     {
       /*
         Images are identical, return a null image.
@@ -649,7 +649,7 @@
       return(bounds);
     }
   bounds.x=x;
-  for (x=(long) image1->columns-1; x >= 0; x--)
+  for (x=(ssize_t) image1->columns-1; x >= 0; x--)
   {
     p=GetVirtualPixels(image1,x,0,1,image1->rows,exception);
     q=GetVirtualPixels(image2,x,0,1,image2->rows,exception);
@@ -658,7 +658,7 @@
       break;
     indexes1=GetVirtualIndexQueue(image1);
     indexes2=GetVirtualIndexQueue(image2);
-    for (y=0; y < (long) image1->rows; y++)
+    for (y=0; y < (ssize_t) image1->rows; y++)
     {
       SetMagickPixelPacket(image1,p,indexes1+x,&pixel1);
       SetMagickPixelPacket(image2,q,indexes2+x,&pixel2);
@@ -667,11 +667,11 @@
       p++;
       q++;
     }
-    if (y < (long) image1->rows)
+    if (y < (ssize_t) image1->rows)
       break;
   }
-  bounds.width=(unsigned long) (x-bounds.x+1);
-  for (y=0; y < (long) image1->rows; y++)
+  bounds.width=(size_t) (x-bounds.x+1);
+  for (y=0; y < (ssize_t) image1->rows; y++)
   {
     p=GetVirtualPixels(image1,0,y,image1->columns,1,exception);
     q=GetVirtualPixels(image2,0,y,image2->columns,1,exception);
@@ -680,7 +680,7 @@
       break;
     indexes1=GetVirtualIndexQueue(image1);
     indexes2=GetVirtualIndexQueue(image2);
-    for (x=0; x < (long) image1->columns; x++)
+    for (x=0; x < (ssize_t) image1->columns; x++)
     {
       SetMagickPixelPacket(image1,p,indexes1+x,&pixel1);
       SetMagickPixelPacket(image2,q,indexes2+x,&pixel2);
@@ -689,11 +689,11 @@
       p++;
       q++;
     }
-    if (x < (long) image1->columns)
+    if (x < (ssize_t) image1->columns)
       break;
   }
   bounds.y=y;
-  for (y=(long) image1->rows-1; y >= 0; y--)
+  for (y=(ssize_t) image1->rows-1; y >= 0; y--)
   {
     p=GetVirtualPixels(image1,0,y,image1->columns,1,exception);
     q=GetVirtualPixels(image2,0,y,image2->columns,1,exception);
@@ -702,7 +702,7 @@
       break;
     indexes1=GetVirtualIndexQueue(image1);
     indexes2=GetVirtualIndexQueue(image2);
-    for (x=0; x < (long) image1->columns; x++)
+    for (x=0; x < (ssize_t) image1->columns; x++)
     {
       SetMagickPixelPacket(image1,p,indexes1+x,&pixel1);
       SetMagickPixelPacket(image2,q,indexes2+x,&pixel2);
@@ -711,10 +711,10 @@
       p++;
       q++;
     }
-    if (x < (long) image1->columns)
+    if (x < (ssize_t) image1->columns)
       break;
   }
-  bounds.height=(unsigned long) (y-bounds.y+1);
+  bounds.height=(size_t) (y-bounds.y+1);
   return(bounds);
 }
 
@@ -770,7 +770,7 @@
   register const Image
     *next;
 
-  register long
+  register ssize_t
     i;
 
   assert(image != (const Image *) NULL);
@@ -976,7 +976,7 @@
   register const Image
     *next;
 
-  register long
+  register ssize_t
     i;
 
   assert(image != (const Image *) NULL);
@@ -1270,7 +1270,7 @@
     if (prev_image == (Image *) NULL)
       break;
     if ( disposals[i] == DelDispose ) {
-      unsigned long time = 0;
+      size_t time = 0;
       while ( disposals[i] == DelDispose ) {
         time += next->delay*1000/next->ticks_per_second;
         next=GetNextImageInList(next);
@@ -1466,14 +1466,14 @@
             bounds.width+=bounds.x;
             bounds.x=0;
           }
-        if ((long) (bounds.x+bounds.width) > (long) current_image->columns)
+        if ((ssize_t) (bounds.x+bounds.width) > (ssize_t) current_image->columns)
           bounds.width=current_image->columns-bounds.x;
         if (bounds.y < 0)
           {
             bounds.height+=bounds.y;
             bounds.y=0;
           }
-        if ((long) (bounds.y+bounds.height) > (long) current_image->rows)
+        if ((ssize_t) (bounds.y+bounds.height) > (ssize_t) current_image->rows)
           bounds.height=current_image->rows-bounds.y;
         ClearBounds(current_image, &bounds);
       }
@@ -1557,7 +1557,7 @@
       /*
         the two images are the same, merge time delays and delete one.
       */
-      unsigned long time;
+      size_t time;
       time = curr->delay*1000/curr->ticks_per_second;
       time += next->delay*1000/next->ticks_per_second;
       next->ticks_per_second = 100L;
@@ -1681,7 +1681,7 @@
 %
 %      void CompositeLayers(Image *destination,
 %          const CompositeOperator compose, Image *source,
-%          const long x_offset, const long y_offset,
+%          const ssize_t x_offset, const ssize_t y_offset,
 %          ExceptionInfo *exception);
 %
 %  A description of each parameter follows:
@@ -1697,7 +1697,7 @@
 */
 static inline void CompositeCanvas(Image *destination,
      const CompositeOperator compose, Image *source,
-     long x_offset, long y_offset )
+     ssize_t x_offset, ssize_t y_offset )
 {
   x_offset += source->page.x - destination->page.x;
   y_offset += source->page.y - destination->page.y;
@@ -1706,7 +1706,7 @@
 
 MagickExport void CompositeLayers(Image *destination,
       const CompositeOperator compose, Image *source,
-      const long x_offset, const long y_offset,
+      const ssize_t x_offset, const ssize_t y_offset,
       ExceptionInfo *exception)
 {
   assert(destination != (Image *) NULL);
@@ -1842,14 +1842,14 @@
   RectangleInfo
     page;
 
-  unsigned long
+  size_t
     width,
     height;
 
   register const Image
     *next;
 
-  unsigned long
+  size_t
     number_images;
 
   assert(image != (Image *) NULL);
@@ -1881,9 +1881,9 @@
              page.y = next->page.y;
         }
         if ( width < (next->page.x + next->columns - page.x) )
-           width = (unsigned long) next->page.x + next->columns - page.x;
+           width = (size_t) next->page.x + next->columns - page.x;
         if ( height < (next->page.y + next->rows - page.y) )
-           height = (unsigned long) next->page.y + next->rows - page.y;
+           height = (size_t) next->page.y + next->rows - page.y;
       }
       break;
     }
@@ -1908,9 +1908,9 @@
           page.x=next->page.x;
           page.y=next->page.y;
           if ( width < (next->page.x + next->columns) )
-             width = (unsigned long) next->page.x + next->columns;
+             width = (size_t) next->page.x + next->columns;
           if ( height < (next->page.y + next->rows) )
-             height = (unsigned long) next->page.y + next->rows;
+             height = (size_t) next->page.y + next->rows;
         }
       }
       page.width=width;
@@ -1931,7 +1931,7 @@
   */
   if ( method == TrimBoundsLayer ) {
     number_images=GetImageListLength(image);
-    for (scene=0; scene < (long) number_images; scene++)
+    for (scene=0; scene < (ssize_t) number_images; scene++)
     {
       image->page.x -= page.x;
       image->page.y -= page.y;
@@ -1959,7 +1959,7 @@
     Compose images onto canvas, with progress monitor
   */
   number_images=GetImageListLength(image);
-  for (scene=0; scene < (long) number_images; scene++)
+  for (scene=0; scene < (ssize_t) number_images; scene++)
   {
     (void) CompositeImage(canvas,image->compose,image,image->page.x-
       canvas->page.x,image->page.y-canvas->page.y);
diff --git a/magick/layer.h b/magick/layer.h
index 1c9ce45..9f54928 100644
--- a/magick/layer.h
+++ b/magick/layer.h
@@ -62,7 +62,7 @@
   *OptimizePlusImageLayers(const Image *,ExceptionInfo *);
 
 extern MagickExport void
-  CompositeLayers(Image *,const CompositeOperator,Image *,const long,const long,
+  CompositeLayers(Image *,const CompositeOperator,Image *,const ssize_t,const ssize_t,
     ExceptionInfo *),
   OptimizeImageTransparency(const Image *,ExceptionInfo *),
   RemoveDuplicateLayers(Image **,ExceptionInfo *),
diff --git a/magick/list.c b/magick/list.c
index 7a78986..7adb840 100644
--- a/magick/list.c
+++ b/magick/list.c
@@ -209,12 +209,12 @@
     *clone_images,
     *image;
 
-  long
+  ssize_t
     first,
     last,
     step;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -236,7 +236,7 @@
       p++;
     first=strtol(p,&p,10);
     if (first < 0)
-      first+=(long) length;
+      first+=(ssize_t) length;
     last=first;
     while (isspace((int) ((unsigned char) *p)) != 0)
       p++;
@@ -244,7 +244,7 @@
       {
         last=strtol(p+1,&p,10);
         if (last < 0)
-          last+=(long) length;
+          last+=(ssize_t) length;
       }
     for (step=first > last ? -1 : 1; first != (last+step); first+=step)
     {
@@ -343,14 +343,14 @@
   Image
     *image;
 
-  long
+  ssize_t
     first,
     last;
 
   MagickBooleanType
     *delete_list;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -375,7 +375,7 @@
       return;
     }
   image=(*images);
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
     delete_list[i]=MagickFalse;
   /*
     Note which images will be deleted, avoid duplicate deleted
@@ -386,7 +386,7 @@
       p++;
     first=strtol(p,&p,10);
     if (first < 0)
-      first+=(long) length;
+      first+=(ssize_t) length;
     last=first;
     while (isspace((int) ((unsigned char) *p)) != 0)
       p++;
@@ -394,19 +394,19 @@
       {
         last=strtol(p+1,&p,10);
         if (last < 0)
-          last+=(long) length;
+          last+=(ssize_t) length;
       }
     if (first > last)
       continue;
     for (i=first; i <= last; i++)
-      if ((i >= 0) && (i < (long) length))
+      if ((i >= 0) && (i < (ssize_t) length))
         delete_list[i]=MagickTrue;
   }
   /*
     Delete images marked for deletion, once only
   */
   image=(*images);
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     *images=image;
     image=GetNextImageInList(image);
@@ -501,7 +501,7 @@
 %
 %  The format of the GetImageFromList method is:
 %
-%      Image *GetImageFromList(const Image *images,const long index)
+%      Image *GetImageFromList(const Image *images,const ssize_t index)
 %
 %  A description of each parameter follows:
 %
@@ -510,15 +510,15 @@
 %    o index: the position within the list.
 %
 */
-MagickExport Image *GetImageFromList(const Image *images,const long index)
+MagickExport Image *GetImageFromList(const Image *images,const ssize_t index)
 {
-  long
+  ssize_t
     offset;
 
   register const Image
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -531,9 +531,9 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
   for (p=images; p->previous != (Image *) NULL; p=p->previous) ;
   length=GetImageListLength(images);
-  for (offset=index; offset < 0; offset+=(long) length) ;
+  for (offset=index; offset < 0; offset+=(ssize_t) length) ;
   for (i=0; p != (Image *) NULL; p=p->next)
-    if (i++ == (long) (offset % length))
+    if (i++ == (ssize_t) (offset % length))
       break;
   if (p == (Image *) NULL)
     return((Image *) NULL);
@@ -555,16 +555,16 @@
 %
 %  The format of the GetImageIndexInList method is:
 %
-%      long GetImageIndexInList(const Image *images)
+%      ssize_t GetImageIndexInList(const Image *images)
 %
 %  A description of each parameter follows:
 %
 %    o images: the image list.
 %
 */
-MagickExport long GetImageIndexInList(const Image *images)
+MagickExport ssize_t GetImageIndexInList(const Image *images)
 {
-  register long
+  register ssize_t
     i;
 
   if (images == (const Image *) NULL)
@@ -591,16 +591,16 @@
 %
 %  The format of the GetImageListLength method is:
 %
-%      unsigned long GetImageListLength(const Image *images)
+%      size_t GetImageListLength(const Image *images)
 %
 %  A description of each parameter follows:
 %
 %    o images: the image list.
 %
 */
-MagickExport unsigned long GetImageListLength(const Image *images)
+MagickExport size_t GetImageListLength(const Image *images)
 {
-  register long
+  register ssize_t
     i;
 
   if (images == (Image *) NULL)
@@ -612,7 +612,7 @@
     images=images->previous;
   for (i=0; images != (Image *) NULL; images=images->next)
     i++;
-  return((unsigned long) i);
+  return((size_t) i);
 }
 
 /*
@@ -747,7 +747,7 @@
   Image
     **group;
 
-  register long
+  register ssize_t
     i;
 
   if (images == (Image *) NULL)
@@ -1136,7 +1136,7 @@
 %
 %  The format of the SpliceImageIntoList method is:
 %
-%      SpliceImageIntoList(Image **images,const unsigned long,
+%      SpliceImageIntoList(Image **images,const size_t,
 %        const Image *splice)
 %
 %  A description of each parameter follows:
@@ -1149,13 +1149,13 @@
 %
 */
 MagickExport Image *SpliceImageIntoList(Image **images,
-  const unsigned long length,const Image *splice)
+  const size_t length,const Image *splice)
 {
   Image
     *image,
     *split;
 
-  register unsigned long
+  register size_t
     i;
 
   assert(images != (Image **) NULL);
diff --git a/magick/list.h b/magick/list.h
index 34dc4e7..8134a3e 100644
--- a/magick/list.h
+++ b/magick/list.h
@@ -27,7 +27,7 @@
   *CloneImages(const Image *,const char *,ExceptionInfo *),
   *DestroyImageList(Image *),
   *GetFirstImageInList(const Image *),
-  *GetImageFromList(const Image *,const long),
+  *GetImageFromList(const Image *,const ssize_t),
   *GetLastImageInList(const Image *),
   *GetNextImageInList(const Image *),
   *GetPreviousImageInList(const Image *),
@@ -36,14 +36,14 @@
   *RemoveImageFromList(Image **),
   *RemoveLastImageFromList(Image **),
   *RemoveFirstImageFromList(Image **),
-  *SpliceImageIntoList(Image **,const unsigned long,const Image *),
+  *SpliceImageIntoList(Image **,const size_t,const Image *),
   *SplitImageList(Image *),
   *SyncNextImageInList(const Image *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   GetImageIndexInList(const Image *);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetImageListLength(const Image *);
 
 extern MagickExport void
diff --git a/magick/locale.c b/magick/locale.c
index 728a62c..e8b7abe 100644
--- a/magick/locale.c
+++ b/magick/locale.c
@@ -191,7 +191,7 @@
 %  The format of the GetLocaleInfoList function is:
 %
 %      const LocaleInfo **GetLocaleInfoList(const char *pattern,
-%        unsigned long *number_messages,ExceptionInfo *exception)
+%        size_t *number_messages,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -226,7 +226,7 @@
 #endif
 
 MagickExport const LocaleInfo **GetLocaleInfoList(const char *pattern,
-  unsigned long *number_messages,ExceptionInfo *exception)
+  size_t *number_messages,ExceptionInfo *exception)
 {
   const LocaleInfo
     **messages;
@@ -234,7 +234,7 @@
   register const LocaleInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -242,7 +242,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_messages != (unsigned long *) NULL);
+  assert(number_messages != (size_t *) NULL);
   *number_messages=0;
   p=GetLocaleInfo_("*",exception);
   if (p == (const LocaleInfo *) NULL)
@@ -267,7 +267,7 @@
   UnlockSemaphoreInfo(locale_semaphore);
   qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleInfoCompare);
   messages[i]=(LocaleInfo *) NULL;
-  *number_messages=(unsigned long) i;
+  *number_messages=(size_t) i;
   return(messages);
 }
 
@@ -287,7 +287,7 @@
 %
 %  The format of the GetLocaleList function is:
 %
-%      char **GetLocaleList(const char *pattern,unsigned long *number_messages,
+%      char **GetLocaleList(const char *pattern,size_t *number_messages,
 %        Exceptioninfo *exception)
 %
 %  A description of each parameter follows:
@@ -321,7 +321,7 @@
 #endif
 
 MagickExport char **GetLocaleList(const char *pattern,
-  unsigned long *number_messages,ExceptionInfo *exception)
+  size_t *number_messages,ExceptionInfo *exception)
 {
   char
     **messages;
@@ -329,7 +329,7 @@
   register const LocaleInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -337,7 +337,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_messages != (unsigned long *) NULL);
+  assert(number_messages != (size_t *) NULL);
   *number_messages=0;
   p=GetLocaleInfo_("*",exception);
   if (p == (const LocaleInfo *) NULL)
@@ -358,7 +358,7 @@
   UnlockSemaphoreInfo(locale_semaphore);
   qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleTagCompare);
   messages[i]=(char *) NULL;
-  *number_messages=(unsigned long) i;
+  *number_messages=(size_t) i;
   return(messages);
 }
 
@@ -617,10 +617,10 @@
   const LocaleInfo
     **locale_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_messages;
 
   if (file == (const FILE *) NULL)
@@ -630,7 +630,7 @@
   if (locale_info == (const LocaleInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_messages; i++)
+  for (i=0; i < (ssize_t) number_messages; i++)
   {
     if (locale_info[i]->stealth != MagickFalse)
       continue;
@@ -672,7 +672,7 @@
 %  The format of the LoadLocaleList method is:
 %
 %      MagickBooleanType LoadLocaleList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -686,9 +686,9 @@
 %
 */
 
-static void ChopLocaleComponents(char *path,const unsigned long components)
+static void ChopLocaleComponents(char *path,const size_t components)
 {
-  long
+  ssize_t
     count;
 
   register char
@@ -699,13 +699,13 @@
   p=path+strlen(path)-1;
   if (*p == '/')
     *p='\0';
-  for (count=0; (count < (long) components) && (p > path); p--)
+  for (count=0; (count < (ssize_t) components) && (p > path); p--)
     if (*p == '/')
       {
         *p='\0';
         count++;
       }
-  if (count < (long) components)
+  if (count < (ssize_t) components)
     *path='\0';
 }
 
@@ -740,7 +740,7 @@
 
 
 static MagickBooleanType LoadLocaleList(const char *xml,const char *filename,
-  const char *locale,const unsigned long depth,ExceptionInfo *exception)
+  const char *locale,const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
diff --git a/magick/locale_.h b/magick/locale_.h
index aba383e..1ef2b52 100644
--- a/magick/locale_.h
+++ b/magick/locale_.h
@@ -38,19 +38,19 @@
     *previous,
     *next;  /* deprecated, use GetLocaleInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } LocaleInfo;
 
 extern MagickExport char
-  **GetLocaleList(const char *,unsigned long *,ExceptionInfo *);
+  **GetLocaleList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const char
   *GetLocaleMessage(const char *);
 
 extern MagickExport const LocaleInfo
   *GetLocaleInfo_(const char *,ExceptionInfo *),
-  **GetLocaleInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetLocaleInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport LinkedListInfo
   *DestroyLocaleOptions(LinkedListInfo *),
diff --git a/magick/log.c b/magick/log.c
index 1d7ecee..a267456 100644
--- a/magick/log.c
+++ b/magick/log.c
@@ -112,14 +112,14 @@
     *filename,
     *format;
 
-  unsigned long
+  size_t
     generations,
     limit;
 
   FILE
     *file;
 
-  unsigned long
+  size_t
     generation;
 
   MagickBooleanType
@@ -130,7 +130,7 @@
   TimerInfo
     timer;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -311,7 +311,7 @@
 %  The format of the GetLogInfoList function is:
 %
 %      const LogInfo **GetLogInfoList(const char *pattern,
-%        unsigned long *number_preferences,ExceptionInfo *exception)
+%        size_t *number_preferences,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -344,7 +344,7 @@
 #endif
 
 MagickExport const LogInfo **GetLogInfoList(const char *pattern,
-  unsigned long *number_preferences,ExceptionInfo *exception)
+  size_t *number_preferences,ExceptionInfo *exception)
 {
   const LogInfo
     **preferences;
@@ -352,7 +352,7 @@
   register const LogInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -360,7 +360,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_preferences != (unsigned long *) NULL);
+  assert(number_preferences != (size_t *) NULL);
   *number_preferences=0;
   p=GetLogInfo("*",exception);
   if (p == (const LogInfo *) NULL)
@@ -385,7 +385,7 @@
   UnlockSemaphoreInfo(log_semaphore);
   qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogInfoCompare);
   preferences[i]=(LogInfo *) NULL;
-  *number_preferences=(unsigned long) i;
+  *number_preferences=(size_t) i;
   return(preferences);
 }
 
@@ -404,7 +404,7 @@
 %
 %  The format of the GetLogList function is:
 %
-%      char **GetLogList(const char *pattern,unsigned long *number_preferences,
+%      char **GetLogList(const char *pattern,size_t *number_preferences,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -437,7 +437,7 @@
 #endif
 
 MagickExport char **GetLogList(const char *pattern,
-  unsigned long *number_preferences,ExceptionInfo *exception)
+  size_t *number_preferences,ExceptionInfo *exception)
 {
   char
     **preferences;
@@ -445,7 +445,7 @@
   register const LogInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -453,7 +453,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_preferences != (unsigned long *) NULL);
+  assert(number_preferences != (size_t *) NULL);
   *number_preferences=0;
   p=GetLogInfo("*",exception);
   if (p == (const LogInfo *) NULL)
@@ -478,7 +478,7 @@
   UnlockSemaphoreInfo(log_semaphore);
   qsort((void *) preferences,(size_t) i,sizeof(*preferences),LogCompare);
   preferences[i]=(char *) NULL;
-  *number_preferences=(unsigned long) i;
+  *number_preferences=(size_t) i;
   return(preferences);
 }
 
@@ -617,13 +617,13 @@
   const LogInfo
     **log_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_aliases;
 
   if (file == (const FILE *) NULL)
@@ -633,7 +633,7 @@
     return(MagickFalse);
   j=0;
   path=(const char *) NULL;
-  for (i=0; i < (long) number_aliases; i++)
+  for (i=0; i < (ssize_t) number_aliases; i++)
   {
     if (log_info[i]->stealth != MagickFalse)
       continue;
@@ -650,7 +650,7 @@
     if (log_info[i]->filename != (char *) NULL)
       {
         (void) fprintf(file,"%s",log_info[i]->filename);
-        for (j=(long) strlen(log_info[i]->filename); j <= 16; j++)
+        for (j=(ssize_t) strlen(log_info[i]->filename); j <= 16; j++)
           (void) fprintf(file," ");
       }
     (void) fprintf(file,"%9lu  ",log_info[i]->generations);
@@ -764,7 +764,7 @@
 %  The format of the LogMagickEvent method is:
 %
 %      MagickBooleanType LogMagickEvent(const LogEventType type,
-%        const char *module,const char *function,const unsigned long line,
+%        const char *module,const char *function,const size_t line,
 %        const char *format,...)
 %
 %  A description of each parameter follows:
@@ -781,7 +781,7 @@
 %
 */
 static char *TranslateEvent(const LogEventType magick_unused(type),
-  const char *module,const char *function,const unsigned long line,
+  const char *module,const char *function,const size_t line,
   const char *domain,const char *event)
 {
   char
@@ -840,9 +840,9 @@
         "  <line>%lu</line>\n"
         "  <domain>%s</domain>\n"
         "  <event>%s</event>\n"
-        "</entry>",timestamp,(long) (elapsed_time/60.0),(long)
-        floor(fmod(elapsed_time,60.0)),(long) (1000.0*(elapsed_time-
-        floor(elapsed_time))+0.5),user_time,(long) getpid(),
+        "</entry>",timestamp,(ssize_t) (elapsed_time/60.0),(ssize_t)
+        floor(fmod(elapsed_time,60.0)),(ssize_t) (1000.0*(elapsed_time-
+        floor(elapsed_time))+0.5),user_time,(ssize_t) getpid(),
         GetMagickThreadSignature(),module,function,line,domain,event);
       return(text);
     }
@@ -960,14 +960,14 @@
       }
       case 'p':
       {
-        q+=FormatMagickString(q,extent,"%ld",(long) getpid());
+        q+=FormatMagickString(q,extent,"%ld",(ssize_t) getpid());
         break;
       }
       case 'r':
       {
-        q+=FormatMagickString(q,extent,"%ld:%02ld.%03ld",(long)
-          (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
-          (long) (1000.0*(elapsed_time-floor(elapsed_time))+0.5));
+        q+=FormatMagickString(q,extent,"%ld:%02ld.%03ld",(ssize_t)
+          (elapsed_time/60.0),(ssize_t) floor(fmod(elapsed_time,60.0)),
+          (ssize_t) (1000.0*(elapsed_time-floor(elapsed_time))+0.5));
         break;
       }
       case 't':
@@ -1078,7 +1078,7 @@
       }
       case 'p':
       {
-        q+=FormatMagickString(q,extent,"%ld",(long) getpid());
+        q+=FormatMagickString(q,extent,"%ld",(ssize_t) getpid());
         break;
       }
       case 'v':
@@ -1104,7 +1104,7 @@
 }
 
 MagickBooleanType LogMagickEventList(const LogEventType type,const char *module,
-  const char *function,const unsigned long line,const char *format,
+  const char *function,const size_t line,const char *format,
   va_list operands)
 {
   char
@@ -1228,7 +1228,7 @@
 }
 
 MagickBooleanType LogMagickEvent(const LogEventType type,const char *module,
-  const char *function,const unsigned long line,const char *format,...)
+  const char *function,const size_t line,const char *format,...)
 {
   va_list
     operands;
@@ -1259,7 +1259,7 @@
 %  The format of the LoadLogList method is:
 %
 %      MagickBooleanType LoadLogList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1273,7 +1273,7 @@
 %
 */
 static MagickBooleanType LoadLogList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -1527,7 +1527,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1544,7 +1544,7 @@
           return(MagickFalse);
         }
     }
-  for (i=0; i < (long) (sizeof(LogMap)/sizeof(*LogMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(LogMap)/sizeof(*LogMap)); i++)
   {
     LogInfo
       *log_info;
@@ -1620,7 +1620,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1679,7 +1679,7 @@
   LogInfo
     *log_info;
 
-  long
+  ssize_t
     option;
 
   exception=AcquireExceptionInfo();
diff --git a/magick/log.h b/magick/log.h
index 1922561..14bf30e 100644
--- a/magick/log.h
+++ b/magick/log.h
@@ -26,7 +26,7 @@
 #include "magick/exception.h"
 
 #if !defined(GetMagickModule)
-# define GetMagickModule()  __FILE__,__func__,(unsigned long) __LINE__
+# define GetMagickModule()  __FILE__,__func__,(size_t) __LINE__
 #endif
 
 #define MagickLogFilename  "log.xml"
@@ -59,14 +59,14 @@
   LogInfo;
 
 extern MagickExport char
-  **GetLogList(const char *,unsigned long *,ExceptionInfo *);
+  **GetLogList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const char
   *GetLogName(void),
   *SetLogName(const char *);
                                                                                 
 extern MagickExport const LogInfo
-  **GetLogInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetLogInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport LogEventType
   SetLogEventMask(const char *);
@@ -76,10 +76,10 @@
   ListLogInfo(FILE *,ExceptionInfo *),
   LogComponentGenesis(void),
   LogMagickEvent(const LogEventType,const char *,const char *,
-    const unsigned long,const char *,...) 
+    const size_t,const char *,...) 
     magick_attribute((format (printf,5,6))),
   LogMagickEventList(const LogEventType,const char *,const char *,
-    const unsigned long,const char *,va_list)
+    const size_t,const char *,va_list)
     magick_attribute((format (printf,5,0)));
 
 extern MagickExport void
diff --git a/magick/mac.c b/magick/mac.c
index ce3fde9..9c8f461 100644
--- a/magick/mac.c
+++ b/magick/mac.c
@@ -193,7 +193,7 @@
 {
 #pragma unused (source_rectangle,matrix,mode,mask,matte,matte_rectangle,flags)
 
-  long
+  ssize_t
     size;
 
   Ptr
@@ -218,7 +218,7 @@
   int
     status;
 
-  long
+  ssize_t
     version;
 
   Rect
@@ -408,7 +408,7 @@
 */
 
 static OSErr HGetVInfo(short volume_index,StringPtr volume_name,short *volume,
-  unsigned long *free_bytes,unsigned long *total_bytes)
+  size_t *free_bytes,size_t *total_bytes)
 {
   HParamBlockRec
     pb;
@@ -416,7 +416,7 @@
   OSErr
     result;
 
-  unsigned long
+  size_t
     blocksize;
 
   unsigned short
@@ -433,7 +433,7 @@
   if (result != noErr)
     return(result);
   *volume=pb.volumeParam.ioVRefNum;
-  blocksize=(unsigned long) pb.volumeParam.ioVAlBlkSiz;
+  blocksize=(size_t) pb.volumeParam.ioVAlBlkSiz;
   allocation_blocks=(unsigned short) pb.volumeParam.ioVNmAlBlks;
   free_blocks=(unsigned short) pb.volumeParam.ioVFrBlk;
   *free_bytes=free_blocks*blocksize;
@@ -443,7 +443,7 @@
 
 MagickExport MagickBooleanType MACIsMagickConflict(const char *magick)
 {
-  unsigned long
+  size_t
     free_bytes,
     number_bytes;
 
@@ -594,7 +594,7 @@
 %
 %
 */
-static OSErr MacGSExecuteCommand(const char *command,long length)
+static OSErr MacGSExecuteCommand(const char *command,ssize_t length)
 {
   AEAddressDesc
     event_descriptor;
@@ -653,7 +653,7 @@
 %
 %
 */
-static OSErr MacGSLaunchApplicationCore(long flags)
+static OSErr MacGSLaunchApplicationCore(ssize_t flags)
 {
   FSSpec
     file_info;
@@ -1206,7 +1206,7 @@
     depth,
     status;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1306,7 +1306,7 @@
   image->rows=picture_info.sourceRect.bottom-picture_info.sourceRect.top;
   if ((depth <= 8) && ((*(picture_info.theColorTable))->ctSize != 0))
     {
-      unsigned long
+      size_t
         number_colors;
 
       /*
@@ -1351,7 +1351,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1417,7 +1417,7 @@
   HParamBlockRec
     parameter_info;
 
-  long
+  ssize_t
     buffer_size = 16384;
 
   OSErr
@@ -1491,7 +1491,7 @@
 %
 %  The format of the seekdir method is:
 %
-%      void seekdir(DIR *entry,long position)
+%      void seekdir(DIR *entry,ssize_t position)
 %
 %  A description of each parameter follows:
 %
@@ -1503,7 +1503,7 @@
 %
 %
 */
-MagickExport void seekdir(DIR *entry,long position)
+MagickExport void seekdir(DIR *entry,ssize_t position)
 {
   assert(entry != (DIR *) NULL);
   entry->d_index=position;
@@ -1596,7 +1596,7 @@
 %
 %
 */
-MagickExport long telldir(DIR *entry)
+MagickExport ssize_t telldir(DIR *entry)
 {
   return(entry->d_index);
 }
diff --git a/magick/mac.h b/magick/mac.h
index 4c644b7..8f92bfc 100644
--- a/magick/mac.h
+++ b/magick/mac.h
@@ -43,7 +43,7 @@
   int
     d_VRefNum;
 
-  long int
+  ssize_t int
     d_DirID;
 
   int
@@ -93,14 +93,14 @@
 extern MagickExport DIR
   *opendir(const char *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   telldir(DIR *);
 
 extern MagickExport struct dirent
   *readdir(DIR *);
 
 extern MagickExport void
-  seekdir(DIR *,long),
+  seekdir(DIR *,ssize_t),
   closedir(DIR *);
 #endif
 
diff --git a/magick/magic.c b/magick/magic.c
index 33646f8..b418797 100644
--- a/magick/magic.c
+++ b/magick/magic.c
@@ -297,7 +297,7 @@
 %  The magic of the GetMagicInfoList function is:
 %
 %      const MagicInfo **GetMagicInfoList(const char *pattern,
-%        unsigned long *number_aliases,ExceptionInfo *exception)
+%        size_t *number_aliases,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -331,7 +331,7 @@
 #endif
 
 MagickExport const MagicInfo **GetMagicInfoList(const char *pattern,
-  unsigned long *number_aliases,ExceptionInfo *exception)
+  size_t *number_aliases,ExceptionInfo *exception)
 {
   const MagicInfo
     **aliases;
@@ -339,7 +339,7 @@
   register const MagicInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -347,7 +347,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_aliases != (unsigned long *) NULL);
+  assert(number_aliases != (size_t *) NULL);
   *number_aliases=0;
   p=GetMagicInfo((const unsigned char *) NULL,0,exception);
   if (p == (const MagicInfo *) NULL)
@@ -372,7 +372,7 @@
   UnlockSemaphoreInfo(magic_semaphore);
   qsort((void *) aliases,(size_t) i,sizeof(*aliases),MagicInfoCompare);
   aliases[i]=(MagicInfo *) NULL;
-  *number_aliases=(unsigned long) i;
+  *number_aliases=(size_t) i;
   return(aliases);
 }
 
@@ -392,7 +392,7 @@
 %
 %  The format of the GetMagicList function is:
 %
-%      char **GetMagicList(const char *pattern,unsigned long *number_aliases,
+%      char **GetMagicList(const char *pattern,size_t *number_aliases,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -426,7 +426,7 @@
 #endif
 
 MagickExport char **GetMagicList(const char *pattern,
-  unsigned long *number_aliases,ExceptionInfo *exception)
+  size_t *number_aliases,ExceptionInfo *exception)
 {
   char
     **aliases;
@@ -434,7 +434,7 @@
   register const MagicInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -442,7 +442,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_aliases != (unsigned long *) NULL);
+  assert(number_aliases != (size_t *) NULL);
   *number_aliases=0;
   p=GetMagicInfo((const unsigned char *) NULL,0,exception);
   if (p == (const MagicInfo *) NULL)
@@ -464,7 +464,7 @@
   UnlockSemaphoreInfo(magic_semaphore);
   qsort((void *) aliases,(size_t) i,sizeof(*aliases),MagicCompare);
   aliases[i]=(char *) NULL;
-  *number_aliases=(unsigned long) i;
+  *number_aliases=(size_t) i;
   return(aliases);
 }
 
@@ -572,13 +572,13 @@
   const MagicInfo
     **magic_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_aliases;
 
   if (file == (const FILE *) NULL)
@@ -588,7 +588,7 @@
     return(MagickFalse);
   j=0;
   path=(const char *) NULL;
-  for (i=0; i < (long) number_aliases; i++)
+  for (i=0; i < (ssize_t) number_aliases; i++)
   {
     if (magic_info[i]->stealth != MagickFalse)
       continue;
@@ -603,12 +603,12 @@
       }
     path=magic_info[i]->path;
     (void) fprintf(file,"%s",magic_info[i]->name);
-    for (j=(long) strlen(magic_info[i]->name); j <= 9; j++)
+    for (j=(ssize_t) strlen(magic_info[i]->name); j <= 9; j++)
       (void) fprintf(file," ");
-    (void) fprintf(file,"%6ld ",(long) magic_info[i]->offset);
+    (void) fprintf(file,"%6ld ",(ssize_t) magic_info[i]->offset);
     if (magic_info[i]->target != (char *) NULL)
       {
-        register long
+        register ssize_t
           j;
 
         for (j=0; magic_info[i]->target[j] != '\0'; j++)
@@ -642,7 +642,7 @@
 %  The format of the LoadMagicList method is:
 %
 %      MagickBooleanType LoadMagicList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -656,7 +656,7 @@
 %
 */
 static MagickBooleanType LoadMagicList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -931,7 +931,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -948,7 +948,7 @@
           return(MagickFalse);
         }
     }
-  for (i=0; i < (long) (sizeof(MagicMap)/sizeof(*MagicMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(MagicMap)/sizeof(*MagicMap)); i++)
   {
     MagicInfo
       *magic_info;
diff --git a/magick/magic.h b/magick/magic.h
index 667c834..d271231 100644
--- a/magick/magic.h
+++ b/magick/magic.h
@@ -46,12 +46,12 @@
     *previous,
     *next;  /* deprecated, use GetMagicInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } MagicInfo;
 
 extern MagickExport char
-  **GetMagicList(const char *,unsigned long *,ExceptionInfo *);
+  **GetMagicList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const char
   *GetMagicName(const MagicInfo *);
@@ -62,7 +62,7 @@
 
 extern MagickExport const MagicInfo
   *GetMagicInfo(const unsigned char *,const size_t,ExceptionInfo *),
-  **GetMagicInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetMagicInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport void
   MagicComponentTerminus(void);
diff --git a/magick/magick-type.h b/magick/magick-type.h
index ab8b0b2..a50d77e 100644
--- a/magick/magick-type.h
+++ b/magick/magick-type.h
@@ -91,7 +91,7 @@
 #define MaxMap  65535UL
 
 #define MAGICKCORE_HDRI_SUPPORT  1
-typedef long double MagickRealType;
+typedef ssize_t double MagickRealType;
 typedef double Quantum;
 #define QuantumRange  18446744073709551615.0
 #define QuantumFormat  "%g"
@@ -112,8 +112,8 @@
 typedef unsigned long long MagickSizeType;
 #define MagickSizeFormat  "%10llu"
 #else
-typedef long MagickOffsetType;
-typedef unsigned long MagickSizeType;
+typedef ssize_t MagickOffsetType;
+typedef size_t MagickSizeType;
 #define MagickSizeFormat  "%10lu"
 #endif
 #else
diff --git a/magick/magick.c b/magick/magick.c
index ac568d5..b50f20e 100644
--- a/magick/magick.c
+++ b/magick/magick.c
@@ -469,7 +469,7 @@
 %  The format of the GetMagickInfoList function is:
 %
 %      const MagickInfo **GetMagickInfoList(const char *pattern,
-%        unsigned long *number_formats,ExceptionInfo *exception)
+%        size_t *number_formats,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -501,7 +501,7 @@
 #endif
 
 MagickExport const MagickInfo **GetMagickInfoList(const char *pattern,
-  unsigned long *number_formats,ExceptionInfo *exception)
+  size_t *number_formats,ExceptionInfo *exception)
 {
   const MagickInfo
     **formats;
@@ -509,7 +509,7 @@
   register const MagickInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -517,7 +517,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_formats != (unsigned long *) NULL);
+  assert(number_formats != (size_t *) NULL);
   *number_formats=0;
   p=GetMagickInfo("*",exception);
   if (p == (const MagickInfo *) NULL)
@@ -542,7 +542,7 @@
   UnlockSemaphoreInfo(magick_semaphore);
   qsort((void *) formats,(size_t) i,sizeof(*formats),MagickInfoCompare);
   formats[i]=(MagickInfo *) NULL;
-  *number_formats=(unsigned long) i;
+  *number_formats=(size_t) i;
   return(formats);
 }
 
@@ -561,7 +561,7 @@
 %
 %  The format of the GetMagickList function is:
 %
-%      char **GetMagickList(const char *pattern,unsigned long *number_formats,
+%      char **GetMagickList(const char *pattern,size_t *number_formats,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -594,7 +594,7 @@
 #endif
 
 MagickExport char **GetMagickList(const char *pattern,
-  unsigned long *number_formats,ExceptionInfo *exception)
+  size_t *number_formats,ExceptionInfo *exception)
 {
   char
     **formats;
@@ -602,7 +602,7 @@
   register const MagickInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -610,7 +610,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_formats != (unsigned long *) NULL);
+  assert(number_formats != (size_t *) NULL);
   *number_formats=0;
   p=GetMagickInfo("*",exception);
   if (p == (const MagickInfo *) NULL)
@@ -632,7 +632,7 @@
   UnlockSemaphoreInfo(magick_semaphore);
   qsort((void *) formats,(size_t) i,sizeof(*formats),MagickCompare);
   formats[i]=(char *) NULL;
-  *number_formats=(unsigned long) i;
+  *number_formats=(size_t) i;
   return(formats);
 }
 
@@ -936,13 +936,13 @@
   const MagickInfo
     **magick_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_formats;
 
   if (file == (FILE *) NULL)
@@ -958,7 +958,7 @@
 #endif
   (void) fprintf(file,"--------------------------------------------------------"
     "-----------------------\n");
-  for (i=0; i < (long) number_formats; i++)
+  for (i=0; i < (ssize_t) number_formats; i++)
   {
     if (magick_info[i]->stealth != MagickFalse)
       continue;
diff --git a/magick/magick.h b/magick/magick.h
index 9ebae00..dca9875 100644
--- a/magick/magick.h
+++ b/magick/magick.h
@@ -89,12 +89,12 @@
     *previous,
     *next;  /* deprecated, use GetMagickInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } MagickInfo;
 
 extern MagickExport char
-  **GetMagickList(const char *,unsigned long *,ExceptionInfo *);
+  **GetMagickList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const char
   *GetMagickDescription(const MagickInfo *);
@@ -122,7 +122,7 @@
 
 extern const MagickExport MagickInfo
   *GetMagickInfo(const char *,ExceptionInfo *),
-  **GetMagickInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetMagickInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickInfo
   *RegisterMagickInfo(MagickInfo *),
diff --git a/magick/matrix.c b/magick/matrix.c
index aee0aa6..70ee8da 100644
--- a/magick/matrix.c
+++ b/magick/matrix.c
@@ -64,8 +64,8 @@
 %
 %  The format of the AcquireMagickMatrix method is:
 %
-%      double **AcquireMagickMatrix(const unsigned long number_rows,
-%        const unsigned long size)
+%      double **AcquireMagickMatrix(const size_t number_rows,
+%        const size_t size)
 %
 %  A description of each parameter follows:
 %
@@ -76,20 +76,20 @@
 %      (second dimension).
 %
 */
-MagickExport double **AcquireMagickMatrix(const unsigned long number_rows,
-  const unsigned long size)
+MagickExport double **AcquireMagickMatrix(const size_t number_rows,
+  const size_t size)
 {
   double
     **matrix;
 
-  register long
+  register ssize_t
     i,
     j;
 
   matrix=(double **) AcquireQuantumMemory(number_rows,sizeof(*matrix));
   if (matrix == (double **) NULL)
     return((double **)NULL);
-  for (i=0; i < (long) number_rows; i++)
+  for (i=0; i < (ssize_t) number_rows; i++)
   {
     matrix[i]=(double *) AcquireQuantumMemory(size,sizeof(*matrix[i]));
     if (matrix[i] == (double *) NULL)
@@ -99,7 +99,7 @@
       matrix=(double **) RelinquishMagickMemory(matrix);
       return((double **) NULL);
     }
-    for (j=0; j < (long) size; j++)
+    for (j=0; j < (ssize_t) size; j++)
       matrix[i][j]=0.0;
   }
   return(matrix);
@@ -125,7 +125,7 @@
 %  The format of the GaussJordanElimination method is:
 %
 %      MagickBooleanType GaussJordanElimination(double **matrix,double **vectors,
-%        const unsigned long rank,const unsigned long number_vectors)
+%        const size_t rank,const size_t number_vectors)
 %
 %  A description of each parameter follows:
 %
@@ -177,7 +177,7 @@
 %
 */
 MagickExport MagickBooleanType GaussJordanElimination(double **matrix,
-  double **vectors,const unsigned long rank,const unsigned long number_vectors)
+  double **vectors,const size_t rank,const size_t number_vectors)
 {
 #define GaussJordanSwap(x,y) \
 { \
@@ -193,30 +193,30 @@
     max,
     scale;
 
-  long
+  ssize_t
     column,
     *columns,
     *pivots,
     row,
     *rows;
 
-  register long
+  register ssize_t
     i,
     j,
     k;
 
-  columns=(long *) AcquireQuantumMemory(rank,sizeof(*columns));
-  rows=(long *) AcquireQuantumMemory(rank,sizeof(*rows));
-  pivots=(long *) AcquireQuantumMemory(rank,sizeof(*pivots));
-  if ((rows == (long *) NULL) || (columns == (long *) NULL) ||
-      (pivots == (long *) NULL))
+  columns=(ssize_t *) AcquireQuantumMemory(rank,sizeof(*columns));
+  rows=(ssize_t *) AcquireQuantumMemory(rank,sizeof(*rows));
+  pivots=(ssize_t *) AcquireQuantumMemory(rank,sizeof(*pivots));
+  if ((rows == (ssize_t *) NULL) || (columns == (ssize_t *) NULL) ||
+      (pivots == (ssize_t *) NULL))
     {
-      if (pivots != (long *) NULL)
-        pivots=(long *) RelinquishMagickMemory(pivots);
-      if (columns != (long *) NULL)
-        columns=(long *) RelinquishMagickMemory(columns);
-      if (rows != (long *) NULL)
-        rows=(long *) RelinquishMagickMemory(rows);
+      if (pivots != (ssize_t *) NULL)
+        pivots=(ssize_t *) RelinquishMagickMemory(pivots);
+      if (columns != (ssize_t *) NULL)
+        columns=(ssize_t *) RelinquishMagickMemory(columns);
+      if (rows != (ssize_t *) NULL)
+        rows=(ssize_t *) RelinquishMagickMemory(rows);
       return(MagickFalse);
     }
   (void) ResetMagickMemory(columns,0,rank*sizeof(*columns));
@@ -224,13 +224,13 @@
   (void) ResetMagickMemory(pivots,0,rank*sizeof(*pivots));
   column=0;
   row=0;
-  for (i=0; i < (long) rank; i++)
+  for (i=0; i < (ssize_t) rank; i++)
   {
     max=0.0;
-    for (j=0; j < (long) rank; j++)
+    for (j=0; j < (ssize_t) rank; j++)
       if (pivots[j] != 1)
         {
-          for (k=0; k < (long) rank; k++)
+          for (k=0; k < (ssize_t) rank; k++)
             if (pivots[k] != 0)
               {
                 if (pivots[k] > 1)
@@ -247,9 +247,9 @@
     pivots[column]++;
     if (row != column)
       {
-        for (k=0; k < (long) rank; k++)
+        for (k=0; k < (ssize_t) rank; k++)
           GaussJordanSwap(matrix[row][k],matrix[column][k]);
-        for (k=0; k < (long) number_vectors; k++)
+        for (k=0; k < (ssize_t) number_vectors; k++)
           GaussJordanSwap(vectors[k][row],vectors[k][column]);
       }
     rows[i]=row;
@@ -258,28 +258,28 @@
       return(MagickFalse);  /* sigularity */
     scale=1.0/matrix[column][column];
     matrix[column][column]=1.0;
-    for (j=0; j < (long) rank; j++)
+    for (j=0; j < (ssize_t) rank; j++)
       matrix[column][j]*=scale;
-    for (j=0; j < (long) number_vectors; j++)
+    for (j=0; j < (ssize_t) number_vectors; j++)
       vectors[j][column]*=scale;
-    for (j=0; j < (long) rank; j++)
+    for (j=0; j < (ssize_t) rank; j++)
       if (j != column)
         {
           scale=matrix[j][column];
           matrix[j][column]=0.0;
-          for (k=0; k < (long) rank; k++)
+          for (k=0; k < (ssize_t) rank; k++)
             matrix[j][k]-=scale*matrix[column][k];
-          for (k=0; k < (long) number_vectors; k++)
+          for (k=0; k < (ssize_t) number_vectors; k++)
             vectors[k][j]-=scale*vectors[k][column];
         }
   }
-  for (j=(long) rank-1; j >= 0; j--)
+  for (j=(ssize_t) rank-1; j >= 0; j--)
     if (columns[j] != rows[j])
-      for (i=0; i < (long) rank; i++)
+      for (i=0; i < (ssize_t) rank; i++)
         GaussJordanSwap(matrix[i][rows[j]],matrix[i][columns[j]]);
-  pivots=(long *) RelinquishMagickMemory(pivots);
-  rows=(long *) RelinquishMagickMemory(rows);
-  columns=(long *) RelinquishMagickMemory(columns);
+  pivots=(ssize_t *) RelinquishMagickMemory(pivots);
+  rows=(ssize_t *) RelinquishMagickMemory(rows);
+  columns=(ssize_t *) RelinquishMagickMemory(columns);
   return(MagickTrue);
 }
 
@@ -300,8 +300,8 @@
 %  The format of the AcquireMagickMatrix method is:
 %
 %      void LeastSquaresAddTerms(double **matrix,double **vectors,
-%        const double *terms,const double *results,const unsigned long rank,
-%        const unsigned long number_vectors);
+%        const double *terms,const double *results,const size_t rank,
+%        const size_t number_vectors);
 %
 %  A description of each parameter follows:
 %
@@ -355,18 +355,18 @@
 %
 */
 MagickExport void LeastSquaresAddTerms(double **matrix,double **vectors,
-  const double *terms,const double *results,const unsigned long rank,
-  const unsigned long number_vectors)
+  const double *terms,const double *results,const size_t rank,
+  const size_t number_vectors)
 {
-  register long
+  register ssize_t
     i,
     j;
 
-  for (j=0; j < (long) rank; j++)
+  for (j=0; j < (ssize_t) rank; j++)
   {
-    for (i=0; i < (long) rank; i++)
+    for (i=0; i < (ssize_t) rank; i++)
       matrix[i][j]+=terms[i]*terms[j];
-    for (i=0; i < (long) number_vectors; i++)
+    for (i=0; i < (ssize_t) number_vectors; i++)
       vectors[i][j]+=results[i]*terms[j];
   }
   return;
@@ -389,7 +389,7 @@
 %  The format of the RelinquishMagickMatrix method is:
 %
 %      double **RelinquishMagickMatrix(double **matrix,
-%        const unsigned long number_rows)
+%        const size_t number_rows)
 %
 %  A description of each parameter follows:
 %
@@ -400,14 +400,14 @@
 %
 */
 MagickExport double **RelinquishMagickMatrix(double **matrix,
-  const unsigned long number_rows)
+  const size_t number_rows)
 {
-  register long
+  register ssize_t
     i;
 
   if (matrix == (double **) NULL )
     return(matrix);
-  for (i=0; i < (long) number_rows; i++)
+  for (i=0; i < (ssize_t) number_rows; i++)
      matrix[i]=(double *) RelinquishMagickMemory(matrix[i]);
   matrix=(double **) RelinquishMagickMemory(matrix);
   return(matrix);
diff --git a/magick/matrix.h b/magick/matrix.h
index 88e226d..51917b1 100644
--- a/magick/matrix.h
+++ b/magick/matrix.h
@@ -23,16 +23,16 @@
 #endif
 
 extern MagickExport double
-  **AcquireMagickMatrix(const unsigned long,const unsigned long),
-  **RelinquishMagickMatrix(double **,const unsigned long);
+  **AcquireMagickMatrix(const size_t,const size_t),
+  **RelinquishMagickMatrix(double **,const size_t);
 
 extern MagickExport MagickBooleanType
-  GaussJordanElimination(double **,double **,const unsigned long,
-       const unsigned long);
+  GaussJordanElimination(double **,double **,const size_t,
+       const size_t);
 
 extern MagickExport void
   LeastSquaresAddTerms(double **,double **,const double *,const double *,
-       const unsigned long, const unsigned long);
+       const size_t, const size_t);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
diff --git a/magick/memory.c b/magick/memory.c
index fec7126..a65fdc3 100644
--- a/magick/memory.c
+++ b/magick/memory.c
@@ -396,7 +396,7 @@
       LockSemaphoreInfo(memory_semaphore);
       if (free_segments == (DataSegmentInfo *) NULL)
         {
-          register long
+          register ssize_t
             i;
 
           assert(2*sizeof(size_t) > (size_t) (~SizeMask));
@@ -545,14 +545,14 @@
 MagickExport void DestroyMagickMemory(void)
 {
 #if defined(MAGICKCORE_EMBEDDABLE_SUPPORT)
-  register long
+  register ssize_t
     i;
 
   if (memory_semaphore == (SemaphoreInfo *) NULL)
     AcquireSemaphoreInfo(&memory_semaphore);
   LockSemaphoreInfo(memory_semaphore);
   UnlockSemaphoreInfo(memory_semaphore);
-  for (i=0; i < (long) memory_info.number_segments; i++)
+  for (i=0; i < (ssize_t) memory_info.number_segments; i++)
     if (memory_info.segments[i]->mapped == MagickFalse)
       memory_methods.destroy_memory_handler(
         memory_info.segments[i]->allocation);
@@ -597,7 +597,7 @@
   MagickBooleanType
     mapped;
 
-  register long
+  register ssize_t
     i;
 
   register void
@@ -623,7 +623,7 @@
   segment_info->length=blocksize;
   segment_info->allocation=segment;
   segment_info->bound=(char *) segment+blocksize;
-  i=(long) memory_info.number_segments-1;
+  i=(ssize_t) memory_info.number_segments-1;
   for ( ; (i >= 0) && (memory_info.segments[i]->allocation > segment); i--)
     memory_info.segments[i+1]=memory_info.segments[i];
   memory_info.segments[i+1]=segment_info;
diff --git a/magick/mime.c b/magick/mime.c
index 3c6ae23..c9fb232 100644
--- a/magick/mime.c
+++ b/magick/mime.c
@@ -70,7 +70,7 @@
     *description,
     *pattern;
 
-  long
+  ssize_t
     priority;
 
   MagickOffsetType
@@ -82,7 +82,7 @@
   DataType
     data_type;
 
-  long
+  ssize_t
     mask,
     value;
 
@@ -98,7 +98,7 @@
   MagickBooleanType
     stealth;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -168,7 +168,7 @@
   EndianType
     endian;
 
-  long
+  ssize_t
     value;
 
   register const MimeInfo
@@ -177,10 +177,10 @@
   register const unsigned char
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     lsb_first;
 
   assert(exception != (ExceptionInfo *) NULL);
@@ -306,7 +306,7 @@
       case StringData:
       default:
       {
-        for (i=0; i <= (long) p->extent; i++)
+        for (i=0; i <= (ssize_t) p->extent; i++)
         {
           if ((size_t) (p->offset+i+p->length) > length)
             break;
@@ -345,7 +345,7 @@
 %  The magic of the GetMimeInfoList function is:
 %
 %      const MimeInfo **GetMimeInfoList(const char *pattern,
-%        unsigned long *number_aliases,ExceptionInfo *exception)
+%        size_t *number_aliases,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -380,7 +380,7 @@
 #endif
 
 MagickExport const MimeInfo **GetMimeInfoList(const char *pattern,
-  unsigned long *number_aliases,ExceptionInfo *exception)
+  size_t *number_aliases,ExceptionInfo *exception)
 {
   const MimeInfo
     **aliases;
@@ -388,7 +388,7 @@
   register const MimeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -396,7 +396,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_aliases != (unsigned long *) NULL);
+  assert(number_aliases != (size_t *) NULL);
   *number_aliases=0;
   p=GetMimeInfo((char *) NULL,(unsigned char *) "*",0,exception);
   if (p == (const MimeInfo *) NULL)
@@ -421,7 +421,7 @@
   UnlockSemaphoreInfo(mime_semaphore);
   qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeInfoCompare);
   aliases[i]=(MimeInfo *) NULL;
-  *number_aliases=(unsigned long) i;
+  *number_aliases=(size_t) i;
   return(aliases);
 }
 
@@ -441,7 +441,7 @@
 %
 %  The format of the GetMimeList function is:
 %
-%      char **GetMimeList(const char *pattern,unsigned long *number_aliases,
+%      char **GetMimeList(const char *pattern,size_t *number_aliases,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -475,7 +475,7 @@
 #endif
 
 MagickExport char **GetMimeList(const char *pattern,
-  unsigned long *number_aliases,ExceptionInfo *exception)
+  size_t *number_aliases,ExceptionInfo *exception)
 {
   char
     **aliases;
@@ -483,7 +483,7 @@
   register const MimeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -491,7 +491,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_aliases != (unsigned long *) NULL);
+  assert(number_aliases != (size_t *) NULL);
   *number_aliases=0;
   p=GetMimeInfo((char *) NULL,(unsigned char *) "*",0,exception);
   if (p == (const MimeInfo *) NULL)
@@ -513,7 +513,7 @@
   UnlockSemaphoreInfo(mime_semaphore);
   qsort((void *) aliases,(size_t) i,sizeof(*aliases),MimeCompare);
   aliases[i]=(char *) NULL;
-  *number_aliases=(unsigned long) i;
+  *number_aliases=(size_t) i;
   return(aliases);
 }
 
@@ -650,13 +650,13 @@
   const MimeInfo
     **mime_info;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_aliases;
 
   if (file == (const FILE *) NULL)
@@ -666,7 +666,7 @@
     return(MagickFalse);
   j=0;
   path=(const char *) NULL;
-  for (i=0; i < (long) number_aliases; i++)
+  for (i=0; i < (ssize_t) number_aliases; i++)
   {
     if (mime_info[i]->stealth != MagickFalse)
       continue;
@@ -683,7 +683,7 @@
     (void) fprintf(file,"%s",mime_info[i]->type);
     if (strlen(mime_info[i]->type) <= 25)
       {
-        for (j=(long) strlen(mime_info[i]->type); j <= 27; j++)
+        for (j=(ssize_t) strlen(mime_info[i]->type); j <= 27; j++)
           (void) fprintf(file," ");
       }
     else
@@ -718,7 +718,7 @@
 %  The format of the LoadMimeList method is:
 %
 %      MagickBooleanType LoadMimeList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -732,7 +732,7 @@
 %
 */
 static MagickBooleanType LoadMimeList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   const char
     *attribute;
diff --git a/magick/mime.h b/magick/mime.h
index 02692b8..ee60350 100644
--- a/magick/mime.h
+++ b/magick/mime.h
@@ -26,7 +26,7 @@
   MimeInfo;
 
 extern MagickExport char
-  **GetMimeList(const char *,unsigned long *,ExceptionInfo *),
+  **GetMimeList(const char *,size_t *,ExceptionInfo *),
   *MagickToMime(const char *);
 
 extern MagickExport const char
@@ -40,7 +40,7 @@
 
 extern MagickExport const MimeInfo
   *GetMimeInfo(const char *,const unsigned char *,const size_t,ExceptionInfo *),
-  **GetMimeInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetMimeInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport void
   MimeComponentTerminus(void);
diff --git a/magick/module.c b/magick/module.c
index 85be72b..5e011b5 100644
--- a/magick/module.c
+++ b/magick/module.c
@@ -261,7 +261,7 @@
 %  The format of the GetModuleInfoList function is:
 %
 %      const ModuleInfo **GetModuleInfoList(const char *pattern,
-%        unsigned long *number_modules,ExceptionInfo *exception)
+%        size_t *number_modules,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -295,7 +295,7 @@
 #endif
 
 MagickExport const ModuleInfo **GetModuleInfoList(const char *pattern,
-  unsigned long *number_modules,ExceptionInfo *exception)
+  size_t *number_modules,ExceptionInfo *exception)
 {
   const ModuleInfo
     **modules;
@@ -303,7 +303,7 @@
   register const ModuleInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -311,7 +311,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_modules != (unsigned long *) NULL);
+  assert(number_modules != (size_t *) NULL);
   *number_modules=0;
   p=GetModuleInfo("*",exception);
   if (p == (const ModuleInfo *) NULL)
@@ -336,7 +336,7 @@
   UnlockSemaphoreInfo(module_semaphore);
   qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleInfoCompare);
   modules[i]=(ModuleInfo *) NULL;
-  *number_modules=(unsigned long) i;
+  *number_modules=(size_t) i;
   return(modules);
 }
 
@@ -356,7 +356,7 @@
 %
 %  The format of the GetModuleList function is:
 %
-%      char **GetModuleList(const char *pattern,unsigned long *number_modules,
+%      char **GetModuleList(const char *pattern,size_t *number_modules,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -403,7 +403,7 @@
 }
 
 MagickExport char **GetModuleList(const char *pattern,
-  unsigned long *number_modules,ExceptionInfo *exception)
+  size_t *number_modules,ExceptionInfo *exception)
 {
   char
     **modules,
@@ -417,7 +417,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -427,7 +427,7 @@
     *buffer,
     *entry;
 
-  unsigned long
+  size_t
     max_entries;
 
   /*
@@ -463,7 +463,7 @@
       continue;
     if (GlobExpression(entry->d_name,pattern,MagickFalse) == MagickFalse)
       continue;
-    if (i >= (long) max_entries)
+    if (i >= (ssize_t) max_entries)
       {
         modules=(char **) NULL;
         if (~max_entries > max_entries)
@@ -496,7 +496,7 @@
     }
   qsort((void *) modules,(size_t) i,sizeof(*modules),ModuleCompare);
   modules[i]=(char *) NULL;
-  *number_modules=(unsigned long) i;
+  *number_modules=(size_t) i;
   return(modules);
 }
 
@@ -995,7 +995,7 @@
       "UnableToLoadModule","`%s': %s",name,lt_dlerror());
   else
     {
-      unsigned long
+      size_t
         signature;
 
       if ((*images)->debug != MagickFalse)
@@ -1049,10 +1049,10 @@
   const ModuleInfo
     **module_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_modules;
 
   if (file == (const FILE *) NULL)
@@ -1071,7 +1071,7 @@
   (void) fprintf(file,"Module\n");
   (void) fprintf(file,"-------------------------------------------------"
     "------------------------------\n");
-  for (i=0; i < (long) number_modules; i++)
+  for (i=0; i < (ssize_t) number_modules; i++)
   {
     if (module_info[i]->stealth != MagickFalse)
       continue;
@@ -1186,7 +1186,7 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     signature;
 
   /*
@@ -1236,8 +1236,8 @@
     Define RegisterFORMATImage method.
   */
   TagToModuleName(module_name,"Register%sImage",name);
-  module_info->register_module=(unsigned long (*)(void)) lt_dlsym(handle,name);
-  if (module_info->register_module == (unsigned long (*)(void)) NULL)
+  module_info->register_module=(size_t (*)(void)) lt_dlsym(handle,name);
+  if (module_info->register_module == (size_t (*)(void)) NULL)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),ModuleError,
         "UnableToRegisterImageFormat","`%s': %s",module_name,lt_dlerror());
@@ -1298,10 +1298,10 @@
   char
     **modules;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_modules;
 
   /*
@@ -1312,12 +1312,12 @@
   modules=GetModuleList("*",&number_modules,exception);
   if (modules == (char **) NULL)
     return(MagickFalse);
-  for (i=0; i < (long) number_modules; i++)
+  for (i=0; i < (ssize_t) number_modules; i++)
     (void) OpenModule(modules[i],exception);
   /*
     Relinquish resources.
   */
-  for (i=0; i < (long) number_modules; i++)
+  for (i=0; i < (ssize_t) number_modules; i++)
     modules[i]=DestroyString(modules[i]);
   modules=(char **) RelinquishMagickMemory(modules);
   return(MagickTrue);
@@ -1567,7 +1567,7 @@
 {
 #if !defined(MAGICKCORE_BUILD_MODULES)
   {
-    extern unsigned long
+    extern size_t
       analyzeImage(Image **,const int,const char **,ExceptionInfo *);
 
     ImageFilterHandler
@@ -1578,7 +1578,7 @@
       image_filter=analyzeImage;
     if (image_filter != (ImageFilterHandler *) NULL)
       {
-        unsigned long
+        size_t
           signature;
 
         signature=image_filter(image,argc,argv,exception);
diff --git a/magick/module.h b/magick/module.h
index 0e8f480..f3c7506 100644
--- a/magick/module.h
+++ b/magick/module.h
@@ -25,9 +25,9 @@
 #include <time.h>
 #include "magick/version.h"
 
-#define MagickImageCoderSignature  ((unsigned long) \
+#define MagickImageCoderSignature  ((size_t) \
   (((MagickLibVersion) << 8) | MAGICKCORE_QUANTUM_DEPTH))
-#define MagickImageFilterSignature  ((unsigned long) \
+#define MagickImageFilterSignature  ((size_t) \
   (((MagickLibVersion) << 8) | MAGICKCORE_QUANTUM_DEPTH))
 
 typedef enum
@@ -46,7 +46,7 @@
     *handle,
     (*unregister_module)(void);
 
-  unsigned long
+  size_t
     (*register_module)(void);
 
   time_t
@@ -59,18 +59,18 @@
     *previous,
     *next;  /* deprecated, use GetModuleInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } ModuleInfo;
 
-typedef ModuleExport unsigned long
+typedef ModuleExport size_t
   ImageFilterHandler(Image **,const int,const char **,ExceptionInfo *);
 
 extern MagickExport char
-  **GetModuleList(const char *,unsigned long *,ExceptionInfo *);
+  **GetModuleList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const ModuleInfo
-  **GetModuleInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetModuleInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
   InitializeModuleList(ExceptionInfo *),
diff --git a/magick/montage.c b/magick/montage.c
index 904665c..75f5c49 100644
--- a/magick/montage.c
+++ b/magick/montage.c
@@ -268,31 +268,31 @@
 %
 */
 
-static void GetMontageGeometry(char *geometry,const unsigned long number_images,
-  long *x_offset,long *y_offset,unsigned long *tiles_per_column,
-  unsigned long *tiles_per_row)
+static void GetMontageGeometry(char *geometry,const size_t number_images,
+  ssize_t *x_offset,ssize_t *y_offset,size_t *tiles_per_column,
+  size_t *tiles_per_row)
 {
   *tiles_per_column=0;
   *tiles_per_row=0;
   (void) GetGeometry(geometry,x_offset,y_offset,tiles_per_row,tiles_per_column);
   if ((*tiles_per_column == 0) && (*tiles_per_row == 0))
-    *tiles_per_column=(unsigned long) sqrt((double) number_images);
+    *tiles_per_column=(size_t) sqrt((double) number_images);
   if (*tiles_per_column == 0)
-    *tiles_per_column=(unsigned long)
+    *tiles_per_column=(size_t)
       ceil((double) number_images/(*tiles_per_row));
   if (*tiles_per_row == 0)
-    *tiles_per_row=(unsigned long)
+    *tiles_per_row=(size_t)
       ceil((double) number_images/(*tiles_per_column));
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -364,7 +364,7 @@
   ImageInfo
     *clone_info;
 
-  long
+  ssize_t
     tile,
     x,
     x_offset,
@@ -385,7 +385,7 @@
   MagickProgressMonitor
     progress_monitor;
 
-  register long
+  register ssize_t
     i;
 
   RectangleInfo
@@ -399,7 +399,7 @@
   TypeMetric
     metrics;
 
-  unsigned long
+  size_t
     bevel_width,
     border_width,
     height,
@@ -433,7 +433,7 @@
   if (master_list == (Image **) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
   thumbnail=NewImageList();
-  for (i=0; i < (long) number_images; i++)
+  for (i=0; i < (ssize_t) number_images; i++)
   {
     image=CloneImage(image_list[i],0,0,MagickTrue,exception);
     if (image == (Image *) NULL)
@@ -447,16 +447,17 @@
       break;
     image_list[i]=thumbnail;
     (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
-    proceed=SetImageProgress(image,TileImageTag,i,number_images);
+    proceed=SetImageProgress(image,TileImageTag,(MagickOffsetType) i,
+      number_images);
     if (proceed == MagickFalse)
       break;
     image=DestroyImage(image);
   }
-  if (i < (long) number_images)
+  if (i < (ssize_t) number_images)
     {
       if (thumbnail == (Image *) NULL)
         i--;
-      for (tile=0; (long) tile <= i; tile++)
+      for (tile=0; (ssize_t) tile <= i; tile++)
         if (image_list[tile] != (Image *) NULL)
           image_list[tile]=DestroyImage(image_list[tile]);
       master_list=(Image **) RelinquishMagickMemory(master_list);
@@ -465,17 +466,17 @@
   /*
     Sort image list by increasing tile number.
   */
-  for (i=0; i < (long) number_images; i++)
+  for (i=0; i < (ssize_t) number_images; i++)
     if (image_list[i]->scene == 0)
       break;
-  if (i == (long) number_images)
+  if (i == (ssize_t) number_images)
     qsort((void *) image_list,(size_t) number_images,sizeof(*image_list),
       SceneCompare);
   /*
     Determine tiles per row and column.
   */
-  tiles_per_column=(unsigned long) sqrt((double) number_images);
-  tiles_per_row=(unsigned long) ceil((double) number_images/tiles_per_column);
+  tiles_per_column=(size_t) sqrt((double) number_images);
+  tiles_per_row=(size_t) ceil((double) number_images/tiles_per_column);
   x_offset=0;
   y_offset=0;
   if (montage_info->tile != (char *) NULL)
@@ -486,8 +487,8 @@
   */
   concatenate=MagickFalse;
   SetGeometry(image_list[0],&extract_info);
-  extract_info.x=(long) montage_info->border_width;
-  extract_info.y=(long) montage_info->border_width;
+  extract_info.x=(ssize_t) montage_info->border_width;
+  extract_info.y=(ssize_t) montage_info->border_width;
   if (montage_info->geometry != (char *) NULL)
     {
       /*
@@ -516,17 +517,17 @@
       if ((flags & HeightValue) == 0)
         frame_info.height=frame_info.width;
       if ((flags & XiValue) == 0)
-        frame_info.outer_bevel=(long) frame_info.width/2;
+        frame_info.outer_bevel=(ssize_t) frame_info.width/2;
       if ((flags & PsiValue) == 0)
         frame_info.inner_bevel=frame_info.outer_bevel;
-      frame_info.x=(long) frame_info.width;
-      frame_info.y=(long) frame_info.height;
-      bevel_width=(unsigned long) MagickMax(frame_info.inner_bevel,
+      frame_info.x=(ssize_t) frame_info.width;
+      frame_info.y=(ssize_t) frame_info.height;
+      bevel_width=(size_t) MagickMax(frame_info.inner_bevel,
         frame_info.outer_bevel);
-      border_width=(unsigned long) MagickMax((long) frame_info.width,
-        (long) frame_info.height);
+      border_width=(size_t) MagickMax((ssize_t) frame_info.width,
+        (ssize_t) frame_info.height);
     }
-  for (i=0; i < (long) number_images; i++)
+  for (i=0; i < (ssize_t) number_images; i++)
   {
     if (image_list[i]->columns > extract_info.width)
       extract_info.width=image_list[i]->columns;
@@ -562,10 +563,10 @@
   title=InterpretImageProperties(clone_info,image_list[0],montage_info->title);
   title_offset=0;
   if (montage_info->title != (char *) NULL)
-    title_offset=(unsigned long) (2*(metrics.ascent-metrics.descent)*
+    title_offset=(size_t) (2*(metrics.ascent-metrics.descent)*
       MultilineCensus(title)+2*extract_info.y);
   number_lines=0;
-  for (i=0; i < (long) number_images; i++)
+  for (i=0; i < (ssize_t) number_images; i++)
   {
     value=GetImageProperty(image_list[i],"label");
     if (value == (const char *) NULL)
@@ -581,8 +582,8 @@
   montage->scene=0;
   images_per_page=(number_images-1)/(tiles_per_row*tiles_per_column)+1;
   tiles=0;
-  total_tiles=(unsigned long) number_images;
-  for (i=0; i < (long) images_per_page; i++)
+  total_tiles=(size_t) number_images;
+  for (i=0; i < (ssize_t) images_per_page; i++)
   {
     /*
       Determine bounding box.
@@ -594,14 +595,14 @@
       GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
         &sans,&sans);
     tiles_per_page=tiles_per_row*tiles_per_column;
-    y_offset+=(long) title_offset;
+    y_offset+=(ssize_t) title_offset;
     max_height=0;
     bounds.width=0;
     bounds.height=0;
     width=0;
-    for (tile=0; tile < (long) tiles_per_page; tile++)
+    for (tile=0; tile < (ssize_t) tiles_per_page; tile++)
     {
-      if (tile < (long) number_images)
+      if (tile < (ssize_t) number_images)
         {
           width=concatenate != MagickFalse ? image_list[tile]->columns :
             extract_info.width;
@@ -609,9 +610,9 @@
             max_height=image_list[tile]->rows;
         }
       x_offset+=width+(extract_info.x+border_width)*2;
-      if (x_offset > (long) bounds.width)
-        bounds.width=(unsigned long) x_offset;
-      if (((tile+1) == (long) tiles_per_page) ||
+      if (x_offset > (ssize_t) bounds.width)
+        bounds.width=(size_t) x_offset;
+      if (((tile+1) == (ssize_t) tiles_per_page) ||
           (((tile+1) % tiles_per_row) == 0))
         {
           x_offset=0;
@@ -619,11 +620,11 @@
             GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y,
               &sans,&sans);
           height=concatenate != MagickFalse ? max_height : extract_info.height;
-          y_offset+=(unsigned long) (height+(extract_info.y+border_width)*2+
+          y_offset+=(size_t) (height+(extract_info.y+border_width)*2+
             (metrics.ascent-metrics.descent+4)*number_lines+
             (montage_info->shadow != MagickFalse ? 4 : 0));
-          if (y_offset > (long) bounds.height)
-            bounds.height=(unsigned long) y_offset;
+          if (y_offset > (ssize_t) bounds.height)
+            bounds.height=(size_t) y_offset;
           max_height=0;
         }
     }
@@ -643,7 +644,7 @@
     montage->montage=AcquireString((char *) NULL);
     tile=0;
     extent=1;
-    while (tile < MagickMin((long) tiles_per_page,(long) number_images))
+    while (tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images))
     {
       extent+=strlen(image_list[tile]->filename)+1;
       tile++;
@@ -658,15 +659,15 @@
     if (montage_info->tile != (char *) NULL)
       GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
         &sans,&sans);
-    y_offset+=(long) title_offset;
+    y_offset+=(ssize_t) title_offset;
     (void) FormatMagickString(montage->montage,MaxTextExtent,"%ldx%ld%+ld%+ld",
-      (long) (extract_info.width+(extract_info.x+border_width)*2),
-      (long) (extract_info.height+(extract_info.y+border_width)*2+
+      (ssize_t) (extract_info.width+(extract_info.x+border_width)*2),
+      (ssize_t) (extract_info.height+(extract_info.y+border_width)*2+
       (metrics.ascent-metrics.descent+4)*number_lines+
       (montage_info->shadow != MagickFalse ? 4 : 0)),x_offset,y_offset);
     *montage->directory='\0';
     tile=0;
-    while (tile < MagickMin((long) tiles_per_page,(long) number_images))
+    while (tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images))
     {
       (void) ConcatenateMagickString(montage->directory,
         image_list[tile]->filename,extent);
@@ -696,8 +697,8 @@
         clone_info->pointsize*=2.0;
         (void) GetTypeMetrics(image_list[0],clone_info,&metrics);
         (void) FormatMagickString(geometry,MaxTextExtent,"%lux%lu%+ld%+ld",
-          montage->columns,(unsigned long) (metrics.ascent-metrics.descent),
-          0L,(long) extract_info.y+4);
+          montage->columns,(size_t) (metrics.ascent-metrics.descent),
+          0L,(ssize_t) extract_info.y+4);
         (void) CloneString(&clone_info->geometry,geometry);
         (void) CloneString(&clone_info->text,title);
         (void) AnnotateImage(montage,clone_info);
@@ -714,9 +715,9 @@
       GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset,
         &sans,&sans);
     x_offset+=extract_info.x;
-    y_offset+=(long) title_offset+extract_info.y;
+    y_offset+=(ssize_t) title_offset+extract_info.y;
     max_height=0;
-    for (tile=0; tile < MagickMin((long) tiles_per_page,(long) number_images); tile++)
+    for (tile=0; tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images); tile++)
     {
       /*
         Copy this tile to the composite.
@@ -767,8 +768,8 @@
       (void) FormatMagickString(tile_geometry,MaxTextExtent,"%lux%lu+0+0",
         image->columns,image->rows);
       flags=ParseGravityGeometry(tile_image,tile_geometry,&geometry,exception);
-      x=(long) (geometry.x+border_width);
-      y=(long) (geometry.y+border_width);
+      x=(ssize_t) (geometry.x+border_width);
+      y=(ssize_t) (geometry.y+border_width);
       if ((montage_info->frame != (char *) NULL) && (bevel_width != 0))
         {
           FrameInfo
@@ -785,7 +786,7 @@
           extract_info.height=height+2*frame_info.height;
           value=GetImageProperty(image,"label");
           if (value != (const char *) NULL)
-            extract_info.height+=(unsigned long) ((metrics.ascent-
+            extract_info.height+=(size_t) ((metrics.ascent-
               metrics.descent+4)*MultilineCensus(value));
           frame_image=FrameImage(image,&extract_info,exception);
           if (frame_image != (Image *) NULL)
@@ -833,7 +834,7 @@
               */
               (void) FormatMagickString(geometry,MaxTextExtent,
                 "%lux%lu%+ld%+ld",(montage_info->frame ? image->columns :
-                width)-2*border_width,(unsigned long) (metrics.ascent-
+                width)-2*border_width,(size_t) (metrics.ascent-
                 metrics.descent+4)*MultilineCensus(value),x_offset+
                 border_width,(montage_info->frame ? y_offset+height+
                 border_width+4 : y_offset+extract_info.height+border_width+
@@ -844,11 +845,11 @@
             }
         }
       x_offset+=width+(extract_info.x+border_width)*2;
-      if (((tile+1) == (long) tiles_per_page) ||
+      if (((tile+1) == (ssize_t) tiles_per_page) ||
           (((tile+1) % tiles_per_row) == 0))
         {
           x_offset=extract_info.x;
-          y_offset+=(unsigned long) (height+(extract_info.y+border_width)*2+
+          y_offset+=(size_t) (height+(extract_info.y+border_width)*2+
             (metrics.ascent-metrics.descent+4)*number_lines+
             (montage_info->shadow != MagickFalse ? 4 : 0));
           max_height=0;
@@ -866,7 +867,7 @@
       image=DestroyImage(image);
       tiles++;
     }
-    if ((i+1) < (long) images_per_page)
+    if ((i+1) < (ssize_t) images_per_page)
       {
         /*
           Allocate next image structure.
diff --git a/magick/montage.h b/magick/montage.h
index 6979486..ebe4c3e 100644
--- a/magick/montage.h
+++ b/magick/montage.h
@@ -43,7 +43,7 @@
   double
     pointsize;
 
-  unsigned long
+  size_t
     border_width;
 
   MagickBooleanType
@@ -65,7 +65,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 } MontageInfo;
 
diff --git a/magick/morphology-private.h b/magick/morphology-private.h
index 680e383..e7f98e5 100644
--- a/magick/morphology-private.h
+++ b/magick/morphology-private.h
@@ -30,7 +30,7 @@
 
 extern MagickExport Image
   *MorphologyApply(const Image *,const ChannelType,const MorphologyMethod,
-    const long, const KernelInfo *, const CompositeOperator, const double,
+    const ssize_t, const KernelInfo *, const CompositeOperator, const double,
     ExceptionInfo *);
 
 extern MagickExport void
diff --git a/magick/morphology.c b/magick/morphology.c
index 706af3d..b208e1a 100644
--- a/magick/morphology.c
+++ b/magick/morphology.c
@@ -147,7 +147,7 @@
 %  anywhere within that array of values.
 %
 %  Previously IM was restricted to a square of odd size using the exact
-%  center as origin, this is no longer the case, and any rectangular kernel
+%  center as origin, this is no ssize_ter the case, and any rectangular kernel
 %  with any value being declared the origin. This in turn allows the use of
 %  highly asymmetrical kernels.
 %
@@ -222,7 +222,7 @@
     *p,
     *end;
 
-  register long
+  register ssize_t
     i;
 
   double
@@ -269,18 +269,18 @@
          args.rho = 1.0;               /* then  width = 1 */
       if ( args.sigma < 1.0 )          /* if height too small */
         args.sigma = args.rho;         /* then  height = width */
-      kernel->width = (unsigned long)args.rho;
-      kernel->height = (unsigned long)args.sigma;
+      kernel->width = (size_t)args.rho;
+      kernel->height = (size_t)args.sigma;
 
       /* Offset Handling and Checks */
       if ( args.xi  < 0.0 || args.psi < 0.0 )
         return(DestroyKernelInfo(kernel));
-      kernel->x = ((flags & XValue)!=0) ? (long)args.xi
-                                               : (long) (kernel->width-1)/2;
-      kernel->y = ((flags & YValue)!=0) ? (long)args.psi
-                                               : (long) (kernel->height-1)/2;
-      if ( kernel->x >= (long) kernel->width ||
-           kernel->y >= (long) kernel->height )
+      kernel->x = ((flags & XValue)!=0) ? (ssize_t)args.xi
+                                               : (ssize_t) (kernel->width-1)/2;
+      kernel->y = ((flags & YValue)!=0) ? (ssize_t)args.psi
+                                               : (ssize_t) (kernel->height-1)/2;
+      if ( kernel->x >= (ssize_t) kernel->width ||
+           kernel->y >= (ssize_t) kernel->height )
         return(DestroyKernelInfo(kernel));
 
       p++; /* advance beyond the ':' */
@@ -298,8 +298,8 @@
           GetMagickToken(p,&p,token);
       }
       /* set the size of the kernel - old sized square */
-      kernel->width = kernel->height= (unsigned long) sqrt((double) i+1.0);
-      kernel->x = kernel->y = (long) (kernel->width-1)/2;
+      kernel->width = kernel->height= (size_t) sqrt((double) i+1.0);
+      kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
       p=(const char *) kernel_string;
       while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == '\''))
         p++;  /* ignore "'" chars for convolve filter usage - Cristy */
@@ -315,7 +315,7 @@
   kernel->maximum = -MagickHuge;
   kernel->negative_range = kernel->positive_range = 0.0;
 
-  for (i=0; (i < (long) (kernel->width*kernel->height)) && (p < end); i++)
+  for (i=0; (i < (ssize_t) (kernel->width*kernel->height)) && (p < end); i++)
   {
     GetMagickToken(p,&p,token);
     if (*token == ',')
@@ -341,15 +341,15 @@
 
 #if 0
   /* this was the old method of handling a incomplete kernel */
-  if ( i < (long) (kernel->width*kernel->height) ) {
+  if ( i < (ssize_t) (kernel->width*kernel->height) ) {
     Minimize(kernel->minimum, kernel->values[i]);
     Maximize(kernel->maximum, kernel->values[i]);
-    for ( ; i < (long) (kernel->width*kernel->height); i++)
+    for ( ; i < (ssize_t) (kernel->width*kernel->height); i++)
       kernel->values[i]=0.0;
   }
 #else
   /* Number of values for kernel was not enough - Report Error */
-  if ( i < (long) (kernel->width*kernel->height) )
+  if ( i < (ssize_t) (kernel->width*kernel->height) )
     return(DestroyKernelInfo(kernel));
 #endif
 
@@ -373,7 +373,7 @@
   char
     token[MaxTextExtent];
 
-  long
+  ssize_t
     type;
 
   const char
@@ -422,9 +422,9 @@
       if ( args.sigma < 1.0 )          /* if height too small */
         args.sigma = args.rho;         /* then  height = width */
       if ( (flags & XValue) == 0 )     /* center offset if not defined */
-        args.xi = (double)(((long)args.rho-1)/2);
+        args.xi = (double)(((ssize_t)args.rho-1)/2);
       if ( (flags & YValue) == 0 )
-        args.psi = (double)(((long)args.sigma-1)/2);
+        args.psi = (double)(((ssize_t)args.sigma-1)/2);
       break;
     case SquareKernel:
     case DiamondKernel:
@@ -479,7 +479,7 @@
   const char
     *p;
 
-  unsigned long
+  size_t
     kernel_number;
 
   p = kernel_string;
@@ -878,10 +878,10 @@
   KernelInfo
     *kernel;
 
-  register long
+  register ssize_t
     i;
 
-  register long
+  register ssize_t
     u,
     v;
 
@@ -959,13 +959,13 @@
           A, B, R;
 
         if ( args->rho >= 1.0 )
-          kernel->width = (unsigned long)args->rho*2+1;
+          kernel->width = (size_t)args->rho*2+1;
         else if ( (type != DOGKernel) || (sigma >= sigma2) )
           kernel->width = GetOptimalKernelWidth2D(args->rho,sigma);
         else
           kernel->width = GetOptimalKernelWidth2D(args->rho,sigma2);
         kernel->height = kernel->width;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
@@ -983,8 +983,8 @@
             if ( sigma > MagickEpsilon )
               { A = 1.0/(2.0*sigma*sigma);  /* simplify loop expressions */
                 B = 1.0/(Magick2PI*sigma*sigma);
-                for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-                  for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+                for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+                  for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
                       kernel->values[i] = exp(-((double)(u*u+v*v))*A)*B;
               }
             else /* limiting case - a unity (normalized Dirac) kernel */
@@ -1000,8 +1000,8 @@
               { sigma = sigma2;                /* simplify loop expressions */
                 A = 1.0/(2.0*sigma*sigma);
                 B = 1.0/(Magick2PI*sigma*sigma);
-                for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-                  for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+                for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+                  for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
                     kernel->values[i] -= exp(-((double)(u*u+v*v))*A)*B;
               }
             else /* limiting case - a unity (normalized Dirac) kernel */
@@ -1013,8 +1013,8 @@
             if ( sigma > MagickEpsilon )
               { A = 1.0/(2.0*sigma*sigma);  /* simplify loop expressions */
                 B = 1.0/(MagickPI*sigma*sigma*sigma*sigma);
-                for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-                  for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+                for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+                  for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
                     { R = ((double)(u*u+v*v))*A;
                       kernel->values[i] = (1-R)*exp(-R)*B;
                     }
@@ -1052,13 +1052,13 @@
           A, B;
 
         if ( args->rho >= 1.0 )
-          kernel->width = (unsigned long)args->rho*2+1;
+          kernel->width = (size_t)args->rho*2+1;
         else if ( (type == BlurKernel) || (sigma >= sigma2) )
           kernel->width = GetOptimalKernelWidth1D(args->rho,sigma);
         else
           kernel->width = GetOptimalKernelWidth1D(args->rho,sigma2);
         kernel->height = 1;
-        kernel->x = (long) (kernel->width-1)/2;
+        kernel->x = (ssize_t) (kernel->width-1)/2;
         kernel->y = 0;
         kernel->negative_range = kernel->positive_range = 0.0;
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
@@ -1082,7 +1082,7 @@
         */
 
         /* initialize */
-        v = (long) (kernel->width*KernelRank-1)/2; /* start/end points to fit range */
+        v = (ssize_t) (kernel->width*KernelRank-1)/2; /* start/end points to fit range */
         (void) ResetMagickMemory(kernel->values,0, (size_t)
                      kernel->width*kernel->height*sizeof(double));
         /* Calculate a Positive 1D Gaussian */
@@ -1117,7 +1117,7 @@
         if ( sigma > MagickEpsilon )
           { A = 1.0/(2.0*sigma*sigma);     /* simplify loop expressions */
             B = 1.0/(MagickSQ2PI*sigma);
-            for ( i=0, u=-kernel->x; u <= (long)kernel->x; u++, i++)
+            for ( i=0, u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
               kernel->values[i] = exp(-((double)(u*u))*A)*B;
           }
         else /* special case - generate a unity kernel */
@@ -1133,7 +1133,7 @@
               { sigma = sigma2;                /* simplify loop expressions */
                 A = 1.0/(2.0*sigma*sigma);
                 B = 1.0/(MagickSQ2PI*sigma);
-                for ( i=0, u=-kernel->x; u <= (long)kernel->x; u++, i++)
+                for ( i=0, u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
                   kernel->values[i] -= exp(-((double)(u*u))*A)*B;
               }
             else /* limiting case - a unity (normalized Dirac) kernel */
@@ -1168,7 +1168,7 @@
         if ( args->rho < 1.0 )
           kernel->width = (GetOptimalKernelWidth1D(args->rho,sigma)-1)/2+1;
         else
-          kernel->width = (unsigned long)args->rho;
+          kernel->width = (size_t)args->rho;
         kernel->x = kernel->y = 0;
         kernel->height = 1;
         kernel->negative_range = kernel->positive_range = 0.0;
@@ -1191,7 +1191,7 @@
           {
 #if 1
 #define KernelRank 3
-            v = (long) kernel->width*KernelRank; /* start/end points */
+            v = (ssize_t) kernel->width*KernelRank; /* start/end points */
             (void) ResetMagickMemory(kernel->values,0, (size_t)
                           kernel->width*sizeof(double));
             sigma *= KernelRank;            /* simplify the loop expression */
@@ -1202,12 +1202,12 @@
                   exp(-((double)(u*u))*A);
               /*  exp(-((double)(i*i))/2.0*sigma*sigma)/(MagickSQ2PI*sigma); */
             }
-            for (i=0; i < (long) kernel->width; i++)
+            for (i=0; i < (ssize_t) kernel->width; i++)
               kernel->positive_range += kernel->values[i];
 #else
             A = 1.0/(2.0*sigma*sigma);     /* simplify the loop expression */
             /* B = 1.0/(MagickSQ2PI*sigma); */
-            for ( i=0; i < (long) kernel->width; i++)
+            for ( i=0; i < (ssize_t) kernel->width; i++)
               kernel->positive_range +=
                 kernel->values[i] =
                   exp(-((double)(i*i))*A);
@@ -1423,8 +1423,8 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 3;  /* default radius = 1 */
         else
-          kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+          kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
@@ -1432,9 +1432,9 @@
           return(DestroyKernelInfo(kernel));
 
         /* set all kernel values within diamond area to scale given */
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
-            if ((labs(u)+labs(v)) <= (long)kernel->x)
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
+            if ((labs(u)+labs(v)) <= (ssize_t)kernel->x)
               kernel->positive_range += kernel->values[i] = args->sigma;
             else
               kernel->values[i] = nan;
@@ -1450,21 +1450,21 @@
             if (args->rho < 1.0)
               kernel->width = kernel->height = 3;  /* default radius = 1 */
             else
-              kernel->width = kernel->height = (unsigned long) (2*args->rho+1);
-            kernel->x = kernel->y = (long) (kernel->width-1)/2;
+              kernel->width = kernel->height = (size_t) (2*args->rho+1);
+            kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
             scale = args->sigma;
           }
         else {
             /* NOTE: user defaults set in "AcquireKernelInfo()" */
             if ( args->rho < 1.0 || args->sigma < 1.0 )
               return(DestroyKernelInfo(kernel));    /* invalid args given */
-            kernel->width = (unsigned long)args->rho;
-            kernel->height = (unsigned long)args->sigma;
+            kernel->width = (size_t)args->rho;
+            kernel->height = (size_t)args->sigma;
             if ( args->xi  < 0.0 || args->xi  > (double)kernel->width ||
                  args->psi < 0.0 || args->psi > (double)kernel->height )
               return(DestroyKernelInfo(kernel));    /* invalid args given */
-            kernel->x = (long) args->xi;
-            kernel->y = (long) args->psi;
+            kernel->x = (ssize_t) args->xi;
+            kernel->y = (ssize_t) args->psi;
             scale = 1.0;
           }
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
@@ -1473,7 +1473,7 @@
           return(DestroyKernelInfo(kernel));
 
         /* set all kernel values to scale given */
-        u=(long) kernel->width*kernel->height;
+        u=(ssize_t) kernel->width*kernel->height;
         for ( i=0; i < u; i++)
             kernel->values[i] = scale;
         kernel->minimum = kernel->maximum = scale;   /* a flat shape */
@@ -1482,12 +1482,12 @@
       }
     case DiskKernel:
       {
-        long limit = (long)(args->rho*args->rho);
+        ssize_t limit = (ssize_t)(args->rho*args->rho);
         if (args->rho < 0.1)             /* default radius approx 3.5 */
           kernel->width = kernel->height = 7L, limit = 10L;
         else
-           kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+           kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
@@ -1495,8 +1495,8 @@
           return(DestroyKernelInfo(kernel));
 
         /* set all kernel values within disk area to scale given */
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             if ((u*u+v*v) <= limit)
               kernel->positive_range += kernel->values[i] = args->sigma;
             else
@@ -1509,17 +1509,17 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 5;  /* default radius 2 */
         else
-           kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+           kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
-        /* set all kernel values along axises to given scale */
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        /* set all kernel values assize_t axises to given scale */
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             kernel->values[i] = (u == 0 || v == 0) ? args->sigma : nan;
         kernel->minimum = kernel->maximum = args->sigma;   /* a flat shape */
         kernel->positive_range = args->sigma*(kernel->width*2.0 - 1.0);
@@ -1530,17 +1530,17 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 5;  /* default radius 2 */
         else
-           kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+           kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
-        /* set all kernel values along axises to given scale */
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        /* set all kernel values assize_t axises to given scale */
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             kernel->values[i] = (u == v || u == -v) ? args->sigma : nan;
         kernel->minimum = kernel->maximum = args->sigma;   /* a flat shape */
         kernel->positive_range = args->sigma*(kernel->width*2.0 - 1.0);
@@ -1550,38 +1550,38 @@
     case RingKernel:
     case PeaksKernel:
       {
-        long
+        ssize_t
           limit1,
           limit2,
           scale;
 
         if (args->rho < args->sigma)
           {
-            kernel->width = ((unsigned long)args->sigma)*2+1;
-            limit1 = (long)args->rho*args->rho;
-            limit2 = (long)args->sigma*args->sigma;
+            kernel->width = ((size_t)args->sigma)*2+1;
+            limit1 = (ssize_t)args->rho*args->rho;
+            limit2 = (ssize_t)args->sigma*args->sigma;
           }
         else
           {
-            kernel->width = ((unsigned long)args->rho)*2+1;
-            limit1 = (long)args->sigma*args->sigma;
-            limit2 = (long)args->rho*args->rho;
+            kernel->width = ((size_t)args->rho)*2+1;
+            limit1 = (ssize_t)args->sigma*args->sigma;
+            limit2 = (ssize_t)args->rho*args->rho;
           }
         if ( limit2 <= 0 )
           kernel->width = 7L, limit1 = 7L, limit2 = 11L;
 
         kernel->height = kernel->width;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
         /* set a ring of points of 'scale' ( 0.0 for PeaksKernel ) */
-        scale = (long) (( type == PeaksKernel) ? 0.0 : args->xi);
-        for ( i=0, v= -kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
-            { long radius=u*u+v*v;
+        scale = (ssize_t) (( type == PeaksKernel) ? 0.0 : args->xi);
+        for ( i=0, v= -kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
+            { ssize_t radius=u*u+v*v;
               if (limit1 < radius && radius <= limit2)
                 kernel->positive_range += kernel->values[i] = (double) scale;
               else
@@ -1783,16 +1783,16 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 3;  /* default radius = 1 */
         else
-          kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+          kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             kernel->positive_range += ( kernel->values[i] =
                  args->sigma*((labs(u)>labs(v)) ? labs(u) : labs(v)) );
         kernel->maximum = kernel->values[0];
@@ -1803,16 +1803,16 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 3;  /* default radius = 1 */
         else
-           kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+           kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             kernel->positive_range += ( kernel->values[i] =
                  args->sigma*(labs(u)+labs(v)) );
         kernel->maximum = kernel->values[0];
@@ -1823,16 +1823,16 @@
         if (args->rho < 1.0)
           kernel->width = kernel->height = 3;  /* default radius = 1 */
         else
-           kernel->width = kernel->height = ((unsigned long)args->rho)*2+1;
-        kernel->x = kernel->y = (long) (kernel->width-1)/2;
+           kernel->width = kernel->height = ((size_t)args->rho)*2+1;
+        kernel->x = kernel->y = (ssize_t) (kernel->width-1)/2;
 
         kernel->values=(double *) AcquireQuantumMemory(kernel->width,
                               kernel->height*sizeof(double));
         if (kernel->values == (double *) NULL)
           return(DestroyKernelInfo(kernel));
 
-        for ( i=0, v=-kernel->y; v <= (long)kernel->y; v++)
-          for ( u=-kernel->x; u <= (long)kernel->x; u++, i++)
+        for ( i=0, v=-kernel->y; v <= (ssize_t)kernel->y; v++)
+          for ( u=-kernel->x; u <= (ssize_t)kernel->x; u++, i++)
             kernel->positive_range += ( kernel->values[i] =
                  args->sigma*sqrt((double)(u*u+v*v)) );
         kernel->maximum = kernel->values[0];
@@ -1867,7 +1867,7 @@
 %
 %  CloneKernelInfo() creates a new clone of the given Kernel List so that its
 %  can be modified without effecting the original.  The cloned kernel should
-%  be destroyed using DestoryKernelInfo() when no longer needed.
+%  be destroyed using DestoryKernelInfo() when no ssize_ter needed.
 %
 %  The format of the CloneKernelInfo method is:
 %
@@ -1880,7 +1880,7 @@
 */
 MagickExport KernelInfo *CloneKernelInfo(const KernelInfo *kernel)
 {
-  register long
+  register ssize_t
     i;
 
   KernelInfo
@@ -1897,7 +1897,7 @@
     kernel->height*sizeof(double));
   if (new_kernel->values == (double *) NULL)
     return(DestroyKernelInfo(new_kernel));
-  for (i=0; i < (long) (kernel->width*kernel->height); i++)
+  for (i=0; i < (ssize_t) (kernel->width*kernel->height); i++)
     new_kernel->values[i]=kernel->values[i];
 
   /* Also clone the next kernel in the kernel list */
@@ -1982,7 +1982,7 @@
 static MagickBooleanType SameKernelInfo(const KernelInfo *kernel1,
      const KernelInfo *kernel2)
 {
-  register unsigned long
+  register size_t
     i;
 
   /* check size and origin location */
@@ -2064,7 +2064,7 @@
 */
 static void CalcKernelMetaData(KernelInfo *kernel)
 {
-  register unsigned long
+  register size_t
     i;
 
   kernel->minimum = kernel->maximum = 0.0;
@@ -2109,7 +2109,7 @@
 %  The format of the MorphologyApply method is:
 %
 %      Image *MorphologyApply(const Image *image,MorphologyMethod method,
-%        const long iterations,const KernelInfo *kernel,
+%        const ssize_t iterations,const KernelInfo *kernel,
 %        const CompositeMethod compose, const double bias,
 %        ExceptionInfo *exception)
 %
@@ -2146,13 +2146,13 @@
 ** Two pre-created images must be provided, no image is created.
 ** Returning the number of pixels that changed.
 */
-static unsigned long MorphologyPrimitive(const Image *image, Image
+static size_t MorphologyPrimitive(const Image *image, Image
      *result_image, const MorphologyMethod method, const ChannelType channel,
      const KernelInfo *kernel,const double bias,ExceptionInfo *exception)
 {
 #define MorphologyTag  "Morphology/Image"
 
-  long
+  ssize_t
     progress,
     y, offx, offy,
     changed;
@@ -2182,8 +2182,8 @@
     case DilateIntensityMorphology:
     case DistanceMorphology:
       /* kernel needs to used with reflection about origin */
-      offx = (long) kernel->width-offx-1;
-      offy = (long) kernel->height-offy-1;
+      offx = (ssize_t) kernel->width-offx-1;
+      offy = (ssize_t) kernel->height-offy-1;
       break;
     case ErodeMorphology:
     case ErodeIntensityMorphology:
@@ -2200,7 +2200,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -2217,10 +2217,10 @@
     register IndexPacket
       *restrict q_indexes;
 
-    register long
+    register ssize_t
       x;
 
-    unsigned long
+    size_t
       r;
 
     if (status == MagickFalse)
@@ -2238,12 +2238,12 @@
     q_indexes=GetCacheViewAuthenticIndexQueue(q_view);
     r = (image->columns+kernel->width)*offy+offx; /* constant */
 
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-       long
+       ssize_t
         v;
 
-      register long
+      register ssize_t
         u;
 
       register const double
@@ -2339,8 +2339,8 @@
                 k = &kernel->values[ kernel->width*kernel->height-1 ];
                 k_pixels = p;
                 k_indexes = p_indexes;
-                for (v=0; v < (long) kernel->height; v++) {
-                  for (u=0; u < (long) kernel->width; u++, k--) {
+                for (v=0; v < (ssize_t) kernel->height; v++) {
+                  for (u=0; u < (ssize_t) kernel->width; u++, k--) {
                     if ( IsNan(*k) ) continue;
                     alpha=(*k)*(QuantumScale*(QuantumRange-
                                           k_pixels[u].opacity));
@@ -2370,8 +2370,8 @@
                 k = &kernel->values[ kernel->width*kernel->height-1 ];
                 k_pixels = p;
                 k_indexes = p_indexes;
-                for (v=0; v < (long) kernel->height; v++) {
-                  for (u=0; u < (long) kernel->width; u++, k--) {
+                for (v=0; v < (ssize_t) kernel->height; v++) {
+                  for (u=0; u < (ssize_t) kernel->width; u++, k--) {
                     if ( IsNan(*k) ) continue;
                     result.red     += (*k)*k_pixels[u].red;
                     result.green   += (*k)*k_pixels[u].green;
@@ -2398,8 +2398,8 @@
             k = kernel->values;
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k++) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k++) {
                 if ( IsNan(*k) || (*k) < 0.5 ) continue;
                 Minimize(min.red,     (double) k_pixels[u].red);
                 Minimize(min.green,   (double) k_pixels[u].green);
@@ -2430,8 +2430,8 @@
             k = &kernel->values[ kernel->width*kernel->height-1 ];
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k--) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k--) {
                 if ( IsNan(*k) || (*k) < 0.5 ) continue;
                 Maximize(max.red,     (double) k_pixels[u].red);
                 Maximize(max.green,   (double) k_pixels[u].green);
@@ -2462,8 +2462,8 @@
             k = kernel->values;
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k++) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k++) {
                 if ( IsNan(*k) ) continue;
                 if ( (*k) > 0.7 )
                 { /* minimim of foreground pixels */
@@ -2509,8 +2509,8 @@
             k = kernel->values;
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k++) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k++) {
                 if ( IsNan(*k) || (*k) < 0.5 ) continue;
                 if ( result.red == 0.0 ||
                      PixelIntensity(&(k_pixels[u])) < PixelIntensity(q) ) {
@@ -2539,8 +2539,8 @@
             k = &kernel->values[ kernel->width*kernel->height-1 ];
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k--) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k--) {
                 if ( IsNan(*k) || (*k) < 0.5 ) continue; /* boolean kernel */
                 if ( result.red == 0.0 ||
                      PixelIntensity(&(k_pixels[u])) > PixelIntensity(q) ) {
@@ -2571,8 +2571,8 @@
             k = &kernel->values[ kernel->width*kernel->height-1 ];
             k_pixels = p;
             k_indexes = p_indexes;
-            for (v=0; v < (long) kernel->height; v++) {
-              for (u=0; u < (long) kernel->width; u++, k--) {
+            for (v=0; v < (ssize_t) kernel->height; v++) {
+              for (u=0; u < (ssize_t) kernel->width; u++, k--) {
                 if ( IsNan(*k) ) continue;
                 Minimize(result.red,     (*k)+k_pixels[u].red);
                 Minimize(result.green,   (*k)+k_pixels[u].green);
@@ -2676,12 +2676,12 @@
   result_image->type=image->type;
   q_view=DestroyCacheView(q_view);
   p_view=DestroyCacheView(p_view);
-  return(status ? (unsigned long) changed : 0);
+  return(status ? (size_t) changed : 0);
 }
 
 
 MagickExport Image *MorphologyApply(const Image *image, const ChannelType
-     channel,const MorphologyMethod method, const long iterations,
+     channel,const MorphologyMethod method, const ssize_t iterations,
      const KernelInfo *kernel, const CompositeOperator compose,
      const double bias, ExceptionInfo *exception)
 {
@@ -2706,7 +2706,7 @@
   MagickBooleanType
     verbose;        /* verbose output of results */
 
-  unsigned long
+  size_t
     method_loop,    /* Loop 1: number of compound method iterations */
     method_limit,   /*         maximum number of compound method iterations */
     kernel_number,  /* Loop 2: the kernel number being applied */
@@ -2733,7 +2733,7 @@
   if ( iterations == 0 )
     return((Image *)NULL);   /* null operation - nothing to do! */
 
-  kernel_limit = (unsigned long) iterations;
+  kernel_limit = (size_t) iterations;
   if ( iterations < 0 )  /* negative interations = infinite (well alomst) */
      kernel_limit = image->columns > image->rows ? image->columns : image->rows;
 
@@ -2965,11 +2965,11 @@
           fprintf(stderr, "\n"); /* add end-of-line before looping */
 
 #if 0
-    fprintf(stderr, "--E-- image=0x%lx\n", (unsigned long)image);
-    fprintf(stderr, "      curr =0x%lx\n", (unsigned long)curr_image);
-    fprintf(stderr, "      work =0x%lx\n", (unsigned long)work_image);
-    fprintf(stderr, "      save =0x%lx\n", (unsigned long)save_image);
-    fprintf(stderr, "      union=0x%lx\n", (unsigned long)rslt_image);
+    fprintf(stderr, "--E-- image=0x%lx\n", (size_t)image);
+    fprintf(stderr, "      curr =0x%lx\n", (size_t)curr_image);
+    fprintf(stderr, "      work =0x%lx\n", (size_t)work_image);
+    fprintf(stderr, "      save =0x%lx\n", (size_t)save_image);
+    fprintf(stderr, "      union=0x%lx\n", (size_t)rslt_image);
 #endif
 
       } /* End Loop 3: Primative (staging) Loop for Coumpound Methods */
@@ -3102,10 +3102,10 @@
 %  The format of the MorphologyImage method is:
 %
 %      Image *MorphologyImage(const Image *image,MorphologyMethod method,
-%        const long iterations,KernelInfo *kernel,ExceptionInfo *exception)
+%        const ssize_t iterations,KernelInfo *kernel,ExceptionInfo *exception)
 %
 %      Image *MorphologyImageChannel(const Image *image, const ChannelType
-%        channel,MorphologyMethod method,const long iterations,
+%        channel,MorphologyMethod method,const ssize_t iterations,
 %        KernelInfo *kernel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -3130,7 +3130,7 @@
 
 MagickExport Image *MorphologyImageChannel(const Image *image,
   const ChannelType channel,const MorphologyMethod method,
-  const long iterations,const KernelInfo *kernel,ExceptionInfo *exception)
+  const ssize_t iterations,const KernelInfo *kernel,ExceptionInfo *exception)
 {
   const char
     *artifact;
@@ -3195,7 +3195,7 @@
 }
 
 MagickExport Image *MorphologyImage(const Image *image, const MorphologyMethod
-  method, const long iterations,const KernelInfo *kernel, ExceptionInfo
+  method, const ssize_t iterations,const KernelInfo *kernel, ExceptionInfo
   *exception)
 {
   Image
@@ -3305,15 +3305,15 @@
           kernel->values[1] = t;
           /* rotate non-centered origin */
           if ( kernel->x != 1 || kernel->y != 1 ) {
-            long x,y;
-            x = (long) kernel->x-1;
-            y = (long) kernel->y-1;
+            ssize_t x,y;
+            x = (ssize_t) kernel->x-1;
+            y = (ssize_t) kernel->y-1;
                  if ( x == y  ) x = 0;
             else if ( x == 0  ) x = -y;
             else if ( x == -y ) y = 0;
             else if ( y == 0  ) y = x;
-            kernel->x = (unsigned long) x+1;
-            kernel->y = (unsigned long) y+1;
+            kernel->x = (size_t) x+1;
+            kernel->y = (size_t) y+1;
           }
           angle = fmod(angle+315.0, 360.0);  /* angle reduced 45 degrees */
           kernel->angle = fmod(kernel->angle+45.0, 360.0);
@@ -3327,11 +3327,11 @@
         { /* Do a transpose of the image, which results in a 90
           ** degree rotation of a 1 dimentional kernel
           */
-          long
+          ssize_t
             t;
-          t = (long) kernel->width;
+          t = (ssize_t) kernel->width;
           kernel->width = kernel->height;
-          kernel->height = (unsigned long) t;
+          kernel->height = (size_t) t;
           t = kernel->x;
           kernel->x = kernel->y;
           kernel->y = t;
@@ -3345,7 +3345,7 @@
         }
       else if ( kernel->width == kernel->height )
         { /* Rotate a square array of values by 90 degrees */
-          { register unsigned long
+          { register size_t
               i,j,x,y;
             register MagickRealType
               *k,t;
@@ -3360,11 +3360,11 @@
                 }
           }
           /* rotate the origin - relative to center of array */
-          { register long x,y;
-            x = (long) kernel->x*2-kernel->width+1;
-            y = (long) kernel->y*2-kernel->height+1;
-            kernel->x = (unsigned long) ( -y +kernel->width-1)/2;
-            kernel->y = (unsigned long) ( +x +kernel->height-1)/2;
+          { register ssize_t x,y;
+            x = (ssize_t) kernel->x*2-kernel->width+1;
+            y = (ssize_t) kernel->y*2-kernel->height+1;
+            kernel->x = (size_t) ( -y +kernel->width-1)/2;
+            kernel->y = (size_t) ( +x +kernel->height-1)/2;
           }
           angle = fmod(angle+270.0, 360.0);     /* angle reduced 90 degrees */
           kernel->angle = fmod(kernel->angle+90.0, 360.0);
@@ -3379,7 +3379,7 @@
        * Basically all that is needed is a reversal of the kernel data!
        * And a reflection of the origon
        */
-      unsigned long
+      size_t
         i,j;
       register double
         *k,t;
@@ -3388,8 +3388,8 @@
       for ( i=0, j=kernel->width*kernel->height-1;  i<j;  i++, j--)
         t=k[i],  k[i]=k[j],  k[j]=t;
 
-      kernel->x = (long) kernel->width  - kernel->x - 1;
-      kernel->y = (long) kernel->height - kernel->y - 1;
+      kernel->x = (ssize_t) kernel->width  - kernel->x - 1;
+      kernel->y = (ssize_t) kernel->height - kernel->y - 1;
       angle = fmod(angle-180.0, 360.0);   /* angle+180 degrees */
       kernel->angle = fmod(kernel->angle+180.0, 360.0);
     }
@@ -3401,9 +3401,9 @@
 #if 0
     { /* Do a Flop by reversing each row.
        */
-      unsigned long
+      size_t
         y;
-      register long
+      register ssize_t
         x,r;
       register double
         *k,t;
@@ -3561,7 +3561,7 @@
 MagickExport void ScaleKernelInfo(KernelInfo *kernel,
   const double scaling_factor,const GeometryFlags normalize_flags)
 {
-  register long
+  register ssize_t
     i;
 
   register double
@@ -3596,7 +3596,7 @@
   pos_scale = scaling_factor/pos_scale;
   neg_scale = scaling_factor/neg_scale;
 
-  for (i=0; i < (long) (kernel->width*kernel->height); i++)
+  for (i=0; i < (ssize_t) (kernel->width*kernel->height); i++)
     if ( ! IsNan(kernel->values[i]) )
       kernel->values[i] *= (kernel->values[i] >= 0) ? pos_scale : neg_scale;
 
@@ -3649,7 +3649,7 @@
   KernelInfo
     *k;
 
-  unsigned long
+  size_t
     c, i, u, v;
 
   for (c=0, k=kernel;  k != (KernelInfo *) NULL;  c++, k=k->next ) {
@@ -3770,7 +3770,7 @@
 */
 MagickExport void ZeroKernelNans(KernelInfo *kernel)
 {
-  register unsigned long
+  register size_t
     i;
 
   /* do the other kernels in a multi-kernel list first */
diff --git a/magick/morphology.h b/magick/morphology.h
index 310cbad..088e006 100644
--- a/magick/morphology.h
+++ b/magick/morphology.h
@@ -100,11 +100,11 @@
   KernelInfoType
     type;
 
-  unsigned long
+  size_t
     width,
     height;
 
-  long
+  ssize_t
     x,
     y;
 
@@ -119,7 +119,7 @@
   struct KernelInfo
     *next;
 
-  unsigned long
+  size_t
     signature;
 } KernelInfo;
 
@@ -131,10 +131,10 @@
   *DestroyKernelInfo(KernelInfo *);
 
 extern MagickExport Image
-  *MorphologyImage(const Image *,const MorphologyMethod,const long,
+  *MorphologyImage(const Image *,const MorphologyMethod,const ssize_t,
     const KernelInfo *,ExceptionInfo *),
   *MorphologyImageChannel(const Image *,const ChannelType,
-    const MorphologyMethod,const long,const KernelInfo *,ExceptionInfo *);
+    const MorphologyMethod,const ssize_t,const KernelInfo *,ExceptionInfo *);
 
 extern MagickExport void
   ScaleGeometryKernelInfo(KernelInfo *,const char *),
diff --git a/magick/nt-base.c b/magick/nt-base.c
index fe3fdb6..94c6e00 100644
--- a/magick/nt-base.c
+++ b/magick/nt-base.c
@@ -286,8 +286,8 @@
       time=date_time.QuadPart;
       time-=EpochFiletime;
       time/=10;
-      time_value->tv_sec=(long) (time / 1000000);
-      time_value->tv_usec=(long) (time % 1000000);
+      time_value->tv_sec=(ssize_t) (time / 1000000);
+      time_value->tv_usec=(ssize_t) (time % 1000000);
     }
   if (time_zone != (struct timezone *) NULL)
     {
@@ -786,7 +786,7 @@
   HMODULE
     handle;
 
-  long
+  ssize_t
     length;
 
   *path='\0';
@@ -892,7 +892,7 @@
   *product_family=NULL;
   *major_version=5;
   *minor_version=49; /* min version of Ghostscript is 5.50 */
-  for (i=0; i < (long) (sizeof(products)/sizeof(products[0])); i++)
+  for (i=0; i < (ssize_t) (sizeof(products)/sizeof(products[0])); i++)
   {
     char
       key[MaxTextExtent];
@@ -996,7 +996,7 @@
     return(FALSE);
   (void) FormatMagickString(key,MaxTextExtent,"SOFTWARE\\%s\\%d.%02d",
     product_family,major_version,minor_version);
-  for (i=0; i < (long) (sizeof(hkeys)/sizeof(hkeys[0])); i++)
+  for (i=0; i < (ssize_t) (sizeof(hkeys)/sizeof(hkeys[0])); i++)
   {
     extent=(int) length;
     if (NTGetRegistryValue(hkeys[i].hkey,key,name,value,&extent) == 0)
@@ -1778,7 +1778,7 @@
 %
 %  The format of the NTSeekDirectory method is:
 %
-%      void NTSeekDirectory(DIR *entry,long position)
+%      void NTSeekDirectory(DIR *entry,ssize_t position)
 %
 %  A description of each parameter follows:
 %
@@ -1788,7 +1788,7 @@
 %      stream.
 %
 */
-MagickExport void NTSeekDirectory(DIR *entry,long position)
+MagickExport void NTSeekDirectory(DIR *entry,ssize_t position)
 {
   (void) position;
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
@@ -1958,14 +1958,14 @@
 %
 %  The format of the exit method is:
 %
-%      long NTSystemConfiguration(int name)
+%      ssize_t NTSystemConfiguration(int name)
 %
 %  A description of each parameter follows:
 %
 %    o name: _SC_PAGE_SIZE or _SC_PHYS_PAGES.
 %
 */
-MagickExport long NTSystemConfiguration(int name)
+MagickExport ssize_t NTSystemConfiguration(int name)
 {
   switch (name)
   {
@@ -2002,12 +2002,12 @@
             status;
 
           GlobalMemoryStatus(&status);
-          return((long) status.dwTotalPhys/system_info.dwPageSize);
+          return((ssize_t) status.dwTotalPhys/system_info.dwPageSize);
         }
       status.dwLength=sizeof(status);
       if (module(&status) == 0)
         return(0L);
-      return((long) status.ullTotalPhys/system_info.dwPageSize);
+      return((ssize_t) status.ullTotalPhys/system_info.dwPageSize);
     }
     case _SC_OPEN_MAX:
       return(2048);
@@ -2033,14 +2033,14 @@
 %
 %  The format of the NTTellDirectory method is:
 %
-%      long NTTellDirectory(DIR *entry)
+%      ssize_t NTTellDirectory(DIR *entry)
 %
 %  A description of each parameter follows:
 %
 %    o entry: Specifies a pointer to a DIR structure.
 %
 */
-MagickExport long NTTellDirectory(DIR *entry)
+MagickExport ssize_t NTTellDirectory(DIR *entry)
 {
   assert(entry != (DIR *) NULL);
   return(0);
@@ -2075,7 +2075,7 @@
   DWORD
     file_pointer;
 
-  long
+  ssize_t
     file_handle,
     high,
     low;
@@ -2083,8 +2083,8 @@
   file_handle=_get_osfhandle(file);
   if (file_handle == -1L)
     return(-1);
-  low=(long) (length & 0xffffffffUL);
-  high=(long) ((((MagickOffsetType) length) >> 32) & 0xffffffffUL);
+  low=(ssize_t) (length & 0xffffffffUL);
+  high=(ssize_t) ((((MagickOffsetType) length) >> 32) & 0xffffffffUL);
   file_pointer=SetFilePointer((HANDLE) file_handle,low,&high,FILE_BEGIN);
   if ((file_pointer == 0xFFFFFFFF) && (GetLastError() != NO_ERROR))
     return(-1);
diff --git a/magick/nt-base.h b/magick/nt-base.h
index e024148..fc4d3a7 100644
--- a/magick/nt-base.h
+++ b/magick/nt-base.h
@@ -359,7 +359,7 @@
   NTUnmapMemory(void *,size_t),
   NTSystemCommand(const char *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   NTSystemConfiguration(int),
   NTTellDirectory(DIR *);
 
@@ -382,7 +382,7 @@
   *NTGetLibrarySymbol(void *,const char *),
   *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
   *NTOpenLibrary(const char *),
-  NTSeekDirectory(DIR *,long),
+  NTSeekDirectory(DIR *,ssize_t),
   NTWarningHandler(const ExceptionType,const char *,const char *);
 
 #endif /* !XS_VERSION */
diff --git a/magick/nt-feature.c b/magick/nt-feature.c
index e091b5f..5eb55d5 100644
--- a/magick/nt-feature.c
+++ b/magick/nt-feature.c
@@ -97,7 +97,7 @@
 {
 #define CropImageTag  "Crop/Image"
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -134,15 +134,15 @@
   assert(geometry != (const RectangleInfo *) NULL);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  if (((geometry->x+(long) geometry->width) < 0) ||
-      ((geometry->y+(long) geometry->height) < 0) ||
-      (geometry->x >= (long) image->columns) ||
-      (geometry->y >= (long) image->rows))
+  if (((geometry->x+(ssize_t) geometry->width) < 0) ||
+      ((geometry->y+(ssize_t) geometry->height) < 0) ||
+      (geometry->x >= (ssize_t) image->columns) ||
+      (geometry->y >= (ssize_t) image->rows))
     ThrowImageException(OptionError,"GeometryDoesNotContainImage");
   page=(*geometry);
-  if ((page.x+(long) page.width) > (long) image->columns)
+  if ((page.x+(ssize_t) page.width) > (ssize_t) image->columns)
     page.width=image->columns-page.x;
-  if ((page.y+(long) page.height) > (long) image->rows)
+  if ((page.y+(ssize_t) page.height) > (ssize_t) image->rows)
     page.height=image->rows-page.y;
   if (page.x < 0)
     {
@@ -181,7 +181,7 @@
     Extract crop image.
   */
   q=bitmap_bits;
-  for (y=0; y < (long) page.height; y++)
+  for (y=0; y < (ssize_t) page.height; y++)
   {
     p=GetVirtualPixels(image,page.x,page.y+y,page.width,1,exception);
     if (p == (const PixelPacket *) NULL)
@@ -194,7 +194,7 @@
 
 #else  /* 16 or 32 bit Quantum */
       {
-        long
+        ssize_t
           x;
 
         /* Transfer pixels, scaling to Quantum */
@@ -213,7 +213,7 @@
     if (proceed == MagickFalse)
       break;
   }
-  if (y < (long) page.height)
+  if (y < (ssize_t) page.height)
     {
       GlobalUnlock((HGLOBAL) bitmap_bitsH);
       GlobalFree((HGLOBAL) bitmap_bitsH);
@@ -592,10 +592,10 @@
   HBITMAP
     bitmapH;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   register const PixelPacket
@@ -637,12 +637,12 @@
     bitmap.bmBits=bitmap_bits;
   (void) TransformImageColorspace(image,RGBColorspace);
   exception=(&image->exception);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       q->rgbRed=ScaleQuantumToChar(GetRedPixelComponent(p));
       q->rgbGreen=ScaleQuantumToChar(GetGreenPixelComponent(p));
diff --git a/magick/option.c b/magick/option.c
index daab07f..4297338 100644
--- a/magick/option.c
+++ b/magick/option.c
@@ -80,31 +80,31 @@
 static const OptionInfo
   AlignOptions[] =
   {
-    { "Undefined", (long) UndefinedAlign, MagickTrue },
-    { "Center", (long) CenterAlign, MagickFalse },
-    { "End", (long) RightAlign, MagickFalse },
-    { "Left", (long) LeftAlign, MagickFalse },
-    { "Middle", (long) CenterAlign, MagickFalse },
-    { "Right", (long) RightAlign, MagickFalse },
-    { "Start", (long) LeftAlign, MagickFalse },
-    { (char *) NULL, (long) UndefinedAlign, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedAlign, MagickTrue },
+    { "Center", (ssize_t) CenterAlign, MagickFalse },
+    { "End", (ssize_t) RightAlign, MagickFalse },
+    { "Left", (ssize_t) LeftAlign, MagickFalse },
+    { "Middle", (ssize_t) CenterAlign, MagickFalse },
+    { "Right", (ssize_t) RightAlign, MagickFalse },
+    { "Start", (ssize_t) LeftAlign, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedAlign, MagickFalse }
   },
   AlphaOptions[] =
   {
-    { "Undefined", (long) UndefinedAlphaChannel, MagickTrue },
-    { "Activate", (long) ActivateAlphaChannel, MagickFalse },
-    { "Background", (long) BackgroundAlphaChannel, MagickFalse },
-    { "Copy", (long) CopyAlphaChannel, MagickFalse },
-    { "Deactivate", (long) DeactivateAlphaChannel, MagickFalse },
-    { "Extract", (long) ExtractAlphaChannel, MagickFalse },
-    { "Off", (long) DeactivateAlphaChannel, MagickFalse },
-    { "On", (long) ActivateAlphaChannel, MagickFalse },
-    { "Opaque", (long) OpaqueAlphaChannel, MagickFalse },
-    { "Set", (long) SetAlphaChannel, MagickFalse },
-    { "Shape", (long) ShapeAlphaChannel, MagickFalse },
-    { "Reset", (long) SetAlphaChannel, MagickTrue }, /* deprecated */
-    { "Transparent", (long) TransparentAlphaChannel, MagickFalse },
-    { (char *) NULL, (long) UndefinedAlphaChannel, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedAlphaChannel, MagickTrue },
+    { "Activate", (ssize_t) ActivateAlphaChannel, MagickFalse },
+    { "Background", (ssize_t) BackgroundAlphaChannel, MagickFalse },
+    { "Copy", (ssize_t) CopyAlphaChannel, MagickFalse },
+    { "Deactivate", (ssize_t) DeactivateAlphaChannel, MagickFalse },
+    { "Extract", (ssize_t) ExtractAlphaChannel, MagickFalse },
+    { "Off", (ssize_t) DeactivateAlphaChannel, MagickFalse },
+    { "On", (ssize_t) ActivateAlphaChannel, MagickFalse },
+    { "Opaque", (ssize_t) OpaqueAlphaChannel, MagickFalse },
+    { "Set", (ssize_t) SetAlphaChannel, MagickFalse },
+    { "Shape", (ssize_t) ShapeAlphaChannel, MagickFalse },
+    { "Reset", (ssize_t) SetAlphaChannel, MagickTrue }, /* deprecated */
+    { "Transparent", (ssize_t) TransparentAlphaChannel, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedAlphaChannel, MagickFalse }
   },
   BooleanOptions[] =
   {
@@ -116,43 +116,43 @@
   },
   ChannelOptions[] =
   {
-    { "Undefined", (long) UndefinedChannel, MagickTrue },
-    { "All", (long) AllChannels, MagickFalse },
-    { "Alpha", (long) OpacityChannel, MagickFalse },
-    { "Black", (long) BlackChannel, MagickFalse },
-    { "Blue", (long) BlueChannel, MagickFalse },
-    { "Cyan", (long) CyanChannel, MagickFalse },
-    { "Default", (long) DefaultChannels, MagickFalse },
-    { "Gray", (long) GrayChannel, MagickFalse },
-    { "Green", (long) GreenChannel, MagickFalse },
-    { "Hue", (long) RedChannel, MagickFalse },
-    { "Index", (long) IndexChannel, MagickFalse },
-    { "Lightness", (long) BlueChannel, MagickFalse },
-    { "Luminance", (long) BlueChannel, MagickFalse },
-    { "Luminosity", (long) BlueChannel, MagickFalse },  /* deprecated */
-    { "Magenta", (long) MagentaChannel, MagickFalse },
-    { "Matte", (long) OpacityChannel, MagickFalse },
-    { "Opacity", (long) OpacityChannel, MagickFalse },
-    { "Red", (long) RedChannel, MagickFalse },
-    { "Saturation", (long) GreenChannel, MagickFalse },
-    { "Yellow", (long) YellowChannel, MagickFalse },
-    { "Sync", (long) SyncChannels, MagickFalse },   /* special channel flag */
-    { (char *) NULL, (long) UndefinedChannel, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedChannel, MagickTrue },
+    { "All", (ssize_t) AllChannels, MagickFalse },
+    { "Alpha", (ssize_t) OpacityChannel, MagickFalse },
+    { "Black", (ssize_t) BlackChannel, MagickFalse },
+    { "Blue", (ssize_t) BlueChannel, MagickFalse },
+    { "Cyan", (ssize_t) CyanChannel, MagickFalse },
+    { "Default", (ssize_t) DefaultChannels, MagickFalse },
+    { "Gray", (ssize_t) GrayChannel, MagickFalse },
+    { "Green", (ssize_t) GreenChannel, MagickFalse },
+    { "Hue", (ssize_t) RedChannel, MagickFalse },
+    { "Index", (ssize_t) IndexChannel, MagickFalse },
+    { "Lightness", (ssize_t) BlueChannel, MagickFalse },
+    { "Luminance", (ssize_t) BlueChannel, MagickFalse },
+    { "Luminosity", (ssize_t) BlueChannel, MagickFalse },  /* deprecated */
+    { "Magenta", (ssize_t) MagentaChannel, MagickFalse },
+    { "Matte", (ssize_t) OpacityChannel, MagickFalse },
+    { "Opacity", (ssize_t) OpacityChannel, MagickFalse },
+    { "Red", (ssize_t) RedChannel, MagickFalse },
+    { "Saturation", (ssize_t) GreenChannel, MagickFalse },
+    { "Yellow", (ssize_t) YellowChannel, MagickFalse },
+    { "Sync", (ssize_t) SyncChannels, MagickFalse },   /* special channel flag */
+    { (char *) NULL, (ssize_t) UndefinedChannel, MagickFalse }
   },
   ClassOptions[] =
   {
-    { "Undefined", (long) UndefinedClass, MagickTrue },
-    { "DirectClass", (long) DirectClass, MagickFalse },
-    { "PseudoClass", (long) PseudoClass, MagickFalse },
-    { (char *) NULL, (long) UndefinedClass, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedClass, MagickTrue },
+    { "DirectClass", (ssize_t) DirectClass, MagickFalse },
+    { "PseudoClass", (ssize_t) PseudoClass, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedClass, MagickFalse }
   },
   ClipPathOptions[] =
   {
-    { "Undefined", (long) UndefinedPathUnits, MagickTrue },
-    { "ObjectBoundingBox", (long) ObjectBoundingBox, MagickFalse },
-    { "UserSpace", (long) UserSpace, MagickFalse },
-    { "UserSpaceOnUse", (long) UserSpaceOnUse, MagickFalse },
-    { (char *) NULL, (long) UndefinedPathUnits, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPathUnits, MagickTrue },
+    { "ObjectBoundingBox", (ssize_t) ObjectBoundingBox, MagickFalse },
+    { "UserSpace", (ssize_t) UserSpace, MagickFalse },
+    { "UserSpaceOnUse", (ssize_t) UserSpaceOnUse, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedPathUnits, MagickFalse }
   },
   CommandOptions[] =
   {
@@ -686,297 +686,297 @@
     { "-window-group", 1L, MagickFalse },
     { "+write", 1L, MagickFalse },
     { "-write", 1L, MagickFalse },
-    { (char *) NULL, (long) 0L, MagickFalse }
+    { (char *) NULL, (ssize_t) 0L, MagickFalse }
   },
   ComposeOptions[] =
   {
-    { "Undefined", (long) UndefinedCompositeOp, MagickTrue },
-    { "Atop", (long) AtopCompositeOp, MagickFalse },
-    { "Blend", (long) BlendCompositeOp, MagickFalse },
-    { "Blur", (long) BlurCompositeOp, MagickFalse },
-    { "Bumpmap", (long) BumpmapCompositeOp, MagickFalse },
-    { "ChangeMask", (long) ChangeMaskCompositeOp, MagickFalse },
-    { "Clear", (long) ClearCompositeOp, MagickFalse },
-    { "ColorBurn", (long) ColorBurnCompositeOp, MagickFalse },
-    { "ColorDodge", (long) ColorDodgeCompositeOp, MagickFalse },
-    { "Colorize", (long) ColorizeCompositeOp, MagickFalse },
-    { "CopyBlack", (long) CopyBlackCompositeOp, MagickFalse },
-    { "CopyBlue", (long) CopyBlueCompositeOp, MagickFalse },
-    { "CopyCyan", (long) CopyCyanCompositeOp, MagickFalse },
-    { "CopyGreen", (long) CopyGreenCompositeOp, MagickFalse },
-    { "Copy", (long) CopyCompositeOp, MagickFalse },
-    { "CopyMagenta", (long) CopyMagentaCompositeOp, MagickFalse },
-    { "CopyOpacity", (long) CopyOpacityCompositeOp, MagickFalse },
-    { "CopyRed", (long) CopyRedCompositeOp, MagickFalse },
-    { "CopyYellow", (long) CopyYellowCompositeOp, MagickFalse },
-    { "Darken", (long) DarkenCompositeOp, MagickFalse },
-    { "Divide", (long) DivideCompositeOp, MagickFalse },
-    { "Dst", (long) DstCompositeOp, MagickFalse },
-    { "Difference", (long) DifferenceCompositeOp, MagickFalse },
-    { "Displace", (long) DisplaceCompositeOp, MagickFalse },
-    { "Dissolve", (long) DissolveCompositeOp, MagickFalse },
-    { "Distort", (long) DistortCompositeOp, MagickFalse },
-    { "DstAtop", (long) DstAtopCompositeOp, MagickFalse },
-    { "DstIn", (long) DstInCompositeOp, MagickFalse },
-    { "DstOut", (long) DstOutCompositeOp, MagickFalse },
-    { "DstOver", (long) DstOverCompositeOp, MagickFalse },
-    { "Dst", (long) DstCompositeOp, MagickFalse },
-    { "Exclusion", (long) ExclusionCompositeOp, MagickFalse },
-    { "HardLight", (long) HardLightCompositeOp, MagickFalse },
-    { "Hue", (long) HueCompositeOp, MagickFalse },
-    { "In", (long) InCompositeOp, MagickFalse },
-    { "Lighten", (long) LightenCompositeOp, MagickFalse },
-    { "LinearBurn", (long) LinearBurnCompositeOp, MagickFalse },
-    { "LinearDodge", (long) LinearDodgeCompositeOp, MagickFalse },
-    { "LinearLight", (long) LinearLightCompositeOp, MagickFalse },
-    { "Luminize", (long) LuminizeCompositeOp, MagickFalse },
-    { "Mathematics", (long) MathematicsCompositeOp, MagickFalse },
-    { "Minus", (long) MinusCompositeOp, MagickFalse },
-    { "Modulate", (long) ModulateCompositeOp, MagickFalse },
-    { "ModulusAdd", (long) ModulusAddCompositeOp, MagickFalse },
-    { "ModulusSubtract", (long) ModulusSubtractCompositeOp, MagickFalse },
-    { "Multiply", (long) MultiplyCompositeOp, MagickFalse },
-    { "None", (long) NoCompositeOp, MagickFalse },
-    { "Out", (long) OutCompositeOp, MagickFalse },
-    { "Overlay", (long) OverlayCompositeOp, MagickFalse },
-    { "Over", (long) OverCompositeOp, MagickFalse },
-    { "PegtopLight", (long) PegtopLightCompositeOp, MagickFalse },
-    { "PinLight", (long) PinLightCompositeOp, MagickFalse },
-    { "Plus", (long) PlusCompositeOp, MagickFalse },
-    { "Replace", (long) ReplaceCompositeOp, MagickFalse },
-    { "Saturate", (long) SaturateCompositeOp, MagickFalse },
-    { "Screen", (long) ScreenCompositeOp, MagickFalse },
-    { "SoftLight", (long) SoftLightCompositeOp, MagickFalse },
-    { "Src", (long) SrcCompositeOp, MagickFalse },
-    { "SrcAtop", (long) SrcAtopCompositeOp, MagickFalse },
-    { "SrcIn", (long) SrcInCompositeOp, MagickFalse },
-    { "SrcOut", (long) SrcOutCompositeOp, MagickFalse },
-    { "SrcOver", (long) SrcOverCompositeOp, MagickFalse },
-    { "Src", (long) SrcCompositeOp, MagickFalse },
-    { "VividLight", (long) VividLightCompositeOp, MagickFalse },
-    { "Xor", (long) XorCompositeOp, MagickFalse },
-    { "Add", (long) AddCompositeOp, MagickTrue }, /* depreciate */
-    { "Subtract", (long) SubtractCompositeOp, MagickTrue }, /* depreciate */
-    { "Threshold", (long) ThresholdCompositeOp, MagickTrue }, /* depreciate */
-    { (char *) NULL, (long) UndefinedCompositeOp, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedCompositeOp, MagickTrue },
+    { "Atop", (ssize_t) AtopCompositeOp, MagickFalse },
+    { "Blend", (ssize_t) BlendCompositeOp, MagickFalse },
+    { "Blur", (ssize_t) BlurCompositeOp, MagickFalse },
+    { "Bumpmap", (ssize_t) BumpmapCompositeOp, MagickFalse },
+    { "ChangeMask", (ssize_t) ChangeMaskCompositeOp, MagickFalse },
+    { "Clear", (ssize_t) ClearCompositeOp, MagickFalse },
+    { "ColorBurn", (ssize_t) ColorBurnCompositeOp, MagickFalse },
+    { "ColorDodge", (ssize_t) ColorDodgeCompositeOp, MagickFalse },
+    { "Colorize", (ssize_t) ColorizeCompositeOp, MagickFalse },
+    { "CopyBlack", (ssize_t) CopyBlackCompositeOp, MagickFalse },
+    { "CopyBlue", (ssize_t) CopyBlueCompositeOp, MagickFalse },
+    { "CopyCyan", (ssize_t) CopyCyanCompositeOp, MagickFalse },
+    { "CopyGreen", (ssize_t) CopyGreenCompositeOp, MagickFalse },
+    { "Copy", (ssize_t) CopyCompositeOp, MagickFalse },
+    { "CopyMagenta", (ssize_t) CopyMagentaCompositeOp, MagickFalse },
+    { "CopyOpacity", (ssize_t) CopyOpacityCompositeOp, MagickFalse },
+    { "CopyRed", (ssize_t) CopyRedCompositeOp, MagickFalse },
+    { "CopyYellow", (ssize_t) CopyYellowCompositeOp, MagickFalse },
+    { "Darken", (ssize_t) DarkenCompositeOp, MagickFalse },
+    { "Divide", (ssize_t) DivideCompositeOp, MagickFalse },
+    { "Dst", (ssize_t) DstCompositeOp, MagickFalse },
+    { "Difference", (ssize_t) DifferenceCompositeOp, MagickFalse },
+    { "Displace", (ssize_t) DisplaceCompositeOp, MagickFalse },
+    { "Dissolve", (ssize_t) DissolveCompositeOp, MagickFalse },
+    { "Distort", (ssize_t) DistortCompositeOp, MagickFalse },
+    { "DstAtop", (ssize_t) DstAtopCompositeOp, MagickFalse },
+    { "DstIn", (ssize_t) DstInCompositeOp, MagickFalse },
+    { "DstOut", (ssize_t) DstOutCompositeOp, MagickFalse },
+    { "DstOver", (ssize_t) DstOverCompositeOp, MagickFalse },
+    { "Dst", (ssize_t) DstCompositeOp, MagickFalse },
+    { "Exclusion", (ssize_t) ExclusionCompositeOp, MagickFalse },
+    { "HardLight", (ssize_t) HardLightCompositeOp, MagickFalse },
+    { "Hue", (ssize_t) HueCompositeOp, MagickFalse },
+    { "In", (ssize_t) InCompositeOp, MagickFalse },
+    { "Lighten", (ssize_t) LightenCompositeOp, MagickFalse },
+    { "LinearBurn", (ssize_t) LinearBurnCompositeOp, MagickFalse },
+    { "LinearDodge", (ssize_t) LinearDodgeCompositeOp, MagickFalse },
+    { "LinearLight", (ssize_t) LinearLightCompositeOp, MagickFalse },
+    { "Luminize", (ssize_t) LuminizeCompositeOp, MagickFalse },
+    { "Mathematics", (ssize_t) MathematicsCompositeOp, MagickFalse },
+    { "Minus", (ssize_t) MinusCompositeOp, MagickFalse },
+    { "Modulate", (ssize_t) ModulateCompositeOp, MagickFalse },
+    { "ModulusAdd", (ssize_t) ModulusAddCompositeOp, MagickFalse },
+    { "ModulusSubtract", (ssize_t) ModulusSubtractCompositeOp, MagickFalse },
+    { "Multiply", (ssize_t) MultiplyCompositeOp, MagickFalse },
+    { "None", (ssize_t) NoCompositeOp, MagickFalse },
+    { "Out", (ssize_t) OutCompositeOp, MagickFalse },
+    { "Overlay", (ssize_t) OverlayCompositeOp, MagickFalse },
+    { "Over", (ssize_t) OverCompositeOp, MagickFalse },
+    { "PegtopLight", (ssize_t) PegtopLightCompositeOp, MagickFalse },
+    { "PinLight", (ssize_t) PinLightCompositeOp, MagickFalse },
+    { "Plus", (ssize_t) PlusCompositeOp, MagickFalse },
+    { "Replace", (ssize_t) ReplaceCompositeOp, MagickFalse },
+    { "Saturate", (ssize_t) SaturateCompositeOp, MagickFalse },
+    { "Screen", (ssize_t) ScreenCompositeOp, MagickFalse },
+    { "SoftLight", (ssize_t) SoftLightCompositeOp, MagickFalse },
+    { "Src", (ssize_t) SrcCompositeOp, MagickFalse },
+    { "SrcAtop", (ssize_t) SrcAtopCompositeOp, MagickFalse },
+    { "SrcIn", (ssize_t) SrcInCompositeOp, MagickFalse },
+    { "SrcOut", (ssize_t) SrcOutCompositeOp, MagickFalse },
+    { "SrcOver", (ssize_t) SrcOverCompositeOp, MagickFalse },
+    { "Src", (ssize_t) SrcCompositeOp, MagickFalse },
+    { "VividLight", (ssize_t) VividLightCompositeOp, MagickFalse },
+    { "Xor", (ssize_t) XorCompositeOp, MagickFalse },
+    { "Add", (ssize_t) AddCompositeOp, MagickTrue }, /* depreciate */
+    { "Subtract", (ssize_t) SubtractCompositeOp, MagickTrue }, /* depreciate */
+    { "Threshold", (ssize_t) ThresholdCompositeOp, MagickTrue }, /* depreciate */
+    { (char *) NULL, (ssize_t) UndefinedCompositeOp, MagickFalse }
   },
   CompressOptions[] =
   {
-    { "Undefined", (long) UndefinedCompression, MagickTrue },
-    { "B44", (long) B44Compression, MagickFalse },
-    { "B44A", (long) B44ACompression, MagickFalse },
-    { "BZip", (long) BZipCompression, MagickFalse },
-    { "DXT1", (long) DXT1Compression, MagickFalse },
-    { "DXT3", (long) DXT3Compression, MagickFalse },
-    { "DXT5", (long) DXT5Compression, MagickFalse },
-    { "Fax", (long) FaxCompression, MagickFalse },
-    { "Group4", (long) Group4Compression, MagickFalse },
-    { "JPEG", (long) JPEGCompression, MagickFalse },
-    { "JPEG2000", (long) JPEG2000Compression, MagickFalse },
-    { "Lossless", (long) LosslessJPEGCompression, MagickFalse },
-    { "LosslessJPEG", (long) LosslessJPEGCompression, MagickFalse },
-    { "LZW", (long) LZWCompression, MagickFalse },
-    { "None", (long) NoCompression, MagickFalse },
-    { "Piz", (long) PizCompression, MagickFalse },
-    { "Pxr24", (long) Pxr24Compression, MagickFalse },
-    { "RLE", (long) RLECompression, MagickFalse },
-    { "Zip", (long) ZipCompression, MagickFalse },
-    { "RunlengthEncoded", (long) RLECompression, MagickFalse },
-    { "ZipS", (long) ZipSCompression, MagickFalse },
-    { (char *) NULL, (long) UndefinedCompression, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedCompression, MagickTrue },
+    { "B44", (ssize_t) B44Compression, MagickFalse },
+    { "B44A", (ssize_t) B44ACompression, MagickFalse },
+    { "BZip", (ssize_t) BZipCompression, MagickFalse },
+    { "DXT1", (ssize_t) DXT1Compression, MagickFalse },
+    { "DXT3", (ssize_t) DXT3Compression, MagickFalse },
+    { "DXT5", (ssize_t) DXT5Compression, MagickFalse },
+    { "Fax", (ssize_t) FaxCompression, MagickFalse },
+    { "Group4", (ssize_t) Group4Compression, MagickFalse },
+    { "JPEG", (ssize_t) JPEGCompression, MagickFalse },
+    { "JPEG2000", (ssize_t) JPEG2000Compression, MagickFalse },
+    { "Lossless", (ssize_t) LosslessJPEGCompression, MagickFalse },
+    { "LosslessJPEG", (ssize_t) LosslessJPEGCompression, MagickFalse },
+    { "LZW", (ssize_t) LZWCompression, MagickFalse },
+    { "None", (ssize_t) NoCompression, MagickFalse },
+    { "Piz", (ssize_t) PizCompression, MagickFalse },
+    { "Pxr24", (ssize_t) Pxr24Compression, MagickFalse },
+    { "RLE", (ssize_t) RLECompression, MagickFalse },
+    { "Zip", (ssize_t) ZipCompression, MagickFalse },
+    { "RunlengthEncoded", (ssize_t) RLECompression, MagickFalse },
+    { "ZipS", (ssize_t) ZipSCompression, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedCompression, MagickFalse }
   },
   ColorspaceOptions[] =
   {
-    { "Undefined", (long) UndefinedColorspace, MagickTrue },
-    { "CMY", (long) CMYColorspace, MagickFalse },
-    { "CMYK", (long) CMYKColorspace, MagickFalse },
-    { "Gray", (long) GRAYColorspace, MagickFalse },
-    { "HSB", (long) HSBColorspace, MagickFalse },
-    { "HSL", (long) HSLColorspace, MagickFalse },
-    { "HWB", (long) HWBColorspace, MagickFalse },
-    { "Lab", (long) LabColorspace, MagickFalse },
-    { "Log", (long) LogColorspace, MagickFalse },
-    { "OHTA", (long) OHTAColorspace, MagickFalse },
-    { "Rec601Luma", (long) Rec601LumaColorspace, MagickFalse },
-    { "Rec601YCbCr", (long) Rec601YCbCrColorspace, MagickFalse },
-    { "Rec709Luma", (long) Rec709LumaColorspace, MagickFalse },
-    { "Rec709YCbCr", (long) Rec709YCbCrColorspace, MagickFalse },
-    { "RGB", (long) RGBColorspace, MagickFalse },
-    { "sRGB", (long) sRGBColorspace, MagickFalse },
-    { "Transparent", (long) TransparentColorspace, MagickFalse },
-    { "XYZ", (long) XYZColorspace, MagickFalse },
-    { "YCbCr", (long) YCbCrColorspace, MagickFalse },
-    { "YCC", (long) YCCColorspace, MagickFalse },
-    { "YIQ", (long) YIQColorspace, MagickFalse },
-    { "YPbPr", (long) YPbPrColorspace, MagickFalse },
-    { "YUV", (long) YUVColorspace, MagickFalse },
-    { (char *) NULL, (long) UndefinedColorspace, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedColorspace, MagickTrue },
+    { "CMY", (ssize_t) CMYColorspace, MagickFalse },
+    { "CMYK", (ssize_t) CMYKColorspace, MagickFalse },
+    { "Gray", (ssize_t) GRAYColorspace, MagickFalse },
+    { "HSB", (ssize_t) HSBColorspace, MagickFalse },
+    { "HSL", (ssize_t) HSLColorspace, MagickFalse },
+    { "HWB", (ssize_t) HWBColorspace, MagickFalse },
+    { "Lab", (ssize_t) LabColorspace, MagickFalse },
+    { "Log", (ssize_t) LogColorspace, MagickFalse },
+    { "OHTA", (ssize_t) OHTAColorspace, MagickFalse },
+    { "Rec601Luma", (ssize_t) Rec601LumaColorspace, MagickFalse },
+    { "Rec601YCbCr", (ssize_t) Rec601YCbCrColorspace, MagickFalse },
+    { "Rec709Luma", (ssize_t) Rec709LumaColorspace, MagickFalse },
+    { "Rec709YCbCr", (ssize_t) Rec709YCbCrColorspace, MagickFalse },
+    { "RGB", (ssize_t) RGBColorspace, MagickFalse },
+    { "sRGB", (ssize_t) sRGBColorspace, MagickFalse },
+    { "Transparent", (ssize_t) TransparentColorspace, MagickFalse },
+    { "XYZ", (ssize_t) XYZColorspace, MagickFalse },
+    { "YCbCr", (ssize_t) YCbCrColorspace, MagickFalse },
+    { "YCC", (ssize_t) YCCColorspace, MagickFalse },
+    { "YIQ", (ssize_t) YIQColorspace, MagickFalse },
+    { "YPbPr", (ssize_t) YPbPrColorspace, MagickFalse },
+    { "YUV", (ssize_t) YUVColorspace, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedColorspace, MagickFalse }
   },
   DataTypeOptions[] =
   {
-    { "Undefined", (long) UndefinedData, MagickTrue },
-    { "Byte", (long) ByteData, MagickFalse },
-    { "Long", (long) LongData, MagickFalse },
-    { "Short", (long) ShortData, MagickFalse },
-    { "String", (long) StringData, MagickFalse },
-    { (char *) NULL, (long) UndefinedData, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedData, MagickTrue },
+    { "Byte", (ssize_t) ByteData, MagickFalse },
+    { "Long", (ssize_t) LongData, MagickFalse },
+    { "Short", (ssize_t) ShortData, MagickFalse },
+    { "String", (ssize_t) StringData, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedData, MagickFalse }
   },
   DecorateOptions[] =
   {
-    { "Undefined", (long) UndefinedDecoration, MagickTrue },
-    { "LineThrough", (long) LineThroughDecoration, MagickFalse },
-    { "None", (long) NoDecoration, MagickFalse },
-    { "Overline", (long) OverlineDecoration, MagickFalse },
-    { "Underline", (long) UnderlineDecoration, MagickFalse },
-    { (char *) NULL, (long) UndefinedDecoration, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDecoration, MagickTrue },
+    { "LineThrough", (ssize_t) LineThroughDecoration, MagickFalse },
+    { "None", (ssize_t) NoDecoration, MagickFalse },
+    { "Overline", (ssize_t) OverlineDecoration, MagickFalse },
+    { "Underline", (ssize_t) UnderlineDecoration, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedDecoration, MagickFalse }
   },
   DirectionOptions[] =
   {
-    { "Undefined", (long) UndefinedDirection, MagickTrue },
-    { "right-to-left", (long) RightToLeftDirection, MagickFalse },
-    { "left-to-right", (long) LeftToRightDirection, MagickFalse },
-    { (char *) NULL, (long) UndefinedDirection, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDirection, MagickTrue },
+    { "right-to-left", (ssize_t) RightToLeftDirection, MagickFalse },
+    { "left-to-right", (ssize_t) LeftToRightDirection, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedDirection, MagickFalse }
   },
   DisposeOptions[] =
   {
-    { "Undefined", (long) UndefinedDispose, MagickTrue },
-    { "Background", (long) BackgroundDispose, MagickFalse },
-    { "None", (long) NoneDispose, MagickFalse },
-    { "Previous", (long) PreviousDispose, MagickFalse },
-    { "Undefined", (long) UndefinedDispose, MagickFalse },
-    { "0", (long) UndefinedDispose, MagickFalse },
-    { "1", (long) NoneDispose, MagickFalse },
-    { "2", (long) BackgroundDispose, MagickFalse },
-    { "3", (long) PreviousDispose, MagickFalse },
-    { (char *) NULL, (long) UndefinedDispose, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDispose, MagickTrue },
+    { "Background", (ssize_t) BackgroundDispose, MagickFalse },
+    { "None", (ssize_t) NoneDispose, MagickFalse },
+    { "Previous", (ssize_t) PreviousDispose, MagickFalse },
+    { "Undefined", (ssize_t) UndefinedDispose, MagickFalse },
+    { "0", (ssize_t) UndefinedDispose, MagickFalse },
+    { "1", (ssize_t) NoneDispose, MagickFalse },
+    { "2", (ssize_t) BackgroundDispose, MagickFalse },
+    { "3", (ssize_t) PreviousDispose, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedDispose, MagickFalse }
   },
   DistortOptions[] =
   {
-    { "Undefined", (long) UndefinedDistortion, MagickTrue },
-    { "Affine", (long) AffineDistortion, MagickFalse },
-    { "AffineProjection", (long) AffineProjectionDistortion, MagickFalse },
-    { "ScaleRotateTranslate", (long) ScaleRotateTranslateDistortion, MagickFalse },
-    { "SRT", (long) ScaleRotateTranslateDistortion, MagickFalse },
-    { "Perspective", (long) PerspectiveDistortion, MagickFalse },
-    { "PerspectiveProjection", (long) PerspectiveProjectionDistortion, MagickFalse },
-    { "Bilinear", (long) BilinearForwardDistortion, MagickTrue },
-    { "BilinearForward", (long) BilinearForwardDistortion, MagickFalse },
-    { "BilinearReverse", (long) BilinearReverseDistortion, MagickFalse },
-    { "Polynomial", (long) PolynomialDistortion, MagickFalse },
-    { "Arc", (long) ArcDistortion, MagickFalse },
-    { "Polar", (long) PolarDistortion, MagickFalse },
-    { "DePolar", (long) DePolarDistortion, MagickFalse },
-    { "Barrel", (long) BarrelDistortion, MagickFalse },
-    { "BarrelInverse", (long) BarrelInverseDistortion, MagickFalse },
-    { "Shepards", (long) ShepardsDistortion, MagickFalse },
-    { (char *) NULL, (long) UndefinedDistortion, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDistortion, MagickTrue },
+    { "Affine", (ssize_t) AffineDistortion, MagickFalse },
+    { "AffineProjection", (ssize_t) AffineProjectionDistortion, MagickFalse },
+    { "ScaleRotateTranslate", (ssize_t) ScaleRotateTranslateDistortion, MagickFalse },
+    { "SRT", (ssize_t) ScaleRotateTranslateDistortion, MagickFalse },
+    { "Perspective", (ssize_t) PerspectiveDistortion, MagickFalse },
+    { "PerspectiveProjection", (ssize_t) PerspectiveProjectionDistortion, MagickFalse },
+    { "Bilinear", (ssize_t) BilinearForwardDistortion, MagickTrue },
+    { "BilinearForward", (ssize_t) BilinearForwardDistortion, MagickFalse },
+    { "BilinearReverse", (ssize_t) BilinearReverseDistortion, MagickFalse },
+    { "Polynomial", (ssize_t) PolynomialDistortion, MagickFalse },
+    { "Arc", (ssize_t) ArcDistortion, MagickFalse },
+    { "Polar", (ssize_t) PolarDistortion, MagickFalse },
+    { "DePolar", (ssize_t) DePolarDistortion, MagickFalse },
+    { "Barrel", (ssize_t) BarrelDistortion, MagickFalse },
+    { "BarrelInverse", (ssize_t) BarrelInverseDistortion, MagickFalse },
+    { "Shepards", (ssize_t) ShepardsDistortion, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedDistortion, MagickFalse }
   },
   DitherOptions[] =
   {
-    { "Undefined", (long) UndefinedDitherMethod, MagickTrue },
-    { "None", (long) NoDitherMethod, MagickFalse },
-    { "FloydSteinberg", (long) FloydSteinbergDitherMethod, MagickFalse },
-    { "Riemersma", (long) RiemersmaDitherMethod, MagickFalse },
-    { (char *) NULL, (long) UndefinedEndian, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDitherMethod, MagickTrue },
+    { "None", (ssize_t) NoDitherMethod, MagickFalse },
+    { "FloydSteinberg", (ssize_t) FloydSteinbergDitherMethod, MagickFalse },
+    { "Riemersma", (ssize_t) RiemersmaDitherMethod, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedEndian, MagickFalse }
   },
   EndianOptions[] =
   {
-    { "Undefined", (long) UndefinedEndian, MagickTrue },
-    { "LSB", (long) LSBEndian, MagickFalse },
-    { "MSB", (long) MSBEndian, MagickFalse },
-    { (char *) NULL, (long) UndefinedEndian, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedEndian, MagickTrue },
+    { "LSB", (ssize_t) LSBEndian, MagickFalse },
+    { "MSB", (ssize_t) MSBEndian, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedEndian, MagickFalse }
   },
   EvaluateOptions[] =
   {
-    { "Undefined", (long) UndefinedEvaluateOperator, MagickTrue },
-    { "Add", (long) AddEvaluateOperator, MagickFalse },
-    { "AddModulus", (long) AddModulusEvaluateOperator, MagickFalse },
-    { "And", (long) AndEvaluateOperator, MagickFalse },
-    { "Cos", (long) CosineEvaluateOperator, MagickFalse },
-    { "Cosine", (long) CosineEvaluateOperator, MagickFalse },
-    { "Divide", (long) DivideEvaluateOperator, MagickFalse },
-    { "GaussianNoise", (long) GaussianNoiseEvaluateOperator, MagickFalse },
-    { "ImpulseNoise", (long) ImpulseNoiseEvaluateOperator, MagickFalse },
-    { "LaplacianNoise", (long) LaplacianNoiseEvaluateOperator, MagickFalse },
-    { "LeftShift", (long) LeftShiftEvaluateOperator, MagickFalse },
-    { "Log", (long) LogEvaluateOperator, MagickFalse },
-    { "Max", (long) MaxEvaluateOperator, MagickFalse },
-    { "Mean", (long) MeanEvaluateOperator, MagickFalse },
-    { "Min", (long) MinEvaluateOperator, MagickFalse },
-    { "MultiplicativeNoise", (long) MultiplicativeNoiseEvaluateOperator, MagickFalse },
-    { "Multiply", (long) MultiplyEvaluateOperator, MagickFalse },
-    { "Or", (long) OrEvaluateOperator, MagickFalse },
-    { "PoissonNoise", (long) PoissonNoiseEvaluateOperator, MagickFalse },
-    { "Pow", (long) PowEvaluateOperator, MagickFalse },
-    { "RightShift", (long) RightShiftEvaluateOperator, MagickFalse },
-    { "Set", (long) SetEvaluateOperator, MagickFalse },
-    { "Sin", (long) SineEvaluateOperator, MagickFalse },
-    { "Sine", (long) SineEvaluateOperator, MagickFalse },
-    { "Subtract", (long) SubtractEvaluateOperator, MagickFalse },
-    { "Threshold", (long) ThresholdEvaluateOperator, MagickFalse },
-    { "ThresholdBlack", (long) ThresholdBlackEvaluateOperator, MagickFalse },
-    { "ThresholdWhite", (long) ThresholdWhiteEvaluateOperator, MagickFalse },
-    { "UniformNoise", (long) UniformNoiseEvaluateOperator, MagickFalse },
-    { "Xor", (long) XorEvaluateOperator, MagickFalse },
-    { (char *) NULL, (long) UndefinedEvaluateOperator, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedEvaluateOperator, MagickTrue },
+    { "Add", (ssize_t) AddEvaluateOperator, MagickFalse },
+    { "AddModulus", (ssize_t) AddModulusEvaluateOperator, MagickFalse },
+    { "And", (ssize_t) AndEvaluateOperator, MagickFalse },
+    { "Cos", (ssize_t) CosineEvaluateOperator, MagickFalse },
+    { "Cosine", (ssize_t) CosineEvaluateOperator, MagickFalse },
+    { "Divide", (ssize_t) DivideEvaluateOperator, MagickFalse },
+    { "GaussianNoise", (ssize_t) GaussianNoiseEvaluateOperator, MagickFalse },
+    { "ImpulseNoise", (ssize_t) ImpulseNoiseEvaluateOperator, MagickFalse },
+    { "LaplacianNoise", (ssize_t) LaplacianNoiseEvaluateOperator, MagickFalse },
+    { "LeftShift", (ssize_t) LeftShiftEvaluateOperator, MagickFalse },
+    { "Log", (ssize_t) LogEvaluateOperator, MagickFalse },
+    { "Max", (ssize_t) MaxEvaluateOperator, MagickFalse },
+    { "Mean", (ssize_t) MeanEvaluateOperator, MagickFalse },
+    { "Min", (ssize_t) MinEvaluateOperator, MagickFalse },
+    { "MultiplicativeNoise", (ssize_t) MultiplicativeNoiseEvaluateOperator, MagickFalse },
+    { "Multiply", (ssize_t) MultiplyEvaluateOperator, MagickFalse },
+    { "Or", (ssize_t) OrEvaluateOperator, MagickFalse },
+    { "PoissonNoise", (ssize_t) PoissonNoiseEvaluateOperator, MagickFalse },
+    { "Pow", (ssize_t) PowEvaluateOperator, MagickFalse },
+    { "RightShift", (ssize_t) RightShiftEvaluateOperator, MagickFalse },
+    { "Set", (ssize_t) SetEvaluateOperator, MagickFalse },
+    { "Sin", (ssize_t) SineEvaluateOperator, MagickFalse },
+    { "Sine", (ssize_t) SineEvaluateOperator, MagickFalse },
+    { "Subtract", (ssize_t) SubtractEvaluateOperator, MagickFalse },
+    { "Threshold", (ssize_t) ThresholdEvaluateOperator, MagickFalse },
+    { "ThresholdBlack", (ssize_t) ThresholdBlackEvaluateOperator, MagickFalse },
+    { "ThresholdWhite", (ssize_t) ThresholdWhiteEvaluateOperator, MagickFalse },
+    { "UniformNoise", (ssize_t) UniformNoiseEvaluateOperator, MagickFalse },
+    { "Xor", (ssize_t) XorEvaluateOperator, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedEvaluateOperator, MagickFalse }
   },
   FillRuleOptions[] =
   {
-    { "Undefined", (long) UndefinedRule, MagickTrue },
-    { "Evenodd", (long) EvenOddRule, MagickFalse },
-    { "NonZero", (long) NonZeroRule, MagickFalse },
-    { (char *) NULL, (long) UndefinedRule, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedRule, MagickTrue },
+    { "Evenodd", (ssize_t) EvenOddRule, MagickFalse },
+    { "NonZero", (ssize_t) NonZeroRule, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedRule, MagickFalse }
   },
   FilterOptions[] =
   {
-    { "Undefined", (long) UndefinedFilter, MagickTrue },
-    { "Bartlett", (long) BartlettFilter, MagickFalse },
-    { "Bessel", (long) BesselFilter, MagickFalse },
-    { "Blackman", (long) BlackmanFilter, MagickFalse },
-    { "Bohman", (long) BohmanFilter, MagickFalse },
-    { "Box", (long) BoxFilter, MagickFalse },
-    { "Catrom", (long) CatromFilter, MagickFalse },
-    { "Cubic", (long) CubicFilter, MagickFalse },
-    { "Gaussian", (long) GaussianFilter, MagickFalse },
-    { "Hamming", (long) HammingFilter, MagickFalse },
-    { "Hanning", (long) HanningFilter, MagickFalse },
-    { "Hermite", (long) HermiteFilter, MagickFalse },
-    { "Kaiser", (long) KaiserFilter, MagickFalse },
-    { "Lagrange", (long) LagrangeFilter, MagickFalse },
-    { "Lanczos", (long) LanczosFilter, MagickFalse },
-    { "Mitchell", (long) MitchellFilter, MagickFalse },
-    { "Parzen", (long) ParzenFilter, MagickFalse },
-    { "Point", (long) PointFilter, MagickFalse },
-    { "Quadratic", (long) QuadraticFilter, MagickFalse },
-    { "Sinc", (long) SincFilter, MagickFalse },
-    { "Triangle", (long) TriangleFilter, MagickFalse },
-    { "Welsh", (long) WelshFilter, MagickFalse },
-    { (char *) NULL, (long) UndefinedFilter, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedFilter, MagickTrue },
+    { "Bartlett", (ssize_t) BartlettFilter, MagickFalse },
+    { "Bessel", (ssize_t) BesselFilter, MagickFalse },
+    { "Blackman", (ssize_t) BlackmanFilter, MagickFalse },
+    { "Bohman", (ssize_t) BohmanFilter, MagickFalse },
+    { "Box", (ssize_t) BoxFilter, MagickFalse },
+    { "Catrom", (ssize_t) CatromFilter, MagickFalse },
+    { "Cubic", (ssize_t) CubicFilter, MagickFalse },
+    { "Gaussian", (ssize_t) GaussianFilter, MagickFalse },
+    { "Hamming", (ssize_t) HammingFilter, MagickFalse },
+    { "Hanning", (ssize_t) HanningFilter, MagickFalse },
+    { "Hermite", (ssize_t) HermiteFilter, MagickFalse },
+    { "Kaiser", (ssize_t) KaiserFilter, MagickFalse },
+    { "Lagrange", (ssize_t) LagrangeFilter, MagickFalse },
+    { "Lanczos", (ssize_t) LanczosFilter, MagickFalse },
+    { "Mitchell", (ssize_t) MitchellFilter, MagickFalse },
+    { "Parzen", (ssize_t) ParzenFilter, MagickFalse },
+    { "Point", (ssize_t) PointFilter, MagickFalse },
+    { "Quadratic", (ssize_t) QuadraticFilter, MagickFalse },
+    { "Sinc", (ssize_t) SincFilter, MagickFalse },
+    { "Triangle", (ssize_t) TriangleFilter, MagickFalse },
+    { "Welsh", (ssize_t) WelshFilter, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedFilter, MagickFalse }
   },
   FunctionOptions[] =
   {
-    { "Undefined", (long) UndefinedFunction, MagickTrue },
-    { "Polynomial", (long) PolynomialFunction, MagickFalse },
-    { "Sinusoid", (long) SinusoidFunction, MagickFalse },
-    { "ArcSin", (long) ArcsinFunction, MagickFalse },
-    { "ArcTan", (long) ArctanFunction, MagickFalse },
-    { (char *) NULL, (long) UndefinedFunction, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedFunction, MagickTrue },
+    { "Polynomial", (ssize_t) PolynomialFunction, MagickFalse },
+    { "Sinusoid", (ssize_t) SinusoidFunction, MagickFalse },
+    { "ArcSin", (ssize_t) ArcsinFunction, MagickFalse },
+    { "ArcTan", (ssize_t) ArctanFunction, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedFunction, MagickFalse }
   },
   GravityOptions[] =
   {
-    { "Undefined", (long) UndefinedGravity, MagickTrue },
-    { "None", (long) UndefinedGravity, MagickFalse },
-    { "Center", (long) CenterGravity, MagickFalse },
-    { "East", (long) EastGravity, MagickFalse },
-    { "Forget", (long) ForgetGravity, MagickFalse },
-    { "NorthEast", (long) NorthEastGravity, MagickFalse },
-    { "North", (long) NorthGravity, MagickFalse },
-    { "NorthWest", (long) NorthWestGravity, MagickFalse },
-    { "SouthEast", (long) SouthEastGravity, MagickFalse },
-    { "South", (long) SouthGravity, MagickFalse },
-    { "SouthWest", (long) SouthWestGravity, MagickFalse },
-    { "West", (long) WestGravity, MagickFalse },
-    { "Static", (long) StaticGravity, MagickFalse },
+    { "Undefined", (ssize_t) UndefinedGravity, MagickTrue },
+    { "None", (ssize_t) UndefinedGravity, MagickFalse },
+    { "Center", (ssize_t) CenterGravity, MagickFalse },
+    { "East", (ssize_t) EastGravity, MagickFalse },
+    { "Forget", (ssize_t) ForgetGravity, MagickFalse },
+    { "NorthEast", (ssize_t) NorthEastGravity, MagickFalse },
+    { "North", (ssize_t) NorthGravity, MagickFalse },
+    { "NorthWest", (ssize_t) NorthWestGravity, MagickFalse },
+    { "SouthEast", (ssize_t) SouthEastGravity, MagickFalse },
+    { "South", (ssize_t) SouthGravity, MagickFalse },
+    { "SouthWest", (ssize_t) SouthWestGravity, MagickFalse },
+    { "West", (ssize_t) WestGravity, MagickFalse },
+    { "Static", (ssize_t) StaticGravity, MagickFalse },
     { (char *) NULL, UndefinedGravity, MagickFalse }
   },
   ImageListOptions[] =
@@ -1018,490 +1018,490 @@
   },
   IntentOptions[] =
   {
-    { "Undefined", (long) UndefinedIntent, MagickTrue },
-    { "Absolute", (long) AbsoluteIntent, MagickFalse },
-    { "Perceptual", (long) PerceptualIntent, MagickFalse },
-    { "Relative", (long) RelativeIntent, MagickFalse },
-    { "Saturation", (long) SaturationIntent, MagickFalse },
-    { (char *) NULL, (long) UndefinedIntent, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedIntent, MagickTrue },
+    { "Absolute", (ssize_t) AbsoluteIntent, MagickFalse },
+    { "Perceptual", (ssize_t) PerceptualIntent, MagickFalse },
+    { "Relative", (ssize_t) RelativeIntent, MagickFalse },
+    { "Saturation", (ssize_t) SaturationIntent, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedIntent, MagickFalse }
   },
   InterlaceOptions[] =
   {
-    { "Undefined", (long) UndefinedInterlace, MagickTrue },
-    { "Line", (long) LineInterlace, MagickFalse },
-    { "None", (long) NoInterlace, MagickFalse },
-    { "Plane", (long) PlaneInterlace, MagickFalse },
-    { "Partition", (long) PartitionInterlace, MagickFalse },
-    { "GIF", (long) GIFInterlace, MagickFalse },
-    { "JPEG", (long) JPEGInterlace, MagickFalse },
-    { "PNG", (long) PNGInterlace, MagickFalse },
-    { (char *) NULL, (long) UndefinedInterlace, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedInterlace, MagickTrue },
+    { "Line", (ssize_t) LineInterlace, MagickFalse },
+    { "None", (ssize_t) NoInterlace, MagickFalse },
+    { "Plane", (ssize_t) PlaneInterlace, MagickFalse },
+    { "Partition", (ssize_t) PartitionInterlace, MagickFalse },
+    { "GIF", (ssize_t) GIFInterlace, MagickFalse },
+    { "JPEG", (ssize_t) JPEGInterlace, MagickFalse },
+    { "PNG", (ssize_t) PNGInterlace, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedInterlace, MagickFalse }
   },
   InterpolateOptions[] =
   {
-    { "Undefined", (long) UndefinedInterpolatePixel, MagickTrue },
-    { "Average", (long) AverageInterpolatePixel, MagickFalse },
-    { "Bicubic", (long) BicubicInterpolatePixel, MagickFalse },
-    { "Bilinear", (long) BilinearInterpolatePixel, MagickFalse },
-    { "filter", (long) FilterInterpolatePixel, MagickFalse },
-    { "Integer", (long) IntegerInterpolatePixel, MagickFalse },
-    { "Mesh", (long) MeshInterpolatePixel, MagickFalse },
-    { "NearestNeighbor", (long) NearestNeighborInterpolatePixel, MagickFalse },
-    { "Spline", (long) SplineInterpolatePixel, MagickFalse },
-    { (char *) NULL, (long) UndefinedInterpolatePixel, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedInterpolatePixel, MagickTrue },
+    { "Average", (ssize_t) AverageInterpolatePixel, MagickFalse },
+    { "Bicubic", (ssize_t) BicubicInterpolatePixel, MagickFalse },
+    { "Bilinear", (ssize_t) BilinearInterpolatePixel, MagickFalse },
+    { "filter", (ssize_t) FilterInterpolatePixel, MagickFalse },
+    { "Integer", (ssize_t) IntegerInterpolatePixel, MagickFalse },
+    { "Mesh", (ssize_t) MeshInterpolatePixel, MagickFalse },
+    { "NearestNeighbor", (ssize_t) NearestNeighborInterpolatePixel, MagickFalse },
+    { "Spline", (ssize_t) SplineInterpolatePixel, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedInterpolatePixel, MagickFalse }
   },
   KernelOptions[] =
   {
-    { "Undefined", (long) UndefinedKernel, MagickTrue },
-    { "Unity", (long) UnityKernel, MagickFalse },
-    { "Gaussian", (long) GaussianKernel, MagickFalse },
-    { "DOG", (long) DOGKernel, MagickFalse },
-    { "LOG", (long) LOGKernel, MagickFalse },
-    { "Blur", (long) BlurKernel, MagickFalse },
-    { "DOB", (long) DOBKernel, MagickFalse },
-    { "Comet", (long) CometKernel, MagickFalse },
-    { "Laplacian", (long) LaplacianKernel, MagickFalse },
-    { "Sobel", (long) SobelKernel, MagickFalse },
-    { "FreiChen", (long) FreiChenKernel, MagickFalse },
-    { "Roberts", (long) RobertsKernel, MagickFalse },
-    { "Prewitt", (long) PrewittKernel, MagickFalse },
-    { "Compass", (long) CompassKernel, MagickFalse },
-    { "Kirsch", (long) KirschKernel, MagickFalse },
-    { "Rectangle", (long) RectangleKernel, MagickFalse },
-    { "Square", (long) SquareKernel, MagickFalse },
-    { "Diamond", (long) DiamondKernel, MagickFalse },
-    { "Disk", (long) DiskKernel, MagickFalse },
-    { "Plus", (long) PlusKernel, MagickFalse },
-    { "Cross", (long) CrossKernel, MagickFalse },
-    { "Ring", (long) RingKernel, MagickFalse },
-    { "Peaks", (long) PeaksKernel, MagickFalse },
-    { "Edges", (long) EdgesKernel, MagickFalse },
-    { "Corners", (long) CornersKernel, MagickFalse },
-    { "Ridges", (long) RidgesKernel, MagickFalse },
-    { "Ridges2", (long) Ridges2Kernel, MagickFalse },
-    { "LineEnds", (long) LineEndsKernel, MagickFalse },
-    { "LineJunctions", (long) LineJunctionsKernel, MagickFalse },
-    { "ConvexHull", (long) ConvexHullKernel, MagickFalse },
-    { "Skeleton", (long) SkeletonKernel, MagickFalse },
-    { "Mat", (long) MatKernel, MagickTrue },      /* experimental */
-    { "Chebyshev", (long) ChebyshevKernel, MagickFalse },
-    { "Manhatten", (long) ManhattenKernel, MagickFalse },
-    { "Euclidean", (long) EuclideanKernel, MagickFalse },
-    { "Test", (long) TestKernel, MagickTrue },    /* for experimental kernels */
-    { "User Defined", (long) UserDefinedKernel, MagickTrue }, /* internel */
-    { (char *) NULL, (long) UndefinedKernel, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedKernel, MagickTrue },
+    { "Unity", (ssize_t) UnityKernel, MagickFalse },
+    { "Gaussian", (ssize_t) GaussianKernel, MagickFalse },
+    { "DOG", (ssize_t) DOGKernel, MagickFalse },
+    { "LOG", (ssize_t) LOGKernel, MagickFalse },
+    { "Blur", (ssize_t) BlurKernel, MagickFalse },
+    { "DOB", (ssize_t) DOBKernel, MagickFalse },
+    { "Comet", (ssize_t) CometKernel, MagickFalse },
+    { "Laplacian", (ssize_t) LaplacianKernel, MagickFalse },
+    { "Sobel", (ssize_t) SobelKernel, MagickFalse },
+    { "FreiChen", (ssize_t) FreiChenKernel, MagickFalse },
+    { "Roberts", (ssize_t) RobertsKernel, MagickFalse },
+    { "Prewitt", (ssize_t) PrewittKernel, MagickFalse },
+    { "Compass", (ssize_t) CompassKernel, MagickFalse },
+    { "Kirsch", (ssize_t) KirschKernel, MagickFalse },
+    { "Rectangle", (ssize_t) RectangleKernel, MagickFalse },
+    { "Square", (ssize_t) SquareKernel, MagickFalse },
+    { "Diamond", (ssize_t) DiamondKernel, MagickFalse },
+    { "Disk", (ssize_t) DiskKernel, MagickFalse },
+    { "Plus", (ssize_t) PlusKernel, MagickFalse },
+    { "Cross", (ssize_t) CrossKernel, MagickFalse },
+    { "Ring", (ssize_t) RingKernel, MagickFalse },
+    { "Peaks", (ssize_t) PeaksKernel, MagickFalse },
+    { "Edges", (ssize_t) EdgesKernel, MagickFalse },
+    { "Corners", (ssize_t) CornersKernel, MagickFalse },
+    { "Ridges", (ssize_t) RidgesKernel, MagickFalse },
+    { "Ridges2", (ssize_t) Ridges2Kernel, MagickFalse },
+    { "LineEnds", (ssize_t) LineEndsKernel, MagickFalse },
+    { "LineJunctions", (ssize_t) LineJunctionsKernel, MagickFalse },
+    { "ConvexHull", (ssize_t) ConvexHullKernel, MagickFalse },
+    { "Skeleton", (ssize_t) SkeletonKernel, MagickFalse },
+    { "Mat", (ssize_t) MatKernel, MagickTrue },      /* experimental */
+    { "Chebyshev", (ssize_t) ChebyshevKernel, MagickFalse },
+    { "Manhatten", (ssize_t) ManhattenKernel, MagickFalse },
+    { "Euclidean", (ssize_t) EuclideanKernel, MagickFalse },
+    { "Test", (ssize_t) TestKernel, MagickTrue },    /* for experimental kernels */
+    { "User Defined", (ssize_t) UserDefinedKernel, MagickTrue }, /* internel */
+    { (char *) NULL, (ssize_t) UndefinedKernel, MagickFalse }
   },
   LayerOptions[] =
   {
-    { "Undefined", (long) UndefinedLayer, MagickTrue },
-    { "Coalesce", (long) CoalesceLayer, MagickFalse },
-    { "CompareAny", (long) CompareAnyLayer, MagickFalse },
-    { "CompareClear", (long) CompareClearLayer, MagickFalse },
-    { "CompareOverlay", (long) CompareOverlayLayer, MagickFalse },
-    { "Dispose", (long) DisposeLayer, MagickFalse },
-    { "Optimize", (long) OptimizeLayer, MagickFalse },
-    { "OptimizeFrame", (long) OptimizeImageLayer, MagickFalse },
-    { "OptimizePlus", (long) OptimizePlusLayer, MagickFalse },
-    { "OptimizeTransparency", (long) OptimizeTransLayer, MagickFalse },
-    { "RemoveDups", (long) RemoveDupsLayer, MagickFalse },
-    { "RemoveZero", (long) RemoveZeroLayer, MagickFalse },
-    { "Composite", (long) CompositeLayer, MagickFalse },
-    { "Merge", (long) MergeLayer, MagickFalse },
-    { "Flatten", (long) FlattenLayer, MagickFalse },
-    { "Mosaic", (long) MosaicLayer, MagickFalse },
-    { "TrimBounds", (long) TrimBoundsLayer, MagickFalse },
-    { (char *) NULL, (long) UndefinedLayer, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedLayer, MagickTrue },
+    { "Coalesce", (ssize_t) CoalesceLayer, MagickFalse },
+    { "CompareAny", (ssize_t) CompareAnyLayer, MagickFalse },
+    { "CompareClear", (ssize_t) CompareClearLayer, MagickFalse },
+    { "CompareOverlay", (ssize_t) CompareOverlayLayer, MagickFalse },
+    { "Dispose", (ssize_t) DisposeLayer, MagickFalse },
+    { "Optimize", (ssize_t) OptimizeLayer, MagickFalse },
+    { "OptimizeFrame", (ssize_t) OptimizeImageLayer, MagickFalse },
+    { "OptimizePlus", (ssize_t) OptimizePlusLayer, MagickFalse },
+    { "OptimizeTransparency", (ssize_t) OptimizeTransLayer, MagickFalse },
+    { "RemoveDups", (ssize_t) RemoveDupsLayer, MagickFalse },
+    { "RemoveZero", (ssize_t) RemoveZeroLayer, MagickFalse },
+    { "Composite", (ssize_t) CompositeLayer, MagickFalse },
+    { "Merge", (ssize_t) MergeLayer, MagickFalse },
+    { "Flatten", (ssize_t) FlattenLayer, MagickFalse },
+    { "Mosaic", (ssize_t) MosaicLayer, MagickFalse },
+    { "TrimBounds", (ssize_t) TrimBoundsLayer, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedLayer, MagickFalse }
   },
   LineCapOptions[] =
   {
-    { "Undefined", (long) UndefinedCap, MagickTrue },
-    { "Butt", (long) ButtCap, MagickFalse },
-    { "Round", (long) RoundCap, MagickFalse },
-    { "Square", (long) SquareCap, MagickFalse },
-    { (char *) NULL, (long) UndefinedCap, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedCap, MagickTrue },
+    { "Butt", (ssize_t) ButtCap, MagickFalse },
+    { "Round", (ssize_t) RoundCap, MagickFalse },
+    { "Square", (ssize_t) SquareCap, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedCap, MagickFalse }
   },
   LineJoinOptions[] =
   {
-    { "Undefined", (long) UndefinedJoin, MagickTrue },
-    { "Bevel", (long) BevelJoin, MagickFalse },
-    { "Miter", (long) MiterJoin, MagickFalse },
-    { "Round", (long) RoundJoin, MagickFalse },
-    { (char *) NULL, (long) UndefinedJoin, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedJoin, MagickTrue },
+    { "Bevel", (ssize_t) BevelJoin, MagickFalse },
+    { "Miter", (ssize_t) MiterJoin, MagickFalse },
+    { "Round", (ssize_t) RoundJoin, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedJoin, MagickFalse }
   },
   ListOptions[] =
   {
-    { "Align", (long) MagickAlignOptions, MagickFalse },
-    { "Alpha", (long) MagickAlphaOptions, MagickFalse },
-    { "Boolean", (long) MagickBooleanOptions, MagickFalse },
-    { "Channel", (long) MagickChannelOptions, MagickFalse },
-    { "Class", (long) MagickClassOptions, MagickFalse },
-    { "ClipPath", (long) MagickClipPathOptions, MagickFalse },
-    { "Coder", (long) MagickCoderOptions, MagickFalse },
-    { "Color", (long) MagickColorOptions, MagickFalse },
-    { "Colorspace", (long) MagickColorspaceOptions, MagickFalse },
-    { "Command", (long) MagickCommandOptions, MagickFalse },
-    { "Compose", (long) MagickComposeOptions, MagickFalse },
-    { "Compress", (long) MagickCompressOptions, MagickFalse },
-    { "Configure", (long) MagickConfigureOptions, MagickFalse },
-    { "DataType", (long) MagickDataTypeOptions, MagickFalse },
-    { "Debug", (long) MagickDebugOptions, MagickFalse },
-    { "Decoration", (long) MagickDecorateOptions, MagickFalse },
-    { "Delegate", (long) MagickDelegateOptions, MagickFalse },
-    { "Direction", (long) MagickDirectionOptions, MagickFalse },
-    { "Dispose", (long) MagickDisposeOptions, MagickFalse },
-    { "Distort", (long) MagickDistortOptions, MagickFalse },
-    { "Dither", (long) MagickDitherOptions, MagickFalse },
-    { "Endian", (long) MagickEndianOptions, MagickFalse },
-    { "Evaluate", (long) MagickEvaluateOptions, MagickFalse },
-    { "FillRule", (long) MagickFillRuleOptions, MagickFalse },
-    { "Filter", (long) MagickFilterOptions, MagickFalse },
-    { "Font", (long) MagickFontOptions, MagickFalse },
-    { "Format", (long) MagickFormatOptions, MagickFalse },
-    { "Function", (long) MagickFunctionOptions, MagickFalse },
-    { "Gravity", (long) MagickGravityOptions, MagickFalse },
-    { "ImageList", (long) MagickImageListOptions, MagickFalse },
-    { "Intent", (long) MagickIntentOptions, MagickFalse },
-    { "Interlace", (long) MagickInterlaceOptions, MagickFalse },
-    { "Interpolate", (long) MagickInterpolateOptions, MagickFalse },
-    { "Kernel", (long) MagickKernelOptions, MagickFalse },
-    { "Layers", (long) MagickLayerOptions, MagickFalse },
-    { "LineCap", (long) MagickLineCapOptions, MagickFalse },
-    { "LineJoin", (long) MagickLineJoinOptions, MagickFalse },
-    { "List", (long) MagickListOptions, MagickFalse },
-    { "Locale", (long) MagickLocaleOptions, MagickFalse },
-    { "LogEvent", (long) MagickLogEventOptions, MagickFalse },
-    { "Log", (long) MagickLogOptions, MagickFalse },
-    { "Magic", (long) MagickMagicOptions, MagickFalse },
-    { "Method", (long) MagickMethodOptions, MagickFalse },
-    { "Metric", (long) MagickMetricOptions, MagickFalse },
-    { "Mime", (long) MagickMimeOptions, MagickFalse },
-    { "Mode", (long) MagickModeOptions, MagickFalse },
-    { "Morphology", (long) MagickMorphologyOptions, MagickFalse },
-    { "Module", (long) MagickModuleOptions, MagickFalse },
-    { "Noise", (long) MagickNoiseOptions, MagickFalse },
-    { "Orientation", (long) MagickOrientationOptions, MagickFalse },
-    { "Policy", (long) MagickPolicyOptions, MagickFalse },
-    { "PolicyDomain", (long) MagickPolicyDomainOptions, MagickFalse },
-    { "PolicyRights", (long) MagickPolicyRightsOptions, MagickFalse },
-    { "Preview", (long) MagickPreviewOptions, MagickFalse },
-    { "Primitive", (long) MagickPrimitiveOptions, MagickFalse },
-    { "QuantumFormat", (long) MagickQuantumFormatOptions, MagickFalse },
-    { "Resource", (long) MagickResourceOptions, MagickFalse },
-    { "SparseColor", (long) MagickSparseColorOptions, MagickFalse },
-    { "Storage", (long) MagickStorageOptions, MagickFalse },
-    { "Stretch", (long) MagickStretchOptions, MagickFalse },
-    { "Style", (long) MagickStyleOptions, MagickFalse },
-    { "Threshold", (long) MagickThresholdOptions, MagickFalse },
-    { "Type", (long) MagickTypeOptions, MagickFalse },
-    { "Units", (long) MagickResolutionOptions, MagickFalse },
-    { "Undefined", (long) MagickUndefinedOptions, MagickTrue },
-    { "Validate", (long) MagickValidateOptions, MagickFalse },
-    { "VirtualPixel", (long) MagickVirtualPixelOptions, MagickFalse },
-    { (char *) NULL, (long) MagickUndefinedOptions, MagickFalse }
+    { "Align", (ssize_t) MagickAlignOptions, MagickFalse },
+    { "Alpha", (ssize_t) MagickAlphaOptions, MagickFalse },
+    { "Boolean", (ssize_t) MagickBooleanOptions, MagickFalse },
+    { "Channel", (ssize_t) MagickChannelOptions, MagickFalse },
+    { "Class", (ssize_t) MagickClassOptions, MagickFalse },
+    { "ClipPath", (ssize_t) MagickClipPathOptions, MagickFalse },
+    { "Coder", (ssize_t) MagickCoderOptions, MagickFalse },
+    { "Color", (ssize_t) MagickColorOptions, MagickFalse },
+    { "Colorspace", (ssize_t) MagickColorspaceOptions, MagickFalse },
+    { "Command", (ssize_t) MagickCommandOptions, MagickFalse },
+    { "Compose", (ssize_t) MagickComposeOptions, MagickFalse },
+    { "Compress", (ssize_t) MagickCompressOptions, MagickFalse },
+    { "Configure", (ssize_t) MagickConfigureOptions, MagickFalse },
+    { "DataType", (ssize_t) MagickDataTypeOptions, MagickFalse },
+    { "Debug", (ssize_t) MagickDebugOptions, MagickFalse },
+    { "Decoration", (ssize_t) MagickDecorateOptions, MagickFalse },
+    { "Delegate", (ssize_t) MagickDelegateOptions, MagickFalse },
+    { "Direction", (ssize_t) MagickDirectionOptions, MagickFalse },
+    { "Dispose", (ssize_t) MagickDisposeOptions, MagickFalse },
+    { "Distort", (ssize_t) MagickDistortOptions, MagickFalse },
+    { "Dither", (ssize_t) MagickDitherOptions, MagickFalse },
+    { "Endian", (ssize_t) MagickEndianOptions, MagickFalse },
+    { "Evaluate", (ssize_t) MagickEvaluateOptions, MagickFalse },
+    { "FillRule", (ssize_t) MagickFillRuleOptions, MagickFalse },
+    { "Filter", (ssize_t) MagickFilterOptions, MagickFalse },
+    { "Font", (ssize_t) MagickFontOptions, MagickFalse },
+    { "Format", (ssize_t) MagickFormatOptions, MagickFalse },
+    { "Function", (ssize_t) MagickFunctionOptions, MagickFalse },
+    { "Gravity", (ssize_t) MagickGravityOptions, MagickFalse },
+    { "ImageList", (ssize_t) MagickImageListOptions, MagickFalse },
+    { "Intent", (ssize_t) MagickIntentOptions, MagickFalse },
+    { "Interlace", (ssize_t) MagickInterlaceOptions, MagickFalse },
+    { "Interpolate", (ssize_t) MagickInterpolateOptions, MagickFalse },
+    { "Kernel", (ssize_t) MagickKernelOptions, MagickFalse },
+    { "Layers", (ssize_t) MagickLayerOptions, MagickFalse },
+    { "LineCap", (ssize_t) MagickLineCapOptions, MagickFalse },
+    { "LineJoin", (ssize_t) MagickLineJoinOptions, MagickFalse },
+    { "List", (ssize_t) MagickListOptions, MagickFalse },
+    { "Locale", (ssize_t) MagickLocaleOptions, MagickFalse },
+    { "LogEvent", (ssize_t) MagickLogEventOptions, MagickFalse },
+    { "Log", (ssize_t) MagickLogOptions, MagickFalse },
+    { "Magic", (ssize_t) MagickMagicOptions, MagickFalse },
+    { "Method", (ssize_t) MagickMethodOptions, MagickFalse },
+    { "Metric", (ssize_t) MagickMetricOptions, MagickFalse },
+    { "Mime", (ssize_t) MagickMimeOptions, MagickFalse },
+    { "Mode", (ssize_t) MagickModeOptions, MagickFalse },
+    { "Morphology", (ssize_t) MagickMorphologyOptions, MagickFalse },
+    { "Module", (ssize_t) MagickModuleOptions, MagickFalse },
+    { "Noise", (ssize_t) MagickNoiseOptions, MagickFalse },
+    { "Orientation", (ssize_t) MagickOrientationOptions, MagickFalse },
+    { "Policy", (ssize_t) MagickPolicyOptions, MagickFalse },
+    { "PolicyDomain", (ssize_t) MagickPolicyDomainOptions, MagickFalse },
+    { "PolicyRights", (ssize_t) MagickPolicyRightsOptions, MagickFalse },
+    { "Preview", (ssize_t) MagickPreviewOptions, MagickFalse },
+    { "Primitive", (ssize_t) MagickPrimitiveOptions, MagickFalse },
+    { "QuantumFormat", (ssize_t) MagickQuantumFormatOptions, MagickFalse },
+    { "Resource", (ssize_t) MagickResourceOptions, MagickFalse },
+    { "SparseColor", (ssize_t) MagickSparseColorOptions, MagickFalse },
+    { "Storage", (ssize_t) MagickStorageOptions, MagickFalse },
+    { "Stretch", (ssize_t) MagickStretchOptions, MagickFalse },
+    { "Style", (ssize_t) MagickStyleOptions, MagickFalse },
+    { "Threshold", (ssize_t) MagickThresholdOptions, MagickFalse },
+    { "Type", (ssize_t) MagickTypeOptions, MagickFalse },
+    { "Units", (ssize_t) MagickResolutionOptions, MagickFalse },
+    { "Undefined", (ssize_t) MagickUndefinedOptions, MagickTrue },
+    { "Validate", (ssize_t) MagickValidateOptions, MagickFalse },
+    { "VirtualPixel", (ssize_t) MagickVirtualPixelOptions, MagickFalse },
+    { (char *) NULL, (ssize_t) MagickUndefinedOptions, MagickFalse }
   },
   LogEventOptions[] =
   {
-    { "Undefined", (long) UndefinedEvents, MagickTrue },
-    { "All", (long) (AllEvents &~ TraceEvent), MagickFalse },
-    { "Annotate", (long) AnnotateEvent, MagickFalse },
-    { "Blob", (long) BlobEvent, MagickFalse },
-    { "Cache", (long) CacheEvent, MagickFalse },
-    { "Coder", (long) CoderEvent, MagickFalse },
-    { "Configure", (long) ConfigureEvent, MagickFalse },
-    { "Deprecate", (long) DeprecateEvent, MagickFalse },
-    { "Draw", (long) DrawEvent, MagickFalse },
-    { "Exception", (long) ExceptionEvent, MagickFalse },
-    { "Locale", (long) LocaleEvent, MagickFalse },
-    { "Module", (long) ModuleEvent, MagickFalse },
-    { "None", (long) NoEvents, MagickFalse },
-    { "Policy", (long) PolicyEvent, MagickFalse },
-    { "Resource", (long) ResourceEvent, MagickFalse },
-    { "Trace", (long) TraceEvent, MagickFalse },
-    { "Transform", (long) TransformEvent, MagickFalse },
-    { "User", (long) UserEvent, MagickFalse },
-    { "Wand", (long) WandEvent, MagickFalse },
-    { "X11", (long) X11Event, MagickFalse },
-    { (char *) NULL, (long) UndefinedEvents, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedEvents, MagickTrue },
+    { "All", (ssize_t) (AllEvents &~ TraceEvent), MagickFalse },
+    { "Annotate", (ssize_t) AnnotateEvent, MagickFalse },
+    { "Blob", (ssize_t) BlobEvent, MagickFalse },
+    { "Cache", (ssize_t) CacheEvent, MagickFalse },
+    { "Coder", (ssize_t) CoderEvent, MagickFalse },
+    { "Configure", (ssize_t) ConfigureEvent, MagickFalse },
+    { "Deprecate", (ssize_t) DeprecateEvent, MagickFalse },
+    { "Draw", (ssize_t) DrawEvent, MagickFalse },
+    { "Exception", (ssize_t) ExceptionEvent, MagickFalse },
+    { "Locale", (ssize_t) LocaleEvent, MagickFalse },
+    { "Module", (ssize_t) ModuleEvent, MagickFalse },
+    { "None", (ssize_t) NoEvents, MagickFalse },
+    { "Policy", (ssize_t) PolicyEvent, MagickFalse },
+    { "Resource", (ssize_t) ResourceEvent, MagickFalse },
+    { "Trace", (ssize_t) TraceEvent, MagickFalse },
+    { "Transform", (ssize_t) TransformEvent, MagickFalse },
+    { "User", (ssize_t) UserEvent, MagickFalse },
+    { "Wand", (ssize_t) WandEvent, MagickFalse },
+    { "X11", (ssize_t) X11Event, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedEvents, MagickFalse }
   },
   MetricOptions[] =
   {
-    { "Undefined", (long) UndefinedMetric, MagickTrue },
-    { "AE", (long) AbsoluteErrorMetric, MagickFalse },
-    { "MAE", (long) MeanAbsoluteErrorMetric, MagickFalse },
-    { "MEPP", (long) MeanErrorPerPixelMetric, MagickFalse },
-    { "MSE", (long) MeanSquaredErrorMetric, MagickFalse },
-    { "PAE", (long) PeakAbsoluteErrorMetric, MagickFalse },
-    { "PSNR", (long) PeakSignalToNoiseRatioMetric, MagickFalse },
-    { "RMSE", (long) RootMeanSquaredErrorMetric, MagickFalse },
-    { (char *) NULL, (long) UndefinedMetric, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedMetric, MagickTrue },
+    { "AE", (ssize_t) AbsoluteErrorMetric, MagickFalse },
+    { "MAE", (ssize_t) MeanAbsoluteErrorMetric, MagickFalse },
+    { "MEPP", (ssize_t) MeanErrorPerPixelMetric, MagickFalse },
+    { "MSE", (ssize_t) MeanSquaredErrorMetric, MagickFalse },
+    { "PAE", (ssize_t) PeakAbsoluteErrorMetric, MagickFalse },
+    { "PSNR", (ssize_t) PeakSignalToNoiseRatioMetric, MagickFalse },
+    { "RMSE", (ssize_t) RootMeanSquaredErrorMetric, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedMetric, MagickFalse }
   },
   MethodOptions[] =
   {
-    { "Undefined", (long) UndefinedMethod, MagickTrue },
-    { "FillToBorder", (long) FillToBorderMethod, MagickFalse },
-    { "Floodfill", (long) FloodfillMethod, MagickFalse },
-    { "Point", (long) PointMethod, MagickFalse },
-    { "Replace", (long) ReplaceMethod, MagickFalse },
-    { "Reset", (long) ResetMethod, MagickFalse },
-    { (char *) NULL, (long) UndefinedMethod, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedMethod, MagickTrue },
+    { "FillToBorder", (ssize_t) FillToBorderMethod, MagickFalse },
+    { "Floodfill", (ssize_t) FloodfillMethod, MagickFalse },
+    { "Point", (ssize_t) PointMethod, MagickFalse },
+    { "Replace", (ssize_t) ReplaceMethod, MagickFalse },
+    { "Reset", (ssize_t) ResetMethod, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedMethod, MagickFalse }
   },
   ModeOptions[] =
   {
-    { "Undefined", (long) UndefinedMode, MagickTrue },
-    { "Concatenate", (long) ConcatenateMode, MagickFalse },
-    { "Frame", (long) FrameMode, MagickFalse },
-    { "Unframe", (long) UnframeMode, MagickFalse },
-    { (char *) NULL, (long) UndefinedMode, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedMode, MagickTrue },
+    { "Concatenate", (ssize_t) ConcatenateMode, MagickFalse },
+    { "Frame", (ssize_t) FrameMode, MagickFalse },
+    { "Unframe", (ssize_t) UnframeMode, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedMode, MagickFalse }
   },
   MorphologyOptions[] =
   {
-    { "Undefined", (long) UndefinedMorphology, MagickTrue },
-    { "Correlate", (long) CorrelateMorphology, MagickFalse },
-    { "Convolve", (long) ConvolveMorphology, MagickFalse },
-    { "Dilate", (long) DilateMorphology, MagickFalse },
-    { "Erode", (long) ErodeMorphology, MagickFalse },
-    { "Close", (long) CloseMorphology, MagickFalse },
-    { "Open", (long) OpenMorphology, MagickFalse },
-    { "DilateIntensity", (long) DilateIntensityMorphology, MagickFalse },
-    { "ErodeIntensity", (long) ErodeIntensityMorphology, MagickFalse },
-    { "CloseIntensity", (long) CloseIntensityMorphology, MagickFalse },
-    { "OpenIntensity", (long) OpenIntensityMorphology, MagickFalse },
-    { "DilateI", (long) DilateIntensityMorphology, MagickFalse },
-    { "ErodeI", (long) ErodeIntensityMorphology, MagickFalse },
-    { "CloseI", (long) CloseIntensityMorphology, MagickFalse },
-    { "OpenI", (long) OpenIntensityMorphology, MagickFalse },
-    { "Smooth", (long) SmoothMorphology, MagickFalse },
-    { "EdgeOut", (long) EdgeOutMorphology, MagickFalse },
-    { "EdgeIn", (long) EdgeInMorphology, MagickFalse },
-    { "Edge", (long) EdgeMorphology, MagickFalse },
-    { "TopHat", (long) TopHatMorphology, MagickFalse },
-    { "BottomHat", (long) BottomHatMorphology, MagickFalse },
-    { "Distance", (long) DistanceMorphology, MagickFalse },
-    { "HitAndMiss", (long) HitAndMissMorphology, MagickFalse },
-    { "Thinning", (long) ThinningMorphology, MagickFalse },
-    { "Thicken", (long) ThickenMorphology, MagickFalse },
-    { (char *) NULL, (long) UndefinedMorphology, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedMorphology, MagickTrue },
+    { "Correlate", (ssize_t) CorrelateMorphology, MagickFalse },
+    { "Convolve", (ssize_t) ConvolveMorphology, MagickFalse },
+    { "Dilate", (ssize_t) DilateMorphology, MagickFalse },
+    { "Erode", (ssize_t) ErodeMorphology, MagickFalse },
+    { "Close", (ssize_t) CloseMorphology, MagickFalse },
+    { "Open", (ssize_t) OpenMorphology, MagickFalse },
+    { "DilateIntensity", (ssize_t) DilateIntensityMorphology, MagickFalse },
+    { "ErodeIntensity", (ssize_t) ErodeIntensityMorphology, MagickFalse },
+    { "CloseIntensity", (ssize_t) CloseIntensityMorphology, MagickFalse },
+    { "OpenIntensity", (ssize_t) OpenIntensityMorphology, MagickFalse },
+    { "DilateI", (ssize_t) DilateIntensityMorphology, MagickFalse },
+    { "ErodeI", (ssize_t) ErodeIntensityMorphology, MagickFalse },
+    { "CloseI", (ssize_t) CloseIntensityMorphology, MagickFalse },
+    { "OpenI", (ssize_t) OpenIntensityMorphology, MagickFalse },
+    { "Smooth", (ssize_t) SmoothMorphology, MagickFalse },
+    { "EdgeOut", (ssize_t) EdgeOutMorphology, MagickFalse },
+    { "EdgeIn", (ssize_t) EdgeInMorphology, MagickFalse },
+    { "Edge", (ssize_t) EdgeMorphology, MagickFalse },
+    { "TopHat", (ssize_t) TopHatMorphology, MagickFalse },
+    { "BottomHat", (ssize_t) BottomHatMorphology, MagickFalse },
+    { "Distance", (ssize_t) DistanceMorphology, MagickFalse },
+    { "HitAndMiss", (ssize_t) HitAndMissMorphology, MagickFalse },
+    { "Thinning", (ssize_t) ThinningMorphology, MagickFalse },
+    { "Thicken", (ssize_t) ThickenMorphology, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedMorphology, MagickFalse }
   },
   NoiseOptions[] =
   {
-    { "Undefined", (long) UndefinedNoise, MagickTrue },
-    { "Gaussian", (long) (long) GaussianNoise, MagickFalse },
-    { "Impulse", (long) ImpulseNoise, MagickFalse },
-    { "Laplacian", (long) LaplacianNoise, MagickFalse },
-    { "Multiplicative", (long) MultiplicativeGaussianNoise, MagickFalse },
-    { "Poisson", (long) PoissonNoise, MagickFalse },
-    { "Random", (long) RandomNoise, MagickFalse },
-    { "Uniform", (long) UniformNoise, MagickFalse },
-    { (char *) NULL, (long) UndefinedNoise, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedNoise, MagickTrue },
+    { "Gaussian", (ssize_t) (ssize_t) GaussianNoise, MagickFalse },
+    { "Impulse", (ssize_t) ImpulseNoise, MagickFalse },
+    { "Laplacian", (ssize_t) LaplacianNoise, MagickFalse },
+    { "Multiplicative", (ssize_t) MultiplicativeGaussianNoise, MagickFalse },
+    { "Poisson", (ssize_t) PoissonNoise, MagickFalse },
+    { "Random", (ssize_t) RandomNoise, MagickFalse },
+    { "Uniform", (ssize_t) UniformNoise, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedNoise, MagickFalse }
   },
   OrientationOptions[] =
   {
-    { "Undefined", (long) UndefinedOrientation, MagickTrue },
-    { "TopLeft", (long) TopLeftOrientation, MagickFalse },
-    { "TopRight", (long) TopRightOrientation, MagickFalse },
-    { "BottomRight", (long) BottomRightOrientation, MagickFalse },
-    { "BottomLeft", (long) BottomLeftOrientation, MagickFalse },
-    { "LeftTop", (long) LeftTopOrientation, MagickFalse },
-    { "RightTop", (long) RightTopOrientation, MagickFalse },
-    { "RightBottom", (long) RightBottomOrientation, MagickFalse },
-    { "LeftBottom", (long) LeftBottomOrientation, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedOrientation, MagickTrue },
+    { "TopLeft", (ssize_t) TopLeftOrientation, MagickFalse },
+    { "TopRight", (ssize_t) TopRightOrientation, MagickFalse },
+    { "BottomRight", (ssize_t) BottomRightOrientation, MagickFalse },
+    { "BottomLeft", (ssize_t) BottomLeftOrientation, MagickFalse },
+    { "LeftTop", (ssize_t) LeftTopOrientation, MagickFalse },
+    { "RightTop", (ssize_t) RightTopOrientation, MagickFalse },
+    { "RightBottom", (ssize_t) RightBottomOrientation, MagickFalse },
+    { "LeftBottom", (ssize_t) LeftBottomOrientation, MagickFalse }
   },
   PolicyDomainOptions[] =
   {
-    { "Undefined", (long) UndefinedPolicyDomain, MagickTrue },
-    { "Coder", (long) CoderPolicyDomain, MagickFalse },
-    { "Delegate", (long) DelegatePolicyDomain, MagickFalse },
-    { "Filter", (long) FilterPolicyDomain, MagickFalse },
-    { "Path", (long) PathPolicyDomain, MagickFalse },
-    { "Resource", (long) ResourcePolicyDomain, MagickFalse },
-    { "System", (long) SystemPolicyDomain, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPolicyDomain, MagickTrue },
+    { "Coder", (ssize_t) CoderPolicyDomain, MagickFalse },
+    { "Delegate", (ssize_t) DelegatePolicyDomain, MagickFalse },
+    { "Filter", (ssize_t) FilterPolicyDomain, MagickFalse },
+    { "Path", (ssize_t) PathPolicyDomain, MagickFalse },
+    { "Resource", (ssize_t) ResourcePolicyDomain, MagickFalse },
+    { "System", (ssize_t) SystemPolicyDomain, MagickFalse }
   },
   PolicyRightsOptions[] =
   {
-    { "Undefined", (long) UndefinedPolicyRights, MagickTrue },
-    { "None", (long) NoPolicyRights, MagickFalse },
-    { "Read", (long) ReadPolicyRights, MagickFalse },
-    { "Write", (long) WritePolicyRights, MagickFalse },
-    { "Execute", (long) ExecutePolicyRights, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPolicyRights, MagickTrue },
+    { "None", (ssize_t) NoPolicyRights, MagickFalse },
+    { "Read", (ssize_t) ReadPolicyRights, MagickFalse },
+    { "Write", (ssize_t) WritePolicyRights, MagickFalse },
+    { "Execute", (ssize_t) ExecutePolicyRights, MagickFalse }
   },
   PreviewOptions[] =
   {
-    { "Undefined", (long) UndefinedPreview, MagickTrue },
-    { "AddNoise", (long) AddNoisePreview, MagickFalse },
-    { "Blur", (long) BlurPreview, MagickFalse },
-    { "Brightness", (long) BrightnessPreview, MagickFalse },
-    { "Charcoal", (long) CharcoalDrawingPreview, MagickFalse },
-    { "Despeckle", (long) DespecklePreview, MagickFalse },
-    { "Dull", (long) DullPreview, MagickFalse },
-    { "EdgeDetect", (long) EdgeDetectPreview, MagickFalse },
-    { "Gamma", (long) GammaPreview, MagickFalse },
-    { "Grayscale", (long) GrayscalePreview, MagickFalse },
-    { "Hue", (long) HuePreview, MagickFalse },
-    { "Implode", (long) ImplodePreview, MagickFalse },
-    { "JPEG", (long) JPEGPreview, MagickFalse },
-    { "OilPaint", (long) OilPaintPreview, MagickFalse },
-    { "Quantize", (long) QuantizePreview, MagickFalse },
-    { "Raise", (long) RaisePreview, MagickFalse },
-    { "ReduceNoise", (long) ReduceNoisePreview, MagickFalse },
-    { "Roll", (long) RollPreview, MagickFalse },
-    { "Rotate", (long) RotatePreview, MagickFalse },
-    { "Saturation", (long) SaturationPreview, MagickFalse },
-    { "Segment", (long) SegmentPreview, MagickFalse },
-    { "Shade", (long) ShadePreview, MagickFalse },
-    { "Sharpen", (long) SharpenPreview, MagickFalse },
-    { "Shear", (long) ShearPreview, MagickFalse },
-    { "Solarize", (long) SolarizePreview, MagickFalse },
-    { "Spiff", (long) SpiffPreview, MagickFalse },
-    { "Spread", (long) SpreadPreview, MagickFalse },
-    { "Swirl", (long) SwirlPreview, MagickFalse },
-    { "Threshold", (long) ThresholdPreview, MagickFalse },
-    { "Wave", (long) WavePreview, MagickFalse },
-    { (char *) NULL, (long) UndefinedPreview, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPreview, MagickTrue },
+    { "AddNoise", (ssize_t) AddNoisePreview, MagickFalse },
+    { "Blur", (ssize_t) BlurPreview, MagickFalse },
+    { "Brightness", (ssize_t) BrightnessPreview, MagickFalse },
+    { "Charcoal", (ssize_t) CharcoalDrawingPreview, MagickFalse },
+    { "Despeckle", (ssize_t) DespecklePreview, MagickFalse },
+    { "Dull", (ssize_t) DullPreview, MagickFalse },
+    { "EdgeDetect", (ssize_t) EdgeDetectPreview, MagickFalse },
+    { "Gamma", (ssize_t) GammaPreview, MagickFalse },
+    { "Grayscale", (ssize_t) GrayscalePreview, MagickFalse },
+    { "Hue", (ssize_t) HuePreview, MagickFalse },
+    { "Implode", (ssize_t) ImplodePreview, MagickFalse },
+    { "JPEG", (ssize_t) JPEGPreview, MagickFalse },
+    { "OilPaint", (ssize_t) OilPaintPreview, MagickFalse },
+    { "Quantize", (ssize_t) QuantizePreview, MagickFalse },
+    { "Raise", (ssize_t) RaisePreview, MagickFalse },
+    { "ReduceNoise", (ssize_t) ReduceNoisePreview, MagickFalse },
+    { "Roll", (ssize_t) RollPreview, MagickFalse },
+    { "Rotate", (ssize_t) RotatePreview, MagickFalse },
+    { "Saturation", (ssize_t) SaturationPreview, MagickFalse },
+    { "Segment", (ssize_t) SegmentPreview, MagickFalse },
+    { "Shade", (ssize_t) ShadePreview, MagickFalse },
+    { "Sharpen", (ssize_t) SharpenPreview, MagickFalse },
+    { "Shear", (ssize_t) ShearPreview, MagickFalse },
+    { "Solarize", (ssize_t) SolarizePreview, MagickFalse },
+    { "Spiff", (ssize_t) SpiffPreview, MagickFalse },
+    { "Spread", (ssize_t) SpreadPreview, MagickFalse },
+    { "Swirl", (ssize_t) SwirlPreview, MagickFalse },
+    { "Threshold", (ssize_t) ThresholdPreview, MagickFalse },
+    { "Wave", (ssize_t) WavePreview, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedPreview, MagickFalse }
   },
   PrimitiveOptions[] =
   {
-    { "Undefined", (long) UndefinedPrimitive, MagickTrue },
-    { "Arc", (long) ArcPrimitive, MagickFalse },
-    { "Bezier", (long) BezierPrimitive, MagickFalse },
-    { "Circle", (long) CirclePrimitive, MagickFalse },
-    { "Color", (long) ColorPrimitive, MagickFalse },
-    { "Ellipse", (long) EllipsePrimitive, MagickFalse },
-    { "Image", (long) ImagePrimitive, MagickFalse },
-    { "Line", (long) LinePrimitive, MagickFalse },
-    { "Matte", (long) MattePrimitive, MagickFalse },
-    { "Path", (long) PathPrimitive, MagickFalse },
-    { "Point", (long) PointPrimitive, MagickFalse },
-    { "Polygon", (long) PolygonPrimitive, MagickFalse },
-    { "Polyline", (long) PolylinePrimitive, MagickFalse },
-    { "Rectangle", (long) RectanglePrimitive, MagickFalse },
-    { "roundRectangle", (long) RoundRectanglePrimitive, MagickFalse },
-    { "Text", (long) TextPrimitive, MagickFalse },
-    { (char *) NULL, (long) UndefinedPrimitive, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPrimitive, MagickTrue },
+    { "Arc", (ssize_t) ArcPrimitive, MagickFalse },
+    { "Bezier", (ssize_t) BezierPrimitive, MagickFalse },
+    { "Circle", (ssize_t) CirclePrimitive, MagickFalse },
+    { "Color", (ssize_t) ColorPrimitive, MagickFalse },
+    { "Ellipse", (ssize_t) EllipsePrimitive, MagickFalse },
+    { "Image", (ssize_t) ImagePrimitive, MagickFalse },
+    { "Line", (ssize_t) LinePrimitive, MagickFalse },
+    { "Matte", (ssize_t) MattePrimitive, MagickFalse },
+    { "Path", (ssize_t) PathPrimitive, MagickFalse },
+    { "Point", (ssize_t) PointPrimitive, MagickFalse },
+    { "Polygon", (ssize_t) PolygonPrimitive, MagickFalse },
+    { "Polyline", (ssize_t) PolylinePrimitive, MagickFalse },
+    { "Rectangle", (ssize_t) RectanglePrimitive, MagickFalse },
+    { "roundRectangle", (ssize_t) RoundRectanglePrimitive, MagickFalse },
+    { "Text", (ssize_t) TextPrimitive, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedPrimitive, MagickFalse }
   },
   QuantumFormatOptions[] =
   {
-    { "Undefined", (long) UndefinedQuantumFormat, MagickTrue },
-    { "FloatingPoint", (long) FloatingPointQuantumFormat, MagickFalse },
-    { "Signed", (long) SignedQuantumFormat, MagickFalse },
-    { "Unsigned", (long) UnsignedQuantumFormat, MagickFalse },
-    { (char *) NULL, (long) FloatingPointQuantumFormat, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedQuantumFormat, MagickTrue },
+    { "FloatingPoint", (ssize_t) FloatingPointQuantumFormat, MagickFalse },
+    { "Signed", (ssize_t) SignedQuantumFormat, MagickFalse },
+    { "Unsigned", (ssize_t) UnsignedQuantumFormat, MagickFalse },
+    { (char *) NULL, (ssize_t) FloatingPointQuantumFormat, MagickFalse }
   },
   ResolutionOptions[] =
   {
-    { "Undefined", (long) UndefinedResolution, MagickTrue },
-    { "PixelsPerInch", (long) PixelsPerInchResolution, MagickFalse },
-    { "PixelsPerCentimeter", (long) PixelsPerCentimeterResolution, MagickFalse },
-    { (char *) NULL, (long) UndefinedResolution, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedResolution, MagickTrue },
+    { "PixelsPerInch", (ssize_t) PixelsPerInchResolution, MagickFalse },
+    { "PixelsPerCentimeter", (ssize_t) PixelsPerCentimeterResolution, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedResolution, MagickFalse }
   },
   ResourceOptions[] =
   {
-    { "Undefined", (long) UndefinedResource, MagickTrue },
-    { "Area", (long) AreaResource, MagickFalse },
-    { "Disk", (long) DiskResource, MagickFalse },
-    { "File", (long) FileResource, MagickFalse },
-    { "Map", (long) MapResource, MagickFalse },
-    { "Memory", (long) MemoryResource, MagickFalse },
-    { "Thread", (long) ThreadResource, MagickFalse },
-    { "Time", (long) TimeResource, MagickFalse },
-    { (char *) NULL, (long) UndefinedResource, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedResource, MagickTrue },
+    { "Area", (ssize_t) AreaResource, MagickFalse },
+    { "Disk", (ssize_t) DiskResource, MagickFalse },
+    { "File", (ssize_t) FileResource, MagickFalse },
+    { "Map", (ssize_t) MapResource, MagickFalse },
+    { "Memory", (ssize_t) MemoryResource, MagickFalse },
+    { "Thread", (ssize_t) ThreadResource, MagickFalse },
+    { "Time", (ssize_t) TimeResource, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedResource, MagickFalse }
   },
   SparseColorOptions[] =
   {
-    { "Undefined", (long) UndefinedDistortion, MagickTrue },
-    { "Barycentric", (long) BarycentricColorInterpolate, MagickFalse },
-    { "Bilinear", (long) BilinearColorInterpolate, MagickFalse },
-    { "Shepards", (long) ShepardsColorInterpolate, MagickFalse },
-    { "Voronoi", (long) VoronoiColorInterpolate, MagickFalse },
-    { (char *) NULL, (long) UndefinedResource, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedDistortion, MagickTrue },
+    { "Barycentric", (ssize_t) BarycentricColorInterpolate, MagickFalse },
+    { "Bilinear", (ssize_t) BilinearColorInterpolate, MagickFalse },
+    { "Shepards", (ssize_t) ShepardsColorInterpolate, MagickFalse },
+    { "Voronoi", (ssize_t) VoronoiColorInterpolate, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedResource, MagickFalse }
   },
   StorageOptions[] =
   {
-    { "Undefined", (long) UndefinedPixel, MagickTrue },
-    { "Char", (long) CharPixel, MagickFalse },
-    { "Double", (long) DoublePixel, MagickFalse },
-    { "Float", (long) FloatPixel, MagickFalse },
-    { "Integer", (long) IntegerPixel, MagickFalse },
-    { "Long", (long) LongPixel, MagickFalse },
-    { "Quantum", (long) QuantumPixel, MagickFalse },
-    { "Short", (long) ShortPixel, MagickFalse },
-    { (char *) NULL, (long) UndefinedResource, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedPixel, MagickTrue },
+    { "Char", (ssize_t) CharPixel, MagickFalse },
+    { "Double", (ssize_t) DoublePixel, MagickFalse },
+    { "Float", (ssize_t) FloatPixel, MagickFalse },
+    { "Integer", (ssize_t) IntegerPixel, MagickFalse },
+    { "Long", (ssize_t) LongPixel, MagickFalse },
+    { "Quantum", (ssize_t) QuantumPixel, MagickFalse },
+    { "Short", (ssize_t) ShortPixel, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedResource, MagickFalse }
   },
   StretchOptions[] =
   {
-    { "Undefined", (long) UndefinedStretch, MagickTrue },
-    { "Any", (long) AnyStretch, MagickFalse },
-    { "Condensed", (long) CondensedStretch, MagickFalse },
-    { "Expanded", (long) ExpandedStretch, MagickFalse },
-    { "ExtraCondensed", (long) ExtraCondensedStretch, MagickFalse },
-    { "ExtraExpanded", (long) ExtraExpandedStretch, MagickFalse },
-    { "Normal", (long) NormalStretch, MagickFalse },
-    { "SemiCondensed", (long) SemiCondensedStretch, MagickFalse },
-    { "SemiExpanded", (long) SemiExpandedStretch, MagickFalse },
-    { "UltraCondensed", (long) UltraCondensedStretch, MagickFalse },
-    { "UltraExpanded", (long) UltraExpandedStretch, MagickFalse },
-    { (char *) NULL, (long) UndefinedStretch, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedStretch, MagickTrue },
+    { "Any", (ssize_t) AnyStretch, MagickFalse },
+    { "Condensed", (ssize_t) CondensedStretch, MagickFalse },
+    { "Expanded", (ssize_t) ExpandedStretch, MagickFalse },
+    { "ExtraCondensed", (ssize_t) ExtraCondensedStretch, MagickFalse },
+    { "ExtraExpanded", (ssize_t) ExtraExpandedStretch, MagickFalse },
+    { "Normal", (ssize_t) NormalStretch, MagickFalse },
+    { "SemiCondensed", (ssize_t) SemiCondensedStretch, MagickFalse },
+    { "SemiExpanded", (ssize_t) SemiExpandedStretch, MagickFalse },
+    { "UltraCondensed", (ssize_t) UltraCondensedStretch, MagickFalse },
+    { "UltraExpanded", (ssize_t) UltraExpandedStretch, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedStretch, MagickFalse }
   },
   StyleOptions[] =
   {
-    { "Undefined", (long) UndefinedStyle, MagickTrue },
-    { "Any", (long) AnyStyle, MagickFalse },
-    { "Italic", (long) ItalicStyle, MagickFalse },
-    { "Normal", (long) NormalStyle, MagickFalse },
-    { "Oblique", (long) ObliqueStyle, MagickFalse },
-    { (char *) NULL, (long) UndefinedStyle, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedStyle, MagickTrue },
+    { "Any", (ssize_t) AnyStyle, MagickFalse },
+    { "Italic", (ssize_t) ItalicStyle, MagickFalse },
+    { "Normal", (ssize_t) NormalStyle, MagickFalse },
+    { "Oblique", (ssize_t) ObliqueStyle, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedStyle, MagickFalse }
   },
   TypeOptions[] =
   {
-    { "Undefined", (long) UndefinedType, MagickTrue },
-    { "Bilevel", (long) BilevelType, MagickFalse },
-    { "ColorSeparation", (long) ColorSeparationType, MagickFalse },
-    { "ColorSeparationMatte", (long) ColorSeparationMatteType, MagickFalse },
-    { "Grayscale", (long) GrayscaleType, MagickFalse },
-    { "GrayscaleMatte", (long) GrayscaleMatteType, MagickFalse },
-    { "Optimize", (long) OptimizeType, MagickFalse },
-    { "Palette", (long) PaletteType, MagickFalse },
-    { "PaletteBilevelMatte", (long) PaletteBilevelMatteType, MagickFalse },
-    { "PaletteMatte", (long) PaletteMatteType, MagickFalse },
-    { "TrueColorMatte", (long) TrueColorMatteType, MagickFalse },
-    { "TrueColor", (long) TrueColorType, MagickFalse },
-    { (char *) NULL, (long) UndefinedType, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedType, MagickTrue },
+    { "Bilevel", (ssize_t) BilevelType, MagickFalse },
+    { "ColorSeparation", (ssize_t) ColorSeparationType, MagickFalse },
+    { "ColorSeparationMatte", (ssize_t) ColorSeparationMatteType, MagickFalse },
+    { "Grayscale", (ssize_t) GrayscaleType, MagickFalse },
+    { "GrayscaleMatte", (ssize_t) GrayscaleMatteType, MagickFalse },
+    { "Optimize", (ssize_t) OptimizeType, MagickFalse },
+    { "Palette", (ssize_t) PaletteType, MagickFalse },
+    { "PaletteBilevelMatte", (ssize_t) PaletteBilevelMatteType, MagickFalse },
+    { "PaletteMatte", (ssize_t) PaletteMatteType, MagickFalse },
+    { "TrueColorMatte", (ssize_t) TrueColorMatteType, MagickFalse },
+    { "TrueColor", (ssize_t) TrueColorType, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedType, MagickFalse }
   },
   ValidateOptions[] =
   {
-    { "Undefined", (long) UndefinedValidate, MagickTrue },
-    { "All", (long) AllValidate, MagickFalse },
-    { "Compare", (long) CompareValidate, MagickFalse },
-    { "Composite", (long) CompositeValidate, MagickFalse },
-    { "Convert", (long) ConvertValidate, MagickFalse },
-    { "FormatsInMemory", (long) FormatsInMemoryValidate, MagickFalse },
-    { "FormatsOnDisk", (long) FormatsOnDiskValidate, MagickFalse },
-    { "Identify", (long) IdentifyValidate, MagickFalse },
-    { "ImportExport", (long) ImportExportValidate, MagickFalse },
-    { "Montage", (long) MontageValidate, MagickFalse },
-    { "Stream", (long) StreamValidate, MagickFalse },
-    { "None", (long) NoValidate, MagickFalse },
-    { (char *) NULL, (long) UndefinedValidate, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedValidate, MagickTrue },
+    { "All", (ssize_t) AllValidate, MagickFalse },
+    { "Compare", (ssize_t) CompareValidate, MagickFalse },
+    { "Composite", (ssize_t) CompositeValidate, MagickFalse },
+    { "Convert", (ssize_t) ConvertValidate, MagickFalse },
+    { "FormatsInMemory", (ssize_t) FormatsInMemoryValidate, MagickFalse },
+    { "FormatsOnDisk", (ssize_t) FormatsOnDiskValidate, MagickFalse },
+    { "Identify", (ssize_t) IdentifyValidate, MagickFalse },
+    { "ImportExport", (ssize_t) ImportExportValidate, MagickFalse },
+    { "Montage", (ssize_t) MontageValidate, MagickFalse },
+    { "Stream", (ssize_t) StreamValidate, MagickFalse },
+    { "None", (ssize_t) NoValidate, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedValidate, MagickFalse }
   },
   VirtualPixelOptions[] =
   {
-    { "Undefined", (long) UndefinedVirtualPixelMethod, MagickTrue },
-    { "Background", (long) BackgroundVirtualPixelMethod, MagickFalse },
-    { "Black", (long) BlackVirtualPixelMethod, MagickFalse },
-    { "Constant", (long) BackgroundVirtualPixelMethod, MagickTrue }, /* deprecated */
-    { "CheckerTile", (long) CheckerTileVirtualPixelMethod, MagickFalse },
-    { "Dither", (long) DitherVirtualPixelMethod, MagickFalse },
-    { "Edge", (long) EdgeVirtualPixelMethod, MagickFalse },
-    { "Gray", (long) GrayVirtualPixelMethod, MagickFalse },
-    { "HorizontalTile", (long) HorizontalTileVirtualPixelMethod, MagickFalse },
-    { "HorizontalTileEdge", (long) HorizontalTileEdgeVirtualPixelMethod, MagickFalse },
-    { "Mirror", (long) MirrorVirtualPixelMethod, MagickFalse },
-    { "Random", (long) RandomVirtualPixelMethod, MagickFalse },
-    { "Tile", (long) TileVirtualPixelMethod, MagickFalse },
-    { "Transparent", (long) TransparentVirtualPixelMethod, MagickFalse },
-    { "VerticalTile", (long) VerticalTileVirtualPixelMethod, MagickFalse },
-    { "VerticalTileEdge", (long) VerticalTileEdgeVirtualPixelMethod, MagickFalse },
-    { "White", (long) WhiteVirtualPixelMethod, MagickFalse },
-    { (char *) NULL, (long) UndefinedVirtualPixelMethod, MagickFalse }
+    { "Undefined", (ssize_t) UndefinedVirtualPixelMethod, MagickTrue },
+    { "Background", (ssize_t) BackgroundVirtualPixelMethod, MagickFalse },
+    { "Black", (ssize_t) BlackVirtualPixelMethod, MagickFalse },
+    { "Constant", (ssize_t) BackgroundVirtualPixelMethod, MagickTrue }, /* deprecated */
+    { "CheckerTile", (ssize_t) CheckerTileVirtualPixelMethod, MagickFalse },
+    { "Dither", (ssize_t) DitherVirtualPixelMethod, MagickFalse },
+    { "Edge", (ssize_t) EdgeVirtualPixelMethod, MagickFalse },
+    { "Gray", (ssize_t) GrayVirtualPixelMethod, MagickFalse },
+    { "HorizontalTile", (ssize_t) HorizontalTileVirtualPixelMethod, MagickFalse },
+    { "HorizontalTileEdge", (ssize_t) HorizontalTileEdgeVirtualPixelMethod, MagickFalse },
+    { "Mirror", (ssize_t) MirrorVirtualPixelMethod, MagickFalse },
+    { "Random", (ssize_t) RandomVirtualPixelMethod, MagickFalse },
+    { "Tile", (ssize_t) TileVirtualPixelMethod, MagickFalse },
+    { "Transparent", (ssize_t) TransparentVirtualPixelMethod, MagickFalse },
+    { "VerticalTile", (ssize_t) VerticalTileVirtualPixelMethod, MagickFalse },
+    { "VerticalTileEdge", (ssize_t) VerticalTileEdgeVirtualPixelMethod, MagickFalse },
+    { "White", (ssize_t) WhiteVirtualPixelMethod, MagickFalse },
+    { (char *) NULL, (ssize_t) UndefinedVirtualPixelMethod, MagickFalse }
   };
 
 /*
@@ -1800,7 +1800,7 @@
   const OptionInfo
     *option_info;
 
-  register long
+  register ssize_t
     i;
 
   option_info=GetOptionInfo(value);
@@ -1902,7 +1902,7 @@
 %  The format of the MagickOptionToMnemonic method is:
 %
 %      const char *MagickOptionToMnemonic(const MagickOption option,
-%        const long type)
+%        const ssize_t type)
 %
 %  A description of each parameter follows:
 %
@@ -1912,12 +1912,12 @@
 %
 */
 MagickExport const char *MagickOptionToMnemonic(const MagickOption option,
-  const long type)
+  const ssize_t type)
 {
   const OptionInfo
     *option_info;
 
-  register long
+  register ssize_t
     i;
 
   option_info=GetOptionInfo(option);
@@ -1964,7 +1964,7 @@
   const OptionInfo
     *option_info;
 
-  register long
+  register ssize_t
     i;
 
   if (file == (FILE *) NULL)
@@ -1997,26 +1997,26 @@
 %
 %  The format of the ParseChannelOption method is:
 %
-%      long ParseChannelOption(const char *channels)
+%      ssize_t ParseChannelOption(const char *channels)
 %
 %  A description of each parameter follows:
 %
 %    o options: One or more values separated by commas.
 %
 */
-MagickExport long ParseChannelOption(const char *channels)
+MagickExport ssize_t ParseChannelOption(const char *channels)
 {
-  long
+  ssize_t
     channel;
 
-  register long
+  register ssize_t
     i;
 
   channel=ParseMagickOption(MagickChannelOptions,MagickTrue,channels);
   if (channel >= 0)
     return(channel);
   channel=0;
-  for (i=0; i < (long) strlen(channels); i++)
+  for (i=0; i < (ssize_t) strlen(channels); i++)
   {
     switch (channels[i])
     {
@@ -2086,7 +2086,7 @@
           More channel flags follow shorthand.  For example "RGB,sync"
           Gather the additional channel flags and merge with shorthand
         */
-        long
+        ssize_t
           more_channel;
         more_channel=ParseMagickOption(MagickChannelOptions,MagickTrue,
                              channels+i+1);
@@ -2117,7 +2117,7 @@
 %
 %  The format of the ParseMagickOption method is:
 %
-%      long ParseMagickOption(const MagickOption option,
+%      ssize_t ParseMagickOption(const MagickOption option,
 %        const MagickBooleanType list,const char *options)
 %
 %  A description of each parameter follows:
@@ -2130,7 +2130,7 @@
 %    o options: One or more options separated by commas.
 %
 */
-MagickExport long ParseMagickOption(const MagickOption option,
+MagickExport ssize_t ParseMagickOption(const MagickOption option,
   const MagickBooleanType list,const char *options)
 {
   char
@@ -2142,7 +2142,7 @@
   int
     sentinel;
 
-  long
+  ssize_t
     option_types;
 
   MagickBooleanType
@@ -2154,7 +2154,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   option_info=GetOptionInfo(option);
diff --git a/magick/option.h b/magick/option.h
index 13853f7..3ccbc90 100644
--- a/magick/option.h
+++ b/magick/option.h
@@ -115,7 +115,7 @@
   const char
     *mnemonic;
 
-  long
+  ssize_t
     type;
 
   MagickBooleanType
@@ -129,9 +129,9 @@
 
 extern MagickExport const char
   *GetImageOption(const ImageInfo *,const char *),
-  *MagickOptionToMnemonic(const MagickOption,const long);
+  *MagickOptionToMnemonic(const MagickOption,const ssize_t);
 
-extern MagickExport long
+extern MagickExport ssize_t
   ParseChannelOption(const char *),
   ParseMagickOption(const MagickOption,const MagickBooleanType,const char *);
 
diff --git a/magick/paint.c b/magick/paint.c
index a8e0f22..a687f2f 100644
--- a/magick/paint.c
+++ b/magick/paint.c
@@ -88,7 +88,7 @@
 %
 %      MagickBooleanType FloodfillPaintImage(Image *image,
 %        const ChannelType channel,const DrawInfo *draw_info,
-%        const MagickPixelPacket target,const long x_offset,const long y_offset,
+%        const MagickPixelPacket target,const ssize_t x_offset,const ssize_t y_offset,
 %        const MagickBooleanType invert)
 %
 %  A description of each parameter follows:
@@ -108,7 +108,7 @@
 */
 MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
   const ChannelType channel,const DrawInfo *draw_info,
-  const MagickPixelPacket *target,const long x_offset,const long y_offset,
+  const MagickPixelPacket *target,const ssize_t x_offset,const ssize_t y_offset,
   const MagickBooleanType invert)
 {
 #define MaxStacksize  (1UL << 15)
@@ -118,7 +118,7 @@
     ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
   else \
     { \
-      if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (long) image->rows)) \
+      if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (ssize_t) image->rows)) \
         { \
           s->x1=(double) (left); \
           s->y1=(double) (up); \
@@ -135,7 +135,7 @@
   Image
     *floodplane_image;
 
-  long
+  ssize_t
     offset,
     start,
     x,
@@ -168,9 +168,9 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(draw_info != (DrawInfo *) NULL);
   assert(draw_info->signature == MagickSignature);
-  if ((x_offset < 0) || (x_offset >= (long) image->columns))
+  if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
     return(MagickFalse);
-  if ((y_offset < 0) || (y_offset >= (long) image->rows))
+  if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
     return(MagickFalse);
   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
     return(MagickFalse);
@@ -211,7 +211,7 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -221,15 +221,15 @@
       Pop segment off stack.
     */
     s--;
-    x1=(long) s->x1;
-    x2=(long) s->x2;
-    offset=(long) s->y2;
-    y=(long) s->y1+offset;
+    x1=(ssize_t) s->x1;
+    x2=(ssize_t) s->x2;
+    offset=(ssize_t) s->y2;
+    y=(ssize_t) s->y1+offset;
     /*
       Recolor neighboring pixels.
     */
-    p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,exception);
-    q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
+    p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,exception);
+    q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
       exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
@@ -261,7 +261,7 @@
     {
       if (skip == MagickFalse)
         {
-          if (x < (long) image->columns)
+          if (x < (ssize_t) image->columns)
             {
               p=GetVirtualPixels(image,x,y,image->columns-x,1,exception);
               q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
@@ -270,7 +270,7 @@
                   (q == (PixelPacket *) NULL))
                 break;
               indexes=GetVirtualIndexQueue(image);
-              for ( ; x < (long) image->columns; x++)
+              for ( ; x < (ssize_t) image->columns; x++)
               {
                 if (q->opacity == (Quantum) TransparentOpacity)
                   break;
@@ -292,8 +292,8 @@
       x++;
       if (x <= x2)
         {
-          p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,exception);
-          q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
+          p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,exception);
+          q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
             exception);
           if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
             break;
@@ -312,7 +312,7 @@
       start=x;
     } while (x <= x2);
   }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -320,7 +320,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -334,7 +334,7 @@
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       break;
     indexes=GetAuthenticIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (p->opacity != OpaqueOpacity)
         {
@@ -362,7 +362,7 @@
   }
   segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
   floodplane_image=DestroyImage(floodplane_image);
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -376,7 +376,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GradientImage() applies a continuously smooth color transitions along a
+%  GradientImage() applies a continuously smooth color transitions assize_t a
 %  vector from one color to another.
 %
 %  Note, the interface of this method will change in the future to support
@@ -416,7 +416,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -452,7 +452,7 @@
       image->filename);
   (void) ResetMagickMemory(gradient->stops,0,gradient->number_stops*
     sizeof(*gradient->stops));
-  for (i=0; i < (long) gradient->number_stops; i++)
+  for (i=0; i < (ssize_t) gradient->number_stops; i++)
     GetMagickPixelPacket(image,&gradient->stops[i].color);
   SetMagickPixelPacket(image,start_color,(IndexPacket *) NULL,
     &gradient->stops[0].color);
@@ -504,39 +504,39 @@
 %
 */
 
-static unsigned long **DestroyHistogramThreadSet(unsigned long **histogram)
+static size_t **DestroyHistogramThreadSet(size_t **histogram)
 {
-  register long
+  register ssize_t
     i;
 
-  assert(histogram != (unsigned long **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
-    if (histogram[i] != (unsigned long *) NULL)
-      histogram[i]=(unsigned long *) RelinquishMagickMemory(histogram[i]);
-  histogram=(unsigned long **) RelinquishAlignedMemory(histogram);
+  assert(histogram != (size_t **) NULL);
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
+    if (histogram[i] != (size_t *) NULL)
+      histogram[i]=(size_t *) RelinquishMagickMemory(histogram[i]);
+  histogram=(size_t **) RelinquishAlignedMemory(histogram);
   return(histogram);
 }
 
-static unsigned long **AcquireHistogramThreadSet(const size_t count)
+static size_t **AcquireHistogramThreadSet(const size_t count)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     **histogram,
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
-  histogram=(unsigned long **) AcquireAlignedMemory(number_threads,
+  histogram=(size_t **) AcquireAlignedMemory(number_threads,
     sizeof(*histogram));
-  if (histogram == (unsigned long **) NULL)
-    return((unsigned long **) NULL);
+  if (histogram == (size_t **) NULL)
+    return((size_t **) NULL);
   (void) ResetMagickMemory(histogram,0,number_threads*sizeof(*histogram));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
-    histogram[i]=(unsigned long *) AcquireQuantumMemory(count,
+    histogram[i]=(size_t *) AcquireQuantumMemory(count,
       sizeof(**histogram));
-    if (histogram[i] == (unsigned long *) NULL)
+    if (histogram[i] == (size_t *) NULL)
       return(DestroyHistogramThreadSet(histogram));
   }
   return(histogram);
@@ -555,17 +555,19 @@
   Image
     *paint_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
-  unsigned long
+  MagickOffsetType
+    progress;
+
+  size_t
     **restrict histograms,
     width;
 
+  ssize_t
+    y;
+
   /*
     Initialize painted image attributes.
   */
@@ -588,7 +590,7 @@
       return((Image *) NULL);
     }
   histograms=AcquireHistogramThreadSet(NumberPaintBins);
-  if (histograms == (unsigned long **) NULL)
+  if (histograms == (size_t **) NULL)
     {
       paint_image=DestroyImage(paint_image);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
@@ -603,7 +605,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -614,18 +616,18 @@
     register IndexPacket
       *restrict paint_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
       *restrict q;
 
-    register unsigned long
+    register size_t
       *histogram;
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-(long) (width/
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t) (width/
       2L),image->columns+width,width,exception);
     q=QueueCacheViewAuthenticPixels(paint_view,0,y,paint_image->columns,1,
       exception);
@@ -637,18 +639,18 @@
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     paint_indexes=GetCacheViewAuthenticIndexQueue(paint_view);
     histogram=histograms[GetOpenMPThreadId()];
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      long
+      ssize_t
         j,
         k,
         v;
 
-      register long
+      register ssize_t
         i,
         u;
 
-      unsigned long
+      size_t
         count;
 
       /*
@@ -658,11 +660,11 @@
       j=0;
       count=0;
       (void) ResetMagickMemory(histogram,0,NumberPaintBins*sizeof(*histogram));
-      for (v=0; v < (long) width; v++)
+      for (v=0; v < (ssize_t) width; v++)
       {
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
         {
-          k=(long) ScaleQuantumToChar(PixelIntensityToQuantum(p+u+i));
+          k=(ssize_t) ScaleQuantumToChar(PixelIntensityToQuantum(p+u+i));
           histogram[k]++;
           if (histogram[k] > count)
             {
@@ -763,16 +765,18 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(target != (MagickPixelPacket *) NULL);
@@ -792,7 +796,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -800,7 +804,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -816,7 +820,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     pixel=zero;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,q,indexes+x,&pixel);
       if (IsMagickColorSimilar(&pixel,target) != invert)
@@ -904,16 +908,18 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   MagickPixelPacket
     zero;
 
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(target != (MagickPixelPacket *) NULL);
@@ -934,7 +940,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickPixelPacket
       pixel;
@@ -942,7 +948,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -958,7 +964,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     pixel=zero;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,q,indexes+x,&pixel);
       if (IsMagickColorSimilar(&pixel,target) != invert)
@@ -1037,13 +1043,15 @@
   ExceptionInfo
     *exception;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(high != (MagickPixelPacket *) NULL);
@@ -1064,7 +1072,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       match;
@@ -1075,7 +1083,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1091,7 +1099,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     GetMagickPixelPacket(image,&pixel);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,q,indexes+x,&pixel);
       match=((pixel.red >= low->red) && (pixel.red <= high->red) &&
diff --git a/magick/paint.h b/magick/paint.h
index 31d03cc..e4ca457 100644
--- a/magick/paint.h
+++ b/magick/paint.h
@@ -30,7 +30,7 @@
 
 extern MagickExport MagickBooleanType
   FloodfillPaintImage(Image *,const ChannelType,const DrawInfo *,
-    const MagickPixelPacket *,const long,const long,const MagickBooleanType),
+    const MagickPixelPacket *,const ssize_t,const ssize_t,const MagickBooleanType),
   GradientImage(Image *,const GradientType,const SpreadMethod,
     const PixelPacket *,const PixelPacket *),
   OpaquePaintImage(Image *,const MagickPixelPacket *,const MagickPixelPacket *,
diff --git a/magick/pixel.c b/magick/pixel.c
index cc8a693..909229c 100644
--- a/magick/pixel.c
+++ b/magick/pixel.c
@@ -77,7 +77,7 @@
 %
 %  ExportImagePixels() extracts pixel data from an image and returns it to you.
 %  The method returns MagickTrue on success otherwise MagickFalse if an error is
-%  encountered.  The data is returned as char, short int, int, long, float,
+%  encountered.  The data is returned as char, short int, int, ssize_t, float,
 %  or double in the order specified by map.
 %
 %  Suppose you want to extract the first scanline of a 640x480 image as
@@ -88,8 +88,8 @@
 %  The format of the ExportImagePixels method is:
 %
 %      MagickBooleanType ExportImagePixels(const Image *image,
-%        const long x_offset,const long y_offset,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType type,
+%        const ssize_t x_offset,const ssize_t y_offset,const size_t columns,
+%        const size_t rows,const char *map,const StorageType type,
 %        void *pixels,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -118,17 +118,17 @@
 %
 */
 MagickExport MagickBooleanType ExportImagePixels(const Image *image,
-  const long x_offset,const long y_offset,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType type,void *pixels,
+  const ssize_t x_offset,const ssize_t y_offset,const size_t columns,
+  const size_t rows,const char *map,const StorageType type,void *pixels,
   ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
   QuantumType
     *quantum_map;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -153,7 +153,7 @@
         ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
       return(MagickFalse);
     }
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     switch (map[i])
     {
@@ -262,12 +262,12 @@
       q=(unsigned char *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -279,12 +279,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -297,12 +297,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -315,12 +315,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
               p++;
@@ -330,12 +330,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -347,12 +347,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -365,12 +365,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
               *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -381,15 +381,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -451,12 +451,12 @@
       q=(double *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetBluePixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -468,12 +468,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetBluePixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -487,12 +487,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetBluePixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -505,12 +505,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*PixelIntensityToQuantum(p));
               p++;
@@ -520,12 +520,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetRedPixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -537,12 +537,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetRedPixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -556,12 +556,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(double) (QuantumScale*GetRedPixelComponent(p));
               *q++=(double) (QuantumScale*GetGreenPixelComponent(p));
@@ -572,15 +572,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -643,12 +643,12 @@
       q=(float *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetBluePixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -660,12 +660,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetBluePixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -678,12 +678,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetBluePixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -696,12 +696,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*PixelIntensityToQuantum(p));
               p++;
@@ -711,12 +711,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetRedPixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -728,12 +728,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetRedPixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -746,12 +746,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(float) (QuantumScale*GetRedPixelComponent(p));
               *q++=(float) (QuantumScale*GetGreenPixelComponent(p));
@@ -762,15 +762,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -832,12 +832,12 @@
       q=(unsigned int *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -849,12 +849,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -868,12 +868,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -886,12 +886,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int)
                 ScaleQuantumToLong(PixelIntensityToQuantum(p));
@@ -902,12 +902,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -919,12 +919,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -938,12 +938,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -954,15 +954,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -1020,18 +1020,18 @@
     }
     case LongPixel:
     {
-      register unsigned long
+      register size_t
         *q;
 
-      q=(unsigned long *) pixels;
+      q=(size_t *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1043,12 +1043,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1061,12 +1061,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1079,12 +1079,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p));
               p++;
@@ -1094,12 +1094,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1111,12 +1111,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1129,12 +1129,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
               *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1145,15 +1145,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -1215,12 +1215,12 @@
       q=(Quantum *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetBluePixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1232,12 +1232,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetBluePixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1250,12 +1250,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetBluePixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1268,12 +1268,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=PixelIntensityToQuantum(p);
               p++;
@@ -1283,12 +1283,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetRedPixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1300,12 +1300,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetRedPixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1318,12 +1318,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=GetRedPixelComponent(p);
               *q++=GetGreenPixelComponent(p);
@@ -1334,15 +1334,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=(Quantum) 0;
             switch (quantum_map[i])
@@ -1404,12 +1404,12 @@
       q=(unsigned short *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1421,12 +1421,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1439,12 +1439,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1457,12 +1457,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p));
               p++;
@@ -1472,12 +1472,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1489,12 +1489,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1507,12 +1507,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (p == (const PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
               *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -1523,15 +1523,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         p=GetVirtualPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetVirtualIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             *q=0;
             switch (quantum_map[i])
@@ -1657,7 +1657,7 @@
 %  ImportImagePixels() accepts pixel data and stores in the image at the
 %  location you specify.  The method returns MagickTrue on success otherwise
 %  MagickFalse if an error is encountered.  The pixel data can be either char,
-%  short int, int, long, float, or double in the order specified by map.
+%  short int, int, ssize_t, float, or double in the order specified by map.
 %
 %  Suppose your want to upload the first scanline of a 640x480 image from
 %  character data in red-green-blue order:
@@ -1666,9 +1666,9 @@
 %
 %  The format of the ImportImagePixels method is:
 %
-%      MagickBooleanType ImportImagePixels(Image *image,const long x_offset,
-%        const long y_offset,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType type,
+%      MagickBooleanType ImportImagePixels(Image *image,const ssize_t x_offset,
+%        const ssize_t y_offset,const size_t columns,
+%        const size_t rows,const char *map,const StorageType type,
 %        const void *pixels)
 %
 %  A description of each parameter follows:
@@ -1695,14 +1695,14 @@
 %
 */
 MagickExport MagickBooleanType ImportImagePixels(Image *image,
-  const long x_offset,const long y_offset,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType type,
+  const ssize_t x_offset,const ssize_t y_offset,const size_t columns,
+  const size_t rows,const char *map,const StorageType type,
   const void *pixels)
 {
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   PixelPacket
@@ -1714,7 +1714,7 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1733,7 +1733,7 @@
   if (quantum_map == (QuantumType *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     switch (map[i])
     {
@@ -1834,12 +1834,12 @@
       p=(const unsigned char *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1853,12 +1853,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1873,12 +1873,12 @@
         }
       if (LocaleCompare(map,"BGRO") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1893,12 +1893,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1913,12 +1913,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=q->red;
@@ -1932,12 +1932,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1951,12 +1951,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1971,12 +1971,12 @@
         }
       if (LocaleCompare(map,"RGBO") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -1991,12 +1991,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleCharToQuantum(*p++);
               q->green=ScaleCharToQuantum(*p++);
@@ -2009,15 +2009,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -2081,12 +2081,12 @@
       p=(const double *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2103,12 +2103,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2128,12 +2128,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2151,12 +2151,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               q->green=q->red;
@@ -2171,12 +2171,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2193,12 +2193,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2218,12 +2218,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2238,15 +2238,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -2311,12 +2311,12 @@
       p=(const float *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2333,12 +2333,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2358,12 +2358,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2381,12 +2381,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               q->green=q->red;
@@ -2401,12 +2401,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2423,12 +2423,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2448,12 +2448,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ClampToQuantum((MagickRealType) QuantumRange*(*p));
               p++;
@@ -2468,15 +2468,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -2541,12 +2541,12 @@
       p=(const unsigned int *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2560,12 +2560,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2580,12 +2580,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2600,12 +2600,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=q->red;
@@ -2619,12 +2619,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2638,12 +2638,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2658,12 +2658,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2676,15 +2676,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -2742,18 +2742,18 @@
     }
     case LongPixel:
     {
-      register const unsigned long
+      register const size_t
         *p;
 
-      p=(const unsigned long *) pixels;
+      p=(const size_t *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2767,12 +2767,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2787,12 +2787,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2807,12 +2807,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=q->red;
@@ -2826,12 +2826,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2845,12 +2845,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2865,12 +2865,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleLongToQuantum(*p++);
               q->green=ScaleLongToQuantum(*p++);
@@ -2883,15 +2883,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -2955,12 +2955,12 @@
       p=(const Quantum *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=(*p++);
               q->green=(*p++);
@@ -2974,12 +2974,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=(*p++);
               q->green=(*p++);
@@ -2994,12 +2994,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=(*p++);
               q->green=(*p++);
@@ -3014,12 +3014,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=(*p++);
               q->green=q->red;
@@ -3033,12 +3033,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=(*p++);
               q->green=(*p++);
@@ -3052,12 +3052,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=(*p++);
               q->green=(*p++);
@@ -3072,12 +3072,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=(*p++);
               q->green=(*p++);
@@ -3090,15 +3090,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
@@ -3162,12 +3162,12 @@
       p=(const unsigned short *) pixels;
       if (LocaleCompare(map,"BGR") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3181,12 +3181,12 @@
         }
       if (LocaleCompare(map,"BGRA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3201,12 +3201,12 @@
         }
       if (LocaleCompare(map,"BGRP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->blue=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3221,12 +3221,12 @@
         }
       if (LocaleCompare(map,"I") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleShortToQuantum(*p++);
               q->green=q->red;
@@ -3240,12 +3240,12 @@
         }
       if (LocaleCompare(map,"RGB") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3259,12 +3259,12 @@
         }
       if (LocaleCompare(map,"RGBA") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3279,12 +3279,12 @@
         }
       if (LocaleCompare(map,"RGBP") == 0)
         {
-          for (y=0; y < (long) rows; y++)
+          for (y=0; y < (ssize_t) rows; y++)
           {
             q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
             if (q == (PixelPacket *) NULL)
               break;
-            for (x=0; x < (long) columns; x++)
+            for (x=0; x < (ssize_t) columns; x++)
             {
               q->red=ScaleShortToQuantum(*p++);
               q->green=ScaleShortToQuantum(*p++);
@@ -3297,15 +3297,15 @@
           }
           break;
         }
-      for (y=0; y < (long) rows; y++)
+      for (y=0; y < (ssize_t) rows; y++)
       {
         q=GetAuthenticPixels(image,x_offset,y_offset+y,columns,1,exception);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetAuthenticIndexQueue(image);
-        for (x=0; x < (long) columns; x++)
+        for (x=0; x < (ssize_t) columns; x++)
         {
-          for (i=0; i < (long) length; i++)
+          for (i=0; i < (ssize_t) length; i++)
           {
             switch (quantum_map[i])
             {
diff --git a/magick/pixel.h b/magick/pixel.h
index 660d0db..593ba12 100644
--- a/magick/pixel.h
+++ b/magick/pixel.h
@@ -80,7 +80,7 @@
 
 typedef struct _LongPixelPacket
 {
-  unsigned long
+  size_t
     red,
     green,
     blue,
@@ -102,7 +102,7 @@
   double
     fuzz;
 
-  unsigned long
+  size_t
     depth;
 
   MagickRealType
@@ -135,10 +135,10 @@
 } PixelPacket;
 
 extern MagickExport MagickBooleanType
-  ExportImagePixels(const Image *,const long,const long,const unsigned long,
-    const unsigned long,const char *,const StorageType,void *,ExceptionInfo *),
-  ImportImagePixels(Image *,const long,const long,const unsigned long,
-    const unsigned long,const char *,const StorageType,const void *);
+  ExportImagePixels(const Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,const char *,const StorageType,void *,ExceptionInfo *),
+  ImportImagePixels(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,const char *,const StorageType,const void *);
 
 extern MagickExport void
   GetMagickPixelPacket(const Image *,MagickPixelPacket *);
diff --git a/magick/policy.c b/magick/policy.c
index af1062e..bb127bd 100644
--- a/magick/policy.c
+++ b/magick/policy.c
@@ -88,7 +88,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -224,7 +224,7 @@
 %  The format of the GetPolicyInfoList function is:
 %
 %      const PolicyInfo **GetPolicyInfoList(const char *pattern,
-%        unsigned long *number_policies,ExceptionInfo *exception)
+%        size_t *number_policies,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -236,7 +236,7 @@
 %
 */
 MagickExport const PolicyInfo **GetPolicyInfoList(const char *pattern,
-  unsigned long *number_policies,ExceptionInfo *exception)
+  size_t *number_policies,ExceptionInfo *exception)
 {
   const PolicyInfo
     **policies;
@@ -244,7 +244,7 @@
   register const PolicyInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -252,7 +252,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_policies != (unsigned long *) NULL);
+  assert(number_policies != (size_t *) NULL);
   *number_policies=0;
   p=GetPolicyInfo("*",exception);
   if (p == (const PolicyInfo *) NULL)
@@ -276,7 +276,7 @@
   }
   UnlockSemaphoreInfo(policy_semaphore);
   policies[i]=(PolicyInfo *) NULL;
-  *number_policies=(unsigned long) i;
+  *number_policies=(size_t) i;
   return(policies);
 }
 
@@ -295,7 +295,7 @@
 %
 %  The format of the GetPolicyList function is:
 %
-%      char **GetPolicyList(const char *pattern,unsigned long *number_policies,
+%      char **GetPolicyList(const char *pattern,size_t *number_policies,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -308,7 +308,7 @@
 %
 */
 MagickExport char **GetPolicyList(const char *pattern,
-  unsigned long *number_policies,ExceptionInfo *exception)
+  size_t *number_policies,ExceptionInfo *exception)
 {
   char
     **policies;
@@ -316,7 +316,7 @@
   register const PolicyInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -324,7 +324,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_policies != (unsigned long *) NULL);
+  assert(number_policies != (size_t *) NULL);
   *number_policies=0;
   p=GetPolicyInfo("*",exception);
   if (p == (const PolicyInfo *) NULL)
@@ -348,7 +348,7 @@
   }
   UnlockSemaphoreInfo(policy_semaphore);
   policies[i]=(char *) NULL;
-  *number_policies=(unsigned long) i;
+  *number_policies=(size_t) i;
   return(policies);
 }
 
@@ -550,10 +550,10 @@
   const PolicyInfo
     **policy_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_policies;
 
   /*
@@ -565,7 +565,7 @@
   if (policy_info == (const PolicyInfo **) NULL)
     return(MagickFalse);
   path=(const char *) NULL;
-  for (i=0; i < (long) number_policies; i++)
+  for (i=0; i < (ssize_t) number_policies; i++)
   {
     if (policy_info[i]->stealth != MagickFalse)
       continue;
@@ -624,7 +624,7 @@
 %  The format of the LoadPolicyList method is:
 %
 %      MagickBooleanType LoadPolicyList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -638,7 +638,7 @@
 %
 */
 static MagickBooleanType LoadPolicyList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     keyword[MaxTextExtent],
@@ -882,7 +882,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -899,7 +899,7 @@
           return(MagickFalse);
         }
     }
-  for (i=0; i < (long) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++)
+  for (i=0; i < (ssize_t) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++)
   {
     PolicyInfo
       *policy_info;
diff --git a/magick/policy.h b/magick/policy.h
index 2796da0..03667cb 100644
--- a/magick/policy.h
+++ b/magick/policy.h
@@ -50,10 +50,10 @@
 
 extern MagickExport char
   *GetPolicyValue(const char *name),
-  **GetPolicyList(const char *,unsigned long *,ExceptionInfo *);
+  **GetPolicyList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport const PolicyInfo
-  **GetPolicyInfoList(const char *,unsigned long *,ExceptionInfo *);
+  **GetPolicyInfoList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
   IsRightsAuthorized(const PolicyDomain,const PolicyRights,const char *),
diff --git a/magick/prepress.c b/magick/prepress.c
index 6d25964..4cd87f1 100644
--- a/magick/prepress.c
+++ b/magick/prepress.c
@@ -88,7 +88,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -111,7 +111,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     double
       density;
@@ -122,7 +122,7 @@
     register const PixelPacket
       *p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -132,7 +132,7 @@
         continue;
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       density=(double) p->red+p->green+p->blue+indexes[x];
       if (density > total_ink_density)
diff --git a/magick/profile.c b/magick/profile.c
index ed7f8d6..e55949f 100644
--- a/magick/profile.c
+++ b/magick/profile.c
@@ -338,11 +338,11 @@
 
 static unsigned short **DestroyPixelThreadSet(unsigned short **pixels)
 {
-  register long
+  register ssize_t
     i;
 
   assert(pixels != (unsigned short **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (pixels[i] != (unsigned short *) NULL)
       pixels[i]=(unsigned short *) RelinquishMagickMemory(pixels[i]);
   pixels=(unsigned short **) RelinquishAlignedMemory(pixels);
@@ -352,13 +352,13 @@
 static unsigned short **AcquirePixelThreadSet(const size_t columns,
   const size_t channels)
 {
-  register long
+  register ssize_t
     i;
 
   unsigned short
     **pixels;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -367,7 +367,7 @@
   if (pixels == (unsigned short **) NULL)
     return((unsigned short **) NULL);
   (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     pixels[i]=(unsigned short *) AcquireQuantumMemory(columns,channels*
       sizeof(**pixels));
@@ -379,11 +379,11 @@
 
 static cmsHTRANSFORM *DestroyTransformThreadSet(cmsHTRANSFORM *transform)
 {
-  register long
+  register ssize_t
     i;
 
   assert(transform != (cmsHTRANSFORM *) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (transform[i] != (cmsHTRANSFORM) NULL)
       cmsDeleteTransform(transform[i]);
   transform=(cmsHTRANSFORM *) RelinquishAlignedMemory(transform);
@@ -398,10 +398,10 @@
   cmsHTRANSFORM
     *transform;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -410,7 +410,7 @@
   if (transform == (cmsHTRANSFORM *) NULL)
     return((cmsHTRANSFORM *) NULL);
   (void) ResetMagickMemory(transform,0,number_threads*sizeof(*transform));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     transform[i]=cmsCreateTransform(source_profile,source_type,target_profile,
       target_type,intent,flags);
@@ -861,7 +861,7 @@
       int
         number_arguments;
 
-      register long
+      register ssize_t
         i;
 
       /*
@@ -991,7 +991,7 @@
             int
               intent;
 
-            long
+            ssize_t
               progress,
               y;
 
@@ -1218,7 +1218,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
             #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-            for (y=0; y < (long) image->rows; y++)
+            for (y=0; y < (ssize_t) image->rows; y++)
             {
               MagickBooleanType
                 sync;
@@ -1226,7 +1226,7 @@
               register IndexPacket
                 *restrict indexes;
 
-              register long
+              register ssize_t
                 id,
                 x;
 
@@ -1248,7 +1248,7 @@
               indexes=GetCacheViewAuthenticIndexQueue(image_view);
               id=GetOpenMPThreadId();
               p=source_pixels[id];
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 *p++=ScaleQuantumToShort(q->red);
                 if (source_channels > 1)
@@ -1264,7 +1264,7 @@
                 (unsigned int) image->columns);
               p=target_pixels[id];
               q-=image->columns;
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 q->red=ScaleShortToQuantum(*p);
                 q->green=q->red;
@@ -1489,12 +1489,12 @@
 }
 
 static inline const unsigned char *ReadResourceLong(const unsigned char *p,
-  unsigned long *quantum)
+  size_t *quantum)
 {
-  *quantum=(unsigned long) (*p++ << 24);
-  *quantum|=(unsigned long) (*p++ << 16);
-  *quantum|=(unsigned long) (*p++ << 8);
-  *quantum|=(unsigned long) (*p++ << 0);
+  *quantum=(size_t) (*p++ << 24);
+  *quantum|=(size_t) (*p++ << 16);
+  *quantum|=(size_t) (*p++ << 8);
+  *quantum|=(size_t) (*p++ << 0);
   return(p);
 }
 
@@ -1524,7 +1524,7 @@
   unsigned char
     length_byte;
 
-  unsigned long
+  size_t
     count;
 
   unsigned short
@@ -1744,25 +1744,25 @@
   return((unsigned short) (value & 0xffff));
 }
 
-static inline unsigned long ReadProfileLong(const EndianType endian,
+static inline size_t ReadProfileLong(const EndianType endian,
   unsigned char *buffer)
 {
-  unsigned long
+  size_t
     value;
 
   if (endian == MSBEndian)
     {
-      value=(unsigned long) ((buffer[0] << 24) | (buffer[1] << 16) |
+      value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
         (buffer[2] << 8) | buffer[3]);
-      return((unsigned long) (value & 0xffffffff));
+      return((size_t) (value & 0xffffffff));
     }
-  value=(unsigned long) ((buffer[3] << 24) | (buffer[2] << 16) |
+  value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
     (buffer[1] << 8 ) | (buffer[0]));
-  return((unsigned long) (value & 0xffffffff));
+  return((size_t) (value & 0xffffffff));
 }
 
 static inline void WriteProfileLong(const EndianType endian,
-  const unsigned long value,unsigned char *p)
+  const size_t value,unsigned char *p)
 {
   unsigned char
     buffer[4];
@@ -1814,7 +1814,7 @@
     unsigned char
       *directory;
 
-    unsigned long
+    size_t
       entry;
   } DirectoryInfo;
 
@@ -1824,7 +1824,7 @@
   EndianType
     endian;
 
-  long
+  ssize_t
     id,
     level;
 
@@ -1844,7 +1844,7 @@
     *directory,
     *exif;
 
-  unsigned long
+  size_t
     entry,
     number_entries;
 
@@ -1908,7 +1908,7 @@
     number_entries=ReadProfileShort(endian,directory);
     for ( ; entry < number_entries; entry++)
     {
-      long
+      ssize_t
         components,
         format,
         tag_value;
@@ -1921,11 +1921,11 @@
         number_bytes;
 
       q=(unsigned char *) (directory+2+(12*entry));
-      tag_value=(long) ReadProfileShort(endian,q);
-      format=(long) ReadProfileShort(endian,q+2);
+      tag_value=(ssize_t) ReadProfileShort(endian,q);
+      format=(ssize_t) ReadProfileShort(endian,q+2);
       if ((format-1) >= EXIF_NUM_FORMATS)
         break;
-      components=(long) ReadProfileLong(endian,q+4);
+      components=(ssize_t) ReadProfileLong(endian,q+4);
       number_bytes=(size_t) components*format_bytes[format];
       if (number_bytes <= 4)
         p=q+8;
@@ -1946,14 +1946,14 @@
       {
         case 0x011a:
         {
-          (void) WriteProfileLong(endian,(unsigned long)
+          (void) WriteProfileLong(endian,(size_t)
             (image->x_resolution+0.5),p);
           (void) WriteProfileLong(endian,1UL,p+4);
           break;
         }
         case 0x011b:
         {
-          (void) WriteProfileLong(endian,(unsigned long)
+          (void) WriteProfileLong(endian,(size_t)
             (image->y_resolution+0.5),p);
           (void) WriteProfileLong(endian,1UL,p+4);
           break;
diff --git a/magick/profile.h b/magick/profile.h
index a16cdea..7781f6f 100644
--- a/magick/profile.h
+++ b/magick/profile.h
@@ -35,7 +35,7 @@
   unsigned char
     *info;
 
-  unsigned long
+  size_t
     signature;
 } ProfileInfo;
 
diff --git a/magick/property.c b/magick/property.c
index 2b22490..7596b7c 100644
--- a/magick/property.c
+++ b/magick/property.c
@@ -381,10 +381,10 @@
 */
 
 static char
-  *TracePSClippath(const unsigned char *,size_t,const unsigned long,
-    const unsigned long),
-  *TraceSVGClippath(const unsigned char *,size_t,const unsigned long,
-    const unsigned long);
+  *TracePSClippath(const unsigned char *,size_t,const size_t,
+    const size_t),
+  *TraceSVGClippath(const unsigned char *,size_t,const size_t,
+    const size_t);
 
 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
 {
@@ -395,12 +395,12 @@
   const StringInfo
     *profile;
 
-  long
+  ssize_t
     count,
     dataset,
     record;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -415,15 +415,15 @@
   if (count != 2)
     return(MagickFalse);
   attribute=(char *) NULL;
-  for (i=0; i < (long) GetStringInfoLength(profile); i+=(long) length)
+  for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
   {
     length=1;
-    if ((long) GetStringInfoDatum(profile)[i] != 0x1c)
+    if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
       continue;
     length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
     length|=GetStringInfoDatum(profile)[i+4];
-    if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
-        ((long) GetStringInfoDatum(profile)[i+2] == record))
+    if (((ssize_t) GetStringInfoDatum(profile)[i+1] == dataset) &&
+        ((ssize_t) GetStringInfoDatum(profile)[i+2] == record))
       {
         message=(char *) NULL;
         if (~length >= 1)
@@ -451,7 +451,7 @@
   return(MagickTrue);
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
@@ -470,19 +470,19 @@
   return(c);
 }
 
-static inline unsigned long ReadPropertyMSBLong(const unsigned char **p,
+static inline size_t ReadPropertyMSBLong(const unsigned char **p,
   size_t *length)
 {
   int
     c;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
     buffer[4];
 
-  unsigned long
+  size_t
     value;
 
   if (*length < 4)
@@ -493,7 +493,7 @@
     (*length)--;
     buffer[i]=(unsigned char) c;
   }
-  value=(unsigned long) (buffer[0] << 24);
+  value=(size_t) (buffer[0] << 24);
   value|=buffer[1] << 16;
   value|=buffer[2] << 8;
   value|=buffer[3];
@@ -506,7 +506,7 @@
   int
     c;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
@@ -542,7 +542,7 @@
   const unsigned char
     *info;
 
-  long
+  ssize_t
     id,
     start,
     stop,
@@ -551,7 +551,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   ssize_t
@@ -592,7 +592,7 @@
       continue;
     if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
       continue;
-    id=(long) ReadPropertyMSBShort(&info,&length);
+    id=(ssize_t) ReadPropertyMSBShort(&info,&length);
     if (id < start)
       continue;
     if (id > stop)
@@ -608,7 +608,7 @@
             sizeof(*resource));
         if (resource != (char *) NULL)
           {
-            for (i=0; i < (long) count; i++)
+            for (i=0; i < (ssize_t) count; i++)
               resource[i]=(char) ReadPropertyByte(&info,&length);
             resource[count]='\0';
           }
@@ -691,21 +691,21 @@
   return((unsigned short) (value & 0xffff));
 }
 
-static inline unsigned long ReadPropertyLong(const EndianType endian,
+static inline size_t ReadPropertyLong(const EndianType endian,
   const unsigned char *buffer)
 {
-  unsigned long
+  size_t
     value;
 
   if (endian == MSBEndian)
     {
-      value=(unsigned long) ((buffer[0] << 24) | (buffer[1] << 16) |
+      value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
         (buffer[2] << 8) | buffer[3]);
-      return((unsigned long) (value & 0xffffffff));
+      return((size_t) (value & 0xffffffff));
     }
-  value=(unsigned long) ((buffer[3] << 24) | (buffer[2] << 16) |
+  value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
     (buffer[1] << 8 ) | (buffer[0]));
-  return((unsigned long) (value & 0xffffffff));
+  return((size_t) (value & 0xffffffff));
 }
 
 static MagickBooleanType GetEXIFProperty(const Image *image,
@@ -732,7 +732,7 @@
 
 #define EXIFMultipleValues(size, format, arg) \
 { \
-   long \
+   ssize_t \
      component; \
  \
    size_t \
@@ -758,7 +758,7 @@
 
 #define EXIFMultipleFractions(size, format, arg1, arg2) \
 { \
-   long \
+   ssize_t \
      component; \
  \
    size_t \
@@ -787,14 +787,14 @@
     const unsigned char
       *directory;
 
-    unsigned long
+    size_t
       entry,
       offset;
   } DirectoryInfo;
 
   typedef struct _TagInfo
   {
-    unsigned long
+    size_t
       tag;
 
     const char
@@ -1090,13 +1090,13 @@
   EndianType
     endian;
 
-  long
+  ssize_t
     all,
     id,
     level,
     tag_value;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1108,7 +1108,7 @@
   static int
     tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
 
-  unsigned long
+  size_t
     entry,
     number_entries,
     tag_offset,
@@ -1166,7 +1166,7 @@
       n/=4;
       do
       {
-        for (i=(long) n-1L; i >= 0; i--)
+        for (i=(ssize_t) n-1L; i >= 0; i--)
         {
           c=(*property++);
           tag<<=4;
@@ -1195,7 +1195,7 @@
           break;
         if (LocaleCompare(EXIFTag[i].description,property) == 0)
           {
-            tag=(unsigned long) EXIFTag[i].tag;
+            tag=(size_t) EXIFTag[i].tag;
             break;
           }
       }
@@ -1224,7 +1224,7 @@
   }
   if (length < 16)
     return(MagickFalse);
-  id=(long) ReadPropertyShort(LSBEndian,exif);
+  id=(ssize_t) ReadPropertyShort(LSBEndian,exif);
   endian=LSBEndian;
   if (id == 0x4949)
     endian=LSBEndian;
@@ -1266,7 +1266,7 @@
     number_entries=ReadPropertyShort(endian,directory);
     for ( ; entry < number_entries; entry++)
     {
-      long
+      ssize_t
         components;
 
       register unsigned char
@@ -1276,15 +1276,15 @@
       size_t
         number_bytes;
 
-      unsigned long
+      size_t
         format;
 
       q=(unsigned char *) (directory+2+(12*entry));
-      tag_value=(long) ReadPropertyShort(endian,q)+tag_offset;
-      format=(unsigned long) ReadPropertyShort(endian,q+2);
+      tag_value=(ssize_t) ReadPropertyShort(endian,q)+tag_offset;
+      format=(size_t) ReadPropertyShort(endian,q+2);
       if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
         break;
-      components=(long) ReadPropertyLong(endian,q+4);
+      components=(ssize_t) ReadPropertyLong(endian,q+4);
       number_bytes=(size_t) components*tag_bytes[format];
       if (number_bytes <= 4)
         p=q+8;
@@ -1301,7 +1301,7 @@
             continue;
           p=(unsigned char *) (exif+offset);
         }
-      if ((all != 0) || (tag == (unsigned long) tag_value))
+      if ((all != 0) || (tag == (size_t) tag_value))
         {
           char
             buffer[MaxTextExtent],
@@ -1312,13 +1312,13 @@
             case EXIF_FMT_BYTE:
             case EXIF_FMT_UNDEFINED:
             {
-              EXIFMultipleValues(1,"%lu",(unsigned long)
+              EXIFMultipleValues(1,"%lu",(size_t)
                 (*(unsigned char *) p1));
               break;
             }
             case EXIF_FMT_SBYTE:
             {
-              EXIFMultipleValues(1,"%ld",(long) (*(signed char *) p1));
+              EXIFMultipleValues(1,"%ld",(ssize_t) (*(signed char *) p1));
               break;
             }
             case EXIF_FMT_SSHORT:
@@ -1372,10 +1372,10 @@
                   sizeof(*value));
               if (value != (char *) NULL)
                 {
-                  register long
+                  register ssize_t
                     i;
 
-                  for (i=0; i < (long) number_bytes; i++)
+                  for (i=0; i < (ssize_t) number_bytes; i++)
                   {
                     value[i]='.';
                     if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
@@ -1402,7 +1402,7 @@
                   const char
                     *description;
 
-                  register long
+                  register ssize_t
                     i;
 
                   description="unknown";
@@ -1410,7 +1410,7 @@
                   {
                     if (EXIFTag[i].tag == 0)
                       break;
-                    if ((long) EXIFTag[i].tag == tag_value)
+                    if ((ssize_t) EXIFTag[i].tag == tag_value)
                       {
                         description=EXIFTag[i].description;
                         break;
@@ -1453,7 +1453,7 @@
             offset=(size_t) ReadPropertyLong(endian,p);
             if ((offset < length) && (level < (MaxDirectoryStack-2)))
               {
-                unsigned long
+                size_t
                   tag_offset1;
 
                 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
@@ -1564,14 +1564,14 @@
 }
 
 static char *TracePSClippath(const unsigned char *blob,size_t length,
-  const unsigned long magick_unused(columns),
-  const unsigned long magick_unused(rows))
+  const size_t magick_unused(columns),
+  const size_t magick_unused(rows))
 {
   char
     *path,
     *message;
 
-  long
+  ssize_t
     knot_count,
     selector,
     y;
@@ -1584,7 +1584,7 @@
     last[3],
     point[3];
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1624,7 +1624,7 @@
   in_subpath=MagickFalse;
   while (length > 0)
   {
-    selector=(long) ReadPropertyMSBShort(&blob,&length);
+    selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
     switch (selector)
     {
       case 0:
@@ -1639,7 +1639,7 @@
         /*
           Expected subpath length record.
         */
-        knot_count=(long) ReadPropertyMSBShort(&blob,&length);
+        knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
         blob+=22;
         length-=22;
         break;
@@ -1663,18 +1663,18 @@
         */
         for (i=0; i < 3; i++)
         {
-          unsigned long 
+          size_t 
             xx,
             yy;
 
           yy=ReadPropertyMSBLong(&blob,&length);
           xx=ReadPropertyMSBLong(&blob,&length);
-          x=(long) xx;
+          x=(ssize_t) xx;
           if (xx > 2147483647)
-            x=(long) xx-4294967295-1;
-          y=(long) yy;
+            x=(ssize_t) xx-4294967295-1;
+          y=(ssize_t) yy;
           if (yy > 2147483647)
-            y=(long) yy-4294967295-1;
+            y=(ssize_t) yy-4294967295-1;
           point[i].x=(double) x/4096/4096;
           point[i].y=1.0-(double) y/4096/4096;
         }
@@ -1773,13 +1773,13 @@
 }
 
 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   char
     *path,
     *message;
 
-  long
+  ssize_t
     knot_count,
     selector,
     x,
@@ -1793,7 +1793,7 @@
     last[3],
     point[3];
 
-  register long
+  register ssize_t
     i;
 
   path=AcquireString((char *) NULL);
@@ -1821,7 +1821,7 @@
   in_subpath=MagickFalse;
   while (length != 0)
   {
-    selector=(long) ReadPropertyMSBShort(&blob,&length);
+    selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
     switch (selector)
     {
       case 0:
@@ -1836,7 +1836,7 @@
         /*
           Expected subpath length record.
         */
-        knot_count=(long) ReadPropertyMSBShort(&blob,&length);
+        knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
         blob+=22;
         length-=22;
         break;
@@ -1860,18 +1860,18 @@
         */
         for (i=0; i < 3; i++)
         {
-          unsigned long 
+          size_t 
             xx,
             yy;
 
           yy=ReadPropertyMSBLong(&blob,&length);
           xx=ReadPropertyMSBLong(&blob,&length);
-          x=(long) xx;
+          x=(ssize_t) xx;
           if (xx > 2147483647)
-            x=(long) xx-4294967295-1;
-          y=(long) yy;
+            x=(ssize_t) xx-4294967295-1;
+          y=(ssize_t) yy;
           if (yy > 2147483647)
-            y=(long) yy-4294967295-1;
+            y=(ssize_t) yy-4294967295-1;
           point[i].x=(double) x*columns/4096/4096;
           point[i].y=(double) y*rows/4096/4096;
         }
@@ -2167,7 +2167,7 @@
             Image channels.
           */
           (void) FormatMagickString(value,MaxTextExtent,"%s",
-            MagickOptionToMnemonic(MagickColorspaceOptions,(long)
+            MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
             image->colorspace));
           LocaleLower(value);
           if (image->matte != MagickFalse)
@@ -2186,7 +2186,7 @@
           if (IsGrayImage(image,&image->exception) != MagickFalse)
             colorspace=GRAYColorspace;
           (void) FormatMagickString(value,MaxTextExtent,"%s",
-            MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace));
+            MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace));
           break;
         }
       break;
@@ -2329,7 +2329,7 @@
           register const Image
             *p;
 
-          unsigned long
+          size_t
             page;
 
           p=image;
@@ -2354,7 +2354,7 @@
       if (LocaleNCompare("scenes",property,6) == 0)
         {
           (void) FormatMagickString(value,MaxTextExtent,"%lu",
-            (unsigned long) GetImageListLength(image));
+            (size_t) GetImageListLength(image));
           break;
         }
       if (LocaleNCompare("scene",property,5) == 0)
@@ -2537,7 +2537,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2610,7 +2610,7 @@
         /*
           File size.
         */
-        (void) FormatMagickString(format,MaxTextExtent,"%lu",(unsigned long)
+        (void) FormatMagickString(format,MaxTextExtent,"%lu",(size_t)
           image->extent);
         if (image->extent != (MagickSizeType) ((size_t) image->extent))
           (void) FormatMagickSize(image->extent,MagickFalse,format);
@@ -2768,7 +2768,7 @@
         /*
           Number of images in the list.
         */
-        q+=FormatMagickString(q,extent,"%lu",(unsigned long)
+        q+=FormatMagickString(q,extent,"%lu",(size_t)
           GetImageListLength(image));
         break;
       }
@@ -2785,7 +2785,7 @@
         register const Image
           *p;
 
-        unsigned long
+        size_t
           page;
 
         /*
@@ -2817,8 +2817,8 @@
         if (IsGrayImage(image,&image->exception) != MagickFalse)
           colorspace=GRAYColorspace;
         q+=FormatMagickString(q,extent,"%s%s%s",MagickOptionToMnemonic(
-          MagickClassOptions,(long) image->storage_class),
-          MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace),
+          MagickClassOptions,(ssize_t) image->storage_class),
+          MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
           image->matte != MagickFalse ? "Matte" : "");
         break;
       }
@@ -2857,7 +2857,7 @@
           Image horizontal resolution.
         */
         q+=FormatMagickString(q,extent,"%g %s",image->x_resolution,
-          MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
+          MagickOptionToMnemonic(MagickResolutionOptions,(ssize_t) image->units));
         break;
       }
       case 'y':
@@ -2866,7 +2866,7 @@
           Image vertical resolution.
         */
         q+=FormatMagickString(q,extent,"%g %s",image->y_resolution,
-          MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
+          MagickOptionToMnemonic(MagickResolutionOptions,(ssize_t) image->units));
         break;
       }
       case 'z':
@@ -2883,7 +2883,7 @@
           Image alpha channel.
         */
         q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
-          MagickBooleanOptions,(long) image->matte));
+          MagickBooleanOptions,(ssize_t) image->matte));
         break;
       }
       case 'C':
@@ -2892,7 +2892,7 @@
           Image compression method.
         */
         q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
-          MagickCompressOptions,(long) image->compression));
+          MagickCompressOptions,(ssize_t) image->compression));
         break;
       }
       case 'D':
@@ -2901,7 +2901,7 @@
           Image dispose method.
         */
         q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
-          MagickDisposeOptions,(long) image->dispose));
+          MagickDisposeOptions,(ssize_t) image->dispose));
         break;
       }
       case 'G':
@@ -2981,7 +2981,7 @@
           *key,
           *value;
 
-        long
+        ssize_t
           depth;
 
         /*
@@ -3281,7 +3281,7 @@
     {
       if (LocaleCompare(property,"colorspace") == 0)
         {
-          long
+          ssize_t
             colorspace;
 
           colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
@@ -3293,7 +3293,7 @@
         }
       if (LocaleCompare(property,"compose") == 0)
         {
-          long
+          ssize_t
             compose;
 
           compose=ParseMagickOption(MagickComposeOptions,MagickFalse,value);
@@ -3304,7 +3304,7 @@
         }
       if (LocaleCompare(property,"compress") == 0)
         {
-          long
+          ssize_t
             compression;
 
           compression=ParseMagickOption(MagickCompressOptions,MagickFalse,
@@ -3329,19 +3329,19 @@
           flags=ParseGeometry(value,&geometry_info);
           if ((flags & GreaterValue) != 0)
             {
-              if (image->delay > (unsigned long) floor(geometry_info.rho+0.5))
-                image->delay=(unsigned long) floor(geometry_info.rho+0.5);
+              if (image->delay > (size_t) floor(geometry_info.rho+0.5))
+                image->delay=(size_t) floor(geometry_info.rho+0.5);
             }
           else
             if ((flags & LessValue) != 0)
               {
-                if (image->delay < (unsigned long) floor(geometry_info.rho+0.5))
-                  image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
+                if (image->delay < (size_t) floor(geometry_info.rho+0.5))
+                  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
               }
             else
-              image->delay=(unsigned long) floor(geometry_info.rho+0.5);
+              image->delay=(size_t) floor(geometry_info.rho+0.5);
           if ((flags & SigmaValue) != 0)
-            image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
+            image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
           break;
         }
       if (LocaleCompare(property,"depth") == 0)
@@ -3351,7 +3351,7 @@
         }
       if (LocaleCompare(property,"dispose") == 0)
         {
-          long
+          ssize_t
             dispose;
 
           dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,value);
@@ -3369,7 +3369,7 @@
     {
       if (LocaleCompare(property,"gravity") == 0)
         {
-          long
+          ssize_t
             gravity;
 
           gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
@@ -3387,7 +3387,7 @@
     {
       if (LocaleCompare(property,"intent") == 0)
         {
-          long
+          ssize_t
             rendering_intent;
 
           rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
@@ -3399,7 +3399,7 @@
         }
       if (LocaleCompare(property,"interpolate") == 0)
         {
-          long
+          ssize_t
             interpolate;
 
           interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
@@ -3464,7 +3464,7 @@
     {
       if (LocaleCompare(property,"rendering-intent") == 0)
         {
-          long
+          ssize_t
             rendering_intent;
 
           rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
diff --git a/magick/quantize.c b/magick/quantize.c
index 6173d31..3fe59f7 100644
--- a/magick/quantize.c
+++ b/magick/quantize.c
@@ -232,7 +232,7 @@
   MagickRealType
     quantize_error;
 
-  unsigned long
+  size_t
     color_number,
     id,
     level;
@@ -252,11 +252,11 @@
   NodeInfo
     *root;
 
-  unsigned long
+  size_t
     colors,
     maximum_colors;
 
-  long
+  ssize_t
     transparent_index;
 
   MagickSizeType
@@ -270,7 +270,7 @@
     pruning_threshold,
     next_threshold;
 
-  unsigned long
+  size_t
     nodes,
     free_nodes,
     color_number;
@@ -281,7 +281,7 @@
   Nodes
     *node_queue;
 
-  long
+  ssize_t
     *cache;
 
   RealPixelPacket
@@ -296,11 +296,11 @@
   MagickBooleanType
     associate_alpha;
 
-  long
+  ssize_t
     x,
     y;
 
-  unsigned long
+  size_t
     depth;
 
   MagickOffsetType
@@ -314,10 +314,10 @@
   Method prototypes.
 */
 static CubeInfo
-  *GetCubeInfo(const QuantizeInfo *,const unsigned long,const unsigned long);
+  *GetCubeInfo(const QuantizeInfo *,const size_t,const size_t);
 
 static NodeInfo
-  *GetNodeInfo(CubeInfo *,const unsigned long,const unsigned long,NodeInfo *);
+  *GetNodeInfo(CubeInfo *,const size_t,const size_t,NodeInfo *);
 
 static MagickBooleanType
   AssignImageColors(Image *,CubeInfo *),
@@ -325,7 +325,7 @@
   DitherImage(Image *,CubeInfo *),
   SetGrayscaleImage(Image *);
 
-static unsigned long
+static size_t
   DefineImageColormap(Image *,CubeInfo *,NodeInfo *);
 
 static void
@@ -452,13 +452,13 @@
   return((Quantum) (value+0.5));
 }
 
-static inline unsigned long ColorToNodeId(const CubeInfo *cube_info,
-  const RealPixelPacket *pixel,unsigned long index)
+static inline size_t ColorToNodeId(const CubeInfo *cube_info,
+  const RealPixelPacket *pixel,size_t index)
 {
-  unsigned long
+  size_t
     id;
 
-  id=(unsigned long) (
+  id=(size_t) (
     ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel->red)) >> index) & 0x1) |
     ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel->green)) >> index) & 0x1) << 1 |
     ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel->blue)) >> index) & 0x1) << 2);
@@ -482,7 +482,7 @@
 {
 #define AssignImageTag  "Assign/Image"
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -491,7 +491,7 @@
   RealPixelPacket
     pixel;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -501,7 +501,7 @@
   ssize_t
     count;
 
-  unsigned long
+  size_t
     id,
     index;
 
@@ -540,7 +540,7 @@
 
       exception=(&image->exception);
       image_view=AcquireCacheView(image);
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         register IndexPacket
           *restrict indexes;
@@ -553,17 +553,17 @@
         if (q == (PixelPacket *) NULL)
           break;
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
-        for (x=0; x < (long) image->columns; x+=count)
+        for (x=0; x < (ssize_t) image->columns; x+=count)
         {
           /*
             Identify the deepest node containing the pixel's color.
           */
-          for (count=1; (x+count) < (long) image->columns; count++)
+          for (count=1; (x+count) < (ssize_t) image->columns; count++)
             if (IsSameColor(image,q,q+count) == MagickFalse)
               break;
           AssociateAlphaPixel(cube_info,q,&pixel);
           node_info=cube_info->root;
-          for (index=MaxTreeDepth-1; (long) index > 0; index--)
+          for (index=MaxTreeDepth-1; (ssize_t) index > 0; index--)
           {
             id=ColorToNodeId(cube_info,&pixel,index);
             if (node_info->child[id] == (NodeInfo *) NULL)
@@ -578,7 +578,7 @@
             (QuantumRange+1.0)+1.0);
           ClosestColor(image,cube_info,node_info->parent);
           index=cube_info->color_number;
-          for (i=0; i < (long) count; i++)
+          for (i=0; i < (ssize_t) count; i++)
           {
             if (image->storage_class == PseudoClass)
               indexes[x+i]=(IndexPacket) index;
@@ -616,7 +616,7 @@
         Monochrome image.
       */
       q=image->colormap;
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         intensity=(Quantum) (PixelIntensity(q) < ((MagickRealType)
           QuantumRange/2.0) ? 0 : QuantumRange);
@@ -716,7 +716,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -737,7 +737,7 @@
   size_t
     count;
 
-  unsigned long
+  size_t
     id,
     index,
     level;
@@ -761,12 +761,12 @@
   midpoint.opacity=(MagickRealType) QuantumRange/2.0;
   error.opacity=0.0;
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -780,7 +780,7 @@
         PruneLevel(image,cube_info,cube_info->root);
         cube_info->depth--;
       }
-    for (x=0; x < (long) image->columns; x+=(long) count)
+    for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) count)
     {
       /*
         Start at the root and descend the color cube tree.
@@ -849,12 +849,12 @@
     if (proceed == MagickFalse)
       break;
   }
-  for (y++; y < (long) image->rows; y++)
+  for (y++; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
@@ -868,7 +868,7 @@
         PruneLevel(image,cube_info,cube_info->root);
         cube_info->depth--;
       }
-    for (x=0; x < (long) image->columns; x+=(long) count)
+    for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) count)
     {
       /*
         Start at the root and descend the color cube tree.
@@ -1017,17 +1017,17 @@
 static void ClosestColor(const Image *image,CubeInfo *cube_info,
   const NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       ClosestColor(image,cube_info,node_info->child[i]);
   if (node_info->number_unique != 0)
@@ -1141,7 +1141,7 @@
 %
 %  The format of the DefineImageColormap method is:
 %
-%      unsigned long DefineImageColormap(Image *image,CubeInfo *cube_info,
+%      size_t DefineImageColormap(Image *image,CubeInfo *cube_info,
 %        NodeInfo *node_info)
 %
 %  A description of each parameter follows.
@@ -1154,20 +1154,20 @@
 %      node in the color cube tree that is to be pruned.
 %
 */
-static unsigned long DefineImageColormap(Image *image,CubeInfo *cube_info,
+static size_t DefineImageColormap(Image *image,CubeInfo *cube_info,
   NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       DefineImageColormap(image,cube_info,node_info->child[i]);
   if (node_info->number_unique != 0)
@@ -1228,7 +1228,7 @@
               if (node_info->number_unique > cube_info->transparent_pixels)
                 {
                   cube_info->transparent_pixels=node_info->number_unique;
-                  cube_info->transparent_index=(long) image->colors;
+                  cube_info->transparent_index=(ssize_t) image->colors;
                 }
             }
         }
@@ -1276,8 +1276,8 @@
       cube_info->node_queue);
     cube_info->node_queue=nodes;
   } while (cube_info->node_queue != (Nodes *) NULL);
-  if (cube_info->cache != (long *) NULL)
-    cube_info->cache=(long *) RelinquishMagickMemory(cube_info->cache);
+  if (cube_info->cache != (ssize_t *) NULL)
+    cube_info->cache=(ssize_t *) RelinquishMagickMemory(cube_info->cache);
   cube_info->quantize_info=DestroyQuantizeInfo(cube_info->quantize_info);
   cube_info=(CubeInfo *) RelinquishMagickMemory(cube_info);
 }
@@ -1353,7 +1353,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     u,
     v,
     y;
@@ -1371,7 +1371,7 @@
   register CubeInfo
     *p;
 
-  unsigned long
+  size_t
     index;
 
   /*
@@ -1384,12 +1384,12 @@
   p=cube_info;
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       i,
       x;
 
@@ -1403,9 +1403,9 @@
     current=scanlines+(y & 0x01)*image->columns;
     previous=scanlines+((y+1) & 0x01)*image->columns;
     v=(y & 0x01) ? -1 : 1;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      u=(y & 0x01) ? (long) image->columns-1-x : x;
+      u=(y & 0x01) ? (ssize_t) image->columns-1-x : x;
       AssociateAlphaPixel(cube_info,q+u,&pixel);
       if (x > 0)
         {
@@ -1417,7 +1417,7 @@
         }
       if (y > 0)
         {
-          if (x < (long) (image->columns-1))
+          if (x < (ssize_t) (image->columns-1))
             {
               pixel.red+=previous[u+v].red/16;
               pixel.green+=previous[u+v].green/16;
@@ -1444,7 +1444,7 @@
       pixel.blue=(MagickRealType) ClampToUnsignedQuantum(pixel.blue);
       if (cube_info->associate_alpha != MagickFalse)
         pixel.opacity=(MagickRealType) ClampToUnsignedQuantum(pixel.opacity);
-      i=(long) ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.red)) >> CacheShift) |
+      i=(ssize_t) ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.red)) >> CacheShift) |
         (ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.green)) >> CacheShift) << 6 |
         (ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.blue)) >> CacheShift) << 12);
       if (cube_info->associate_alpha != MagickFalse)
@@ -1455,14 +1455,14 @@
           register NodeInfo
             *node_info;
 
-          register unsigned long
+          register size_t
             id;
 
           /*
             Identify the deepest node containing the pixel's color.
           */
           node_info=p->root;
-          for (index=MaxTreeDepth-1; (long) index > 0; index--)
+          for (index=MaxTreeDepth-1; (ssize_t) index > 0; index--)
           {
             id=ColorToNodeId(cube_info,&pixel,index);
             if (node_info->child[id] == (NodeInfo *) NULL)
@@ -1476,12 +1476,12 @@
           p->distance=(MagickRealType) (4.0*(QuantumRange+1.0)*(QuantumRange+
             1.0)+1.0);
           ClosestColor(image,p,node_info->parent);
-          p->cache[i]=(long) p->color_number;
+          p->cache[i]=(ssize_t) p->color_number;
         }
       /*
         Assign pixel to closest colormap entry.
       */
-      index=(unsigned long) p->cache[i];
+      index=(size_t) p->cache[i];
       if (image->storage_class == PseudoClass)
         indexes[u]=(IndexPacket) index;
       if (cube_info->quantize_info->measure_error == MagickFalse)
@@ -1518,7 +1518,7 @@
   RiemersmaDither(Image *,CacheView *,CubeInfo *,const unsigned int);
 
 static void Riemersma(Image *image,CacheView *image_view,CubeInfo *cube_info,
-  const unsigned long level,const unsigned int direction)
+  const size_t level,const unsigned int direction)
 {
   if (level == 1)
     switch (direction)
@@ -1621,12 +1621,12 @@
   register CubeInfo
     *p;
 
-  unsigned long
+  size_t
     index;
 
   p=cube_info;
-  if ((p->x >= 0) && (p->x < (long) image->columns) &&
-      (p->y >= 0) && (p->y < (long) image->rows))
+  if ((p->x >= 0) && (p->x < (ssize_t) image->columns) &&
+      (p->y >= 0) && (p->y < (ssize_t) image->rows))
     {
       ExceptionInfo
         *exception;
@@ -1634,7 +1634,7 @@
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         i;
 
       register PixelPacket
@@ -1662,7 +1662,7 @@
       pixel.blue=(MagickRealType) ClampToUnsignedQuantum(pixel.blue);
       if (cube_info->associate_alpha != MagickFalse)
         pixel.opacity=(MagickRealType) ClampToUnsignedQuantum(pixel.opacity);
-      i=(long) ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.red)) >> CacheShift) |
+      i=(ssize_t) ((ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.red)) >> CacheShift) |
         (ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.green)) >> CacheShift) << 6 |
         (ScaleQuantumToChar(ClampToUnsignedQuantum(pixel.blue)) >> CacheShift) << 12);
       if (cube_info->associate_alpha != MagickFalse)
@@ -1673,14 +1673,14 @@
           register NodeInfo
             *node_info;
 
-          register unsigned long
+          register size_t
             id;
 
           /*
             Identify the deepest node containing the pixel's color.
           */
           node_info=p->root;
-          for (index=MaxTreeDepth-1; (long) index > 0; index--)
+          for (index=MaxTreeDepth-1; (ssize_t) index > 0; index--)
           {
             id=ColorToNodeId(cube_info,&pixel,index);
             if (node_info->child[id] == (NodeInfo *) NULL)
@@ -1694,12 +1694,12 @@
           p->distance=(MagickRealType) (4.0*(QuantumRange+1.0)*((MagickRealType)
             QuantumRange+1.0)+1.0);
           ClosestColor(image,p,node_info->parent);
-          p->cache[i]=(long) p->color_number;
+          p->cache[i]=(ssize_t) p->color_number;
         }
       /*
         Assign pixel to closest colormap entry.
       */
-      index=(unsigned long) (1*p->cache[i]);
+      index=(size_t) (1*p->cache[i]);
       if (image->storage_class == PseudoClass)
         *indexes=(IndexPacket) index;
       if (cube_info->quantize_info->measure_error == MagickFalse)
@@ -1738,14 +1738,14 @@
   return(MagickTrue);
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -1760,25 +1760,25 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     depth;
 
   if (cube_info->quantize_info->dither_method == FloydSteinbergDitherMethod)
     return(FloydSteinbergDither(image,cube_info));
   /*
-    Distribute quantization error along a Hilbert curve.
+    Distribute quantization error assize_t a Hilbert curve.
   */
   (void) ResetMagickMemory(cube_info->error,0,ErrorQueueLength*
     sizeof(*cube_info->error));
   cube_info->x=0;
   cube_info->y=0;
-  i=MagickMax((long) image->columns,(long) image->rows);
+  i=MagickMax((ssize_t) image->columns,(ssize_t) image->rows);
   for (depth=1; i != 0; depth++)
     i>>=1;
-  if ((long) (1L << depth) < MagickMax((long) image->columns,(long) image->rows))
+  if ((ssize_t) (1L << depth) < MagickMax((ssize_t) image->columns,(ssize_t) image->rows))
     depth++;
   cube_info->offset=0;
   cube_info->span=(MagickSizeType) image->columns*image->rows;
@@ -1806,7 +1806,7 @@
 %  The format of the GetCubeInfo method is:
 %
 %      CubeInfo GetCubeInfo(const QuantizeInfo *quantize_info,
-%        const unsigned long depth,const unsigned long maximum_colors)
+%        const size_t depth,const size_t maximum_colors)
 %
 %  A description of each parameter follows.
 %
@@ -1825,7 +1825,7 @@
 %
 */
 static CubeInfo *GetCubeInfo(const QuantizeInfo *quantize_info,
-  const unsigned long depth,const unsigned long maximum_colors)
+  const size_t depth,const size_t maximum_colors)
 {
   CubeInfo
     *cube_info;
@@ -1837,7 +1837,7 @@
   size_t
     length;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1867,17 +1867,17 @@
     Initialize dither resources.
   */
   length=(size_t) (1UL << (4*(8-CacheShift)));
-  cube_info->cache=(long *) AcquireQuantumMemory(length,
+  cube_info->cache=(ssize_t *) AcquireQuantumMemory(length,
     sizeof(*cube_info->cache));
-  if (cube_info->cache == (long *) NULL)
+  if (cube_info->cache == (ssize_t *) NULL)
     return((CubeInfo *) NULL);
   /*
     Initialize color cache.
   */
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
     cube_info->cache[i]=(-1);
   /*
-    Distribute weights along a curve of exponential decay.
+    Distribute weights assize_t a curve of exponential decay.
   */
   weight=1.0;
   for (i=0; i < ErrorQueueLength; i++)
@@ -1917,8 +1917,8 @@
 %
 %  The format of the GetNodeInfo method is:
 %
-%      NodeInfo *GetNodeInfo(CubeInfo *cube_info,const unsigned long id,
-%        const unsigned long level,NodeInfo *parent)
+%      NodeInfo *GetNodeInfo(CubeInfo *cube_info,const size_t id,
+%        const size_t level,NodeInfo *parent)
 %
 %  A description of each parameter follows.
 %
@@ -1929,8 +1929,8 @@
 %    o level: Specifies the level in the storage_class the node resides.
 %
 */
-static NodeInfo *GetNodeInfo(CubeInfo *cube_info,const unsigned long id,
-  const unsigned long level,NodeInfo *parent)
+static NodeInfo *GetNodeInfo(CubeInfo *cube_info,const size_t id,
+  const size_t level,NodeInfo *parent)
 {
   NodeInfo
     *node_info;
@@ -2015,7 +2015,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     y;
 
   MagickRealType
@@ -2027,7 +2027,7 @@
     mean_error,
     mean_error_per_pixel;
 
-  unsigned long
+  size_t
     index;
 
   assert(image != (Image *) NULL);
@@ -2046,19 +2046,19 @@
   mean_error=0.0;
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       index=1UL*indexes[x];
       if (image->matte != MagickFalse)
@@ -2144,7 +2144,7 @@
 %
 %  The format of the PosterizeImage method is:
 %
-%      MagickBooleanType PosterizeImage(Image *image,const unsigned long levels,
+%      MagickBooleanType PosterizeImage(Image *image,const size_t levels,
 %        const MagickBooleanType dither)
 %
 %  A description of each parameter follows:
@@ -2159,7 +2159,7 @@
 %
 */
 MagickExport MagickBooleanType PosterizeImage(Image *image,
-  const unsigned long levels,const MagickBooleanType dither)
+  const size_t levels,const MagickBooleanType dither)
 {
   CacheView
     *posterize_view;
@@ -2173,7 +2173,7 @@
   IndexPacket
     *indexes;
 
-  long
+  ssize_t
     j,
     k,
     l,
@@ -2185,7 +2185,7 @@
   QuantizeInfo
     *quantize_info;
 
-  register long
+  register ssize_t
     i;
 
   register PixelPacket
@@ -2202,9 +2202,9 @@
   if (posterize_image == (Image *) NULL)
     return(MagickFalse);
   l=1;
-  while ((l*l*l) < (long) MagickMin((long) levels*levels*levels,MaxColormapSize+1))
+  while ((l*l*l) < (ssize_t) MagickMin((ssize_t) levels*levels*levels,MaxColormapSize+1))
     l++;
-  status=SetImageExtent(posterize_image,(unsigned long) (l*l*l),1);
+  status=SetImageExtent(posterize_image,(size_t) (l*l*l),1);
   if (status == MagickFalse)
     {
       posterize_image=DestroyImage(posterize_image);
@@ -2292,17 +2292,17 @@
   NodeInfo
     *parent;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       PruneChild(image,cube_info,node_info->child[i]);
   /*
@@ -2349,17 +2349,17 @@
 static void PruneLevel(const Image *image,CubeInfo *cube_info,
   const NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       PruneLevel(image,cube_info,node_info->child[i]);
   if (node_info->level == cube_info->depth)
@@ -2396,17 +2396,17 @@
 static void PruneToCubeDepth(const Image *image,CubeInfo *cube_info,
   const NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       PruneToCubeDepth(image,cube_info,node_info->child[i]);
   if (node_info->level > cube_info->depth)
@@ -2447,26 +2447,26 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_colors;
 
   status=MagickTrue;
-  number_colors=(unsigned long) (image->columns*image->rows);
+  number_colors=(size_t) (image->columns*image->rows);
   if (AcquireImageColormap(image,number_colors) == MagickFalse)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   i=0;
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       proceed;
@@ -2477,14 +2477,14 @@
     register PixelPacket
       *restrict q;
 
-    register long
+    register ssize_t
       x;
 
     q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
     if (q == (const PixelPacket *) NULL)
       break;
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       indexes[x]=i;
       image->colormap[i++]=(*q++);
@@ -2508,7 +2508,7 @@
   MagickBooleanType
     status;
 
-  unsigned long
+  size_t
     depth,
     maximum_colors;
 
@@ -2534,7 +2534,7 @@
   depth=quantize_info->tree_depth;
   if (depth == 0)
     {
-      unsigned long
+      size_t
         colors;
 
       /*
@@ -2612,10 +2612,10 @@
   MagickProgressMonitor
     progress_monitor;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     depth,
     maximum_colors,
     number_images;
@@ -2643,7 +2643,7 @@
   depth=quantize_info->tree_depth;
   if (depth == 0)
     {
-      unsigned long
+      size_t
         colors;
 
       /*
@@ -2736,17 +2736,17 @@
 static void Reduce(const Image *image,CubeInfo *cube_info,
   const NodeInfo *node_info)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_children;
 
   /*
     Traverse any children.
   */
   number_children=cube_info->associate_alpha == MagickFalse ? 8UL : 16UL;
-  for (i=0; i < (long) number_children; i++)
+  for (i=0; i < (ssize_t) number_children; i++)
     if (node_info->child[i] != (NodeInfo *) NULL)
       Reduce(image,cube_info,node_info->child[i]);
   if (node_info->quantize_error <= cube_info->pruning_threshold)
@@ -2827,7 +2827,7 @@
   MagickOffsetType
     offset;
 
-  unsigned long
+  size_t
     span;
 
   cube_info->next_threshold=0.0;
@@ -3018,7 +3018,7 @@
 
 static int IntensityCompare(const void *x,const void *y)
 {
-  long
+  ssize_t
     intensity;
 
   PixelPacket
@@ -3027,7 +3027,7 @@
 
   color_1=(PixelPacket *) x;
   color_2=(PixelPacket *) y;
-  intensity=PixelIntensityToQuantum(color_1)-(long)
+  intensity=PixelIntensityToQuantum(color_1)-(ssize_t)
     PixelIntensityToQuantum(color_2);
   return(intensity);
 }
@@ -3044,17 +3044,17 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     j,
     y;
 
   PixelPacket
     *colormap;
 
-  long
+  ssize_t
     *colormap_index;
 
-  register long
+  register ssize_t
     i;
 
   MagickBooleanType
@@ -3064,9 +3064,9 @@
   assert(image->signature == MagickSignature);
   if (image->type != GrayscaleType)
     (void) TransformImageColorspace(image,GRAYColorspace);
-  colormap_index=(long *) AcquireQuantumMemory(MaxMap+1,
+  colormap_index=(ssize_t *) AcquireQuantumMemory(MaxMap+1,
     sizeof(*colormap_index));
-  if (colormap_index == (long *) NULL)
+  if (colormap_index == (ssize_t *) NULL)
     ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
       image->filename);
   if (image->storage_class != PseudoClass)
@@ -3074,7 +3074,7 @@
       ExceptionInfo
         *exception;
 
-      for (i=0; i <= (long) MaxMap; i++)
+      for (i=0; i <= (ssize_t) MaxMap; i++)
         colormap_index[i]=(-1);
       if (AcquireImageColormap(image,MaxMap+1) == MagickFalse)
         ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
@@ -3086,12 +3086,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           x;
 
         register const PixelPacket
@@ -3107,9 +3107,9 @@
             continue;
           }
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
-          register unsigned long
+          register size_t
             intensity;
 
           intensity=ScaleQuantumToMap(q->red);
@@ -3120,7 +3120,7 @@
 #endif
               if (colormap_index[intensity] < 0)
                 {
-                  colormap_index[intensity]=(long) image->colors;
+                  colormap_index[intensity]=(ssize_t) image->colors;
                   image->colormap[image->colors]=(*q);
                   image->colors++;
                }
@@ -3133,7 +3133,7 @@
       }
       image_view=DestroyCacheView(image_view);
     }
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < (ssize_t) image->colors; i++)
     image->colormap[i].opacity=(unsigned short) i;
   qsort((void *) image->colormap,image->colors,sizeof(PixelPacket),
     IntensityCompare);
@@ -3144,16 +3144,16 @@
       image->filename);
   j=0;
   colormap[j]=image->colormap[0];
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < (ssize_t) image->colors; i++)
   {
     if (IsSameColor(image,&colormap[j],&image->colormap[i]) == MagickFalse)
       {
         j++;
         colormap[j]=image->colormap[i];
       }
-    colormap_index[(long) image->colormap[i].opacity]=j;
+    colormap_index[(ssize_t) image->colormap[i].opacity]=j;
   }
-  image->colors=(unsigned long) (j+1);
+  image->colors=(size_t) (j+1);
   image->colormap=(PixelPacket *) RelinquishMagickMemory(image->colormap);
   image->colormap=colormap;
   status=MagickTrue;
@@ -3162,12 +3162,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register const PixelPacket
@@ -3182,13 +3182,13 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       indexes[x]=(IndexPacket) colormap_index[ScaleQuantumToMap(indexes[x])];
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
       status=MagickFalse;
   }
   image_view=DestroyCacheView(image_view);
-  colormap_index=(long *) RelinquishMagickMemory(colormap_index);
+  colormap_index=(ssize_t *) RelinquishMagickMemory(colormap_index);
   image->type=GrayscaleType;
   if (IsMonochromeImage(image,&image->exception) != MagickFalse)
     image->type=BilevelType;
diff --git a/magick/quantize.h b/magick/quantize.h
index 6efd04d..26e4a34 100644
--- a/magick/quantize.h
+++ b/magick/quantize.h
@@ -34,10 +34,10 @@
 
 typedef struct _QuantizeInfo
 {
-  unsigned long
+  size_t
     number_colors;
 
-  unsigned long
+  size_t
     tree_depth;
 
   MagickBooleanType
@@ -49,7 +49,7 @@
   MagickBooleanType
     measure_error;
 
-  unsigned long
+  size_t
     signature;
 
   DitherMethod
@@ -59,7 +59,7 @@
 extern MagickExport MagickBooleanType
   CompressImageColormap(Image *),
   GetImageQuantizeError(Image *),
-  PosterizeImage(Image *,const unsigned long,const MagickBooleanType),
+  PosterizeImage(Image *,const size_t,const MagickBooleanType),
   QuantizeImage(const QuantizeInfo *,Image *),
   QuantizeImages(const QuantizeInfo *,Image *),
   RemapImage(const QuantizeInfo *,Image *,const Image *),
diff --git a/magick/quantum-export.c b/magick/quantum-export.c
index 88c28a2..0278ec7 100644
--- a/magick/quantum-export.c
+++ b/magick/quantum-export.c
@@ -173,19 +173,19 @@
 }
 
 static inline unsigned char *PopQuantumPixel(QuantumState *quantum_state,
-  const unsigned long depth,const QuantumAny pixel,unsigned char *pixels)
+  const size_t depth,const QuantumAny pixel,unsigned char *pixels)
 {
-  register long
+  register ssize_t
     i;
 
-  register unsigned long
+  register size_t
     quantum_bits;
 
   if (quantum_state->bits == 0UL)
     quantum_state->bits=8UL;
-  for (i=(long) depth; i > 0L; )
+  for (i=(ssize_t) depth; i > 0L; )
   {
-    quantum_bits=(unsigned long) i;
+    quantum_bits=(size_t) i;
     if (quantum_bits > quantum_state->bits)
       quantum_bits=quantum_state->bits;
     i-=quantum_bits;
@@ -204,19 +204,19 @@
 }
 
 static inline unsigned char *PopQuantumLongPixel(QuantumState *quantum_state,
-  const unsigned long depth,const unsigned long pixel,unsigned char *pixels)
+  const size_t depth,const size_t pixel,unsigned char *pixels)
 {
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     quantum_bits;
 
   if (quantum_state->bits == 0UL)
     quantum_state->bits=32UL;
-  for (i=(long) depth; i > 0; )
+  for (i=(ssize_t) depth; i > 0; )
   {
-    quantum_bits=(unsigned long) i;
+    quantum_bits=(size_t) i;
     if (quantum_bits > quantum_state->bits)
       quantum_bits=quantum_state->bits;
     quantum_state->pixel|=(((pixel >> (depth-i)) &
@@ -240,7 +240,7 @@
   EndianType
     endian;
 
-  long
+  ssize_t
     bit;
 
   MagickRealType
@@ -261,7 +261,7 @@
   register const PixelPacket
     *restrict p;
 
-  register long
+  register ssize_t
     x;
 
   register unsigned char
@@ -301,7 +301,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         alpha=QuantumScale*((double) QuantumRange-q->opacity);
         q->red=ClampToQuantum(alpha*q->red);
@@ -318,7 +318,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         q->opacity=(Quantum) GetAlphaPixelComponent(q);
         q++;
@@ -335,7 +335,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=GetAuthenticPixelQueue(image);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         quantum=q->red;
         q->red=q->green;
@@ -365,7 +365,7 @@
           register unsigned char
             pixel;
 
-          for (x=((long) number_pixels-7); x > 0; x-=8)
+          for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
           {
             pixel=(unsigned char) *indexes++;
             *q=((pixel & 0x01) << 7);
@@ -388,7 +388,7 @@
           if ((number_pixels % 8) != 0)
             {
               *q='\0';
-              for (bit=7; bit >= (long) (8-(number_pixels % 8)); bit--)
+              for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
               {
                 pixel=(unsigned char) *indexes++;
                 *q|=((pixel & 0x01) << (unsigned char) bit);
@@ -402,7 +402,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) (number_pixels-1) ; x+=2)
+          for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
           {
             pixel=(unsigned char) *indexes++;
             *q=((pixel & 0xf) << 4);
@@ -420,7 +420,7 @@
         }
         case 8:
         {
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopCharPixel((unsigned char) indexes[x],q);
             q+=quantum_info->pad;
@@ -431,7 +431,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopShortPixel(endian,SinglePrecisionToHalf(QuantumScale*
                   indexes[x]),q);
@@ -439,7 +439,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopShortPixel(endian,(unsigned short) indexes[x],q);
             q+=quantum_info->pad;
@@ -450,7 +450,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
                 p++;
@@ -458,9 +458,9 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
-            q=PopLongPixel(endian,(unsigned long) indexes[x],q);
+            q=PopLongPixel(endian,(size_t) indexes[x],q);
             q+=quantum_info->pad;
           }
           break;
@@ -469,7 +469,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
                 p++;
@@ -480,7 +480,7 @@
         }
         default:
         {
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,indexes[x],q);
             p++;
@@ -506,7 +506,7 @@
           register unsigned char
             pixel;
 
-          for (x=((long) number_pixels-3); x > 0; x-=4)
+          for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
           {
             pixel=(unsigned char) *indexes++;
             *q=((pixel & 0x01) << 7);
@@ -537,7 +537,7 @@
           if ((number_pixels % 4) != 0)
             {
               *q='\0';
-              for (bit=3; bit >= (long) (4-(number_pixels % 4)); bit-=2)
+              for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
               {
                 pixel=(unsigned char) *indexes++;
                 *q|=((pixel & 0x01) << (unsigned char) (bit+4));
@@ -555,7 +555,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels ; x++)
+          for (x=0; x < (ssize_t) number_pixels ; x++)
           {
             pixel=(unsigned char) *indexes++;
             *q=((pixel & 0xf) << 4);
@@ -572,7 +572,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopCharPixel((unsigned char) indexes[x],q);
             pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
@@ -590,7 +590,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopShortPixel(endian,(unsigned short) indexes[x],q);
                 pixel=SinglePrecisionToHalf(QuantumScale*
@@ -601,7 +601,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopShortPixel(endian,(unsigned short) indexes[x],q);
             pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
@@ -614,12 +614,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -632,9 +632,9 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
-            q=PopLongPixel(endian,(unsigned long) indexes[x],q);
+            q=PopLongPixel(endian,(size_t) indexes[x],q);
             pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
               GetOpacityPixelComponent(p)));
             q=PopLongPixel(endian,pixel,q);
@@ -647,7 +647,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 double
                   pixel;
@@ -664,7 +664,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,indexes[x],q);
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
@@ -698,7 +698,7 @@
               white=0x00;
             }
           threshold=(Quantum) (QuantumRange/2);
-          for (x=((long) number_pixels-7); x > 0; x-=8)
+          for (x=((ssize_t) number_pixels-7); x > 0; x-=8)
           {
             *q='\0';
             *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 7;
@@ -722,7 +722,7 @@
           if ((number_pixels % 8) != 0)
             {
               *q='\0';
-              for (bit=7; bit >= (long) (8-(number_pixels % 8)); bit--)
+              for (bit=7; bit >= (ssize_t) (8-(number_pixels % 8)); bit--)
               {
                 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) <<
                   bit;
@@ -737,7 +737,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) (number_pixels-1) ; x+=2)
+          for (x=0; x < (ssize_t) (number_pixels-1) ; x+=2)
           {
             pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
             *q=(((pixel >> 4) & 0xf) << 4);
@@ -761,7 +761,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
             q=PopCharPixel(pixel,q);
@@ -775,12 +775,12 @@
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              register unsigned long
+              register size_t
                 pixel;
 
-              for (x=0; x < (long) (number_pixels-2); x+=3)
+              for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
               {
-                pixel=(unsigned long) (
+                pixel=(size_t) (
                   ScaleQuantumToAny(PixelIntensityToQuantum(p+2),range) << 22 |
                   ScaleQuantumToAny(PixelIntensityToQuantum(p+1),range) << 12 |
                   ScaleQuantumToAny(PixelIntensityToQuantum(p+0),range) << 2);
@@ -789,16 +789,16 @@
                 q+=quantum_info->pad;
               }
               pixel=0UL;
-              if (x++ < (long) (number_pixels-1))
+              if (x++ < (ssize_t) (number_pixels-1))
                 pixel|=ScaleQuantumToAny(PixelIntensityToQuantum(p+1),
                   range) << 12;
-              if (x++ < (long) number_pixels)
+              if (x++ < (ssize_t) number_pixels)
                 pixel|=ScaleQuantumToAny(PixelIntensityToQuantum(p+0),
                   range) << 2;
               q=PopLongPixel(endian,pixel,q);
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               PixelIntensityToQuantum(p),range),q);
@@ -815,7 +815,7 @@
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
                 q=PopShortPixel(endian,(unsigned short) (pixel >> 4),q);
@@ -824,7 +824,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               PixelIntensityToQuantum(p),range),q);
@@ -840,7 +840,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   PixelIntensityToQuantum(p));
@@ -850,7 +850,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
             q=PopShortPixel(endian,pixel,q);
@@ -861,12 +861,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -878,7 +878,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(PixelIntensityToQuantum(p));
             q=PopLongPixel(endian,pixel,q);
@@ -891,7 +891,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 double
                   pixel;
@@ -907,7 +907,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               PixelIntensityToQuantum(p),range),q);
@@ -941,7 +941,7 @@
               white=0x00;
             }
           threshold=(Quantum) (QuantumRange/2);
-          for (x=((long) number_pixels-3); x > 0; x-=4)
+          for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
           {
             *q='\0';
             *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) << 7;
@@ -965,7 +965,7 @@
           if ((number_pixels % 4) != 0)
             {
               *q='\0';
-              for (bit=3; bit >= (long) (4-(number_pixels % 4)); bit-=2)
+              for (bit=3; bit >= (ssize_t) (4-(number_pixels % 4)); bit-=2)
               {
                 *q|=(PixelIntensityToQuantum(p) < threshold ? black : white) <<
                   (bit+4);
@@ -984,7 +984,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels ; x++)
+          for (x=0; x < (ssize_t) number_pixels ; x++)
           {
             pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
             *q=(((pixel >> 4) & 0xf) << 4);
@@ -1001,7 +1001,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(PixelIntensityToQuantum(p));
             q=PopCharPixel(pixel,q);
@@ -1020,7 +1020,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   PixelIntensityToQuantum(p));
@@ -1033,7 +1033,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(PixelIntensityToQuantum(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1047,12 +1047,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -1066,7 +1066,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(PixelIntensityToQuantum(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1082,7 +1082,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 double
                   pixel;
@@ -1100,7 +1100,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               PixelIntensityToQuantum(p),range),q);
@@ -1124,7 +1124,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -1140,7 +1140,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetRedPixelComponent(p));
@@ -1150,7 +1150,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1161,12 +1161,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->red,q);
                 p++;
@@ -1174,7 +1174,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1187,7 +1187,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->red,q);
                 p++;
@@ -1199,7 +1199,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->red,range),q);
@@ -1221,7 +1221,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetGreenPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -1237,7 +1237,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetGreenPixelComponent(p));
@@ -1247,7 +1247,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetGreenPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1258,12 +1258,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->green,q);
                 p++;
@@ -1271,7 +1271,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetGreenPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1284,7 +1284,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->green,q);
                 p++;
@@ -1296,7 +1296,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->green,range),q);
@@ -1318,7 +1318,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetBluePixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -1334,7 +1334,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetBluePixelComponent(p));
@@ -1344,7 +1344,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetBluePixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1355,12 +1355,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->blue,q);
                 p++;
@@ -1368,7 +1368,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetBluePixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1381,7 +1381,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->blue,q);
                 p++;
@@ -1393,7 +1393,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->blue,range),q);
@@ -1414,7 +1414,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar((Quantum) (QuantumRange-
               GetOpacityPixelComponent(p)));
@@ -1431,7 +1431,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetAlphaPixelComponent(p));
@@ -1441,7 +1441,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort((Quantum) (QuantumRange-
               GetOpacityPixelComponent(p)));
@@ -1453,12 +1453,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -1470,7 +1470,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong((Quantum) (QuantumRange-
               GetOpacityPixelComponent(p)));
@@ -1484,7 +1484,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 double
                   pixel;
@@ -1500,7 +1500,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               (Quantum) (GetAlphaPixelComponent(p)),range),q);
@@ -1521,7 +1521,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetOpacityPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -1537,7 +1537,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetOpacityPixelComponent(p));
@@ -1547,7 +1547,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetOpacityPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1558,12 +1558,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->opacity,q);
                 p++;
@@ -1571,7 +1571,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetOpacityPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1584,7 +1584,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->opacity,q);
                 p++;
@@ -1596,7 +1596,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->opacity,range),q);
@@ -1623,7 +1623,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(indexes[x]);
             q=PopCharPixel(pixel,q);
@@ -1639,7 +1639,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*indexes[x]);
                 q=PopShortPixel(endian,pixel,q);
@@ -1648,7 +1648,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(indexes[x]);
             q=PopShortPixel(endian,pixel,q);
@@ -1659,12 +1659,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) indexes[x],q);
                 p++;
@@ -1672,7 +1672,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(indexes[x]);
             q=PopLongPixel(endian,pixel,q);
@@ -1685,7 +1685,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) indexes[x],q);
                 p++;
@@ -1697,7 +1697,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               (Quantum) indexes[x],range),q);
@@ -1716,7 +1716,7 @@
       {
         case 8:
         {
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopCharPixel(ScaleQuantumToChar(GetRedPixelComponent(p)),q);
             q=PopCharPixel(ScaleQuantumToChar(GetGreenPixelComponent(p)),q);
@@ -1728,15 +1728,15 @@
         }
         case 10:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
-                pixel=(unsigned long) (ScaleQuantumToAny(p->red,range) << 22 |
+                pixel=(size_t) (ScaleQuantumToAny(p->red,range) << 22 |
                   ScaleQuantumToAny(p->green,range) << 12 |
                   ScaleQuantumToAny(p->blue,range) << 2);
                 q=PopLongPixel(endian,pixel,q);
@@ -1747,26 +1747,26 @@
             }
           if (quantum_info->quantum == 32UL)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
-                pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                pixel=(size_t) ScaleQuantumToAny(p->red,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                pixel=(size_t) ScaleQuantumToAny(p->green,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
                 p++;
                 q+=quantum_info->pad;
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
-            pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+            pixel=(size_t) ScaleQuantumToAny(p->red,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+            pixel=(size_t) ScaleQuantumToAny(p->green,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+            pixel=(size_t) ScaleQuantumToAny(p->blue,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
             p++;
             q+=quantum_info->pad;
@@ -1775,30 +1775,30 @@
         }
         case 12:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              for (x=0; x < (long) (3*number_pixels-1); x+=2)
+              for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
               {
                 switch (x % 3)
                 {
                   default:
                   case 0:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->red,range);
                     break;
                   }
                   case 1:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->green,range);
                     break;
                   }
                   case 2:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                     p++;
                     break;
                   }
@@ -1809,17 +1809,17 @@
                   default:
                   case 0:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->red,range);
                     break;
                   }
                   case 1:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->green,range);
                     break;
                   }
                   case 2:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                     p++;
                     break;
                   }
@@ -1827,24 +1827,24 @@
                 q=PopShortPixel(endian,(unsigned short) (pixel << 4),q);
                 q+=quantum_info->pad;
               }
-              for (bit=0; bit < (long) (3*number_pixels % 2); bit++)
+              for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
               {
                 switch ((x+bit) % 3)
                 {
                   default:
                   case 0:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->red,range);
                     break;
                   }
                   case 1:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->green,range);
                     break;
                   }
                   case 2:
                   {
-                    pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                    pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                     p++;
                     break;
                   }
@@ -1858,26 +1858,26 @@
             }
           if (quantum_info->quantum == 32UL)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
-                pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                pixel=(size_t) ScaleQuantumToAny(p->red,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                pixel=(size_t) ScaleQuantumToAny(p->green,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
                 p++;
                 q+=quantum_info->pad;
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
-            pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+            pixel=(size_t) ScaleQuantumToAny(p->red,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+            pixel=(size_t) ScaleQuantumToAny(p->green,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+            pixel=(size_t) ScaleQuantumToAny(p->blue,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
             p++;
             q+=quantum_info->pad;
@@ -1891,7 +1891,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetRedPixelComponent(p));
@@ -1907,7 +1907,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -1922,12 +1922,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->red,q);
                 q=PopFloatPixel(&quantum_state,(float) p->green,q);
@@ -1937,7 +1937,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -1954,7 +1954,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->red,q);
                 q=PopDoublePixel(&quantum_state,(double) p->green,q);
@@ -1968,7 +1968,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->red,range),q);
@@ -1995,7 +1995,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -2012,25 +2012,25 @@
         }
         case 10:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              long
+              ssize_t
                 n;
 
-              register long
+              register ssize_t
                 i;
 
-              unsigned long
+              size_t
                 quantum;
 
               n=0;
               quantum=0;
               pixel=0;
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 for (i=0; i < 4; i++)
                 {
@@ -2045,19 +2045,19 @@
                   {
                     case 0:
                     {
-                      pixel|=(unsigned long) (ScaleQuantumToAny(quantum,
+                      pixel|=(size_t) (ScaleQuantumToAny(quantum,
                         range) << 22);
                       break;
                     }
                     case 1:
                     {
-                      pixel|=(unsigned long) (ScaleQuantumToAny(quantum,
+                      pixel|=(size_t) (ScaleQuantumToAny(quantum,
                         range) << 12);
                       break;
                     }
                     case 2:
                     {
-                      pixel|=(unsigned long) (ScaleQuantumToAny(quantum,
+                      pixel|=(size_t) (ScaleQuantumToAny(quantum,
                         range) << 2);
                       q=PopLongPixel(endian,pixel,q);
                       pixel=0;
@@ -2073,15 +2073,15 @@
             }
           if (quantum_info->quantum == 32UL)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
-                pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+                pixel=(size_t) ScaleQuantumToAny(p->red,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+                pixel=(size_t) ScaleQuantumToAny(p->green,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+                pixel=(size_t) ScaleQuantumToAny(p->blue,range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
-                pixel=(unsigned long) ScaleQuantumToAny(QuantumRange-p->opacity,
+                pixel=(size_t) ScaleQuantumToAny(QuantumRange-p->opacity,
                   range);
                 q=PopQuantumLongPixel(&quantum_state,image->depth,pixel,q);
                 p++;
@@ -2089,15 +2089,15 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
-            pixel=(unsigned long) ScaleQuantumToAny(p->red,range);
+            pixel=(size_t) ScaleQuantumToAny(p->red,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->green,range);
+            pixel=(size_t) ScaleQuantumToAny(p->green,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(p->blue,range);
+            pixel=(size_t) ScaleQuantumToAny(p->blue,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
-            pixel=(unsigned long) ScaleQuantumToAny(QuantumRange-
+            pixel=(size_t) ScaleQuantumToAny(QuantumRange-
               p->opacity,range);
             q=PopQuantumPixel(&quantum_state,image->depth,pixel,q);
             p++;
@@ -2112,7 +2112,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetRedPixelComponent(p));
@@ -2131,7 +2131,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -2148,12 +2148,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -2168,7 +2168,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -2190,7 +2190,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->red,q);
                 q=PopDoublePixel(&quantum_state,(double) p->green,q);
@@ -2206,7 +2206,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               GetRedPixelComponent(p),range),q);
@@ -2239,7 +2239,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -2261,7 +2261,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetRedPixelComponent(p));
@@ -2279,7 +2279,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -2296,12 +2296,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopFloatPixel(&quantum_state,(float) p->red,q);
                 q=PopFloatPixel(&quantum_state,(float) p->green,q);
@@ -2312,7 +2312,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -2331,7 +2331,7 @@
         {
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->red,q);
                 q=PopDoublePixel(&quantum_state,(double) p->green,q);
@@ -2346,7 +2346,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->red,range),q);
@@ -2380,7 +2380,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToChar(GetRedPixelComponent(p));
             q=PopCharPixel(pixel,q);
@@ -2405,7 +2405,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 pixel=SinglePrecisionToHalf(QuantumScale*
                   GetRedPixelComponent(p));
@@ -2426,7 +2426,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToShort(GetRedPixelComponent(p));
             q=PopShortPixel(endian,pixel,q);
@@ -2446,12 +2446,12 @@
         }
         case 32:
         {
-          register unsigned long
+          register size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 float
                   pixel;
@@ -2467,7 +2467,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=ScaleQuantumToLong(GetRedPixelComponent(p));
             q=PopLongPixel(endian,pixel,q);
@@ -2492,7 +2492,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 q=PopDoublePixel(&quantum_state,(double) p->red,q);
                 q=PopDoublePixel(&quantum_state,(double) p->green,q);
@@ -2509,7 +2509,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             q=PopQuantumPixel(&quantum_state,image->depth,ScaleQuantumToAny(
               p->red,range),q);
@@ -2531,19 +2531,19 @@
     }
     case CbYCrYQuantum:
     {
-     long
+     ssize_t
         n;
 
       Quantum
         cbcr[4];
 
-      register long
+      register ssize_t
         i;
 
-      register unsigned long
+      register size_t
         pixel;
 
-      unsigned long
+      size_t
         quantum;
 
       n=0;
@@ -2555,7 +2555,7 @@
         {
           if (quantum_info->pack == MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x+=2)
+              for (x=0; x < (ssize_t) number_pixels; x+=2)
               {
                 for (i=0; i < 4; i++)
                 {
@@ -2580,14 +2580,14 @@
                   cbcr[i]=(Quantum) quantum;
                   n++;
                 }
-                pixel=(unsigned long) ((unsigned long) (cbcr[1]) << 22 |
-                  (unsigned long) (cbcr[0]) << 12 |
-                  (unsigned long) (cbcr[2]) << 2);
+                pixel=(size_t) ((size_t) (cbcr[1]) << 22 |
+                  (size_t) (cbcr[0]) << 12 |
+                  (size_t) (cbcr[2]) << 2);
                 q=PopLongPixel(endian,pixel,q);
                 p++;
-                pixel=(unsigned long) ((unsigned long) (cbcr[3]) << 22 |
-                  (unsigned long) (cbcr[0]) << 12 |
-                  (unsigned long) (cbcr[2]) << 2);
+                pixel=(size_t) ((size_t) (cbcr[3]) << 22 |
+                  (size_t) (cbcr[0]) << 12 |
+                  (size_t) (cbcr[2]) << 2);
                 q=PopLongPixel(endian,pixel,q);
                 p++;
                 q+=quantum_info->pad;
@@ -2598,7 +2598,7 @@
         }
         default:
         {
-          for (x=0; x < (long) number_pixels; x+=2)
+          for (x=0; x < (ssize_t) number_pixels; x+=2)
           {
             for (i=0; i < 4; i++)
             {
@@ -2658,7 +2658,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         quantum=q->red;
         q->red=q->green;
@@ -2674,7 +2674,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=(PixelPacket *) GetCacheViewVirtualPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         q->opacity=(Quantum) GetAlphaPixelComponent(q);
         q++;
diff --git a/magick/quantum-import.c b/magick/quantum-import.c
index a7f35a9..06a0097 100644
--- a/magick/quantum-import.c
+++ b/magick/quantum-import.c
@@ -111,7 +111,7 @@
 */
 
 static inline IndexPacket PushColormapIndex(Image *image,
-  const unsigned long index,MagickBooleanType *range_exception)
+  const size_t index,MagickBooleanType *range_exception)
 {
   if (index < image->colors)
     return((IndexPacket) index);
@@ -192,24 +192,24 @@
 }
 
 static inline const unsigned char *PushQuantumPixel(
-  QuantumState *quantum_state,const unsigned long depth,
-  const unsigned char *pixels,unsigned long *quantum)
+  QuantumState *quantum_state,const size_t depth,
+  const unsigned char *pixels,size_t *quantum)
 {
-  register long
+  register ssize_t
     i;
 
-  register unsigned long
+  register size_t
     quantum_bits;
 
   *quantum=(QuantumAny) 0;
-  for (i=(long) depth; i > 0L; )
+  for (i=(ssize_t) depth; i > 0L; )
   {
     if (quantum_state->bits == 0UL)
       {
         quantum_state->pixel=(*pixels++);
         quantum_state->bits=8UL;
       }
-    quantum_bits=(unsigned long) i;
+    quantum_bits=(size_t) i;
     if (quantum_bits > quantum_state->bits)
       quantum_bits=quantum_state->bits;
     i-=quantum_bits;
@@ -221,17 +221,17 @@
 }
 
 static inline const unsigned char *PushQuantumLongPixel(
-  QuantumState *quantum_state,const unsigned long depth,
-  const unsigned char *pixels,unsigned long *quantum)
+  QuantumState *quantum_state,const size_t depth,
+  const unsigned char *pixels,size_t *quantum)
 {
-  register long
+  register ssize_t
     i;
 
-  register unsigned long
+  register size_t
     quantum_bits;
 
   *quantum=0UL;
-  for (i=(long) depth; i > 0; )
+  for (i=(ssize_t) depth; i > 0; )
   {
     if (quantum_state->bits == 0)
       {
@@ -239,7 +239,7 @@
           &quantum_state->pixel);
         quantum_state->bits=32UL;
       }
-    quantum_bits=(unsigned long) i;
+    quantum_bits=(size_t) i;
     if (quantum_bits > quantum_state->bits)
       quantum_bits=quantum_state->bits;
     *quantum|=(((quantum_state->pixel >> (32UL-quantum_state->bits)) &
@@ -257,7 +257,7 @@
   EndianType
     endian;
 
-  long
+  ssize_t
     bit;
 
   MagickSizeType
@@ -275,7 +275,7 @@
   register IndexPacket
     *restrict indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -284,7 +284,7 @@
   size_t
     extent;
 
-  unsigned long
+  size_t
     pixel;
 
   assert(image != (Image *) NULL);
@@ -333,7 +333,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < ((long) number_pixels-7); x+=8)
+          for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
             {
@@ -344,12 +344,12 @@
                 pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
                   0x00 : 0x01);
               indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
-              *q=image->colormap[(long) indexes[x+bit]];
+              *q=image->colormap[(ssize_t) indexes[x+bit]];
               q++;
             }
             p++;
           }
-          for (bit=0; bit < (long) (number_pixels % 8); bit++)
+          for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
           {
             if (quantum_info->min_is_white == MagickFalse)
               pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
@@ -358,7 +358,7 @@
               pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ?
                 0x00 : 0x01);
             indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x+bit]];
+            *q=image->colormap[(ssize_t) indexes[x+bit]];
             q++;
           }
           break;
@@ -368,23 +368,23 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < ((long) number_pixels-1); x+=2)
+          for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
           {
             pixel=(unsigned char) ((*p >> 4) & 0xf);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             q++;
             pixel=(unsigned char) ((*p) & 0xf);
             indexes[x+1]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x+1]];
+            *q=image->colormap[(ssize_t) indexes[x+1]];
             p++;
             q++;
           }
-          for (bit=0; bit < (long) (number_pixels % 2); bit++)
+          for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
           {
             pixel=(unsigned char) ((*p++ >> 4) & 0xf);
             indexes[x+bit]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x+bit]];
+            *q=image->colormap[(ssize_t) indexes[x+bit]];
             q++;
           }
           break;
@@ -394,11 +394,11 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p+=quantum_info->pad;
             q++;
           }
@@ -411,23 +411,23 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(
                   (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p+=quantum_info->pad;
                 q++;
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p+=quantum_info->pad;
             q++;
           }
@@ -435,7 +435,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -443,22 +443,22 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p+=quantum_info->pad;
                 q++;
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p+=quantum_info->pad;
             q++;
           }
@@ -471,12 +471,12 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p+=quantum_info->pad;
                 q++;
               }
@@ -485,11 +485,11 @@
         }
         default:
         {
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p+=quantum_info->pad;
             q++;
           }
@@ -520,7 +520,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < ((long) number_pixels-3); x+=4)
+          for (x=0; x < ((ssize_t) number_pixels-3); x+=4)
           {
             for (bit=0; bit < 8; bit+=2)
             {
@@ -539,7 +539,7 @@
               q++;
             }
           }
-          for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
+          for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
           {
             if (quantum_info->min_is_white == MagickFalse)
               pixel=(unsigned char) (((*p) & (1 << (7-bit))) == 0 ?
@@ -563,11 +563,11 @@
             pixel;
 
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=(unsigned char) ((*p >> 4) & 0xf);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             pixel=(unsigned char) ((*p) & 0xf);
             q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
             p++;
@@ -580,11 +580,11 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p=PushCharPixel(p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
             p+=quantum_info->pad;
@@ -599,13 +599,13 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(
                   (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p=PushShortPixel(endian,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
                   (MagickRealType) QuantumRange*HalfToSinglePrecision(pixel)));
@@ -614,11 +614,11 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p=PushShortPixel(endian,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
             p+=quantum_info->pad;
@@ -628,7 +628,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -636,12 +636,12 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
                 p+=quantum_info->pad;
@@ -649,11 +649,11 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p=PushLongPixel(endian,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
             p+=quantum_info->pad;
@@ -668,12 +668,12 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 indexes[x]=PushColormapIndex(image,ClampToQuantum(pixel),
                   &range_exception);
-                *q=image->colormap[(long) indexes[x]];
+                *q=image->colormap[(ssize_t) indexes[x]];
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
                 p+=quantum_info->pad;
@@ -685,11 +685,11 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             indexes[x]=PushColormapIndex(image,pixel,&range_exception);
-            *q=image->colormap[(long) indexes[x]];
+            *q=image->colormap[(ssize_t) indexes[x]];
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
             p+=quantum_info->pad;
@@ -720,7 +720,7 @@
               black=(Quantum) QuantumRange;
               white=0;
             }
-          for (x=0; x < ((long) number_pixels-7); x+=8)
+          for (x=0; x < ((ssize_t) number_pixels-7); x+=8)
           {
             for (bit=0; bit < 8; bit++)
             {
@@ -731,7 +731,7 @@
             }
             p++;
           }
-          for (bit=0; bit < (long) (number_pixels % 8); bit++)
+          for (bit=0; bit < (ssize_t) (number_pixels % 8); bit++)
           {
             q->red=(((*p) & (1 << (7-bit))) == 0 ? black : white);
             q->green=q->red;
@@ -748,7 +748,7 @@
             pixel;
 
           range=GetQuantumRange(image->depth);
-          for (x=0; x < ((long) number_pixels-1); x+=2)
+          for (x=0; x < ((ssize_t) number_pixels-1); x+=2)
           {
             pixel=(unsigned char) ((*p >> 4) & 0xf);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -762,7 +762,7 @@
             p++;
             q++;
           }
-          for (bit=0; bit < (long) (number_pixels % 2); bit++)
+          for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
           {
             pixel=(unsigned char) (*p++ >> 4);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -779,7 +779,7 @@
 
           if (quantum_info->min_is_white != MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushCharPixel(p,&pixel);
                 q->red=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
@@ -791,7 +791,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -810,7 +810,7 @@
             {
               if (image->endian != LSBEndian)
                 {
-                  for (x=0; x < (long) (number_pixels-2); x+=3)
+                  for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
                   {
                     p=PushLongPixel(endian,p,&pixel);
                     q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
@@ -828,14 +828,14 @@
                     q++;
                   }
                   p=PushLongPixel(endian,p,&pixel);
-                  if (x++ < (long) (number_pixels-1))
+                  if (x++ < (ssize_t) (number_pixels-1))
                     {
                       q->red=ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range);
                       q->green=q->red;
                       q->blue=q->red;
                       q++;
                     }
-                  if (x++ < (long) number_pixels)
+                  if (x++ < (ssize_t) number_pixels)
                     {
                       q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
                       q->green=q->red;
@@ -844,7 +844,7 @@
                     }
                   break;
                 }
-              for (x=0; x < (long) (number_pixels-2); x+=3)
+              for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
               {
                 p=PushLongPixel(endian,p,&pixel);
                 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
@@ -862,14 +862,14 @@
                 q++;
               }
               p=PushLongPixel(endian,p,&pixel);
-              if (x++ < (long) (number_pixels-1))
+              if (x++ < (ssize_t) (number_pixels-1))
                 {
                   q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
                   q->green=q->red;
                   q->blue=q->red;
                   q++;
                 }
-              if (x++ < (long) number_pixels)
+              if (x++ < (ssize_t) number_pixels)
                 {
                   q->red=ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range);
                   q->green=q->red;
@@ -878,7 +878,7 @@
                 }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -897,7 +897,7 @@
               unsigned short
                 pixel;
 
-              for (x=0; x < (long) (number_pixels-1); x+=2)
+              for (x=0; x < (ssize_t) (number_pixels-1); x+=2)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
@@ -911,7 +911,7 @@
                 p+=quantum_info->pad;
                 q++;
               }
-              for (bit=0; bit < (long) (number_pixels % 2); bit++)
+              for (bit=0; bit < (ssize_t) (number_pixels % 2); bit++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ScaleAnyToQuantum((QuantumAny) (pixel >> 4),range);
@@ -924,7 +924,7 @@
                 p++;
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -942,7 +942,7 @@
 
           if (quantum_info->min_is_white != MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
@@ -955,7 +955,7 @@
             }
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -967,7 +967,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -980,7 +980,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -988,7 +988,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -999,7 +999,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -1017,7 +1017,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -1032,7 +1032,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1055,7 +1055,7 @@
           register unsigned char
             pixel;
 
-          for (x=0; x < ((long) number_pixels-3); x+=4)
+          for (x=0; x < ((ssize_t) number_pixels-3); x+=4)
           {
             for (bit=0; bit < 8; bit+=2)
             {
@@ -1070,7 +1070,7 @@
             }
             p++;
           }
-          for (bit=0; bit < (long) (number_pixels % 4); bit+=2)
+          for (bit=0; bit < (ssize_t) (number_pixels % 4); bit+=2)
           {
             pixel=(unsigned char) (((*p) & (1 << (7-bit))) != 0 ? 0x00 : 0x01);
             q->red=(Quantum) (pixel == 0 ? 0 : QuantumRange);
@@ -1090,7 +1090,7 @@
             pixel;
 
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             pixel=(unsigned char) ((*p >> 4) & 0xf);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1108,7 +1108,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -1124,7 +1124,7 @@
         case 10:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1140,7 +1140,7 @@
         case 12:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1160,7 +1160,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1175,7 +1175,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -1190,7 +1190,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1198,7 +1198,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -1211,7 +1211,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -1231,7 +1231,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -1248,7 +1248,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1274,7 +1274,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -1290,7 +1290,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1300,7 +1300,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -1311,7 +1311,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1319,7 +1319,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -1328,7 +1328,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -1344,7 +1344,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -1357,7 +1357,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1379,7 +1379,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetGreenPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -1395,7 +1395,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->green=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1405,7 +1405,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetGreenPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -1416,7 +1416,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1424,7 +1424,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->green=ClampToQuantum(pixel);
@@ -1433,7 +1433,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetGreenPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -1449,7 +1449,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->green=ClampToQuantum(pixel);
@@ -1462,7 +1462,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetGreenPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1484,7 +1484,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetBluePixelComponent(q,ScaleCharToQuantum(pixel));
@@ -1500,7 +1500,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->blue=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1510,7 +1510,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetBluePixelComponent(q,ScaleShortToQuantum(pixel));
@@ -1521,7 +1521,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1529,7 +1529,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->blue=ClampToQuantum(pixel);
@@ -1538,7 +1538,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetBluePixelComponent(q,ScaleLongToQuantum(pixel));
@@ -1554,7 +1554,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->blue=ClampToQuantum(pixel);
@@ -1567,7 +1567,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetBluePixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1588,7 +1588,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(pixel));
@@ -1604,7 +1604,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(
@@ -1614,7 +1614,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleShortToQuantum(pixel));
@@ -1625,7 +1625,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1633,7 +1633,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
@@ -1642,7 +1642,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleLongToQuantum(pixel));
@@ -1658,7 +1658,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->opacity=(Quantum) (QuantumRange-ClampToQuantum(pixel));
@@ -1671,7 +1671,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel,range));
@@ -1698,7 +1698,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             indexes[x]=ScaleCharToQuantum(pixel);
@@ -1713,7 +1713,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 indexes[x]=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1722,7 +1722,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             indexes[x]=ScaleShortToQuantum(pixel);
@@ -1732,7 +1732,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -1740,7 +1740,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 indexes[x]=ClampToQuantum(pixel);
@@ -1749,7 +1749,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             indexes[x]=ScaleLongToQuantum(pixel);
@@ -1765,7 +1765,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 indexes[x]=ClampToQuantum(pixel);
@@ -1778,7 +1778,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             indexes[x]=ScaleAnyToQuantum(pixel,range);
@@ -1800,7 +1800,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -1819,7 +1819,7 @@
           range=GetQuantumRange(image->depth);
           if (quantum_info->pack == MagickFalse)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushLongPixel(endian,p,&pixel);
                 q->red=ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range);
@@ -1832,7 +1832,7 @@
             }
           if (quantum_info->quantum == 32UL)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
                 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1844,7 +1844,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1864,7 +1864,7 @@
               unsigned short
                 pixel;
 
-              for (x=0; x < (long) (3*number_pixels-1); x+=2)
+              for (x=0; x < (ssize_t) (3*number_pixels-1); x+=2)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 switch (x % 3)
@@ -1910,7 +1910,7 @@
                 }
                 p+=quantum_info->pad;
               }
-              for (bit=0; bit < (long) (3*number_pixels % 2); bit++)
+              for (bit=0; bit < (ssize_t) (3*number_pixels % 2); bit++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 switch ((x+bit) % 3)
@@ -1941,7 +1941,7 @@
             }
           if (quantum_info->quantum == 32UL)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushQuantumLongPixel(&quantum_state,image->depth,p,&pixel);
                 SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1953,7 +1953,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -1972,7 +1972,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -1988,7 +1988,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -2003,7 +2003,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -2011,7 +2011,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2024,7 +2024,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -2044,7 +2044,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2061,7 +2061,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -2087,7 +2087,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -2107,18 +2107,18 @@
           pixel=0;
           if (quantum_info->pack == MagickFalse)
             {
-              long
+              ssize_t
                 n;
 
-              register long
+              register ssize_t
                 i;
 
-              unsigned long
+              size_t
                 quantum;
 
               n=0;
               quantum=0;
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 for (i=0; i < 4; i++)
                 {
@@ -2127,19 +2127,19 @@
                     case 0:
                     {
                       p=PushLongPixel(endian,p,&pixel);
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
                       break;
                     }
                     case 1:
                     {
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
                       break;
                     }
                     case 2:
                     {
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
                       break;
                     }
@@ -2158,7 +2158,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             q->red=ScaleShortToQuantum((unsigned short) (pixel << 6));
@@ -2180,7 +2180,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -2199,7 +2199,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -2216,7 +2216,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -2224,7 +2224,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2239,7 +2239,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -2261,7 +2261,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2280,7 +2280,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -2312,7 +2312,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -2334,7 +2334,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -2353,7 +2353,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -2370,7 +2370,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -2378,7 +2378,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2393,7 +2393,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -2415,7 +2415,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2434,7 +2434,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -2467,7 +2467,7 @@
           unsigned char
             pixel;
 
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushCharPixel(p,&pixel);
             SetRedPixelComponent(q,ScaleCharToQuantum(pixel));
@@ -2491,7 +2491,7 @@
 
           if (quantum_info->format == FloatingPointQuantumFormat)
             {
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushShortPixel(endian,p,&pixel);
                 q->red=ClampToQuantum((MagickRealType) QuantumRange*
@@ -2513,7 +2513,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushShortPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleShortToQuantum(pixel));
@@ -2532,7 +2532,7 @@
         }
         case 32:
         {
-          unsigned long
+          size_t
             pixel;
 
           if (quantum_info->format == FloatingPointQuantumFormat)
@@ -2540,7 +2540,7 @@
               float
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushFloatPixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2557,7 +2557,7 @@
               }
               break;
             }
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushLongPixel(endian,p,&pixel);
             SetRedPixelComponent(q,ScaleLongToQuantum(pixel));
@@ -2581,7 +2581,7 @@
               double
                 pixel;
 
-              for (x=0; x < (long) number_pixels; x++)
+              for (x=0; x < (ssize_t) number_pixels; x++)
               {
                 p=PushDoublePixel(&quantum_state,p,&pixel);
                 q->red=ClampToQuantum(pixel);
@@ -2603,7 +2603,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -2634,18 +2634,18 @@
           pixel=0;
           if (quantum_info->pack == MagickFalse)
             {
-              long
+              ssize_t
                 n;
 
-              register long
+              register ssize_t
                 i;
 
-              unsigned long
+              size_t
                 quantum;
 
               n=0;
               quantum=0;
-              for (x=0; x < (long) number_pixels; x+=2)
+              for (x=0; x < (ssize_t) number_pixels; x+=2)
               {
                 for (i=0; i < 4; i++)
                 {
@@ -2654,19 +2654,19 @@
                     case 0:
                     {
                       p=PushLongPixel(endian,p,&pixel);
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 22) & 0x3ff) << 6)));
                       break;
                     }
                     case 1:
                     {
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 12) & 0x3ff) << 6)));
                       break;
                     }
                     case 2:
                     {
-                      quantum=(unsigned long) (ScaleShortToQuantum(
+                      quantum=(size_t) (ScaleShortToQuantum(
                         (unsigned short) (((pixel >> 2) & 0x3ff) << 6)));
                       break;
                     }
@@ -2690,7 +2690,7 @@
         default:
         {
           range=GetQuantumRange(image->depth);
-          for (x=0; x < (long) number_pixels; x++)
+          for (x=0; x < (ssize_t) number_pixels; x++)
           {
             p=PushQuantumPixel(&quantum_state,image->depth,p,&pixel);
             SetRedPixelComponent(q,ScaleAnyToQuantum(pixel,range));
@@ -2717,7 +2717,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=GetCacheViewAuthenticPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         quantum=q->red;
         q->red=q->green;
@@ -2733,7 +2733,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=GetCacheViewAuthenticPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         q->opacity=(Quantum) GetAlphaPixelComponent(q);
         q++;
@@ -2753,7 +2753,7 @@
       q=GetAuthenticPixelQueue(image);
       if (image_view != (CacheView *) NULL)
         q=GetCacheViewAuthenticPixelQueue(image_view);
-      for (x=0; x < (long) number_pixels; x++)
+      for (x=0; x < (ssize_t) number_pixels; x++)
       {
         alpha=QuantumScale*((MagickRealType) QuantumRange-q->opacity);
         alpha=1.0/(fabs(alpha) <= MagickEpsilon ? 1.0 : alpha);
diff --git a/magick/quantum-private.h b/magick/quantum-private.h
index 4211476..d56a3e9 100644
--- a/magick/quantum-private.h
+++ b/magick/quantum-private.h
@@ -34,17 +34,17 @@
     scale,
     inverse_scale;
 
-  unsigned long
+  size_t
     pixel,
     bits;
 
-  const unsigned long
+  const size_t
     *mask;
 } QuantumState;
 
 struct _QuantumInfo
 {
-  unsigned long
+  size_t
     depth,
     quantum;
 
@@ -66,7 +66,7 @@
   QuantumAlphaType
     alpha_type;
 
-  unsigned long
+  size_t
     number_threads;
 
   unsigned char
@@ -78,11 +78,11 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
-static inline MagickSizeType GetQuantumRange(const unsigned long depth)
+static inline MagickSizeType GetQuantumRange(const size_t depth)
 {
   return((MagickSizeType) ((MagickULLConstant(1) << (depth-1))+
     ((MagickULLConstant(1) << (depth-1))-1)));
@@ -179,7 +179,7 @@
 static inline void InitializeQuantumState(const QuantumInfo *quantum_info,
   const EndianType endian,QuantumState *quantum_state)
 {
-  static const unsigned long mask[32] =
+  static const size_t mask[32] =
   {
     0x00000000UL, 0x00000001UL, 0x00000003UL, 0x00000007UL, 0x0000000fUL,
     0x0000001fUL, 0x0000003fUL, 0x0000007fUL, 0x000000ffUL, 0x000001ffUL,
@@ -209,7 +209,7 @@
 }
 
 static inline unsigned char *PopLongPixel(const EndianType endian,
-  const unsigned long pixel,unsigned char *pixels)
+  const size_t pixel,unsigned char *pixels)
 {
   register unsigned int
     quantum;
@@ -256,7 +256,7 @@
 }
 
 static inline const unsigned char *PushLongPixel(const EndianType endian,
-  const unsigned char *pixels,unsigned long *pixel)
+  const unsigned char *pixels,size_t *pixel)
 {
   register unsigned int
     quantum;
@@ -275,7 +275,7 @@
       quantum|=(unsigned int) (*pixels++ << 16);
       quantum|=(unsigned int) (*pixels++ << 24);
     }
-  *pixel=(unsigned long) (quantum & 0xffffffff);
+  *pixel=(size_t) (quantum & 0xffffffff);
   return(pixels);
 }
 
@@ -321,7 +321,7 @@
   return((Quantum) value);
 }
 
-static inline Quantum ScaleLongToQuantum(const unsigned long value)
+static inline Quantum ScaleLongToQuantum(const size_t value)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) ((value+8421504UL)/16843009UL));
@@ -343,29 +343,29 @@
 #endif
 }
 
-static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
+static inline size_t ScaleQuantumToLong(const Quantum quantum)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) (16843009UL*quantum));
+  return((size_t) (16843009UL*quantum));
 #else
   if (quantum <= 0.0)
     return(0UL);
   if ((16843009.0*quantum) >= 4294967295.0)
     return(4294967295UL);
-  return((unsigned long) (16843009.0*quantum+0.5));
+  return((size_t) (16843009.0*quantum+0.5));
 #endif
 }
 
-static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
+static inline size_t ScaleQuantumToMap(const Quantum quantum)
 {
   if (quantum >= (Quantum) MaxMap)
-    return((unsigned long) MaxMap);
+    return((size_t) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) quantum);
+  return((size_t) quantum);
 #else
   if (quantum < 0.0)
     return(0UL);
-  return((unsigned long) (quantum+0.5));
+  return((size_t) (quantum+0.5));
 #endif
 }
 
@@ -400,7 +400,7 @@
 #endif
 }
 
-static inline Quantum ScaleLongToQuantum(const unsigned long value)
+static inline Quantum ScaleLongToQuantum(const size_t value)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
   return((Quantum) ((value+MagickULLConstant(32768))/
@@ -423,29 +423,29 @@
 #endif
 }
 
-static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
+static inline size_t ScaleQuantumToLong(const Quantum quantum)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) (65537UL*quantum));
+  return((size_t) (65537UL*quantum));
 #else
   if (quantum <= 0.0)
     return(0UL);
   if ((65537.0*quantum) >= 4294967295.0)
     return(4294967295UL);
-  return((unsigned long) (65537.0*quantum+0.5));
+  return((size_t) (65537.0*quantum+0.5));
 #endif
 }
 
-static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
+static inline size_t ScaleQuantumToMap(const Quantum quantum)
 {
   if (quantum >= (Quantum) MaxMap)
-    return((unsigned long) MaxMap);
+    return((size_t) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) quantum);
+  return((size_t) quantum);
 #else
   if (quantum < 0.0)
     return(0UL);
-  return((unsigned long) (quantum+0.5));
+  return((size_t) (quantum+0.5));
 #endif
 }
 
@@ -476,7 +476,7 @@
 #endif
 }
 
-static inline Quantum ScaleLongToQuantum(const unsigned long value)
+static inline Quantum ScaleLongToQuantum(const size_t value)
 {
   return((Quantum) value);
 }
@@ -494,26 +494,26 @@
 #endif
 }
 
-static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
+static inline size_t ScaleQuantumToLong(const Quantum quantum)
 {
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) quantum);
+  return((size_t) quantum);
 #else
-  return((unsigned long) (quantum+0.5));
+  return((size_t) (quantum+0.5));
 #endif
 }
 
-static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
+static inline size_t ScaleQuantumToMap(const Quantum quantum)
 {
   if (quantum < 0.0)
     return(0UL);
   if ((quantum/65537) >= (Quantum) MaxMap)
-    return((unsigned long) MaxMap);
+    return((size_t) MaxMap);
 #if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((unsigned long) ((quantum+MagickULLConstant(32768))/
+  return((size_t) ((quantum+MagickULLConstant(32768))/
     MagickULLConstant(65537)));
 #else
-  return((unsigned long) (quantum/65537.0+0.5));
+  return((size_t) (quantum/65537.0+0.5));
 #endif
 }
 
@@ -545,7 +545,7 @@
   return((Quantum) (72340172838076673.0*value));
 }
 
-static inline Quantum ScaleLongToQuantum(const unsigned long value)
+static inline Quantum ScaleLongToQuantum(const size_t value)
 {
   return((Quantum) (4294967297.0*value));
 }
@@ -559,18 +559,18 @@
   return((Quantum) (281479271743489.0*value));
 }
 
-static inline unsigned long ScaleQuantumToLong(const Quantum quantum)
+static inline size_t ScaleQuantumToLong(const Quantum quantum)
 {
-  return((unsigned long) (quantum/4294967297.0+0.5));
+  return((size_t) (quantum/4294967297.0+0.5));
 }
 
-static inline unsigned long ScaleQuantumToMap(const Quantum quantum)
+static inline size_t ScaleQuantumToMap(const Quantum quantum)
 {
   if (quantum <= 0.0)
     return(0UL);
   if ((quantum/281479271743489.0) >= MaxMap)
-    return((unsigned long) MaxMap);
-  return((unsigned long) (quantum/281479271743489.0+0.5));
+    return((size_t) MaxMap);
+  return((size_t) (quantum/281479271743489.0+0.5));
 }
 
 static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
@@ -625,13 +625,13 @@
   significand=map.fixed_point & 0x007fffff;
   if (exponent <= 0)
     {
-      long
+      ssize_t
         shift;
 
       if (exponent < -10)
         return((unsigned short) sign_bit);
       significand=significand | 0x00800000;
-      shift=14-exponent;
+      shift=(ssize_t) (14-exponent);
       significand=(unsigned int) ((significand+((1 << (shift-1))-1)+
         ((significand >> shift) & 0x01)) >> shift);
       return((unsigned short) (sign_bit | significand));
@@ -660,7 +660,7 @@
       float
         alpha;
 
-      register long
+      register ssize_t
         i;
 
       /*
diff --git a/magick/quantum.c b/magick/quantum.c
index fec235a..9d2e06e 100644
--- a/magick/quantum.c
+++ b/magick/quantum.c
@@ -103,8 +103,8 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
@@ -161,7 +161,7 @@
 static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
   const size_t extent)
 {
-  register long
+  register ssize_t
     i;
 
   assert(quantum_info != (QuantumInfo *) NULL);
@@ -174,7 +174,7 @@
   quantum_info->extent=extent;
   (void) ResetMagickMemory(quantum_info->pixels,0,
     sizeof(*quantum_info->pixels));
-  for (i=0; i < (long) quantum_info->number_threads; i++)
+  for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
   {
     quantum_info->pixels[i]=(unsigned char *) AcquireQuantumMemory(extent+1,
       sizeof(**quantum_info->pixels));
@@ -247,13 +247,13 @@
 */
 static void DestroyQuantumPixels(QuantumInfo *quantum_info)
 {
-  register long
+  register ssize_t
     i;
 
   assert(quantum_info != (QuantumInfo *) NULL);
   assert(quantum_info->signature == MagickSignature);
   assert(quantum_info->pixels != (unsigned char **) NULL);
-  for (i=0; i < (long) quantum_info->number_threads; i++)
+  for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
   {
     /*
       Did we overrun our quantum buffer?
@@ -415,7 +415,7 @@
 */
 MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info)
 {
-  long
+  ssize_t
     id;
 
   assert(quantum_info != (QuantumInfo *) NULL);
@@ -529,7 +529,7 @@
 %  The format of the SetQuantumDepth method is:
 %
 %      MagickBooleanType SetQuantumDepth(const Image *image,
-%        QuantumInfo *quantum_info,const unsigned long depth)
+%        QuantumInfo *quantum_info,const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -541,7 +541,7 @@
 %
 */
 MagickExport MagickBooleanType SetQuantumDepth(const Image *image,
-  QuantumInfo *quantum_info,const unsigned long depth)
+  QuantumInfo *quantum_info,const size_t depth)
 {
   MagickBooleanType
     status;
@@ -730,7 +730,7 @@
 %  The format of the SetQuantumPad method is:
 %
 %      MagickBooleanType SetQuantumPad(const Image *image,
-%        QuantumInfo *quantum_info,const unsigned long pad)
+%        QuantumInfo *quantum_info,const size_t pad)
 %
 %  A description of each parameter follows:
 %
@@ -742,7 +742,7 @@
 %
 */
 MagickExport MagickBooleanType SetQuantumPad(const Image *image,
-  QuantumInfo *quantum_info,const unsigned long pad)
+  QuantumInfo *quantum_info,const size_t pad)
 {
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -803,7 +803,7 @@
 %  The format of the SetQuantumQuantum method is:
 %
 %      void SetQuantumQuantum(QuantumInfo *quantum_info,
-%        const unsigned long quantum)
+%        const size_t quantum)
 %
 %  A description of each parameter follows:
 %
@@ -813,7 +813,7 @@
 %
 */
 MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info,
-  const unsigned long quantum)
+  const size_t quantum)
 {
   assert(quantum_info != (QuantumInfo *) NULL);
   assert(quantum_info->signature == MagickSignature);
diff --git a/magick/quantum.h b/magick/quantum.h
index 330e40d..2c8c72f 100644
--- a/magick/quantum.h
+++ b/magick/quantum.h
@@ -150,9 +150,9 @@
 #endif
 
 extern MagickExport MagickBooleanType
-  SetQuantumDepth(const Image *,QuantumInfo *,const unsigned long),
+  SetQuantumDepth(const Image *,QuantumInfo *,const size_t),
   SetQuantumFormat(const Image *,QuantumInfo *,const QuantumFormatType),
-  SetQuantumPad(const Image *,QuantumInfo *,const unsigned long);
+  SetQuantumPad(const Image *,QuantumInfo *,const size_t);
 
 extern MagickExport QuantumInfo
   *AcquireQuantumInfo(const ImageInfo *,Image *),
@@ -177,7 +177,7 @@
   SetQuantumImageType(Image *,const QuantumType),
   SetQuantumMinIsWhite(QuantumInfo *,const MagickBooleanType),
   SetQuantumPack(QuantumInfo *,const MagickBooleanType),
-  SetQuantumQuantum(QuantumInfo *,const unsigned long),
+  SetQuantumQuantum(QuantumInfo *,const size_t),
   SetQuantumScale(QuantumInfo *,const double);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/random-private.h b/magick/random-private.h
index 3024910..f664f09 100644
--- a/magick/random-private.h
+++ b/magick/random-private.h
@@ -27,11 +27,11 @@
 static inline RandomInfo **DestroyRandomInfoThreadSet(
   RandomInfo **random_info)
 {
-  register long
+  register ssize_t
     i;
 
   assert(random_info != (RandomInfo **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (random_info[i] != (RandomInfo *) NULL)
       random_info[i]=DestroyRandomInfo(random_info[i]);
   return((RandomInfo **) RelinquishAlignedMemory(random_info));
@@ -39,13 +39,13 @@
 
 static inline RandomInfo **AcquireRandomInfoThreadSet(void)
 {
-  register long
+  register ssize_t
     i;
 
   RandomInfo
     **random_info;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -54,7 +54,7 @@
   if (random_info == (RandomInfo **) NULL)
     return((RandomInfo **) NULL);
   (void) ResetMagickMemory(random_info,0,number_threads*sizeof(*random_info));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     random_info[i]=AcquireRandomInfo();
     if (random_info[i] == (RandomInfo *) NULL)
diff --git a/magick/random.c b/magick/random.c
index 4b6fb2b..f7f33d0 100644
--- a/magick/random.c
+++ b/magick/random.c
@@ -84,7 +84,7 @@
   size_t
     i;
 
-  unsigned long
+  size_t
     seed[4];
 
   double
@@ -97,10 +97,10 @@
   SemaphoreInfo
     *semaphore;
 
-  long
+  ssize_t
     timestamp;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -121,7 +121,7 @@
 static SemaphoreInfo
   *random_semaphore = (SemaphoreInfo *) NULL;
 
-static unsigned long
+static size_t
   random_seed = ~0UL;
 
 static MagickBooleanType
@@ -187,7 +187,7 @@
   random_info->semaphore=AllocateSemaphoreInfo();
   random_info->protocol_major=RandomProtocolMajorVersion;
   random_info->protocol_minor=RandomProtocolMinorVersion;
-  random_info->timestamp=(long) time(0);
+  random_info->timestamp=(ssize_t) time(0);
   random_info->signature=MagickSignature;
   /*
     Seed random nonce.
@@ -347,7 +347,7 @@
 {
 #define MaxEntropyExtent  64
 
-  long
+  ssize_t
     pid;
 
   MagickThreadType
@@ -357,7 +357,7 @@
     *chaos,
     *entropy;
 
-  unsigned long
+  size_t
     nanoseconds,
     seconds;
 
@@ -371,7 +371,7 @@
   ConcatenateStringInfo(entropy,chaos);
   SetStringInfoDatum(chaos,(unsigned char *) entropy);
   ConcatenateStringInfo(entropy,chaos);
-  pid=(long) getpid();
+  pid=(ssize_t) getpid();
   SetStringInfoLength(chaos,sizeof(pid));
   SetStringInfoDatum(chaos,(unsigned char *) &pid);
   ConcatenateStringInfo(entropy,chaos);
@@ -511,7 +511,7 @@
     */
     if (environ != (char **) NULL)
       {
-        register long
+        register ssize_t
           i;
 
         /*
@@ -596,16 +596,16 @@
 */
 MagickExport double GetPseudoRandomValue(RandomInfo *random_info)
 {
-  register unsigned long
+  register size_t
     *seed;
 
-  unsigned long
+  size_t
     alpha;
 
   seed=random_info->seed;
   do
   {
-    alpha=(unsigned long) (seed[1] ^ (seed[1] << 11));
+    alpha=(size_t) (seed[1] ^ (seed[1] << 11));
     seed[1]=seed[2];
     seed[2]=seed[3];
     seed[3]=seed[0];
@@ -672,7 +672,7 @@
 */
 MagickExport double GetRandomValue(RandomInfo *random_info)
 {
-  unsigned long
+  size_t
     key,
     range;
 
@@ -749,14 +749,14 @@
 %
 %  The format of the SeedPseudoRandomGenerator method is:
 %
-%      void SeedPseudoRandomGenerator(const unsigned long seed)
+%      void SeedPseudoRandomGenerator(const size_t seed)
 %
 %  A description of each parameter follows:
 %
 %    o seed: the seed.
 %
 */
-MagickExport void SeedPseudoRandomGenerator(const unsigned long seed)
+MagickExport void SeedPseudoRandomGenerator(const size_t seed)
 {
   random_seed=seed;
 }
@@ -791,14 +791,14 @@
 
 static inline void IncrementRandomNonce(StringInfo *nonce)
 {
-  register long
+  register ssize_t
     i;
 
   unsigned char
     *datum;
 
   datum=GetStringInfoDatum(nonce);
-  for (i=(long) (GetStringInfoLength(nonce)-1); i != 0; i--)
+  for (i=(ssize_t) (GetStringInfoLength(nonce)-1); i != 0; i--)
   {
     datum[i]++;
     if (datum[i] != 0)
diff --git a/magick/random_.h b/magick/random_.h
index 3e9d7cd..fd0b542 100644
--- a/magick/random_.h
+++ b/magick/random_.h
@@ -49,7 +49,7 @@
 
 extern MagickExport void
   RandomComponentTerminus(void),
-  SeedPseudoRandomGenerator(const unsigned long),
+  SeedPseudoRandomGenerator(const size_t),
   SetRandomKey(RandomInfo *,const size_t,unsigned char *),
   SetRandomTrueRandom(const MagickBooleanType);
 
diff --git a/magick/registry.c b/magick/registry.c
index 6222cde..2976362 100644
--- a/magick/registry.c
+++ b/magick/registry.c
@@ -62,7 +62,7 @@
   void
     *value;
 
-  unsigned long
+  size_t
     signature;
 } RegistryInfo;
 
diff --git a/magick/resample-private.h b/magick/resample-private.h
index 1a1c8aa..6b97124 100644
--- a/magick/resample-private.h
+++ b/magick/resample-private.h
@@ -27,11 +27,11 @@
 static inline ResampleFilter **DestroyResampleFilterThreadSet(
   ResampleFilter **filter)
 {
-  register long
+  register ssize_t
     i;
 
   assert(filter != (ResampleFilter **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (filter[i] != (ResampleFilter *) NULL)
       filter[i]=DestroyResampleFilter(filter[i]);
   filter=(ResampleFilter **) RelinquishAlignedMemory(filter);
@@ -42,13 +42,13 @@
   const Image *image,const VirtualPixelMethod method,
   const MagickBooleanType interpolate,ExceptionInfo *exception)
 {
-  register long
+  register ssize_t
     i;
 
   ResampleFilter
     **filter;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -57,7 +57,7 @@
   if (filter == (ResampleFilter **) NULL)
     return((ResampleFilter **) NULL);
   (void) ResetMagickMemory(filter,0,number_threads*sizeof(*filter));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     filter[i]=AcquireResampleFilter(image,exception);
     if (filter[i] == (ResampleFilter *) NULL)
diff --git a/magick/resample.c b/magick/resample.c
index 6da3c9b..1408741 100644
--- a/magick/resample.c
+++ b/magick/resample.c
@@ -78,7 +78,7 @@
     debug;
 
   /* Information about image being resampled */
-  long
+  ssize_t
     image_area;
 
   InterpolatePixelMethod
@@ -109,7 +109,7 @@
     filter_lut[WLUT_WIDTH],
     support;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -143,8 +143,8 @@
 %
 %  Usage Example...
 %      resample_filter=AcquireResampleFilter(image,exception);
-%      for (y=0; y < (long) image->rows; y++) {
-%        for (x=0; x < (long) image->columns; x++) {
+%      for (y=0; y < (ssize_t) image->rows; y++) {
+%        for (x=0; x < (ssize_t) image->columns; x++) {
 %          X= ....;   Y= ....;
 %          ScaleResampleFilter(resample_filter, ... scaling vectors ...);
 %          (void) ResamplePixelColor(resample_filter,X,Y,&pixel);
@@ -191,7 +191,7 @@
   resample_filter->debug=IsEventLogging();
   resample_filter->signature=MagickSignature;
 
-  resample_filter->image_area = (long) resample_filter->image->columns *
+  resample_filter->image_area = (ssize_t) resample_filter->image->columns *
     resample_filter->image->rows;
   resample_filter->average_defined = MagickFalse;
 
@@ -352,11 +352,11 @@
   return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
 }
 
-static inline long NearestNeighbor(MagickRealType x)
+static inline ssize_t NearestNeighbor(MagickRealType x)
 {
   if (x >= 0.0)
-    return((long) (x+0.5));
-  return((long) (x-0.5));
+    return((ssize_t) (x+0.5));
+  return((ssize_t) (x-0.5));
 }
 
 static MagickBooleanType InterpolateResampleFilter(
@@ -372,7 +372,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i;
 
   assert(resample_filter != (ResampleFilter *) NULL);
@@ -389,7 +389,7 @@
         alpha[16],
         gamma;
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x)-1,(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x)-1,(ssize_t)
         floor(y)-1,4,4,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -435,7 +435,7 @@
       PointInfo
         delta;
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x)-1,(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x)-1,(ssize_t)
         floor(y)-1,4,4,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -480,7 +480,7 @@
         delta,
         epsilon;
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x),(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x),(ssize_t)
         floor(y),2,2,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -552,8 +552,8 @@
 
       geometry.width=4L;
       geometry.height=4L;
-      geometry.x=(long) floor(x)-1L;
-      geometry.y=(long) floor(y)-1L;
+      geometry.x=(ssize_t) floor(x)-1L;
+      geometry.y=(ssize_t) floor(y)-1L;
       excerpt_image=ExcerptImage(resample_filter->image,&geometry,
         resample_filter->exception);
       if (excerpt_image == (Image *) NULL)
@@ -584,7 +584,7 @@
       MagickPixelPacket
         pixels[1];
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x),(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x),(ssize_t)
         floor(y),1,1,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -609,7 +609,7 @@
         delta,
         luminance;
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x),(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x),(ssize_t)
         floor(y),2,2,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -750,7 +750,7 @@
     }
     case SplineInterpolatePixel:
     {
-      long
+      ssize_t
         j,
         n;
 
@@ -766,7 +766,7 @@
       PointInfo
         delta;
 
-      p=GetCacheViewVirtualPixels(resample_filter->view,(long) floor(x)-1,(long)
+      p=GetCacheViewVirtualPixels(resample_filter->view,(ssize_t) floor(x)-1,(ssize_t)
         floor(y)-1,4,4,resample_filter->exception);
       if (p == (const PixelPacket *) NULL)
         {
@@ -852,7 +852,7 @@
   MagickBooleanType
     status;
 
-  long u,v, uw,v1,v2, hit;
+  ssize_t u,v, uw,v1,v2, hit;
   double u1;
   double U,V,Q,DQ,DDQ;
   double divisor_c,divisor_m;
@@ -1064,11 +1064,11 @@
         u = -By/2A  +/- sqrt(F/A)
     Which has been pre-calculated above.
   */
-  v1 = (long)(v0 - resample_filter->sqrtA);               /* range of scan lines */
-  v2 = (long)(v0 + resample_filter->sqrtA + 1);
+  v1 = (ssize_t)(v0 - resample_filter->sqrtA);               /* range of scan lines */
+  v2 = (ssize_t)(v0 + resample_filter->sqrtA + 1);
 
   u1 = u0 + (v1-v0)*resample_filter->slope - resample_filter->sqrtU; /* start of scanline for v=v1 */
-  uw = (long)(2*resample_filter->sqrtU)+1;       /* width of parallelogram */
+  uw = (ssize_t)(2*resample_filter->sqrtU)+1;       /* width of parallelogram */
 
   /*
     Do weighted resampling of all pixels,  within the scaled ellipse,
@@ -1076,7 +1076,7 @@
   */
   DDQ = 2*resample_filter->A;
   for( v=v1; v<=v2;  v++, u1+=resample_filter->slope ) {
-    u = (long)u1;       /* first pixel in scanline  ( floor(u1) ) */
+    u = (ssize_t)u1;       /* first pixel in scanline  ( floor(u1) ) */
     U = (double)u-u0;   /* location of that pixel, relative to u0,v0 */
     V = (double)v-v0;
 
@@ -1085,7 +1085,7 @@
     DQ = resample_filter->A*(2.0*U+1) + resample_filter->B*V;
 
     /* get the scanline of pixels for this v */
-    pixels=GetCacheViewVirtualPixels(resample_filter->view,u,v,(unsigned long) uw,
+    pixels=GetCacheViewVirtualPixels(resample_filter->view,u,v,(size_t) uw,
       1,resample_filter->exception);
     if (pixels == (const PixelPacket *) NULL)
       return(MagickFalse);
diff --git a/magick/resize.c b/magick/resize.c
index 6fa1914..4bedcf1 100644
--- a/magick/resize.c
+++ b/magick/resize.c
@@ -86,7 +86,7 @@
     blur,           /* x-scale (blur-sharpen) */
     cubic[8];       /* cubic coefficents for smooth Cubic filters */
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -254,14 +254,14 @@
 static MagickRealType Lagrange(const MagickRealType x,
   const ResizeFilter *resize_filter)
 {
-  long
+  ssize_t
     n,
     order;
 
   MagickRealType
     value;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -277,8 +277,8 @@
   */
   if (x > resize_filter->support)
     return(0.0);
-  order=(long) (2.0*resize_filter->window_support);  /* number of pieces */
-  n=(long) ((1.0*order)/2.0+x);  /* which piece does x belong to */
+  order=(ssize_t) (2.0*resize_filter->window_support);  /* number of pieces */
+  n=(ssize_t) ((1.0*order)/2.0+x);  /* which piece does x bessize_t to */
   value=1.0f;
   for (i=0; i < order; i++)
     if (i != n)
@@ -464,7 +464,7 @@
     filter_type,
     window_type;
 
-  long
+  ssize_t
     option;
 
   MagickRealType
@@ -712,7 +712,7 @@
   artifact=GetImageArtifact(image,"filter:lobes");
   if (artifact != (const char *) NULL)
     {
-      long
+      ssize_t
         lobes;
 
       lobes=StringToLong(artifact);
@@ -822,7 +822,7 @@
 %  The format of the AdaptiveResizeImage method is:
 %
 %      Image *AdaptiveResizeImage(const Image *image,
-%        const unsigned long columns,const unsigned long rows,
+%        const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -837,7 +837,7 @@
 %
 */
 MagickExport Image *AdaptiveResizeImage(const Image *image,
-  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
+  const size_t columns,const size_t rows,ExceptionInfo *exception)
 {
 #define AdaptiveResizeImageTag  "Resize/Image"
 
@@ -847,7 +847,7 @@
   Image
     *resize_image;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -890,12 +890,12 @@
     (void) SetResampleFilterInterpolateMethod(resample_filter,
       MeshInterpolatePixel);
   resize_view=AcquireCacheView(resize_image);
-  for (y=0; y < (long) resize_image->rows; y++)
+  for (y=0; y < (ssize_t) resize_image->rows; y++)
   {
     register IndexPacket
       *restrict resize_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -907,7 +907,7 @@
       break;
     resize_indexes=GetCacheViewAuthenticIndexQueue(resize_view);
     offset.y=((MagickRealType) y*image->rows/resize_image->rows);
-    for (x=0; x < (long) resize_image->columns; x++)
+    for (x=0; x < (ssize_t) resize_image->columns; x++)
     {
       offset.x=((MagickRealType) x*image->columns/resize_image->columns);
       (void) ResamplePixelColor(resample_filter,offset.x-0.5,offset.y-0.5,
@@ -973,7 +973,7 @@
     t,
     y;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -997,7 +997,7 @@
     p,
     q;
 
-  register long
+  register ssize_t
     i;
 
   static const double
@@ -1043,7 +1043,7 @@
     p,
     q;
 
-  register long
+  register ssize_t
     i;
 
   static const double
@@ -1083,7 +1083,7 @@
     p,
     q;
 
-  register long
+  register ssize_t
     i;
 
   static const double
@@ -1375,7 +1375,7 @@
   Image
     *resample_image;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -1388,9 +1388,9 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  width=(unsigned long) (x_resolution*image->columns/
+  width=(size_t) (x_resolution*image->columns/
     (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
-  height=(unsigned long) (y_resolution*image->rows/
+  height=(size_t) (y_resolution*image->rows/
     (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
   resample_image=ResizeImage(image,width,height,filter,blur,exception);
   if (resample_image != (Image *) NULL)
@@ -1418,7 +1418,7 @@
 %  The format of the LiquidRescaleImage method is:
 %
 %      Image *LiquidRescaleImage(const Image *image,
-%        const unsigned long columns,const unsigned long rows,
+%        const size_t columns,const size_t rows,
 %        const double delta_x,const double rigidity,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1437,7 +1437,7 @@
 %
 */
 MagickExport Image *LiquidRescaleImage(const Image *image,
-  const unsigned long columns,const unsigned long rows,
+  const size_t columns,const size_t rows,
   const double delta_x,const double rigidity,ExceptionInfo *exception)
 {
 #define LiquidRescaleImageTag  "Rescale/Image"
@@ -1490,7 +1490,7 @@
       Image
         *resize_image;
 
-      unsigned long
+      size_t
         height,
         width;
 
@@ -1589,8 +1589,8 @@
 }
 #else
 MagickExport Image *LiquidRescaleImage(const Image *image,
-  const unsigned long magick_unused(columns),
-  const unsigned long magick_unused(rows),const double magick_unused(delta_x),
+  const size_t magick_unused(columns),
+  const size_t magick_unused(rows),const double magick_unused(delta_x),
   const double magick_unused(rigidity),ExceptionInfo *exception)
 {
   assert(image != (const Image *) NULL);
@@ -1627,8 +1627,8 @@
 %
 %  The format of the ResizeImage method is:
 %
-%      Image *ResizeImage(Image *image,const unsigned long columns,
-%        const unsigned long rows,const FilterTypes filter,const double blur,
+%      Image *ResizeImage(Image *image,const size_t columns,
+%        const size_t rows,const FilterTypes filter,const double blur,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -1653,18 +1653,18 @@
   MagickRealType
     weight;
 
-  long
+  ssize_t
     pixel;
 } ContributionInfo;
 
 static ContributionInfo **DestroyContributionThreadSet(
   ContributionInfo **contribution)
 {
-  register long
+  register ssize_t
     i;
 
   assert(contribution != (ContributionInfo **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (contribution[i] != (ContributionInfo *) NULL)
       contribution[i]=(ContributionInfo *) RelinquishMagickMemory(
         contribution[i]);
@@ -1674,13 +1674,13 @@
 
 static ContributionInfo **AcquireContributionThreadSet(const size_t count)
 {
-  register long
+  register ssize_t
     i;
 
   ContributionInfo
     **contribution;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -1689,7 +1689,7 @@
   if (contribution == (ContributionInfo **) NULL)
     return((ContributionInfo **) NULL);
   (void) ResetMagickMemory(contribution,0,number_threads*sizeof(*contribution));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     contribution[i]=(ContributionInfo *) AcquireQuantumMemory(count,
       sizeof(**contribution));
@@ -1729,7 +1729,7 @@
   ContributionInfo
     **restrict contributions;
 
-  long
+  ssize_t
     x;
 
   MagickBooleanType
@@ -1776,9 +1776,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for shared(status)
 #endif
-  for (x=0; x < (long) resize_image->columns; x++)
+  for (x=0; x < (ssize_t) resize_image->columns; x++)
   {
-    long
+    ssize_t
       n,
       start,
       stop;
@@ -1799,7 +1799,7 @@
     register IndexPacket
       *restrict resize_indexes;
 
-    register long
+    register ssize_t
       y;
 
     register PixelPacket
@@ -1808,8 +1808,8 @@
     if (status == MagickFalse)
       continue;
     center=(MagickRealType) (x+0.5)/x_factor;
-    start=(long) MagickMax(center-support+0.5,0.0);
-    stop=(long) MagickMin(center+support+0.5,(double) image->columns);
+    start=(ssize_t) MagickMax(center-support+0.5,0.0);
+    stop=(ssize_t) MagickMin(center+support+0.5,(double) image->columns);
     density=0.0;
     contribution=contributions[GetOpenMPThreadId()];
     for (n=0; n < (stop-start); n++)
@@ -1821,7 +1821,7 @@
     }
     if ((density != 0.0) && (density != 1.0))
       {
-        register long
+        register ssize_t
           i;
 
         /*
@@ -1832,7 +1832,7 @@
           contribution[i].weight*=density;
       }
     p=GetCacheViewVirtualPixels(image_view,contribution[0].pixel,0,
-      (unsigned long) (contribution[n-1].pixel-contribution[0].pixel+1),
+      (size_t) (contribution[n-1].pixel-contribution[0].pixel+1),
       image->rows,exception);
     q=QueueCacheViewAuthenticPixels(resize_view,x,0,1,resize_image->rows,
       exception);
@@ -1843,9 +1843,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     resize_indexes=GetCacheViewAuthenticIndexQueue(resize_view);
-    for (y=0; y < (long) resize_image->rows; y++)
+    for (y=0; y < (ssize_t) resize_image->rows; y++)
     {
-      long
+      ssize_t
         j;
 
       MagickPixelPacket
@@ -1854,7 +1854,7 @@
       MagickRealType
         alpha;
 
-      register long
+      register ssize_t
         i;
 
       pixel=zero;
@@ -1928,7 +1928,7 @@
       if ((resize_image->storage_class == PseudoClass) &&
           (image->storage_class == PseudoClass))
         {
-          i=(long) (MagickMin(MagickMax(center,(double) start),(double) stop-
+          i=(ssize_t) (MagickMin(MagickMax(center,(double) start),(double) stop-
             1.0)+0.5);
           j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+
             (contribution[i-start].pixel-contribution[0].pixel);
@@ -1971,7 +1971,7 @@
   ContributionInfo
     **restrict contributions;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -2018,9 +2018,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for shared(status)
 #endif
-  for (y=0; y < (long) resize_image->rows; y++)
+  for (y=0; y < (ssize_t) resize_image->rows; y++)
   {
-    long
+    ssize_t
       n,
       start,
       stop;
@@ -2041,7 +2041,7 @@
     register IndexPacket
       *restrict resize_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2050,8 +2050,8 @@
     if (status == MagickFalse)
       continue;
     center=(MagickRealType) (y+0.5)/y_factor;
-    start=(long) MagickMax(center-support+0.5,0.0);
-    stop=(long) MagickMin(center+support+0.5,(double) image->rows);
+    start=(ssize_t) MagickMax(center-support+0.5,0.0);
+    stop=(ssize_t) MagickMin(center+support+0.5,(double) image->rows);
     density=0.0;
     contribution=contributions[GetOpenMPThreadId()];
     for (n=0; n < (stop-start); n++)
@@ -2063,7 +2063,7 @@
     }
     if ((density != 0.0) && (density != 1.0))
       {
-        register long
+        register ssize_t
           i;
 
         /*
@@ -2074,7 +2074,7 @@
           contribution[i].weight*=density;
       }
     p=GetCacheViewVirtualPixels(image_view,0,contribution[0].pixel,
-      image->columns,(unsigned long) (contribution[n-1].pixel-
+      image->columns,(size_t) (contribution[n-1].pixel-
       contribution[0].pixel+1),exception);
     q=QueueCacheViewAuthenticPixels(resize_view,0,y,resize_image->columns,1,
       exception);
@@ -2085,9 +2085,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     resize_indexes=GetCacheViewAuthenticIndexQueue(resize_view);
-    for (x=0; x < (long) resize_image->columns; x++)
+    for (x=0; x < (ssize_t) resize_image->columns; x++)
     {
-      long
+      ssize_t
         j;
 
       MagickPixelPacket
@@ -2096,7 +2096,7 @@
       MagickRealType
         alpha;
 
-      register long
+      register ssize_t
         i;
 
       pixel=zero;
@@ -2104,7 +2104,7 @@
         {
           for (i=0; i < n; i++)
           {
-            j=(long) ((contribution[i].pixel-contribution[0].pixel)*
+            j=(ssize_t) ((contribution[i].pixel-contribution[0].pixel)*
               image->columns+x);
             alpha=contribution[i].weight;
             pixel.red+=alpha*(p+j)->red;
@@ -2121,7 +2121,7 @@
             {
               for (i=0; i < n; i++)
               {
-                j=(long) ((contribution[i].pixel-contribution[0].pixel)*
+                j=(ssize_t) ((contribution[i].pixel-contribution[0].pixel)*
                   image->columns+x);
                 alpha=contribution[i].weight;
                 pixel.index+=alpha*indexes[j];
@@ -2137,7 +2137,7 @@
           gamma=0.0;
           for (i=0; i < n; i++)
           {
-            j=(long) ((contribution[i].pixel-contribution[0].pixel)*
+            j=(ssize_t) ((contribution[i].pixel-contribution[0].pixel)*
               image->columns+x);
             alpha=contribution[i].weight*QuantumScale*
               GetAlphaPixelComponent(p+j);
@@ -2157,7 +2157,7 @@
             {
               for (i=0; i < n; i++)
               {
-                j=(long) ((contribution[i].pixel-contribution[0].pixel)*
+                j=(ssize_t) ((contribution[i].pixel-contribution[0].pixel)*
                   image->columns+x);
                 alpha=contribution[i].weight*QuantumScale*
                   GetAlphaPixelComponent(p+j);
@@ -2170,9 +2170,9 @@
       if ((resize_image->storage_class == PseudoClass) &&
           (image->storage_class == PseudoClass))
         {
-          i=(long) (MagickMin(MagickMax(center,(double) start),(double) stop-
+          i=(ssize_t) (MagickMin(MagickMax(center,(double) start),(double) stop-
             1.0)+0.5);
-          j=(long) ((contribution[i-start].pixel-contribution[0].pixel)*
+          j=(ssize_t) ((contribution[i-start].pixel-contribution[0].pixel)*
             image->columns+x);
           resize_indexes[x]=indexes[j];
         }
@@ -2199,8 +2199,8 @@
   return(status);
 }
 
-MagickExport Image *ResizeImage(const Image *image,const unsigned long columns,
-  const unsigned long rows,const FilterTypes filter,const double blur,
+MagickExport Image *ResizeImage(const Image *image,const size_t columns,
+  const size_t rows,const FilterTypes filter,const double blur,
   ExceptionInfo *exception)
 {
 #define WorkLoadFactor  0.265
@@ -2316,8 +2316,8 @@
 %
 %  The format of the SampleImage method is:
 %
-%      Image *SampleImage(const Image *image,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%      Image *SampleImage(const Image *image,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2330,8 +2330,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *SampleImage(const Image *image,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+MagickExport Image *SampleImage(const Image *image,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
 #define SampleImageTag  "Sample/Image"
 
@@ -2342,7 +2342,7 @@
   Image
     *sample_image;
 
-  long
+  ssize_t
     progress,
     *x_offset,
     y;
@@ -2350,7 +2350,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     x;
 
   /*
@@ -2372,15 +2372,15 @@
   /*
     Allocate scan line buffer and column offset buffers.
   */
-  x_offset=(long *) AcquireQuantumMemory((size_t) sample_image->columns,
+  x_offset=(ssize_t *) AcquireQuantumMemory((size_t) sample_image->columns,
     sizeof(*x_offset));
-  if (x_offset == (long *) NULL)
+  if (x_offset == (ssize_t *) NULL)
     {
       sample_image=DestroyImage(sample_image);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
-  for (x=0; x < (long) sample_image->columns; x++)
-    x_offset[x]=(long) (((MagickRealType) x+0.5)*image->columns/
+  for (x=0; x < (ssize_t) sample_image->columns; x++)
+    x_offset[x]=(ssize_t) (((MagickRealType) x+0.5)*image->columns/
       sample_image->columns);
   /*
     Sample each row.
@@ -2392,9 +2392,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) sample_image->rows; y++)
+  for (y=0; y < (ssize_t) sample_image->rows; y++)
   {
-    long
+    ssize_t
       y_offset;
 
     register const IndexPacket
@@ -2406,7 +2406,7 @@
     register IndexPacket
       *restrict sample_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2414,7 +2414,7 @@
 
     if (status == MagickFalse)
       continue;
-    y_offset=(long) (((MagickRealType) y+0.5)*image->rows/sample_image->rows);
+    y_offset=(ssize_t) (((MagickRealType) y+0.5)*image->rows/sample_image->rows);
     p=GetCacheViewVirtualPixels(image_view,0,y_offset,image->columns,1,
       exception);
     q=QueueCacheViewAuthenticPixels(sample_view,0,y,sample_image->columns,1,
@@ -2429,11 +2429,11 @@
     /*
       Sample each column.
     */
-    for (x=0; x < (long) sample_image->columns; x++)
+    for (x=0; x < (ssize_t) sample_image->columns; x++)
       *q++=p[x_offset[x]];
     if ((image->storage_class == PseudoClass) ||
         (image->colorspace == CMYKColorspace))
-      for (x=0; x < (long) sample_image->columns; x++)
+      for (x=0; x < (ssize_t) sample_image->columns; x++)
         sample_indexes[x]=indexes[x_offset[x]];
     if (SyncCacheViewAuthenticPixels(sample_view,exception) == MagickFalse)
       status=MagickFalse;
@@ -2452,7 +2452,7 @@
   }
   image_view=DestroyCacheView(image_view);
   sample_view=DestroyCacheView(sample_view);
-  x_offset=(long *) RelinquishMagickMemory(x_offset);
+  x_offset=(ssize_t *) RelinquishMagickMemory(x_offset);
   sample_image->type=image->type;
   return(sample_image);
 }
@@ -2472,8 +2472,8 @@
 %
 %  The format of the ScaleImage method is:
 %
-%      Image *ScaleImage(const Image *image,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%      Image *ScaleImage(const Image *image,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2486,8 +2486,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ScaleImage(const Image *image,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+MagickExport Image *ScaleImage(const Image *image,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
 #define ScaleImageTag  "Scale/Image"
 
@@ -2498,7 +2498,7 @@
   Image
     *scale_image;
 
-  long
+  ssize_t
     number_rows,
     y;
 
@@ -2519,7 +2519,7 @@
     scale,
     span;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -2579,7 +2579,7 @@
   i=0;
   image_view=AcquireCacheView(image);
   scale_view=AcquireCacheView(scale_image);
-  for (y=0; y < (long) scale_image->rows; y++)
+  for (y=0; y < (ssize_t) scale_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -2590,7 +2590,7 @@
     register IndexPacket
       *restrict scale_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register MagickPixelPacket
@@ -2615,7 +2615,7 @@
         if (p == (const PixelPacket *) NULL)
           break;
         indexes=GetCacheViewVirtualIndexQueue(image_view);
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           x_vector[x].red=(MagickRealType) GetRedPixelComponent(p);
           x_vector[x].green=(MagickRealType) GetGreenPixelComponent(p);
@@ -2634,7 +2634,7 @@
         */
         while (scale.y < span.y)
         {
-          if ((next_row != MagickFalse) && (number_rows < (long) image->rows))
+          if ((next_row != MagickFalse) && (number_rows < (ssize_t) image->rows))
             {
               /*
                 Read a new scanline.
@@ -2644,7 +2644,7 @@
               if (p == (const PixelPacket *) NULL)
                 break;
               indexes=GetCacheViewVirtualIndexQueue(image_view);
-              for (x=0; x < (long) image->columns; x++)
+              for (x=0; x < (ssize_t) image->columns; x++)
               {
                 x_vector[x].red=(MagickRealType) GetRedPixelComponent(p);
                 x_vector[x].green=(MagickRealType) GetGreenPixelComponent(p);
@@ -2658,7 +2658,7 @@
               }
               number_rows++;
             }
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
           {
             y_vector[x].red+=scale.y*x_vector[x].red;
             y_vector[x].green+=scale.y*x_vector[x].green;
@@ -2672,7 +2672,7 @@
           scale.y=(double) scale_image->rows/(double) image->rows;
           next_row=MagickTrue;
         }
-        if ((next_row != MagickFalse) && (number_rows < (long) image->rows))
+        if ((next_row != MagickFalse) && (number_rows < (ssize_t) image->rows))
           {
             /*
               Read a new scanline.
@@ -2682,7 +2682,7 @@
             if (p == (const PixelPacket *) NULL)
               break;
             indexes=GetCacheViewVirtualIndexQueue(image_view);
-            for (x=0; x < (long) image->columns; x++)
+            for (x=0; x < (ssize_t) image->columns; x++)
             {
               x_vector[x].red=(MagickRealType) GetRedPixelComponent(p);
               x_vector[x].green=(MagickRealType) GetGreenPixelComponent(p);
@@ -2698,7 +2698,7 @@
             next_row=MagickFalse;
           }
         s=scanline;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           pixel.red=y_vector[x].red+span.y*x_vector[x].red;
           pixel.green=y_vector[x].green+span.y*x_vector[x].green;
@@ -2731,7 +2731,7 @@
           Transfer scanline to scaled image.
         */
         s=scanline;
-        for (x=0; x < (long) scale_image->columns; x++)
+        for (x=0; x < (ssize_t) scale_image->columns; x++)
         {
           q->red=ClampToQuantum(s->red);
           q->green=ClampToQuantum(s->green);
@@ -2754,7 +2754,7 @@
         span.x=1.0;
         s=scanline;
         t=scale_scanline;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           scale.x=(double) scale_image->columns/(double) image->columns;
           while (scale.x >= span.x)
@@ -2813,7 +2813,7 @@
             pixel.index+=span.x*s->index;
         }
       if ((next_column == MagickFalse) &&
-          ((long) (t-scale_scanline) < (long) scale_image->columns))
+          ((ssize_t) (t-scale_scanline) < (ssize_t) scale_image->columns))
         {
           t->red=pixel.red;
           t->green=pixel.green;
@@ -2827,7 +2827,7 @@
         Transfer scanline to scaled image.
       */
       t=scale_scanline;
-      for (x=0; x < (long) scale_image->columns; x++)
+      for (x=0; x < (ssize_t) scale_image->columns; x++)
       {
         q->red=ClampToQuantum(t->red);
         q->green=ClampToQuantum(t->green);
@@ -2910,8 +2910,8 @@
 %
 %  The format of the ThumbnailImage method is:
 %
-%      Image *ThumbnailImage(const Image *image,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%      Image *ThumbnailImage(const Image *image,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2925,7 +2925,7 @@
 %
 */
 MagickExport Image *ThumbnailImage(const Image *image,
-  const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
+  const size_t columns,const size_t rows,ExceptionInfo *exception)
 {
 #define SampleFactor  5
 
@@ -2945,7 +2945,7 @@
   struct stat
     attributes;
 
-  unsigned long
+  size_t
     version;
 
   assert(image != (Image *) NULL);
@@ -3002,11 +3002,11 @@
   (void) CopyMagickString(value,image->magick_filename,MaxTextExtent);
   if (GetPathAttributes(image->filename,&attributes) != MagickFalse)
     {
-      (void) FormatMagickString(value,MaxTextExtent,"%ld",(long)
+      (void) FormatMagickString(value,MaxTextExtent,"%ld",(ssize_t)
         attributes.st_mtime);
       (void) SetImageProperty(thumbnail_image,"Thumb::MTime",value);
     }
-  (void) FormatMagickString(value,MaxTextExtent,"%ld",(long)
+  (void) FormatMagickString(value,MaxTextExtent,"%ld",(ssize_t)
     attributes.st_mtime);
   (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
   (void) ConcatenateMagickString(value,"B",MaxTextExtent);
@@ -3049,8 +3049,8 @@
 %
 %  The format of the ZoomImage method is:
 %
-%      Image *ZoomImage(const Image *image,const unsigned long columns,
-%        const unsigned long rows,ExceptionInfo *exception)
+%      Image *ZoomImage(const Image *image,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -3065,8 +3065,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ZoomImage(const Image *image,const unsigned long columns,
-  const unsigned long rows,ExceptionInfo *exception)
+MagickExport Image *ZoomImage(const Image *image,const size_t columns,
+  const size_t rows,ExceptionInfo *exception)
 {
   Image
     *zoom_image;
diff --git a/magick/resize.h b/magick/resize.h
index 511436f..759cd1a 100644
--- a/magick/resize.h
+++ b/magick/resize.h
@@ -23,23 +23,23 @@
 #endif
 
 extern MagickExport Image
-  *AdaptiveResizeImage(const Image *,const unsigned long,const unsigned long,
+  *AdaptiveResizeImage(const Image *,const size_t,const size_t,
     ExceptionInfo *),
-  *LiquidRescaleImage(const Image *,const unsigned long,const unsigned long,
+  *LiquidRescaleImage(const Image *,const size_t,const size_t,
     const double,const double,ExceptionInfo *),
   *MagnifyImage(const Image *,ExceptionInfo *),
   *MinifyImage(const Image *,ExceptionInfo *),
   *ResampleImage(const Image *,const double,const double,const FilterTypes,
     const double,ExceptionInfo *),
-  *ResizeImage(const Image *,const unsigned long,const unsigned long,
+  *ResizeImage(const Image *,const size_t,const size_t,
     const FilterTypes,const double,ExceptionInfo *),
-  *SampleImage(const Image *,const unsigned long,const unsigned long,
+  *SampleImage(const Image *,const size_t,const size_t,
     ExceptionInfo *),
-  *ScaleImage(const Image *,const unsigned long,const unsigned long,
+  *ScaleImage(const Image *,const size_t,const size_t,
     ExceptionInfo *),
-  *ThumbnailImage(const Image *,const unsigned long,const unsigned long,
+  *ThumbnailImage(const Image *,const size_t,const size_t,
     ExceptionInfo *),
-  *ZoomImage(const Image *,const unsigned long,const unsigned long,
+  *ZoomImage(const Image *,const size_t,const size_t,
     ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/magick/resource.c b/magick/resource.c
index d21247d..5bb6e95 100644
--- a/magick/resource.c
+++ b/magick/resource.c
@@ -260,7 +260,7 @@
   }
   UnlockSemaphoreInfo(resource_semaphore);
   (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %sB/%sB/%sB",
-    MagickOptionToMnemonic(MagickResourceOptions,(long) type),resource_request,
+    MagickOptionToMnemonic(MagickResourceOptions,(ssize_t) type),resource_request,
     resource_current,resource_limit);
   return(status);
 }
@@ -424,7 +424,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   static const char
@@ -678,15 +678,15 @@
   (void) FormatMagickSize(resource_info.disk_limit,MagickFalse,disk_limit);
   (void) CopyMagickString(time_limit,"unlimited",MaxTextExtent);
   if (resource_info.time_limit != MagickResourceInfinity)
-    (void) FormatMagickString(time_limit,MaxTextExtent,"%lu",(unsigned long)
+    (void) FormatMagickString(time_limit,MaxTextExtent,"%lu",(size_t)
       resource_info.time_limit);
   (void) fprintf(file,"File         Area       Memory          Map"
     "         Disk    Thread         Time\n");
   (void) fprintf(file,"--------------------------------------------------------"
     "-----------------------\n");
   (void) fprintf(file,"%4lu  %10sB  %10sB  %10sB  %10sB    %6lu  %11s\n",
-    (unsigned long) resource_info.file_limit,area_limit,memory_limit,map_limit,
-    disk_limit,(unsigned long) resource_info.thread_limit,time_limit);
+    (size_t) resource_info.file_limit,area_limit,memory_limit,map_limit,
+    disk_limit,(size_t) resource_info.thread_limit,time_limit);
   (void) fflush(file);
   UnlockSemaphoreInfo(resource_semaphore);
   return(MagickTrue);
@@ -799,7 +799,7 @@
   }
   UnlockSemaphoreInfo(resource_semaphore);
   (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %sB/%sB/%sB",
-    MagickOptionToMnemonic(MagickResourceOptions,(long) type),resource_request,
+    MagickOptionToMnemonic(MagickResourceOptions,(ssize_t) type),resource_request,
     resource_current,resource_limit);
 }
 
@@ -873,8 +873,8 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
@@ -898,7 +898,7 @@
   char
     *limit;
 
-  long
+  ssize_t
     files,
     pages,
     pagesize;
@@ -968,7 +968,7 @@
         resources;
 
       if (getrlimit(RLIMIT_NOFILE,&resources) != -1)
-        files=(long) resources.rlim_cur;
+        files=(ssize_t) resources.rlim_cur;
   }
 #endif
 #if defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
@@ -977,7 +977,7 @@
 #endif
   if (files < 0)
     files=64;
-  (void) SetMagickResourceLimit(FileResource,MagickMax((unsigned long)
+  (void) SetMagickResourceLimit(FileResource,MagickMax((size_t)
     (3*files/4),64));
   limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
   if (limit == (char *) NULL)
@@ -1100,7 +1100,7 @@
     }
     case ThreadResource:
     {
-      SetOpenMPMaximumThreads((unsigned long) limit);
+      SetOpenMPMaximumThreads((size_t) limit);
       resource_info.thread_limit=GetOpenMPMaximumThreads();
       break;
     }
diff --git a/magick/segment.c b/magick/segment.c
index 85953c3..8b6005a 100644
--- a/magick/segment.c
+++ b/magick/segment.c
@@ -122,7 +122,7 @@
   MagickRealType
     center;
 
-  long
+  ssize_t
     index,
     left,
     right;
@@ -138,7 +138,7 @@
     green,
     blue;
 
-  long
+  ssize_t
     count,
     id;
 } Cluster;
@@ -148,7 +148,7 @@
   MagickRealType
     tau;
 
-  long
+  ssize_t
     left,
     right;
 
@@ -185,15 +185,15 @@
   Method prototypes.
 */
 static MagickRealType
-  OptimalTau(const long *,const double,const double,const double,
+  OptimalTau(const ssize_t *,const double,const double,const double,
     const double,short *);
 
-static long
+static ssize_t
   DefineRegion(const short *,ExtentPacket *);
 
 static void
-  InitializeHistogram(const Image *,long **,ExceptionInfo *),
-  ScaleSpace(const long *,const MagickRealType,MagickRealType *),
+  InitializeHistogram(const Image *,ssize_t **,ExceptionInfo *),
+  ScaleSpace(const ssize_t *,const MagickRealType,MagickRealType *),
   ZeroCrossHistogram(MagickRealType *,const MagickRealType,short *);
 
 /*
@@ -208,7 +208,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  Classify() defines one or more classes.  Each pixel is thresholded to
-%  determine which class it belongs to.  If the class is not identified it is
+%  determine which class it bessize_ts to.  If the class is not identified it is
 %  assigned to the closest class based on the fuzzy c-Means technique.
 %
 %  The format of the Classify method is:
@@ -259,7 +259,7 @@
     green,
     red;
 
-  long
+  ssize_t
     count,
     progress,
     y;
@@ -270,13 +270,13 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   register MagickRealType
     *squares;
 
-  unsigned long
+  size_t
     number_clusters;
 
   /*
@@ -350,31 +350,31 @@
   progress=0;
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)
-        if (((long) ScaleQuantumToChar(GetRedPixelComponent(p)) >=
+        if (((ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p)) >=
              (cluster->red.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetRedPixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p)) <=
              (cluster->red.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetGreenPixelComponent(p)) >=
+            ((ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p)) >=
              (cluster->green.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetGreenPixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p)) <=
              (cluster->green.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetBluePixelComponent(p)) >=
+            ((ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p)) >=
              (cluster->blue.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetBluePixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p)) <=
              (cluster->blue.right+SafeMargin)))
           {
             /*
@@ -437,7 +437,7 @@
       last_cluster->next=next_cluster;
     cluster=(Cluster *) RelinquishMagickMemory(cluster);
   }
-  number_clusters=(unsigned long) count;
+  number_clusters=(size_t) count;
   if (verbose != MagickFalse)
     {
       /*
@@ -524,7 +524,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     Cluster
       *cluster;
@@ -535,7 +535,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -550,22 +550,22 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       indexes[x]=(IndexPacket) 0;
       for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)
       {
-        if (((long) ScaleQuantumToChar(q->red) >=
+        if (((ssize_t) ScaleQuantumToChar(q->red) >=
              (cluster->red.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(q->red) <=
+            ((ssize_t) ScaleQuantumToChar(q->red) <=
              (cluster->red.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(q->green) >=
+            ((ssize_t) ScaleQuantumToChar(q->green) >=
              (cluster->green.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(q->green) <=
+            ((ssize_t) ScaleQuantumToChar(q->green) <=
              (cluster->green.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(q->blue) >=
+            ((ssize_t) ScaleQuantumToChar(q->blue) >=
              (cluster->blue.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(q->blue) <=
+            ((ssize_t) ScaleQuantumToChar(q->blue) <=
              (cluster->blue.right+SafeMargin)))
           {
             /*
@@ -584,7 +584,7 @@
             ratio,
             sum;
 
-          register long
+          register ssize_t
             j,
             k;
 
@@ -592,26 +592,26 @@
             Compute fuzzy membership.
           */
           local_minima=0.0;
-          for (j=0; j < (long) image->colors; j++)
+          for (j=0; j < (ssize_t) image->colors; j++)
           {
             sum=0.0;
             p=image->colormap+j;
-            distance_squared=squares[(long) ScaleQuantumToChar(q->red)-
-              (long) ScaleQuantumToChar(GetRedPixelComponent(p))]+
-              squares[(long) ScaleQuantumToChar(q->green)-
-              (long) ScaleQuantumToChar(GetGreenPixelComponent(p))]+
-              squares[(long) ScaleQuantumToChar(q->blue)-
-              (long) ScaleQuantumToChar(GetBluePixelComponent(p))];
+            distance_squared=squares[(ssize_t) ScaleQuantumToChar(q->red)-
+              (ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p))]+
+              squares[(ssize_t) ScaleQuantumToChar(q->green)-
+              (ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p))]+
+              squares[(ssize_t) ScaleQuantumToChar(q->blue)-
+              (ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p))];
             numerator=distance_squared;
-            for (k=0; k < (long) image->colors; k++)
+            for (k=0; k < (ssize_t) image->colors; k++)
             {
               p=image->colormap+k;
-              distance_squared=squares[(long) ScaleQuantumToChar(q->red)-
-                (long) ScaleQuantumToChar(GetRedPixelComponent(p))]+
-                squares[(long) ScaleQuantumToChar(q->green)-
-                (long) ScaleQuantumToChar(GetGreenPixelComponent(p))]+
-                squares[(long) ScaleQuantumToChar(q->blue)-
-                (long) ScaleQuantumToChar(GetBluePixelComponent(p))];
+              distance_squared=squares[(ssize_t) ScaleQuantumToChar(q->red)-
+                (ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p))]+
+                squares[(ssize_t) ScaleQuantumToChar(q->green)-
+                (ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p))]+
+                squares[(ssize_t) ScaleQuantumToChar(q->blue)-
+                (ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p))];
               ratio=numerator/distance_squared;
               sum+=SegmentPower(ratio);
             }
@@ -676,32 +676,32 @@
 %  The format of the ConsolidateCrossings method is:
 %
 %      ConsolidateCrossings(ZeroCrossing *zero_crossing,
-%        const unsigned long number_crossings)
+%        const size_t number_crossings)
 %
 %  A description of each parameter follows.
 %
 %    o zero_crossing: Specifies an array of structures of type ZeroCrossing.
 %
-%    o number_crossings: This unsigned long specifies the number of elements
+%    o number_crossings: This size_t specifies the number of elements
 %      in the zero_crossing array.
 %
 */
 
-static inline long MagickAbsoluteValue(const long x)
+static inline ssize_t MagickAbsoluteValue(const ssize_t x)
 {
   if (x < 0)
     return(-x);
   return(x);
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline long MagickMin(const long x,const long y)
+static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
 {
   if (x < y)
     return(x);
@@ -709,16 +709,16 @@
 }
 
 static void ConsolidateCrossings(ZeroCrossing *zero_crossing,
-  const unsigned long number_crossings)
+  const size_t number_crossings)
 {
-  long
+  ssize_t
     center,
     correct,
     count,
     left,
     right;
 
-  register long
+  register ssize_t
     i,
     j,
     k,
@@ -727,7 +727,7 @@
   /*
     Consolidate zero crossings.
   */
-  for (i=(long) number_crossings-1; i >= 0; i--)
+  for (i=(ssize_t) number_crossings-1; i >= 0; i--)
     for (j=0; j <= 255; j++)
     {
       if (zero_crossing[i].crossings[j] == 0)
@@ -813,7 +813,7 @@
 %
 %  The format of the DefineRegion method is:
 %
-%      long DefineRegion(const short *extrema,ExtentPacket *extents)
+%      ssize_t DefineRegion(const short *extrema,ExtentPacket *extents)
 %
 %  A description of each parameter follows.
 %
@@ -825,7 +825,7 @@
 %      of a particular peak or valley of a color component.
 %
 */
-static long DefineRegion(const short *extrema,ExtentPacket *extents)
+static ssize_t DefineRegion(const short *extrema,ExtentPacket *extents)
 {
   /*
     Initialize to default values.
@@ -884,7 +884,7 @@
 static void DerivativeHistogram(const MagickRealType *histogram,
   MagickRealType *derivative)
 {
-  register long
+  register ssize_t
     i,
     n;
 
@@ -955,7 +955,7 @@
     green,
     red;
 
-  long
+  ssize_t
     count,
     *histogram[MaxDimension],
     y;
@@ -969,7 +969,7 @@
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -986,14 +986,14 @@
   GetMagickPixelPacket(image,pixel);
   for (i=0; i < MaxDimension; i++)
   {
-    histogram[i]=(long *) AcquireQuantumMemory(256UL,sizeof(**histogram));
+    histogram[i]=(ssize_t *) AcquireQuantumMemory(256UL,sizeof(**histogram));
     extrema[i]=(short *) AcquireQuantumMemory(256UL,sizeof(**histogram));
-    if ((histogram[i] == (long *) NULL) || (extrema[i] == (short *) NULL))
+    if ((histogram[i] == (ssize_t *) NULL) || (extrema[i] == (short *) NULL))
       {
         for (i-- ; i >= 0; i--)
         {
           extrema[i]=(short *) RelinquishMagickMemory(extrema[i]);
-          histogram[i]=(long *) RelinquishMagickMemory(histogram[i]);
+          histogram[i]=(ssize_t *) RelinquishMagickMemory(histogram[i]);
         }
         (void) ThrowMagickException(exception,GetMagickModule(),
           ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
@@ -1084,25 +1084,25 @@
     Count the pixels for each cluster.
   */
   count=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       for (cluster=head; cluster != (Cluster *) NULL; cluster=cluster->next)
-        if (((long) ScaleQuantumToChar(GetRedPixelComponent(p)) >=
+        if (((ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p)) >=
              (cluster->red.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetRedPixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p)) <=
              (cluster->red.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetGreenPixelComponent(p)) >=
+            ((ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p)) >=
              (cluster->green.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetGreenPixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p)) <=
              (cluster->green.right+SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetBluePixelComponent(p)) >=
+            ((ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p)) >=
              (cluster->blue.left-SafeMargin)) &&
-            ((long) ScaleQuantumToChar(GetBluePixelComponent(p)) <=
+            ((ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p)) <=
              (cluster->blue.right+SafeMargin)))
           {
             /*
@@ -1195,7 +1195,7 @@
   for (i=0; i < MaxDimension; i++)
   {
     extrema[i]=(short *) RelinquishMagickMemory(extrema[i]);
-    histogram[i]=(long *) RelinquishMagickMemory(histogram[i]);
+    histogram[i]=(ssize_t *) RelinquishMagickMemory(histogram[i]);
   }
   return(MagickTrue);
 }
@@ -1215,7 +1215,7 @@
 %
 %  The format of the InitializeHistogram method is:
 %
-%      InitializeHistogram(const Image *image,long **histogram)
+%      InitializeHistogram(const Image *image,ssize_t **histogram)
 %
 %  A description of each parameter follows.
 %
@@ -1226,16 +1226,16 @@
 %      of pixels for each intensity of a particular color component.
 %
 */
-static void InitializeHistogram(const Image *image,long **histogram,
+static void InitializeHistogram(const Image *image,ssize_t **histogram,
   ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
   register const PixelPacket
     *p;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1248,16 +1248,16 @@
     histogram[Green][i]=0;
     histogram[Blue][i]=0;
   }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      histogram[Red][(long) ScaleQuantumToChar(GetRedPixelComponent(p))]++;
-      histogram[Green][(long) ScaleQuantumToChar(GetGreenPixelComponent(p))]++;
-      histogram[Blue][(long) ScaleQuantumToChar(GetBluePixelComponent(p))]++;
+      histogram[Red][(ssize_t) ScaleQuantumToChar(GetRedPixelComponent(p))]++;
+      histogram[Green][(ssize_t) ScaleQuantumToChar(GetGreenPixelComponent(p))]++;
+      histogram[Blue][(ssize_t) ScaleQuantumToChar(GetBluePixelComponent(p))]++;
       p++;
     }
   }
@@ -1279,19 +1279,19 @@
 %
 %  The format of the InitializeIntervalTree method is:
 %
-%      InitializeIntervalTree(IntervalTree **list,long *number_nodes,
+%      InitializeIntervalTree(IntervalTree **list,ssize_t *number_nodes,
 %        IntervalTree *node)
 %
 %  A description of each parameter follows.
 %
 %    o zero_crossing: Specifies an array of structures of type ZeroCrossing.
 %
-%    o number_crossings: This unsigned long specifies the number of elements
+%    o number_crossings: This size_t specifies the number of elements
 %      in the zero_crossing array.
 %
 */
 
-static void InitializeList(IntervalTree **list,long *number_nodes,
+static void InitializeList(IntervalTree **list,ssize_t *number_nodes,
   IntervalTree *node)
 {
   if (node == (IntervalTree *) NULL)
@@ -1313,7 +1313,7 @@
   child=node->child;
   if (child != (IntervalTree *) NULL)
     {
-      register long
+      register ssize_t
         count;
 
       register MagickRealType
@@ -1345,7 +1345,7 @@
 }
 
 static IntervalTree *InitializeIntervalTree(const ZeroCrossing *zero_crossing,
-  const unsigned long number_crossings)
+  const size_t number_crossings)
 {
   IntervalTree
     *head,
@@ -1353,13 +1353,13 @@
     *node,
     *root;
 
-  long
+  ssize_t
     j,
     k,
     left,
     number_nodes;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1378,7 +1378,7 @@
   root->tau=0.0;
   root->left=0;
   root->right=255;
-  for (i=(-1); i < (long) number_crossings; i++)
+  for (i=(-1); i < (ssize_t) number_crossings; i++)
   {
     /*
       Initialize list with all nodes with no children.
@@ -1454,7 +1454,7 @@
 %
 %  The format of the OptimalTau method is:
 %
-%    MagickRealType OptimalTau(const long *histogram,const double max_tau,
+%    MagickRealType OptimalTau(const ssize_t *histogram,const double max_tau,
 %      const double min_tau,const double delta_tau,
 %      const double smooth_threshold,short *extrema)
 %
@@ -1469,7 +1469,7 @@
 %
 */
 
-static void ActiveNodes(IntervalTree **list,long *number_nodes,
+static void ActiveNodes(IntervalTree **list,ssize_t *number_nodes,
   IntervalTree *node)
 {
   if (node == (IntervalTree *) NULL)
@@ -1495,7 +1495,7 @@
   node=(IntervalTree *) RelinquishMagickMemory(node);
 }
 
-static MagickRealType OptimalTau(const long *histogram,const double max_tau,
+static MagickRealType OptimalTau(const ssize_t *histogram,const double max_tau,
   const double min_tau,const double delta_tau,const double smooth_threshold,
   short *extrema)
 {
@@ -1504,7 +1504,7 @@
     *node,
     *root;
 
-  long
+  ssize_t
     index,
     j,
     k,
@@ -1517,14 +1517,14 @@
     tau,
     value;
 
-  register long
+  register ssize_t
     i,
     x;
 
   MagickBooleanType
     peak;
 
-  unsigned long
+  size_t
     count,
     number_crossings;
 
@@ -1541,12 +1541,12 @@
   /*
     Allocate zero crossing list.
   */
-  count=(unsigned long) ((max_tau-min_tau)/delta_tau)+2;
+  count=(size_t) ((max_tau-min_tau)/delta_tau)+2;
   zero_crossing=(ZeroCrossing *) AcquireQuantumMemory((size_t) count,
     sizeof(*zero_crossing));
   if (zero_crossing == (ZeroCrossing *) NULL)
     return(0.0);
-  for (i=0; i < (long) count; i++)
+  for (i=0; i < (ssize_t) count; i++)
     zero_crossing[i].tau=(-1.0);
   /*
     Initialize zero crossing list.
@@ -1579,7 +1579,7 @@
   DerivativeHistogram(derivative,second_derivative);
   ZeroCrossHistogram(second_derivative,smooth_threshold,
     zero_crossing[i].crossings);
-  number_crossings=(unsigned long) i;
+  number_crossings=(size_t) i;
   derivative=(MagickRealType *) RelinquishMagickMemory(derivative);
   second_derivative=(MagickRealType *)
     RelinquishMagickMemory(second_derivative);
@@ -1590,7 +1590,7 @@
   /*
     Force endpoints to be included in the interval.
   */
-  for (i=0; i <= (long) number_crossings; i++)
+  for (i=0; i <= (ssize_t) number_crossings; i++)
   {
     for (j=0; j < 255; j++)
       if (zero_crossing[i].crossings[j] != 0)
@@ -1625,7 +1625,7 @@
     */
     k=0;
     node=list[i];
-    for (j=0; j <= (long) number_crossings; j++)
+    for (j=0; j <= (ssize_t) number_crossings; j++)
       if (zero_crossing[j].tau == node->tau)
         k=j;
     /*
@@ -1693,7 +1693,7 @@
 %
 %  The format of the ScaleSpace method is:
 %
-%      ScaleSpace(const long *histogram,const MagickRealType tau,
+%      ScaleSpace(const ssize_t *histogram,const MagickRealType tau,
 %        MagickRealType *scale_histogram)
 %
 %  A description of each parameter follows.
@@ -1703,7 +1703,7 @@
 %
 */
 
-static void ScaleSpace(const long *histogram,const MagickRealType tau,
+static void ScaleSpace(const ssize_t *histogram,const MagickRealType tau,
   MagickRealType *scale_histogram)
 {
   MagickRealType
@@ -1712,7 +1712,7 @@
     *gamma,
     sum;
 
-  register long
+  register ssize_t
     u,
     x;
 
@@ -1783,13 +1783,13 @@
   const ColorspaceType colorspace,const MagickBooleanType verbose,
   const double cluster_threshold,const double smooth_threshold)
 {
-  long
+  ssize_t
     *histogram[MaxDimension];
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i;
 
   short
@@ -1804,14 +1804,14 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   for (i=0; i < MaxDimension; i++)
   {
-    histogram[i]=(long *) AcquireQuantumMemory(256,sizeof(**histogram));
+    histogram[i]=(ssize_t *) AcquireQuantumMemory(256,sizeof(**histogram));
     extrema[i]=(short *) AcquireQuantumMemory(256,sizeof(**extrema));
-    if ((histogram[i] == (long *) NULL) || (extrema[i] == (short *) NULL))
+    if ((histogram[i] == (ssize_t *) NULL) || (extrema[i] == (short *) NULL))
       {
         for (i-- ; i >= 0; i--)
         {
           extrema[i]=(short *) RelinquishMagickMemory(extrema[i]);
-          histogram[i]=(long *) RelinquishMagickMemory(histogram[i]);
+          histogram[i]=(ssize_t *) RelinquishMagickMemory(histogram[i]);
         }
         ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
           image->filename)
@@ -1841,7 +1841,7 @@
   for (i=0; i < MaxDimension; i++)
   {
     extrema[i]=(short *) RelinquishMagickMemory(extrema[i]);
-    histogram[i]=(long *) RelinquishMagickMemory(histogram[i]);
+    histogram[i]=(ssize_t *) RelinquishMagickMemory(histogram[i]);
   }
   return(status);
 }
@@ -1879,10 +1879,10 @@
 static void ZeroCrossHistogram(MagickRealType *second_derivative,
   const MagickRealType smooth_threshold,short *crossings)
 {
-  long
+  ssize_t
     parity;
 
-  register long
+  register ssize_t
     i;
 
   /*
diff --git a/magick/semaphore-private.h b/magick/semaphore-private.h
index 0059ae1..bbee776 100644
--- a/magick/semaphore-private.h
+++ b/magick/semaphore-private.h
@@ -29,7 +29,7 @@
 static LONG
   semaphore_mutex = 0;
 #else
-static long
+static ssize_t
   semaphore_mutex = 0;
 #endif
 
diff --git a/magick/semaphore.c b/magick/semaphore.c
index 9e31017..e730cf2 100644
--- a/magick/semaphore.c
+++ b/magick/semaphore.c
@@ -62,10 +62,10 @@
   MagickThreadType
     id;
 
-  long
+  ssize_t
     reference_count;
 
-  unsigned long
+  size_t
     signature;
 };
 
diff --git a/magick/shear.c b/magick/shear.c
index a4aba6e..7d1c9cf 100644
--- a/magick/shear.c
+++ b/magick/shear.c
@@ -182,7 +182,7 @@
     geometry,
     page;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -218,10 +218,10 @@
     if (max.y < extent[i].y)
       max.y=extent[i].y;
   }
-  geometry.x=(long) ceil(min.x-0.5);
-  geometry.y=(long) ceil(min.y-0.5);
-  geometry.width=(unsigned long) floor(max.x-min.x+0.5);
-  geometry.height=(unsigned long) floor(max.y-min.y+0.5);
+  geometry.x=(ssize_t) ceil(min.x-0.5);
+  geometry.y=(ssize_t) ceil(min.y-0.5);
+  geometry.width=(size_t) floor(max.x-min.x+0.5);
+  geometry.height=(size_t) floor(max.y-min.y+0.5);
   page=(*image)->page;
   (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
   crop_image=CropImage(*image,&geometry,exception);
@@ -269,7 +269,7 @@
   CacheType
     type;
 
-  unsigned long
+  size_t
     width,
     height;
 
@@ -327,10 +327,10 @@
 
 static MagickBooleanType ResetRadonCells(RadonInfo *radon_info)
 {
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     x;
 
   ssize_t
@@ -346,22 +346,22 @@
     }
   value=0;
   (void) MagickSeek(radon_info->file,0,SEEK_SET);
-  for (y=0; y < (long) radon_info->height; y++)
+  for (y=0; y < (ssize_t) radon_info->height; y++)
   {
-    for (x=0; x < (long) radon_info->width; x++)
+    for (x=0; x < (ssize_t) radon_info->width; x++)
     {
       count=write(radon_info->file,&value,sizeof(*radon_info->cells));
       if (count != (ssize_t) sizeof(*radon_info->cells))
         break;
     }
-    if (x < (long) radon_info->width)
+    if (x < (ssize_t) radon_info->width)
       break;
   }
-  return(y < (long) radon_info->height ? MagickFalse : MagickTrue);
+  return(y < (ssize_t) radon_info->height ? MagickFalse : MagickTrue);
 }
 
-static RadonInfo *AcquireRadonInfo(const Image *image,const unsigned long width,
-  const unsigned long height,ExceptionInfo *exception)
+static RadonInfo *AcquireRadonInfo(const Image *image,const size_t width,
+  const size_t height,ExceptionInfo *exception)
 {
   MagickBooleanType
     status;
@@ -525,7 +525,7 @@
 }
 
 static inline unsigned short GetRadonCell(const RadonInfo *radon_info,
-  const long x,const long y)
+  const ssize_t x,const ssize_t y)
 {
   off_t
     i;
@@ -546,7 +546,7 @@
 }
 
 static inline MagickBooleanType SetRadonCell(const RadonInfo *radon_info,
-  const long x,const long y,const unsigned short value)
+  const ssize_t x,const ssize_t y,const unsigned short value)
 {
   off_t
     i;
@@ -571,51 +571,51 @@
 }
 
 static void RadonProjection(RadonInfo *source_cells,
-  RadonInfo *destination_cells,const long sign,unsigned long *projection)
+  RadonInfo *destination_cells,const ssize_t sign,size_t *projection)
 {
   RadonInfo
     *swap;
 
-  register long
+  register ssize_t
     x;
 
   register RadonInfo
     *p,
     *q;
 
-  unsigned long
+  size_t
     step;
 
   p=source_cells;
   q=destination_cells;
   for (step=1; step < p->width; step*=2)
   {
-    for (x=0; x < (long) p->width; x+=2*step)
+    for (x=0; x < (ssize_t) p->width; x+=2*step)
     {
-      long
+      ssize_t
         y;
 
-      register long
+      register ssize_t
         i;
 
       unsigned short
         cell;
 
-      for (i=0; i < (long) step; i++)
+      for (i=0; i < (ssize_t) step; i++)
       {
-        for (y=0; y < (long) (p->height-i-1); y++)
+        for (y=0; y < (ssize_t) (p->height-i-1); y++)
         {
           cell=GetRadonCell(p,x+i,y);
           (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i));
           (void) SetRadonCell(q,x+2*i+1,y,cell+GetRadonCell(p,x+i+step,y+i+1));
         }
-        for ( ; y < (long) (p->height-i); y++)
+        for ( ; y < (ssize_t) (p->height-i); y++)
         {
           cell=GetRadonCell(p,x+i,y);
           (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i));
           (void) SetRadonCell(q,x+2*i+1,y,cell);
         }
-        for ( ; y < (long) p->height; y++)
+        for ( ; y < (ssize_t) p->height; y++)
         {
           cell=GetRadonCell(p,x+i,y);
           (void) SetRadonCell(q,x+2*i,y,cell);
@@ -630,21 +630,21 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4)
 #endif
-  for (x=0; x < (long) p->width; x++)
+  for (x=0; x < (ssize_t) p->width; x++)
   {
-    register long
+    register ssize_t
       y;
 
-    unsigned long
+    size_t
       sum;
 
     sum=0;
-    for (y=0; y < (long) (p->height-1); y++)
+    for (y=0; y < (ssize_t) (p->height-1); y++)
     {
-      long
+      ssize_t
         delta;
 
-      delta=GetRadonCell(p,x,y)-(long) GetRadonCell(p,x,y+1);
+      delta=GetRadonCell(p,x,y)-(ssize_t) GetRadonCell(p,x,y+1);
       sum+=delta*delta;
     }
     projection[p->width+sign*x-1]=sum;
@@ -652,12 +652,12 @@
 }
 
 static MagickBooleanType RadonTransform(const Image *image,
-  const double threshold,unsigned long *projection,ExceptionInfo *exception)
+  const double threshold,size_t *projection,ExceptionInfo *exception)
 {
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -667,13 +667,13 @@
     *destination_cells,
     *source_cells;
 
-  register long
+  register ssize_t
     i;
 
   unsigned char
     byte;
 
-  unsigned long
+  size_t
     count,
     width;
 
@@ -710,16 +710,16 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       i,
       x;
 
-    unsigned long
+    size_t
       bit,
       byte;
 
@@ -733,8 +733,8 @@
       }
     bit=0;
     byte=0;
-    i=(long) (image->columns+7)/8;
-    for (x=0; x < (long) image->columns; x++)
+    i=(ssize_t) (image->columns+7)/8;
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       byte<<=1;
       if (((MagickRealType) p->red < threshold) ||
@@ -761,16 +761,16 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       i,
       x;
 
-    unsigned long
+    size_t
       bit,
       byte;
 
@@ -785,7 +785,7 @@
     bit=0;
     byte=0;
     i=0;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       byte<<=1;
       if (((MagickRealType) p->red < threshold) ||
@@ -814,13 +814,13 @@
   return(MagickTrue);
 }
 
-static void GetImageBackgroundColor(Image *image,const long offset,
+static void GetImageBackgroundColor(Image *image,const ssize_t offset,
   ExceptionInfo *exception)
 {
   CacheView
     *image_view;
 
-  long
+  ssize_t
     y;
 
   MagickPixelPacket
@@ -837,22 +837,22 @@
   GetMagickPixelPacket(image,&background);
   count=0.0;
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
-    if ((y >= offset) && (y < ((long) image->rows-offset)))
+    if ((y >= offset) && (y < ((ssize_t) image->rows-offset)))
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       continue;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if ((x >= offset) && (x < ((long) image->columns-offset)))
+      if ((x >= offset) && (x < ((ssize_t) image->columns-offset)))
         continue;
       background.red+=QuantumScale*GetRedPixelComponent(p);
       background.green+=QuantumScale*GetGreenPixelComponent(p);
@@ -891,7 +891,7 @@
     *deskew_image,
     *median_image;
 
-  long
+  ssize_t
     skew;
 
   MagickBooleanType
@@ -900,10 +900,10 @@
   RectangleInfo
     geometry;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     max_projection,
     *projection,
     width;
@@ -912,27 +912,27 @@
     Compute deskew angle.
   */
   for (width=1; width < ((image->columns+7)/8); width<<=1) ;
-  projection=(unsigned long *) AcquireQuantumMemory((size_t) (2*width-1),
+  projection=(size_t *) AcquireQuantumMemory((size_t) (2*width-1),
     sizeof(*projection));
-  if (projection == (unsigned long *) NULL)
+  if (projection == (size_t *) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
   status=RadonTransform(image,threshold,projection,exception);
   if (status == MagickFalse)
     {
-      projection=(unsigned long *) RelinquishMagickMemory(projection);
+      projection=(size_t *) RelinquishMagickMemory(projection);
       ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
     }
   max_projection=0;
   skew=0;
-  for (i=0; i < (long) (2*width-1); i++)
+  for (i=0; i < (ssize_t) (2*width-1); i++)
   {
     if (projection[i] > max_projection)
       {
-        skew=i-(long) width+1;
+        skew=i-(ssize_t) width+1;
         max_projection=projection[i];
       }
   }
-  projection=(unsigned long *) RelinquishMagickMemory(projection);
+  projection=(size_t *) RelinquishMagickMemory(projection);
   /*
     Deskew image.
   */
@@ -998,7 +998,7 @@
 %
 %  The format of the IntegralRotateImage method is:
 %
-%      Image *IntegralRotateImage(const Image *image,unsigned long rotations,
+%      Image *IntegralRotateImage(const Image *image,size_t rotations,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
@@ -1008,7 +1008,7 @@
 %    o rotations: Specifies the number of 90 degree rotations.
 %
 */
-static Image *IntegralRotateImage(const Image *image,unsigned long rotations,
+static Image *IntegralRotateImage(const Image *image,size_t rotations,
   ExceptionInfo *exception)
 {
 #define RotateImageTag  "Rotate/Image"
@@ -1020,7 +1020,7 @@
   Image
     *rotate_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1064,10 +1064,10 @@
     }
     case 1:
     {
-      long
+      ssize_t
         tile_y;
 
-      unsigned long
+      size_t
         tile_height,
         tile_width;
 
@@ -1078,14 +1078,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress, status)
 #endif
-      for (tile_y=0; tile_y < (long) image->rows; tile_y+=tile_height)
+      for (tile_y=0; tile_y < (ssize_t) image->rows; tile_y+=tile_height)
       {
-        register long
+        register ssize_t
           tile_x;
 
         if (status == MagickFalse)
           continue;
-        for (tile_x=0; tile_x < (long) image->columns; tile_x+=tile_width)
+        for (tile_x=0; tile_x < (ssize_t) image->columns; tile_x+=tile_width)
         {
           MagickBooleanType
             sync;
@@ -1099,23 +1099,23 @@
           register IndexPacket
             *restrict rotate_indexes;
 
-          register long
+          register ssize_t
             y;
 
           register PixelPacket
             *restrict q;
 
-          unsigned long
+          size_t
             height,
             width;
 
           width=tile_width;
-          if ((tile_x+(long) tile_width) > (long) image->columns)
-            width=(unsigned long) (tile_width-(tile_x+tile_width-
+          if ((tile_x+(ssize_t) tile_width) > (ssize_t) image->columns)
+            width=(size_t) (tile_width-(tile_x+tile_width-
               image->columns));
           height=tile_height;
-          if ((tile_y+(long) tile_height) > (long) image->rows)
-            height=(unsigned long) (tile_height-(tile_y+tile_height-
+          if ((tile_y+(ssize_t) tile_height) > (ssize_t) image->rows)
+            height=(size_t) (tile_height-(tile_y+tile_height-
               image->rows));
           p=GetCacheViewVirtualPixels(image_view,tile_x,tile_y,width,height,
             exception);
@@ -1125,15 +1125,15 @@
               break;
             }
           indexes=GetCacheViewVirtualIndexQueue(image_view);
-          for (y=0; y < (long) width; y++)
+          for (y=0; y < (ssize_t) width; y++)
           {
             register const PixelPacket
               *restrict tile_pixels;
 
-            register long
+            register ssize_t
               x;
 
-            q=QueueCacheViewAuthenticPixels(rotate_view,(long)
+            q=QueueCacheViewAuthenticPixels(rotate_view,(ssize_t)
               rotate_image->columns-(tile_y+height),y+tile_x,height,
               1,exception);
             if (q == (PixelPacket *) NULL)
@@ -1142,7 +1142,7 @@
                 break;
               }
             tile_pixels=p+(height-1)*width+y;
-            for (x=0; x < (long) height; x++)
+            for (x=0; x < (ssize_t) height; x++)
             {
               *q++=(*tile_pixels);
               tile_pixels-=width;
@@ -1155,7 +1155,7 @@
                   *restrict tile_indexes;
 
                 tile_indexes=indexes+(height-1)*width+y;
-                for (x=0; x < (long) height; x++)
+                for (x=0; x < (ssize_t) height; x++)
                 {
                   *rotate_indexes++=(*tile_indexes);
                   tile_indexes-=width;
@@ -1182,7 +1182,7 @@
       Swap(page.width,page.height);
       Swap(page.x,page.y);
       if (page.width != 0)
-        page.x=(long) (page.width-rotate_image->columns-page.x);
+        page.x=(ssize_t) (page.width-rotate_image->columns-page.x);
       break;
     }
     case 2:
@@ -1193,7 +1193,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress, status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1207,7 +1207,7 @@
         register IndexPacket
           *restrict rotate_indexes;
 
-        register long
+        register ssize_t
           x;
 
         register PixelPacket
@@ -1217,7 +1217,7 @@
           continue;
         p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,
           exception);
-        q=QueueCacheViewAuthenticPixels(rotate_view,0,(long) (image->rows-
+        q=QueueCacheViewAuthenticPixels(rotate_view,0,(ssize_t) (image->rows-
           y-1),image->columns,1,exception);
         if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
           {
@@ -1227,11 +1227,11 @@
         indexes=GetCacheViewVirtualIndexQueue(image_view);
         rotate_indexes=GetCacheViewAuthenticIndexQueue(rotate_view);
         q+=image->columns;
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
           *--q=(*p++);
         if ((indexes != (IndexPacket *) NULL) &&
             (rotate_indexes != (IndexPacket *) NULL))
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             rotate_indexes[image->columns-x-1]=indexes[x];
         sync=SyncCacheViewAuthenticPixels(rotate_view,exception);
         if (sync == MagickFalse)
@@ -1248,17 +1248,17 @@
           }
       }
       if (page.width != 0)
-        page.x=(long) (page.width-rotate_image->columns-page.x);
+        page.x=(ssize_t) (page.width-rotate_image->columns-page.x);
       if (page.height != 0)
-        page.y=(long) (page.height-rotate_image->rows-page.y);
+        page.y=(ssize_t) (page.height-rotate_image->rows-page.y);
       break;
     }
     case 3:
     {
-      long
+      ssize_t
         tile_y;
 
-      unsigned long
+      size_t
         tile_height,
         tile_width;
 
@@ -1269,14 +1269,14 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress, status)
 #endif
-      for (tile_y=0; tile_y < (long) image->rows; tile_y+=tile_height)
+      for (tile_y=0; tile_y < (ssize_t) image->rows; tile_y+=tile_height)
       {
-        register long
+        register ssize_t
           tile_x;
 
         if (status == MagickFalse)
           continue;
-        for (tile_x=0; tile_x < (long) image->columns; tile_x+=tile_width)
+        for (tile_x=0; tile_x < (ssize_t) image->columns; tile_x+=tile_width)
         {
           MagickBooleanType
             sync;
@@ -1290,23 +1290,23 @@
           register IndexPacket
             *restrict rotate_indexes;
 
-          register long
+          register ssize_t
             y;
 
           register PixelPacket
             *restrict q;
 
-          unsigned long
+          size_t
             height,
             width;
 
           width=tile_width;
-          if ((tile_x+(long) tile_width) > (long) image->columns)
-            width=(unsigned long) (tile_width-(tile_x+tile_width-
+          if ((tile_x+(ssize_t) tile_width) > (ssize_t) image->columns)
+            width=(size_t) (tile_width-(tile_x+tile_width-
               image->columns));
           height=tile_height;
-          if ((tile_y+(long) tile_height) > (long) image->rows)
-            height=(unsigned long) (tile_height-(tile_y+tile_height-
+          if ((tile_y+(ssize_t) tile_height) > (ssize_t) image->rows)
+            height=(size_t) (tile_height-(tile_y+tile_height-
               image->rows));
           p=GetCacheViewVirtualPixels(image_view,tile_x,tile_y,width,
             height,exception);
@@ -1316,15 +1316,15 @@
               break;
             }
           indexes=GetCacheViewVirtualIndexQueue(image_view);
-          for (y=0; y < (long) width; y++)
+          for (y=0; y < (ssize_t) width; y++)
           {
             register const PixelPacket
               *restrict tile_pixels;
 
-            register long
+            register ssize_t
               x;
 
-            q=QueueCacheViewAuthenticPixels(rotate_view,tile_y,(long)
+            q=QueueCacheViewAuthenticPixels(rotate_view,tile_y,(ssize_t)
               y+rotate_image->rows-(tile_x+width),height,1,exception);
             if (q == (PixelPacket *) NULL)
               {
@@ -1332,7 +1332,7 @@
                 break;
               }
             tile_pixels=p+(width-1)-y;
-            for (x=0; x < (long) height; x++)
+            for (x=0; x < (ssize_t) height; x++)
             {
               *q++=(*tile_pixels);
               tile_pixels+=width;
@@ -1345,7 +1345,7 @@
                   *restrict tile_indexes;
 
                 tile_indexes=indexes+(width-1)-y;
-                for (x=0; x < (long) height; x++)
+                for (x=0; x < (ssize_t) height; x++)
                 {
                   *rotate_indexes++=(*tile_indexes);
                   tile_indexes+=width;
@@ -1372,7 +1372,7 @@
       Swap(page.width,page.height);
       Swap(page.x,page.y);
       if (page.height != 0)
-        page.y=(long) (page.height-rotate_image->rows-page.y);
+        page.y=(ssize_t) (page.height-rotate_image->rows-page.y);
       break;
     }
   }
@@ -1405,14 +1405,14 @@
 %  The format of the XShearImage method is:
 %
 %      MagickBooleanType XShearImage(Image *image,const MagickRealType degrees,
-%        const unsigned long width,const unsigned long height,
-%        const long x_offset,const long y_offset,ExceptionInfo *exception)
+%        const size_t width,const size_t height,
+%        const ssize_t x_offset,const ssize_t y_offset,ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
 %
 %    o image: the image.
 %
-%    o degrees: A MagickRealType representing the shearing angle along the X
+%    o degrees: A MagickRealType representing the shearing angle assize_t the X
 %      axis.
 %
 %    o width, height, x_offset, y_offset: Defines a region of the image
@@ -1422,8 +1422,8 @@
 %
 */
 static MagickBooleanType XShearImage(Image *image,const MagickRealType degrees,
-  const unsigned long width,const unsigned long height,const long x_offset,
-  const long y_offset,ExceptionInfo *exception)
+  const size_t width,const size_t height,const ssize_t x_offset,
+  const ssize_t y_offset,ExceptionInfo *exception)
 {
 #define XShearImageTag  "XShear/Image"
 
@@ -1436,7 +1436,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1464,9 +1464,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress, status)
 #endif
-  for (y=0; y < (long) height; y++)
+  for (y=0; y < (ssize_t) height; y++)
   {
-    long
+    ssize_t
       step;
 
     MagickPixelPacket
@@ -1478,7 +1478,7 @@
       area,
       displacement;
 
-    register long
+    register ssize_t
       i;
 
     register IndexPacket
@@ -1514,7 +1514,7 @@
         displacement*=(-1.0);
         direction=LEFT;
       }
-    step=(long) floor((double) displacement);
+    step=(ssize_t) floor((double) displacement);
     area=(MagickRealType) (displacement-step);
     step++;
     pixel=background;
@@ -1531,7 +1531,7 @@
           break;
         q=p-step;
         shear_indexes=indexes-step;
-        for (i=0; i < (long) width; i++)
+        for (i=0; i < (ssize_t) width; i++)
         {
           if ((x_offset+i) < step)
             {
@@ -1562,13 +1562,13 @@
         indexes+=width;
         q=p+step;
         shear_indexes=indexes+step;
-        for (i=0; i < (long) width; i++)
+        for (i=0; i < (ssize_t) width; i++)
         {
           p--;
           indexes--;
           q--;
           shear_indexes--;
-          if ((unsigned long) (x_offset+width+step-i) >= image->columns)
+          if ((size_t) (x_offset+width+step-i) >= image->columns)
             continue;
           SetMagickPixelPacket(image,p,indexes,&source);
           MagickPixelCompositeAreaBlend(&pixel,(MagickRealType) pixel.opacity,
@@ -1623,14 +1623,14 @@
 %  The format of the YShearImage method is:
 %
 %      MagickBooleanType YShearImage(Image *image,const MagickRealType degrees,
-%        const unsigned long width,const unsigned long height,
-%        const long x_offset,const long y_offset,ExceptionInfo *exception)
+%        const size_t width,const size_t height,
+%        const ssize_t x_offset,const ssize_t y_offset,ExceptionInfo *exception)
 %
 %  A description of each parameter follows.
 %
 %    o image: the image.
 %
-%    o degrees: A MagickRealType representing the shearing angle along the Y
+%    o degrees: A MagickRealType representing the shearing angle assize_t the Y
 %      axis.
 %
 %    o width, height, x_offset, y_offset: Defines a region of the image
@@ -1640,8 +1640,8 @@
 %
 */
 static MagickBooleanType YShearImage(Image *image,const MagickRealType degrees,
-  const unsigned long width,const unsigned long height,const long x_offset,
-  const long y_offset,ExceptionInfo *exception)
+  const size_t width,const size_t height,const ssize_t x_offset,
+  const ssize_t y_offset,ExceptionInfo *exception)
 {
 #define YShearImageTag  "YShear/Image"
 
@@ -1654,7 +1654,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     progress,
     x;
 
@@ -1682,9 +1682,9 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress, status)
 #endif
-  for (x=0; x < (long) width; x++)
+  for (x=0; x < (ssize_t) width; x++)
   {
-    long
+    ssize_t
       step;
 
     MagickPixelPacket
@@ -1700,7 +1700,7 @@
       *restrict indexes,
       *restrict shear_indexes;
 
-    register long
+    register ssize_t
       i;
 
     register PixelPacket
@@ -1732,7 +1732,7 @@
         displacement*=(-1.0);
         direction=UP;
       }
-    step=(long) floor((double) displacement);
+    step=(ssize_t) floor((double) displacement);
     area=(MagickRealType) (displacement-step);
     step++;
     pixel=background;
@@ -1749,7 +1749,7 @@
           break;
         q=p-step;
         shear_indexes=indexes-step;
-        for (i=0; i < (long) height; i++)
+        for (i=0; i < (ssize_t) height; i++)
         {
           if ((y_offset+i) < step)
             {
@@ -1780,13 +1780,13 @@
         indexes+=height;
         q=p+step;
         shear_indexes=indexes+step;
-        for (i=0; i < (long) height; i++)
+        for (i=0; i < (ssize_t) height; i++)
         {
           p--;
           indexes--;
           q--;
           shear_indexes--;
-          if ((unsigned long) (y_offset+height+step-i) >= image->rows)
+          if ((size_t) (y_offset+height+step-i) >= image->rows)
             continue;
           SetMagickPixelPacket(image,p,indexes,&source);
           MagickPixelCompositeAreaBlend(&pixel,(MagickRealType) pixel.opacity,
@@ -1867,7 +1867,7 @@
     *integral_image,
     *rotate_image;
 
-  long
+  ssize_t
     x_offset,
     y_offset;
 
@@ -1883,7 +1883,7 @@
   RectangleInfo
     border_info;
 
-  unsigned long
+  size_t
     height,
     rotations,
     width,
@@ -1932,16 +1932,16 @@
       width=image->rows;
       height=image->columns;
     }
-  y_width=width+(long) floor(fabs(shear.x)*height+0.5);
-  x_offset=(long) ceil(width+((fabs(shear.y)*height)-width)/2.0-0.5);
-  y_offset=(long) ceil(height+((fabs(shear.y)*y_width)-height)/2.0-0.5);
+  y_width=width+(ssize_t) floor(fabs(shear.x)*height+0.5);
+  x_offset=(ssize_t) ceil(width+((fabs(shear.y)*height)-width)/2.0-0.5);
+  y_offset=(ssize_t) ceil(height+((fabs(shear.y)*y_width)-height)/2.0-0.5);
   /*
     Surround image with a border.
   */
   integral_image->border_color=integral_image->background_color;
   integral_image->compose=CopyCompositeOp;
-  border_info.width=(unsigned long) x_offset;
-  border_info.height=(unsigned long) y_offset;
+  border_info.width=(size_t) x_offset;
+  border_info.height=(size_t) y_offset;
   rotate_image=BorderImage(integral_image,&border_info,exception);
   integral_image=DestroyImage(integral_image);
   if (rotate_image == (Image *) NULL)
@@ -1949,21 +1949,21 @@
   /*
     Rotate the image.
   */
-  status=XShearImage(rotate_image,shear.x,width,height,x_offset,((long)
+  status=XShearImage(rotate_image,shear.x,width,height,x_offset,((ssize_t)
     rotate_image->rows-height)/2,exception);
   if (status == MagickFalse)
     {
       rotate_image=DestroyImage(rotate_image);
       return((Image *) NULL);
     }
-  status=YShearImage(rotate_image,shear.y,y_width,height,((long)
+  status=YShearImage(rotate_image,shear.y,y_width,height,((ssize_t)
     rotate_image->columns-y_width)/2,y_offset,exception);
   if (status == MagickFalse)
     {
       rotate_image=DestroyImage(rotate_image);
       return((Image *) NULL);
     }
-  status=XShearImage(rotate_image,shear.x,y_width,rotate_image->rows,((long)
+  status=XShearImage(rotate_image,shear.x,y_width,rotate_image->rows,((ssize_t)
     rotate_image->columns-y_width)/2,0,exception);
   if (status == MagickFalse)
     {
@@ -1995,9 +1995,9 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  ShearImage() creates a new image that is a shear_image copy of an existing
-%  one.  Shearing slides one edge of an image along the X or Y axis, creating
-%  a parallelogram.  An X direction shear slides an edge along the X axis,
-%  while a Y direction shear slides an edge along the Y axis.  The amount of
+%  one.  Shearing slides one edge of an image assize_t the X or Y axis, creating
+%  a parallelogram.  An X direction shear slides an edge assize_t the X axis,
+%  while a Y direction shear slides an edge assize_t the Y axis.  The amount of
 %  the shear is controlled by a shear angle.  For X direction shears, x_shear
 %  is measured relative to the Y axis, and similarly, for Y direction shears
 %  y_shear is measured relative to the X axis.  Empty triangles left over from
@@ -2029,7 +2029,7 @@
     *integral_image,
     *shear_image;
 
-  long
+  ssize_t
     x_offset,
     y_offset;
 
@@ -2042,7 +2042,7 @@
   RectangleInfo
     border_info;
 
-  unsigned long
+  size_t
     y_width;
 
   assert(image != (Image *) NULL);
@@ -2076,18 +2076,18 @@
   /*
     Compute image size.
   */
-  y_width=image->columns+(long) floor(fabs(shear.x)*image->rows+0.5);
-  x_offset=(long) ceil(image->columns+((fabs(shear.x)*image->rows)-
+  y_width=image->columns+(ssize_t) floor(fabs(shear.x)*image->rows+0.5);
+  x_offset=(ssize_t) ceil(image->columns+((fabs(shear.x)*image->rows)-
     image->columns)/2.0-0.5);
-  y_offset=(long) ceil(image->rows+((fabs(shear.y)*y_width)-image->rows)/2.0-
+  y_offset=(ssize_t) ceil(image->rows+((fabs(shear.y)*y_width)-image->rows)/2.0-
     0.5);
   /*
     Surround image with border.
   */
   integral_image->border_color=integral_image->background_color;
   integral_image->compose=CopyCompositeOp;
-  border_info.width=(unsigned long) x_offset;
-  border_info.height=(unsigned long) y_offset;
+  border_info.width=(size_t) x_offset;
+  border_info.height=(size_t) y_offset;
   shear_image=BorderImage(integral_image,&border_info,exception);
   integral_image=DestroyImage(integral_image);
   if (shear_image == (Image *) NULL)
@@ -2098,13 +2098,13 @@
   if (shear_image->matte == MagickFalse)
     (void) SetImageAlphaChannel(shear_image,OpaqueAlphaChannel);
   status=XShearImage(shear_image,shear.x,image->columns,image->rows,x_offset,
-    ((long) shear_image->rows-image->rows)/2,exception);
+    ((ssize_t) shear_image->rows-image->rows)/2,exception);
   if (status == MagickFalse)
     {
       shear_image=DestroyImage(shear_image);
       return((Image *) NULL);
     }
-  status=YShearImage(shear_image,shear.y,y_width,image->rows,((long)
+  status=YShearImage(shear_image,shear.y,y_width,image->rows,((ssize_t)
     shear_image->columns-y_width)/2,y_offset,exception);
   if (status == MagickFalse)
     {
diff --git a/magick/signature.c b/magick/signature.c
index 2f1bb1b..1a7d000 100644
--- a/magick/signature.c
+++ b/magick/signature.c
@@ -81,10 +81,10 @@
   MagickBooleanType
     lsb_first;
 
-  long
+  ssize_t
     timestamp;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -135,7 +135,7 @@
   lsb_first=1;
   signature_info->lsb_first=(int) (*(char *) &lsb_first) == 1 ? MagickTrue :
     MagickFalse;
-  signature_info->timestamp=(long) time(0);
+  signature_info->timestamp=(ssize_t) time(0);
   signature_info->signature=MagickSignature;
   InitializeSignature(signature_info);
   return(signature_info);
@@ -205,7 +205,7 @@
 */
 MagickExport void FinalizeSignature(SignatureInfo *signature_info)
 {
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -476,7 +476,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     y;
 
   QuantumInfo
@@ -525,7 +525,7 @@
   pixels=GetQuantumPixels(quantum_info);
   exception=(&image->exception);
   image_view=AcquireCacheView(image);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
@@ -601,10 +601,10 @@
 #define Suma0(x)  (RotateRight(x,2) ^ RotateRight(x,13) ^ RotateRight(x,22))
 #define Suma1(x)  (RotateRight(x,6) ^ RotateRight(x,11) ^ RotateRight(x,25))
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
diff --git a/magick/splay-tree.c b/magick/splay-tree.c
index 7e755a8..036ff30 100644
--- a/magick/splay-tree.c
+++ b/magick/splay-tree.c
@@ -97,7 +97,7 @@
     *key,
     *next;
 
-  unsigned long
+  size_t
     nodes;
 
   MagickBooleanType
@@ -106,7 +106,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -240,13 +240,13 @@
 %
 */
 
-static NodeInfo *LinkSplayTreeNodes(NodeInfo **nodes,const unsigned long low,
-  const unsigned long high)
+static NodeInfo *LinkSplayTreeNodes(NodeInfo **nodes,const size_t low,
+  const size_t high)
 {
   register NodeInfo
     *node;
 
-  unsigned long
+  size_t
     bisect;
 
   bisect=low+(high-low)/2;
@@ -918,7 +918,7 @@
 %
 %  The format of the GetNumberOfNodesInSplayTree method is:
 %
-%      unsigned long GetNumberOfNodesInSplayTree(
+%      size_t GetNumberOfNodesInSplayTree(
 %        const SplayTreeInfo *splay_tree)
 %
 %  A description of each parameter follows:
@@ -926,7 +926,7 @@
 %    o splay_tree: the splay tree.
 %
 */
-MagickExport unsigned long GetNumberOfNodesInSplayTree(
+MagickExport size_t GetNumberOfNodesInSplayTree(
   const SplayTreeInfo *splay_tree)
 {
   assert(splay_tree != (SplayTreeInfo *) NULL);
@@ -983,7 +983,7 @@
   NodeInfo
     **nodes;
 
-  register long
+  register ssize_t
     i;
 
   register NodeInfo
@@ -1467,7 +1467,7 @@
 %
 */
 
-static NodeInfo *Splay(SplayTreeInfo *splay_tree,const unsigned long depth,
+static NodeInfo *Splay(SplayTreeInfo *splay_tree,const size_t depth,
   const void *key,NodeInfo **node,NodeInfo **parent,NodeInfo **grandparent)
 {
   int
diff --git a/magick/splay-tree.h b/magick/splay-tree.h
index ec4fa54..155e756 100644
--- a/magick/splay-tree.h
+++ b/magick/splay-tree.h
@@ -45,7 +45,7 @@
   *NewSplayTree(int (*)(const void *,const void *),void *(*)(void *),
     void *(*)(void *));
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   GetNumberOfNodesInSplayTree(const SplayTreeInfo *);
 
 extern MagickExport void
diff --git a/magick/static.c b/magick/static.c
index ba2e8ec..4dc1ee5 100644
--- a/magick/static.c
+++ b/magick/static.c
@@ -107,7 +107,7 @@
   (void) exception;
 #else
   {
-    extern unsigned long
+    extern size_t
       analyzeImage(Image **,const int,char **,ExceptionInfo *);
 
     ImageFilterHandler
@@ -118,7 +118,7 @@
       image_filter=(ImageFilterHandler *) analyzeImage;
     if (image_filter != (ImageFilterHandler *) NULL)
       {
-        unsigned long
+        size_t
           signature;
 
         if ((*image)->debug != MagickFalse)
diff --git a/magick/static.h b/magick/static.h
index dec9e44..0652aab 100644
--- a/magick/static.h
+++ b/magick/static.h
@@ -26,7 +26,7 @@
   InvokeStaticImageFilter(const char *,Image **,const int,const char **,
     ExceptionInfo *);
 
-extern ModuleExport unsigned long
+extern ModuleExport size_t
   RegisterARTImage(void),
   RegisterAVIImage(void),
   RegisterAVSImage(void),
diff --git a/magick/statistic.c b/magick/statistic.c
index 08ec15b..010472d 100644
--- a/magick/statistic.c
+++ b/magick/statistic.c
@@ -134,11 +134,11 @@
 
 static MagickPixelPacket **DestroyPixelThreadSet(MagickPixelPacket **pixels)
 {
-  register long
+  register ssize_t
     i;
 
   assert(pixels != (MagickPixelPacket **) NULL);
-  for (i=0; i < (long) GetOpenMPMaximumThreads(); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (pixels[i] != (MagickPixelPacket *) NULL)
       pixels[i]=(MagickPixelPacket *) RelinquishMagickMemory(pixels[i]);
   pixels=(MagickPixelPacket **) RelinquishAlignedMemory(pixels);
@@ -147,14 +147,14 @@
 
 static MagickPixelPacket **AcquirePixelThreadSet(const Image *image)
 {
-  register long
+  register ssize_t
     i,
     j;
 
   MagickPixelPacket
     **pixels;
 
-  unsigned long
+  size_t
     number_threads;
 
   number_threads=GetOpenMPMaximumThreads();
@@ -163,13 +163,13 @@
   if (pixels == (MagickPixelPacket **) NULL)
     return((MagickPixelPacket **) NULL);
   (void) ResetMagickMemory(pixels,0,number_threads*sizeof(*pixels));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     pixels[i]=(MagickPixelPacket *) AcquireQuantumMemory(image->columns,
       sizeof(**pixels));
     if (pixels[i] == (MagickPixelPacket *) NULL)
       return(DestroyPixelThreadSet(pixels));
-    for (j=0; j < (long) image->columns; j++)
+    for (j=0; j < (ssize_t) image->columns; j++)
       GetMagickPixelPacket(image,&pixels[i][j]);
   }
   return(pixels);
@@ -219,7 +219,7 @@
     }
     case AndEvaluateOperator:
     {
-      result=(MagickRealType) ((unsigned long) pixel & (unsigned long)
+      result=(MagickRealType) ((size_t) pixel & (size_t)
         (value+0.5));
       break;
     }
@@ -254,7 +254,7 @@
     }
     case LeftShiftEvaluateOperator:
     {
-      result=(MagickRealType) ((unsigned long) pixel << (unsigned long)
+      result=(MagickRealType) ((size_t) pixel << (size_t)
         (value+0.5));
       break;
     }
@@ -292,7 +292,7 @@
     }
     case OrEvaluateOperator:
     {
-      result=(MagickRealType) ((unsigned long) pixel | (unsigned long)
+      result=(MagickRealType) ((size_t) pixel | (size_t)
         (value+0.5));
       break;
     }
@@ -310,7 +310,7 @@
     }
     case RightShiftEvaluateOperator:
     {
-      result=(MagickRealType) ((unsigned long) pixel >> (unsigned long)
+      result=(MagickRealType) ((size_t) pixel >> (size_t)
         (value+0.5));
       break;
     }
@@ -355,7 +355,7 @@
     }
     case XorEvaluateOperator:
     {
-      result=(MagickRealType) ((unsigned long) pixel ^ (unsigned long)
+      result=(MagickRealType) ((size_t) pixel ^ (size_t)
         (value+0.5));
       break;
     }
@@ -387,7 +387,7 @@
   Image
     *evaluate_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -401,7 +401,7 @@
   RandomInfo
     **restrict random_info;
 
-  unsigned long
+  size_t
     number_images;
 
   /*
@@ -453,7 +453,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic) shared(progress,status)
 #endif
-  for (y=0; y < (long) evaluate_image->rows; y++)
+  for (y=0; y < (ssize_t) evaluate_image->rows; y++)
   {
     CacheView
       *image_view;
@@ -467,7 +467,7 @@
     register IndexPacket
       *restrict evaluate_indexes;
 
-    register long
+    register ssize_t
       i,
       id,
       x;
@@ -491,10 +491,10 @@
     pixel=zero;
     id=GetOpenMPThreadId();
     evaluate_pixel=evaluate_pixels[id];
-    for (x=0; x < (long) evaluate_image->columns; x++)
+    for (x=0; x < (ssize_t) evaluate_image->columns; x++)
       evaluate_pixel[x]=zero;
     next=images;
-    for (i=0; i < (long) number_images; i++)
+    for (i=0; i < (ssize_t) number_images; i++)
     {
       register const IndexPacket
         *indexes;
@@ -510,7 +510,7 @@
           break;
         }
       indexes=GetCacheViewVirtualIndexQueue(image_view);
-      for (x=0; x < (long) next->columns; x++)
+      for (x=0; x < (ssize_t) next->columns; x++)
       {
         evaluate_pixel[x].red=ApplyEvaluateOperator(random_info[id],p->red,
           i == 0 ? AddEvaluateOperator : op,evaluate_pixel[x].red);
@@ -531,7 +531,7 @@
       next=GetNextImageInList(next);
     }
     if (op == MeanEvaluateOperator)
-      for (x=0; x < (long) evaluate_image->columns; x++)
+      for (x=0; x < (ssize_t) evaluate_image->columns; x++)
       {
         evaluate_pixel[x].red/=number_images;
         evaluate_pixel[x].green/=number_images;
@@ -539,7 +539,7 @@
         evaluate_pixel[x].opacity/=number_images;
         evaluate_pixel[x].index/=number_images;
       }
-    for (x=0; x < (long) evaluate_image->columns; x++)
+    for (x=0; x < (ssize_t) evaluate_image->columns; x++)
     {
       q->red=ClampToQuantum(evaluate_pixel[x].red);
       q->green=ClampToQuantum(evaluate_pixel[x].green);
@@ -583,7 +583,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -611,12 +611,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -633,7 +633,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ClampToQuantum(ApplyEvaluateOperator(random_info[id],q->red,op,
@@ -697,11 +697,11 @@
 %  The format of the FunctionImageChannel method is:
 %
 %      MagickBooleanType FunctionImage(Image *image,
-%        const MagickFunction function,const long number_parameters,
+%        const MagickFunction function,const ssize_t number_parameters,
 %        const double *parameters,ExceptionInfo *exception)
 %      MagickBooleanType FunctionImageChannel(Image *image,
 %        const ChannelType channel,const MagickFunction function,
-%        const long number_parameters,const double *argument,
+%        const ssize_t number_parameters,const double *argument,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -719,13 +719,13 @@
 */
 
 static Quantum ApplyFunction(Quantum pixel,const MagickFunction function,
-  const unsigned long number_parameters,const double *parameters,
+  const size_t number_parameters,const double *parameters,
   ExceptionInfo *exception)
 {
   MagickRealType
     result;
 
-  register long
+  register ssize_t
     i;
 
   (void) exception;
@@ -740,7 +740,7 @@
        *   For example:      c0*x^3 + c1*x^2 + c2*x  + c3
        */
       result=0.0;
-      for (i=0; i < (long) number_parameters; i++)
+      for (i=0; i < (ssize_t) number_parameters; i++)
         result = result*QuantumScale*pixel + parameters[i];
       result *= QuantumRange;
       break;
@@ -801,7 +801,7 @@
 }
 
 MagickExport MagickBooleanType FunctionImage(Image *image,
-  const MagickFunction function,const unsigned long number_parameters,
+  const MagickFunction function,const size_t number_parameters,
   const double *parameters,ExceptionInfo *exception)
 {
   MagickBooleanType
@@ -814,7 +814,7 @@
 
 MagickExport MagickBooleanType FunctionImageChannel(Image *image,
   const ChannelType channel,const MagickFunction function,
-  const unsigned long number_parameters,const double *parameters,
+  const size_t number_parameters,const double *parameters,
   ExceptionInfo *exception)
 {
 #define FunctionImageTag  "Function/Image "
@@ -822,7 +822,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -846,12 +846,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -866,7 +866,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ApplyFunction(q->red,function,number_parameters,parameters,
@@ -927,7 +927,7 @@
 %  The format of the GetImageChannelExtrema method is:
 %
 %      MagickBooleanType GetImageChannelExtrema(const Image *image,
-%        const ChannelType channel,unsigned long *minima,unsigned long *maxima,
+%        const ChannelType channel,size_t *minima,size_t *maxima,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -945,13 +945,13 @@
 */
 
 MagickExport MagickBooleanType GetImageExtrema(const Image *image,
-  unsigned long *minima,unsigned long *maxima,ExceptionInfo *exception)
+  size_t *minima,size_t *maxima,ExceptionInfo *exception)
 {
   return(GetImageChannelExtrema(image,AllChannels,minima,maxima,exception));
 }
 
 MagickExport MagickBooleanType GetImageChannelExtrema(const Image *image,
-  const ChannelType channel,unsigned long *minima,unsigned long *maxima,
+  const ChannelType channel,size_t *minima,size_t *maxima,
   ExceptionInfo *exception)
 {
   double
@@ -966,8 +966,8 @@
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   status=GetImageChannelRange(image,channel,&min,&max,exception);
-  *minima=(unsigned long) ceil(min-0.5);
-  *maxima=(unsigned long) floor(max+0.5);
+  *minima=(size_t) ceil(min-0.5);
+  *maxima=(size_t) floor(max+0.5);
   return(status);
 }
 
@@ -1023,7 +1023,7 @@
   double
     area;
 
-  long
+  ssize_t
     y;
 
   assert(image != (Image *) NULL);
@@ -1033,7 +1033,7 @@
   *mean=0.0;
   *standard_deviation=0.0;
   area=0.0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1041,14 +1041,14 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
@@ -1084,7 +1084,7 @@
       p++;
     }
   }
-  if (y < (long) image->rows)
+  if (y < (ssize_t) image->rows)
     return(MagickFalse);
   if (area != 0)
     {
@@ -1092,7 +1092,7 @@
       *standard_deviation/=area;
     }
   *standard_deviation=sqrt(*standard_deviation-(*mean*(*mean)));
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -1152,7 +1152,7 @@
     sum_cubes,
     sum_fourth_power;
 
-  long
+  ssize_t
     y;
 
   assert(image != (Image *) NULL);
@@ -1167,7 +1167,7 @@
   sum_squares=0.0;
   sum_cubes=0.0;
   sum_fourth_power=0.0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1175,14 +1175,14 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
@@ -1233,7 +1233,7 @@
       p++;
     }
   }
-  if (y < (long) image->rows)
+  if (y < (ssize_t) image->rows)
     return(MagickFalse);
   if (area != 0.0)
     {
@@ -1253,7 +1253,7 @@
       *skewness=sum_cubes-3.0*mean*sum_squares+2.0*mean*mean*mean;
       *skewness/=standard_deviation*standard_deviation*standard_deviation;
     }
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -1299,7 +1299,7 @@
   const ChannelType channel,double *minima,double *maxima,
   ExceptionInfo *exception)
 {
-  long
+  ssize_t
     y;
 
   MagickPixelPacket
@@ -1312,7 +1312,7 @@
   *maxima=(-1.0E-37);
   *minima=1.0E+37;
   GetMagickPixelPacket(image,&pixel);
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1320,14 +1320,14 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       SetMagickPixelPacket(image,p,indexes+x,&pixel);
       if ((channel & RedChannel) != 0)
@@ -1369,7 +1369,7 @@
       p++;
     }
   }
-  return(y == (long) image->rows ? MagickTrue : MagickFalse);
+  return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
 }
 
 /*
@@ -1416,7 +1416,7 @@
     sum_squares,
     sum_cubes;
 
-  long
+  ssize_t
     y;
 
   MagickStatusType
@@ -1425,13 +1425,13 @@
   QuantumAny
     range;
 
-  register long
+  register ssize_t
     i;
 
   size_t
     length;
 
-  unsigned long
+  size_t
     channels,
     depth;
 
@@ -1456,7 +1456,7 @@
     channel_statistics[i].kurtosis=0.0;
     channel_statistics[i].skewness=0.0;
   }
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1464,14 +1464,14 @@
     register const PixelPacket
       *restrict p;
 
-    register long
+    register ssize_t
       x;
 
     p=GetVirtualPixels(image,0,y,image->columns,1,exception);
     if (p == (const PixelPacket *) NULL)
       break;
     indexes=GetVirtualIndexQueue(image);
-    for (x=0; x < (long) image->columns; )
+    for (x=0; x < (ssize_t) image->columns; )
     {
       if (channel_statistics[RedChannel].depth != MAGICKCORE_QUANTUM_DEPTH)
         {
@@ -1620,7 +1620,7 @@
   }
   for (i=0; i < AllChannels; i++)
   {
-    channel_statistics[AllChannels].depth=(unsigned long) MagickMax((double)
+    channel_statistics[AllChannels].depth=(size_t) MagickMax((double)
       channel_statistics[AllChannels].depth,(double)
       channel_statistics[i].depth);
     channel_statistics[AllChannels].minima=MagickMin(
diff --git a/magick/statistic.h b/magick/statistic.h
index 580e9fe..2aea0ae 100644
--- a/magick/statistic.h
+++ b/magick/statistic.h
@@ -24,7 +24,7 @@
 
 typedef struct _ChannelStatistics
 {
-  unsigned long
+  size_t
     depth;
 
   double
@@ -87,19 +87,19 @@
     ExceptionInfo *),
   EvaluateImageChannel(Image *,const ChannelType,const MagickEvaluateOperator,
     const double,ExceptionInfo *),
-  FunctionImage(Image *,const MagickFunction,const unsigned long,const double *,
+  FunctionImage(Image *,const MagickFunction,const size_t,const double *,
     ExceptionInfo *),
   FunctionImageChannel(Image *,const ChannelType,const MagickFunction,
-    const unsigned long,const double *,ExceptionInfo *),
-  GetImageChannelExtrema(const Image *,const ChannelType,unsigned long *,
-    unsigned long *,ExceptionInfo *),
+    const size_t,const double *,ExceptionInfo *),
+  GetImageChannelExtrema(const Image *,const ChannelType,size_t *,
+    size_t *,ExceptionInfo *),
   GetImageChannelMean(const Image *,const ChannelType,double *,double *,
     ExceptionInfo *),
   GetImageChannelKurtosis(const Image *,const ChannelType,double *,double *,
     ExceptionInfo *),
   GetImageChannelRange(const Image *,const ChannelType,double *,double *,
     ExceptionInfo *),
-  GetImageExtrema(const Image *,unsigned long *,unsigned long *,
+  GetImageExtrema(const Image *,size_t *,size_t *,
     ExceptionInfo *),
   GetImageRange(const Image *,double *,double *,ExceptionInfo *),
   GetImageMean(const Image *,double *,double *,ExceptionInfo *),
diff --git a/magick/stream.c b/magick/stream.c
index 4d92ceb..ce65b46 100644
--- a/magick/stream.c
+++ b/magick/stream.c
@@ -89,7 +89,7 @@
   RectangleInfo
     extract_info;
 
-  long
+  ssize_t
     y;
 
   ExceptionInfo
@@ -98,7 +98,7 @@
   const void
     *client_data;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -110,16 +110,16 @@
 #endif
 
 static const PixelPacket
-  *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const long,
-    const long,const unsigned long,const unsigned long,ExceptionInfo *);
+  *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const ssize_t,
+    const ssize_t,const size_t,const size_t,ExceptionInfo *);
 
 static MagickBooleanType
   StreamImagePixels(const StreamInfo *,const Image *,ExceptionInfo *),
   SyncAuthenticPixelsStream(Image *,ExceptionInfo *);
 
 static PixelPacket
-  *QueueAuthenticPixelsStream(Image *,const long,const long,const unsigned long,
-    const unsigned long,ExceptionInfo *);
+  *QueueAuthenticPixelsStream(Image *,const ssize_t,const ssize_t,const size_t,
+    const size_t,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
@@ -336,8 +336,8 @@
 %
 %  The format of the GetAuthenticPixelsStream() method is:
 %
-%      PixelPacket *GetAuthenticPixelsStream(Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      PixelPacket *GetAuthenticPixelsStream(Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -350,8 +350,8 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static PixelPacket *GetAuthenticPixelsStream(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+static PixelPacket *GetAuthenticPixelsStream(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   PixelPacket
@@ -419,7 +419,7 @@
 %  The format of the GetOneAuthenticPixelFromStream() method is:
 %
 %      MagickBooleanType GetOneAuthenticPixelFromStream(const Image image,
-%        const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -433,7 +433,7 @@
 %
 */
 static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image,
-  const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 {
   register PixelPacket
     *pixels;
@@ -465,8 +465,8 @@
 %  The format of the GetOneVirtualPixelFromStream() method is:
 %
 %      MagickBooleanType GetOneVirtualPixelFromStream(const Image image,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,PixelPacket *pixel,ExceptionInfo *exception)
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -482,7 +482,7 @@
 %
 */
 static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image,
-  const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
+  const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
   PixelPacket *pixel,ExceptionInfo *exception)
 {
   const PixelPacket
@@ -623,8 +623,8 @@
 %  The format of the GetVirtualPixelStream() method is:
 %
 %      const PixelPacket *GetVirtualPixelStream(const Image *image,
-%        const VirtualPixelMethod virtual_pixel_method,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -665,8 +665,8 @@
 }
 
 static const PixelPacket *GetVirtualPixelStream(const Image *image,
-  const VirtualPixelMethod magick_unused(virtual_pixel_method),const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+  const VirtualPixelMethod magick_unused(virtual_pixel_method),const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
@@ -688,8 +688,8 @@
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
-      ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
+  if ((x < 0) || (y < 0) || ((x+(ssize_t) columns) > (ssize_t) image->columns) ||
+      ((y+(ssize_t) rows) > (ssize_t) image->rows) || (columns == 0) || (rows == 0))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
         "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
@@ -787,8 +787,8 @@
 %
 %  The format of the QueueAuthenticPixelsStream() method is:
 %
-%      PixelPacket *QueueAuthenticPixelsStream(Image *image,const long x,
-%        const long y,const unsigned long columns,const unsigned long rows,
+%      PixelPacket *QueueAuthenticPixelsStream(Image *image,const ssize_t x,
+%        const ssize_t y,const size_t columns,const size_t rows,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -799,8 +799,8 @@
 %      pixels.
 %
 */
-static PixelPacket *QueueAuthenticPixelsStream(Image *image,const long x,
-  const long y,const unsigned long columns,const unsigned long rows,
+static PixelPacket *QueueAuthenticPixelsStream(Image *image,const ssize_t x,
+  const ssize_t y,const size_t columns,const size_t rows,
   ExceptionInfo *exception)
 {
   CacheInfo
@@ -819,8 +819,8 @@
     Validate pixel cache geometry.
   */
   assert(image != (Image *) NULL);
-  if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
-      ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
+  if ((x < 0) || (y < 0) || ((x+(ssize_t) columns) > (ssize_t) image->columns) ||
+      ((y+(ssize_t) rows) > (ssize_t) image->rows) || (columns == 0) || (rows == 0))
     {
       (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
         "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
@@ -1108,7 +1108,7 @@
     case DoublePixel: packet_size=sizeof(double); break;
     case FloatPixel: packet_size=sizeof(float); break;
     case IntegerPixel: packet_size=sizeof(int); break;
-    case LongPixel: packet_size=sizeof(long); break;
+    case LongPixel: packet_size=sizeof(ssize_t); break;
     case QuantumPixel: packet_size=sizeof(Quantum); break;
     case ShortPixel: packet_size=sizeof(unsigned short); break;
   }
@@ -1150,7 +1150,7 @@
       return(count == 0 ? 0 : columns);
     }
   if ((stream_info->y < extract_info.y) ||
-      (stream_info->y >= (long) (extract_info.y+extract_info.height)))
+      (stream_info->y >= (ssize_t) (extract_info.y+extract_info.height)))
     {
       stream_info->y++;
       return(columns);
@@ -1237,7 +1237,7 @@
   QuantumType
     *quantum_map;
 
-  register long
+  register ssize_t
     i,
     x;
 
@@ -1264,7 +1264,7 @@
         ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
       return(MagickFalse);
     }
-  for (i=0; i < (long) length; i++)
+  for (i=0; i < (ssize_t) length; i++)
   {
     switch (stream_info->map[i])
     {
@@ -1377,7 +1377,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1391,7 +1391,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1406,7 +1406,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
               break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1421,7 +1421,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
             p++;
@@ -1433,7 +1433,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1447,7 +1447,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1462,7 +1462,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
             *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
@@ -1476,9 +1476,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
@@ -1542,7 +1542,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1559,7 +1559,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1578,7 +1578,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1596,7 +1596,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1609,7 +1609,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1626,7 +1626,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1645,7 +1645,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1662,9 +1662,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
@@ -1735,7 +1735,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1752,7 +1752,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1771,7 +1771,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1789,7 +1789,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1802,7 +1802,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1819,7 +1819,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1838,7 +1838,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
               quantum_info->scale+quantum_info->minimum);
@@ -1855,9 +1855,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
@@ -1928,7 +1928,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1942,7 +1942,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1958,7 +1958,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -1973,7 +1973,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(
               PixelIntensityToQuantum(p));
@@ -1986,7 +1986,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2000,7 +2000,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2016,7 +2016,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2030,9 +2030,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
@@ -2089,16 +2089,16 @@
     }
     case LongPixel:
     {
-      register unsigned long
+      register size_t
         *q;
 
-      q=(unsigned long *) stream_info->pixels;
+      q=(size_t *) stream_info->pixels;
       if (LocaleCompare(stream_info->map,"BGR") == 0)
         {
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2112,7 +2112,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2127,7 +2127,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2142,7 +2142,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p));
             p++;
@@ -2154,7 +2154,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2168,7 +2168,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2183,7 +2183,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
             *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
@@ -2197,9 +2197,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
@@ -2263,7 +2263,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetBluePixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2277,7 +2277,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetBluePixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2292,7 +2292,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetBluePixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2307,7 +2307,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=PixelIntensityToQuantum(p);
             p++;
@@ -2319,7 +2319,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetRedPixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2333,7 +2333,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetRedPixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2348,7 +2348,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=GetRedPixelComponent(p);
             *q++=GetGreenPixelComponent(p);
@@ -2362,9 +2362,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=(Quantum) 0;
           switch (quantum_map[i])
@@ -2428,7 +2428,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2442,7 +2442,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2457,7 +2457,7 @@
           p=GetAuthenticPixelQueue(image);
             if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2472,7 +2472,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p));
             p++;
@@ -2484,7 +2484,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2498,7 +2498,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2513,7 +2513,7 @@
           p=GetAuthenticPixelQueue(image);
           if (p == (const PixelPacket *) NULL)
             break;
-          for (x=0; x < (long) GetImageExtent(image); x++)
+          for (x=0; x < (ssize_t) GetImageExtent(image); x++)
           {
             *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
             *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
@@ -2527,9 +2527,9 @@
       if (p == (const PixelPacket *) NULL)
         break;
       indexes=GetAuthenticIndexQueue(image);
-      for (x=0; x < (long) GetImageExtent(image); x++)
+      for (x=0; x < (ssize_t) GetImageExtent(image); x++)
       {
-        for (i=0; i < (long) length; i++)
+        for (i=0; i < (ssize_t) length; i++)
         {
           *q=0;
           switch (quantum_map[i])
diff --git a/magick/string-private.h b/magick/string-private.h
index 95b5187..9dbd4e5 100644
--- a/magick/string-private.h
+++ b/magick/string-private.h
@@ -61,12 +61,12 @@
   return((int) strtol(value,(char **) NULL,10));
 }
 
-static inline long StringToLong(const char *value)
+static inline ssize_t StringToLong(const char *value)
 {
-  return(strtol(value,(char **) NULL,10));
+  return((ssize_t) strtol(value,(char **) NULL,10));
 }
 
-static inline unsigned long StringToUnsignedLong(const char *value)
+static inline size_t StringToUnsignedLong(const char *value)
 {
   return(strtoul(value,(char **) NULL,10));
 }
diff --git a/magick/string.c b/magick/string.c
index b716adb..95974b9 100644
--- a/magick/string.c
+++ b/magick/string.c
@@ -803,7 +803,7 @@
 */
 MagickExport char **DestroyStringList(char **list)
 {
-  register long
+  register ssize_t
     i;
 
   assert(list != (char **) NULL);
@@ -990,7 +990,7 @@
 %
 %  The format of the FormatMagickSize method is:
 %
-%      long FormatMagickSize(const MagickSizeType size,char *format)
+%      ssize_t FormatMagickSize(const MagickSizeType size,char *format)
 %
 %  A description of each parameter follows:
 %
@@ -1001,7 +1001,7 @@
 %    o format:  human readable format.
 %
 */
-MagickExport long FormatMagickSize(const MagickSizeType size,
+MagickExport ssize_t FormatMagickSize(const MagickSizeType size,
   const MagickBooleanType bi,char *format)
 {
   const char
@@ -1011,10 +1011,10 @@
     bytes,
     length;
 
-  long
+  ssize_t
     count;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -1067,7 +1067,7 @@
 %
 %  The format of the FormatMagickString method is:
 %
-%      long FormatMagickString(char *string,const size_t length,
+%      ssize_t FormatMagickString(char *string,const size_t length,
 %        const char *format,...)
 %
 %  A description of each parameter follows.
@@ -1082,7 +1082,7 @@
 %
 */
 
-MagickExport long FormatMagickStringList(char *string,const size_t length,
+MagickExport ssize_t FormatMagickStringList(char *string,const size_t length,
   const char *format,va_list operands)
 {
   int
@@ -1095,20 +1095,20 @@
 #endif
   if (n < 0)
     string[length-1]='\0';
-  return((long) n);
+  return((ssize_t) n);
 }
 
-MagickExport long FormatMagickString(char *string,const size_t length,
+MagickExport ssize_t FormatMagickString(char *string,const size_t length,
   const char *format,...)
 {
-  long
+  ssize_t
     n;
 
   va_list
     operands;
 
   va_start(operands,format);
-  n=(long) FormatMagickStringList(string,length,format,operands);
+  n=(ssize_t) FormatMagickStringList(string,length,format,operands);
   va_end(operands);
   return(n);
 }
@@ -1129,7 +1129,7 @@
 %
 %  The format of the FormatMagickTime method is:
 %
-%      long FormatMagickTime(const time_t time,const size_t length,
+%      ssize_t FormatMagickTime(const time_t time,const size_t length,
 %        char *timestamp)
 %
 %  A description of each parameter follows.
@@ -1142,10 +1142,10 @@
 %   o timestamp:  Return the Internet date/time here.
 %
 */
-MagickExport long FormatMagickTime(const time_t time,const size_t length,
+MagickExport ssize_t FormatMagickTime(const time_t time,const size_t length,
   char *timestamp)
 {
-  long
+  ssize_t
     count;
 
   struct tm
@@ -1189,7 +1189,7 @@
   count=FormatMagickString(timestamp,length,
     "%04d-%02d-%02dT%02d:%02d:%02d%+03ld:00",local_time.tm_year+1900,
     local_time.tm_mon+1,local_time.tm_mday,local_time.tm_hour,
-    local_time.tm_min,local_time.tm_sec,(long) timezone);
+    local_time.tm_min,local_time.tm_sec,(ssize_t) timezone);
   return(count);
 }
 
@@ -1568,10 +1568,10 @@
   p=(char *) string_info->datum;
   for (i=0; i < string_info->length; i+=0x14)
   {
-    (void) fprintf(file,"0x%08lx: ",(unsigned long) (0x14*i));
+    (void) fprintf(file,"0x%08lx: ",(size_t) (0x14*i));
     for (j=1; j <= MagickMin(string_info->length-i,0x14); j++)
     {
-      (void) fprintf(file,"%02lx",(unsigned long) (*(p+j)) & 0xff);
+      (void) fprintf(file,"%02lx",(size_t) (*(p+j)) & 0xff);
       if ((j % 0x04) == 0)
         (void) fputc(' ',file);
     }
@@ -1894,7 +1894,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i;
 
   *argc=0;
@@ -1924,7 +1924,7 @@
   */
   argv[0]=AcquireString("magick");
   p=text;
-  for (i=1; i < (long) *argc; i++)
+  for (i=1; i < (ssize_t) *argc; i++)
   {
     while (isspace((int) ((unsigned char) *p)) != 0)
       p++;
@@ -1992,7 +1992,7 @@
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -2028,7 +2028,7 @@
   hex_digits[15]='f';
   p=string_info->datum;
   q=(unsigned char *) string;
-  for (i=0; i < (long) string_info->length; i++)
+  for (i=0; i < (ssize_t) string_info->length; i++)
   {
     *q++=hex_digits[(*p >> 4) & 0x0f];
     *q++=hex_digits[*p & 0x0f];
@@ -2136,10 +2136,10 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     lines;
 
   if (text == (char *) NULL)
@@ -2165,7 +2165,7 @@
       if (textlist == (char **) NULL)
         ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
       p=text;
-      for (i=0; i < (long) lines; i++)
+      for (i=0; i < (ssize_t) lines; i++)
       {
         for (q=p; *q != '\0'; q++)
           if ((*q == '\r') || (*q == '\n'))
@@ -2188,19 +2188,19 @@
       register char
         *q;
 
-      register long
+      register ssize_t
         j;
 
       /*
         Convert string to a HEX list.
       */
-      lines=(unsigned long) (strlen(text)/0x14)+1;
+      lines=(size_t) (strlen(text)/0x14)+1;
       textlist=(char **) AcquireQuantumMemory((size_t) lines+1UL,
         sizeof(*textlist));
       if (textlist == (char **) NULL)
         ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
       p=text;
-      for (i=0; i < (long) lines; i++)
+      for (i=0; i < (ssize_t) lines; i++)
       {
         textlist[i]=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
           sizeof(*textlist));
@@ -2208,7 +2208,7 @@
           ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
         (void) FormatMagickString(textlist[i],MaxTextExtent,"0x%08lx: ",0x14*i);
         q=textlist[i]+strlen(textlist[i]);
-        for (j=1; j <= (long) MagickMin(strlen(p),0x14); j++)
+        for (j=1; j <= (ssize_t) MagickMin(strlen(p),0x14); j++)
         {
           (void) FormatMagickString(hex_string,MaxTextExtent,"%02x",*(p+j));
           (void) CopyMagickString(q,hex_string,MaxTextExtent);
@@ -2224,7 +2224,7 @@
             *q++=' ';
         }
         *q++=' ';
-        for (j=1; j <= (long) MagickMin(strlen(p),0x14); j++)
+        for (j=1; j <= (ssize_t) MagickMin(strlen(p),0x14); j++)
         {
           if (isprint((int) ((unsigned char) *p)) != 0)
             *q++=(*p);
diff --git a/magick/string_.h b/magick/string_.h
index afad01c..df0b780 100644
--- a/magick/string_.h
+++ b/magick/string_.h
@@ -37,7 +37,7 @@
   size_t
     length;
 
-  unsigned long
+  size_t
     signature;
 } StringInfo;
 
@@ -64,7 +64,7 @@
   LocaleCompare(const char *,const char *),
   LocaleNCompare(const char *,const char *,const size_t);
 
-extern MagickExport long
+extern MagickExport ssize_t
   FormatMagickSize(const MagickSizeType,const MagickBooleanType,char *),
   FormatMagickString(char *,const size_t,const char *,...)
     magick_attribute((format (printf,3,4))),
diff --git a/magick/thread-private.h b/magick/thread-private.h
index b8902c4..4b4bff0 100644
--- a/magick/thread-private.h
+++ b/magick/thread-private.h
@@ -36,7 +36,7 @@
 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
   typedef CRITICAL_SECTION MagickMutexType;
 #else
-  typedef unsigned long MagickMutexType;
+  typedef size_t MagickMutexType;
 #endif
 
 static inline MagickThreadType GetMagickThreadId(void)
@@ -50,7 +50,7 @@
 #endif
 }
 
-static inline unsigned long GetMagickThreadSignature(void)
+static inline size_t GetMagickThreadSignature(void)
 {
 #if defined(MAGICKCORE_HAVE_PTHREAD)
   {
@@ -59,7 +59,7 @@
       pthread_t
         id;
 
-      unsigned long
+      size_t
         signature;
     } magick_thread;
 
@@ -68,9 +68,9 @@
     return(magick_thread.signature);
   }
 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
-  return((unsigned long) GetCurrentThreadId());
+  return((size_t) GetCurrentThreadId());
 #else
-  return((unsigned long) getpid());
+  return((size_t) getpid());
 #endif
 }
 
@@ -92,14 +92,14 @@
 /*
   Lightweight OpenMP methods.
 */
-static inline unsigned long GetOpenMPMaximumThreads(void)
+static inline size_t GetOpenMPMaximumThreads(void)
 {
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && (_OPENMP >= 200203)
   {
-    static unsigned long
+    static size_t
       maximum_threads = 1UL;
 
-    if (omp_get_max_threads() > (long) maximum_threads)
+    if (omp_get_max_threads() > (ssize_t) maximum_threads)
       maximum_threads=omp_get_max_threads();
     return(maximum_threads);
   }
@@ -108,7 +108,7 @@
 #endif
 }
 
-static inline long GetOpenMPThreadId(void)
+static inline ssize_t GetOpenMPThreadId(void)
 {
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && (_OPENMP >= 200203)
   return(omp_get_thread_num());
@@ -117,7 +117,7 @@
 #endif
 }
 
-static inline void SetOpenMPMaximumThreads(const unsigned long threads)
+static inline void SetOpenMPMaximumThreads(const size_t threads)
 {
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && (_OPENMP >= 200203)
   omp_set_num_threads(threads);
diff --git a/magick/thread.c b/magick/thread.c
index 6de531b..3529e6d 100644
--- a/magick/thread.c
+++ b/magick/thread.c
@@ -175,7 +175,7 @@
 #elif defined(MAGICKCORE_HAVE_WINTHREADS)
   return(TlsSetValue(key,(void *) value) != 0 ? MagickTrue : MagickFalse);
 #else
-  *key=(unsigned long) value;
+  *key=(size_t) value;
   return(MagickTrue);
 #endif
 }
diff --git a/magick/thread_.h b/magick/thread_.h
index ffb59ab..cf189d4 100644
--- a/magick/thread_.h
+++ b/magick/thread_.h
@@ -35,7 +35,7 @@
 #elif defined(MAGICKCORE_HAVE_WINTHREADS)
 typedef DWORD MagickThreadKey;
 #else
-typedef unsigned long *MagickThreadKey;
+typedef size_t *MagickThreadKey;
 #endif
 
 extern MagickExport MagickBooleanType
diff --git a/magick/threshold.c b/magick/threshold.c
index 211e6a8..825d3dc 100644
--- a/magick/threshold.c
+++ b/magick/threshold.c
@@ -97,11 +97,11 @@
     *map_id,
     *description;
 
-  unsigned long
+  size_t
     width,
     height;
 
-  long
+  ssize_t
     divisor,
     *levels;
 };
@@ -125,8 +125,8 @@
 %  The format of the AdaptiveThresholdImage method is:
 %
 %      Image *AdaptiveThresholdImage(const Image *image,
-%        const unsigned long width,const unsigned long height,
-%        const long offset,ExceptionInfo *exception)
+%        const size_t width,const size_t height,
+%        const ssize_t offset,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -142,7 +142,7 @@
 %
 */
 MagickExport Image *AdaptiveThresholdImage(const Image *image,
-  const unsigned long width,const unsigned long height,const long offset,
+  const size_t width,const size_t height,const ssize_t offset,
   ExceptionInfo *exception)
 {
 #define ThresholdImageTag  "Threshold/Image"
@@ -154,7 +154,7 @@
   Image
     *threshold_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -196,7 +196,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -210,7 +210,7 @@
     register IndexPacket
       *restrict threshold_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -218,7 +218,7 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,-((long) width/2L),y-height/2L,
+    p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-height/2L,
       image->columns+width,height,exception);
     q=GetCacheViewAuthenticPixels(threshold_view,0,y,threshold_image->columns,1,
       exception);
@@ -229,9 +229,9 @@
       }
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     threshold_indexes=GetCacheViewAuthenticIndexQueue(threshold_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      long
+      ssize_t
         v;
 
       MagickPixelPacket
@@ -241,15 +241,15 @@
       register const PixelPacket
         *r;
 
-      register long
+      register ssize_t
         u;
 
       pixel=zero;
       mean=zero;
       r=p;
-      for (v=0; v < (long) height; v++)
+      for (v=0; v < (ssize_t) height; v++)
       {
-        for (u=0; u < (long) width; u++)
+        for (u=0; u < (ssize_t) width; u++)
         {
           pixel.red+=r[u].red;
           pixel.green+=r[u].green;
@@ -367,7 +367,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -390,12 +390,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -412,7 +412,7 @@
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     if (channel == DefaultChannels)
       {
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           q->red=(Quantum) ((MagickRealType) PixelIntensityToQuantum(q) <=
             threshold ? 0 : QuantumRange);
@@ -422,7 +422,7 @@
         }
       }
     else
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         if ((channel & RedChannel) != 0)
           q->red=(Quantum) ((MagickRealType) q->red <= threshold ? 0 :
@@ -523,7 +523,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -576,12 +576,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -596,7 +596,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (channel != DefaultChannels)
         {
@@ -710,7 +710,7 @@
   ExceptionInfo
     *exception;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -723,14 +723,14 @@
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   if (image->storage_class == PseudoClass)
     {
-      register long
+      register ssize_t
         i;
 
       register PixelPacket
         *restrict q;
 
       q=image->colormap;
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         q->red=ClampToUnsignedQuantum(q->red);
         q->green=ClampToUnsignedQuantum(q->green);
@@ -750,12 +750,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -770,7 +770,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         q->red=ClampToUnsignedQuantum(q->red);
@@ -834,8 +834,8 @@
     map->map_id=DestroyString(map->map_id);
   if (map->description != (char *) NULL)
     map->description=DestroyString(map->description);
-  if (map->levels != (long *) NULL)
-    map->levels=(long *) RelinquishMagickMemory(map->levels);
+  if (map->levels != (ssize_t *) NULL)
+    map->levels=(ssize_t *) RelinquishMagickMemory(map->levels);
   map=(ThresholdMap *) RelinquishMagickMemory(map);
   return(map);
 }
@@ -930,7 +930,7 @@
     ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap");
   map->map_id = (char *)NULL;
   map->description = (char *)NULL;
-  map->levels = (long *) NULL;
+  map->levels = (ssize_t *) NULL;
 
   /* Assign Basic Attributes */
   attr = GetXMLTreeAttribute(threshold, "map");
@@ -1001,14 +1001,14 @@
     map = DestroyThresholdMap(map);
     return(map);
   }
-  map->levels=(long *) AcquireQuantumMemory((size_t) map->width,map->height*
+  map->levels=(ssize_t *) AcquireQuantumMemory((size_t) map->width,map->height*
     sizeof(*map->levels));
-  if ( map->levels == (long *)NULL )
+  if ( map->levels == (ssize_t *)NULL )
     ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireThresholdMap");
   { /* parse levels into integer array */
     int i;
     char *p;
-    for( i=0; i< (long) (map->width*map->height); i++) {
+    for( i=0; i< (ssize_t) (map->width*map->height); i++) {
       map->levels[i] = (int)strtol(content, &p, 10);
       if ( p == content ) {
         (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
@@ -1353,7 +1353,7 @@
   CacheView
     *image_view;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1410,7 +1410,7 @@
 
     p = strchr((char *) threshold_map,',');
     if ( p != (char *)NULL && isdigit((int) ((unsigned char) *(++p))) )
-      levels.index = (unsigned long) strtol(p, &p, 10);
+      levels.index = (size_t) strtol(p, &p, 10);
     else
       levels.index = 2;
 
@@ -1426,15 +1426,15 @@
       p=strchr((char *) threshold_map,',');
       p++;
       if ((channel & RedChannel) != 0)
-        levels.red = (unsigned long) strtol(p, &p, 10),   (void)(*p == ',' && p++);
+        levels.red = (size_t) strtol(p, &p, 10),   (void)(*p == ',' && p++);
       if ((channel & GreenChannel) != 0)
-        levels.green = (unsigned long) strtol(p, &p, 10), (void)(*p == ',' && p++);
+        levels.green = (size_t) strtol(p, &p, 10), (void)(*p == ',' && p++);
       if ((channel & BlueChannel) != 0)
-        levels.blue = (unsigned long) strtol(p, &p, 10),  (void)(*p == ',' && p++);
+        levels.blue = (size_t) strtol(p, &p, 10),  (void)(*p == ',' && p++);
       if ((channel & IndexChannel) != 0 && image->colorspace == CMYKColorspace)
-        levels.index=(unsigned long) strtol(p, &p, 10), (void)(*p == ',' && p++);
+        levels.index=(size_t) strtol(p, &p, 10), (void)(*p == ',' && p++);
       if ((channel & OpacityChannel) != 0)
-        levels.opacity = (unsigned long) strtol(p, &p, 10), (void)(*p == ',' && p++);
+        levels.opacity = (size_t) strtol(p, &p, 10), (void)(*p == ',' && p++);
     }
   }
 #else
@@ -1446,7 +1446,7 @@
    * EG  -channel BA  -ordered-dither map,2,3
    * will need to map  g.rho -> l.blue, and g.sigma -> l.opacity
    * A simpler way is needed, probably converting geometry to a temporary
-   * array, then using channel to advance the index into long pixel packet.
+   * array, then using channel to advance the index into ssize_t pixel packet.
    */
 #endif
 
@@ -1480,12 +1480,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-    for (y=0; y < (long) image->rows; y++)
+    for (y=0; y < (ssize_t) image->rows; y++)
     {
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -1500,7 +1500,7 @@
           continue;
         }
       indexes=GetCacheViewAuthenticIndexQueue(image_view);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < (ssize_t) image->columns; x++)
       {
         register int
           threshold,
@@ -1636,7 +1636,7 @@
   MagickStatusType
     flags;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1699,7 +1699,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < (ssize_t) image->rows; y++)
       {
         MagickBooleanType
           sync;
@@ -1707,7 +1707,7 @@
         register IndexPacket
           *restrict indexes;
 
-        register long
+        register ssize_t
           id,
           x;
 
@@ -1725,7 +1725,7 @@
           }
         indexes=GetCacheViewAuthenticIndexQueue(image_view);
         id=GetOpenMPThreadId();
-        for (x=0; x < (long) image->columns; x++)
+        for (x=0; x < (ssize_t) image->columns; x++)
         {
           IndexPacket
             index;
@@ -1743,7 +1743,7 @@
               GetPseudoRandomValue(random_info[id]));
           index=(IndexPacket) (intensity <= threshold.index ? 0 : 1);
           indexes[x]=index;
-          *q++=image->colormap[(long) index];
+          *q++=image->colormap[(ssize_t) index];
         }
         sync=SyncCacheViewAuthenticPixels(image_view,exception);
         if (sync == MagickFalse)
@@ -1776,12 +1776,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -1798,7 +1798,7 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     id=GetOpenMPThreadId();
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if ((channel & RedChannel) != 0)
         {
@@ -1947,7 +1947,7 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -2003,12 +2003,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2023,7 +2023,7 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
       if (channel != DefaultChannels)
         {
diff --git a/magick/threshold.h b/magick/threshold.h
index af6fd8c..6719480 100644
--- a/magick/threshold.h
+++ b/magick/threshold.h
@@ -26,8 +26,8 @@
   ThresholdMap;
 
 extern MagickExport Image
-  *AdaptiveThresholdImage(const Image *,const unsigned long,const unsigned long,
-    const long,ExceptionInfo *);
+  *AdaptiveThresholdImage(const Image *,const size_t,const size_t,
+    const ssize_t,ExceptionInfo *);
 
 extern MagickExport ThresholdMap
   *DestroyThresholdMap(ThresholdMap *),
diff --git a/magick/timer.h b/magick/timer.h
index e46bb74..510d586 100644
--- a/magick/timer.h
+++ b/magick/timer.h
@@ -46,7 +46,7 @@
   TimerState
     state;
   
-  unsigned long
+  size_t
     signature;
 } TimerInfo;
 
diff --git a/magick/token-private.h b/magick/token-private.h
index 54cd8e4..67cfb73 100644
--- a/magick/token-private.h
+++ b/magick/token-private.h
@@ -30,7 +30,7 @@
 
 typedef struct
 {
-  long
+  ssize_t
     code_mask,
     code_value,
     utf_mask,
@@ -89,15 +89,15 @@
   return(utf8);
 }
 
-static inline long GetNextUTFCode(const char *text,size_t *octets)
+static inline ssize_t GetNextUTFCode(const char *text,size_t *octets)
 {
-  long
+  ssize_t
     code;
 
-  register long
+  register ssize_t
     i;
 
-  register long
+  register ssize_t
     c,
     unicode;
 
@@ -107,7 +107,7 @@
       errno=EINVAL;
       return(-1);
     }
-  code=(long) (*text++) & 0xff;
+  code=(ssize_t) (*text++) & 0xff;
   unicode=code;
   for (i=0; i < MaxMultibyteCodes; i++)
   {
@@ -122,7 +122,7 @@
         *octets=(size_t) (i+1);
         return(unicode);
       }
-    c=(long) (*text++ ^ 0x80) & 0xff;
+    c=(ssize_t) (*text++ ^ 0x80) & 0xff;
     if ((c & 0xc0) != 0)
       {
         errno=EILSEQ;
@@ -134,7 +134,7 @@
   return(-1);
 }
 
-static inline long GetUTFCode(const char *text)
+static inline ssize_t GetUTFCode(const char *text)
 {
   size_t
     octets;
@@ -151,7 +151,7 @@
   return(octets);
 }
 
-static inline MagickBooleanType IsUTFSpace(long code)
+static inline MagickBooleanType IsUTFSpace(ssize_t code)
 {
   if (((code >= 0x0009) && (code <= 0x000d)) || (code == 0x0020) ||
       (code == 0x0085) || (code == 0x00a0) || (code == 0x1680) ||
@@ -162,24 +162,24 @@
   return(MagickFalse);
 }
 
-static inline MagickBooleanType IsUTFValid(long code)
+static inline MagickBooleanType IsUTFValid(ssize_t code)
 {
-  long
+  ssize_t
     mask;
 
-  mask=(long) 0x7fffffff;
+  mask=(ssize_t) 0x7fffffff;
   if (((code & ~mask) != 0) && ((code < 0xd800) || (code > 0xdfff)) &&
       (code != 0xfffe) && (code != 0xffff))
     return(MagickFalse);
   return(MagickTrue);
 }
 
-static inline MagickBooleanType IsUTFAscii(long code)
+static inline MagickBooleanType IsUTFAscii(ssize_t code)
 {
-  long
+  ssize_t
     mask;
 
-  mask=(long) 0x7f;
+  mask=(ssize_t) 0x7f;
   if ((code & ~mask) != 0)
     return(MagickFalse);
   return(MagickTrue);
diff --git a/magick/token.c b/magick/token.c
index f86b7f3..d51109b 100644
--- a/magick/token.c
+++ b/magick/token.c
@@ -61,13 +61,13 @@
   MagickStatusType
     flag;
 
-  long
+  ssize_t
     offset;
 
   char
     quote;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -172,7 +172,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   i=0;
@@ -273,7 +273,7 @@
       offset=4;
       if (token[offset] == '#')
         offset++;
-      i=(long) strlen(token);
+      i=(ssize_t) strlen(token);
       (void) CopyMagickString(token,token+offset,MaxTextExtent);
       token[i-offset-1]='\0';
     }
@@ -388,7 +388,7 @@
       }
       case '[':
       {
-        long
+        ssize_t
           c;
 
         pattern+=GetUTFOctets(pattern);
@@ -768,7 +768,7 @@
 #define IN_QUOTE 2
 #define IN_OZONE 3
 
-static long sindex(int c,const char *string)
+static ssize_t sindex(int c,const char *string)
 {
   register const char
     *p;
@@ -782,7 +782,7 @@
 static void StoreToken(TokenInfo *token_info,char *string,
   size_t max_token_length,int c)
 {
-  register long
+  register ssize_t
     i;
 
   if ((token_info->offset < 0) ||
@@ -817,7 +817,7 @@
   int
     c;
 
-  register long
+  register ssize_t
     i;
 
   *breaker='\0';
diff --git a/magick/transform.c b/magick/transform.c
index 7967d0f..86ec542 100644
--- a/magick/transform.c
+++ b/magick/transform.c
@@ -105,7 +105,7 @@
   Image
     *chop_image;
 
-  long
+  ssize_t
     j,
     y;
 
@@ -116,7 +116,7 @@
   RectangleInfo
     extent;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -129,24 +129,24 @@
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   assert(chop_info != (RectangleInfo *) NULL);
-  if (((chop_info->x+(long) chop_info->width) < 0) ||
-      ((chop_info->y+(long) chop_info->height) < 0) ||
-      (chop_info->x > (long) image->columns) ||
-      (chop_info->y > (long) image->rows))
+  if (((chop_info->x+(ssize_t) chop_info->width) < 0) ||
+      ((chop_info->y+(ssize_t) chop_info->height) < 0) ||
+      (chop_info->x > (ssize_t) image->columns) ||
+      (chop_info->y > (ssize_t) image->rows))
     ThrowImageException(OptionWarning,"GeometryDoesNotContainImage");
   extent=(*chop_info);
-  if ((extent.x+(long) extent.width) > (long) image->columns)
-    extent.width=(unsigned long) ((long) image->columns-extent.x);
-  if ((extent.y+(long) extent.height) > (long) image->rows)
-    extent.height=(unsigned long) ((long) image->rows-extent.y);
+  if ((extent.x+(ssize_t) extent.width) > (ssize_t) image->columns)
+    extent.width=(size_t) ((ssize_t) image->columns-extent.x);
+  if ((extent.y+(ssize_t) extent.height) > (ssize_t) image->rows)
+    extent.height=(size_t) ((ssize_t) image->rows-extent.y);
   if (extent.x < 0)
     {
-      extent.width-=(unsigned long) (-extent.x);
+      extent.width-=(size_t) (-extent.x);
       extent.x=0;
     }
   if (extent.y < 0)
     {
-      extent.height-=(unsigned long) (-extent.y);
+      extent.height-=(size_t) (-extent.y);
       extent.y=0;
     }
   chop_image=CloneImage(image,image->columns-extent.width,image->rows-
@@ -161,7 +161,7 @@
   j=0;
   image_view=AcquireCacheView(image);
   chop_view=AcquireCacheView(chop_image);
-  for (y=0; y < (long) extent.y; y++)
+  for (y=0; y < (ssize_t) extent.y; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -170,7 +170,7 @@
       *restrict chop_indexes,
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -188,9 +188,9 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     chop_indexes=GetCacheViewAuthenticIndexQueue(chop_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if ((x < extent.x) || (x >= (long) (extent.x+extent.width)))
+      if ((x < extent.x) || (x >= (ssize_t) (extent.x+extent.width)))
         {
           *q=(*p);
           if (indexes != (IndexPacket *) NULL)
@@ -204,7 +204,8 @@
     }
     if (SyncCacheViewAuthenticPixels(chop_view,exception) == MagickFalse)
       status=MagickFalse;
-    proceed=SetImageProgress(image,ChopImageTag,y,chop_image->rows);
+    proceed=SetImageProgress(image,ChopImageTag,(MagickOffsetType) y,
+      chop_image->rows);
     if (proceed == MagickFalse)
       status=MagickFalse;
   }
@@ -212,7 +213,7 @@
     Extract chop image.
   */
   i+=extent.height;
-  for (y=0; y < (long) (image->rows-(extent.y+extent.height)); y++)
+  for (y=0; y < (ssize_t) (image->rows-(extent.y+extent.height)); y++)
   {
     register const PixelPacket
       *restrict p;
@@ -221,7 +222,7 @@
       *restrict chop_indexes,
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -239,9 +240,9 @@
       }
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     chop_indexes=GetCacheViewAuthenticIndexQueue(chop_view);
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if ((x < extent.x) || (x >= (long) (extent.x+extent.width)))
+      if ((x < extent.x) || (x >= (ssize_t) (extent.x+extent.width)))
         {
           *q=(*p);
           if (indexes != (IndexPacket *) NULL)
@@ -255,7 +256,8 @@
     }
     if (SyncCacheViewAuthenticPixels(chop_view,exception) == MagickFalse)
       status=MagickFalse;
-    proceed=SetImageProgress(image,ChopImageTag,y,chop_image->rows);
+    proceed=SetImageProgress(image,ChopImageTag,(MagickOffsetType) y,
+      chop_image->rows);
     if (proceed == MagickFalse)
       status=MagickFalse;
   }
@@ -297,10 +299,10 @@
     *cmyk_image,
     *cmyk_images;
 
-  long
+  ssize_t
     y;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -313,7 +315,7 @@
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   cmyk_images=NewImageList();
-  for (i=0; i < (long) GetImageListLength(images); i+=4)
+  for (i=0; i < (ssize_t) GetImageListLength(images); i+=4)
   {
     cmyk_image=CloneImage(images,images->columns,images->rows,MagickTrue,
       exception);
@@ -322,12 +324,12 @@
     if (SetImageStorageClass(cmyk_image,DirectClass) == MagickFalse)
       break;
     (void) SetImageColorspace(cmyk_image,CMYKColorspace);
-    for (y=0; y < (long) images->rows; y++)
+    for (y=0; y < (ssize_t) images->rows; y++)
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -337,7 +339,7 @@
       q=QueueAuthenticPixels(cmyk_image,0,y,cmyk_image->columns,1,exception);
       if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
         break;
-      for (x=0; x < (long) images->columns; x++)
+      for (x=0; x < (ssize_t) images->columns; x++)
       {
         q->red=(Quantum) (QuantumRange-PixelIntensityToQuantum(p));
         p++;
@@ -349,12 +351,12 @@
     images=GetNextImageInList(images);
     if (images == (Image *) NULL)
       break;
-    for (y=0; y < (long) images->rows; y++)
+    for (y=0; y < (ssize_t) images->rows; y++)
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -364,7 +366,7 @@
       q=GetAuthenticPixels(cmyk_image,0,y,cmyk_image->columns,1,exception);
       if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
         break;
-      for (x=0; x < (long) images->columns; x++)
+      for (x=0; x < (ssize_t) images->columns; x++)
       {
         q->green=(Quantum) (QuantumRange-PixelIntensityToQuantum(p));
         p++;
@@ -376,12 +378,12 @@
     images=GetNextImageInList(images);
     if (images == (Image *) NULL)
       break;
-    for (y=0; y < (long) images->rows; y++)
+    for (y=0; y < (ssize_t) images->rows; y++)
     {
       register const PixelPacket
         *restrict p;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -391,7 +393,7 @@
       q=GetAuthenticPixels(cmyk_image,0,y,cmyk_image->columns,1,exception);
       if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
         break;
-      for (x=0; x < (long) images->columns; x++)
+      for (x=0; x < (ssize_t) images->columns; x++)
       {
         q->blue=(Quantum) (QuantumRange-PixelIntensityToQuantum(p));
         p++;
@@ -403,7 +405,7 @@
     images=GetNextImageInList(images);
     if (images == (Image *) NULL)
       break;
-    for (y=0; y < (long) images->rows; y++)
+    for (y=0; y < (ssize_t) images->rows; y++)
     {
       register const PixelPacket
         *restrict p;
@@ -411,7 +413,7 @@
       register IndexPacket
         *restrict indexes;
 
-      register long
+      register ssize_t
         x;
 
       register PixelPacket
@@ -422,7 +424,7 @@
       if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
         break;
       indexes=GetAuthenticIndexQueue(cmyk_image);
-      for (x=0; x < (long) images->columns; x++)
+      for (x=0; x < (ssize_t) images->columns; x++)
       {
         indexes[x]=(IndexPacket) (QuantumRange-PixelIntensityToQuantum(p));
         p++;
@@ -479,17 +481,19 @@
   Image
     *crop_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   RectangleInfo
     bounding_box,
     page;
 
+  ssize_t
+    y;
+
   /*
     Check crop geometry.
   */
@@ -511,10 +515,10 @@
     page.width=bounding_box.width;
   if (page.height == 0)
     page.height=bounding_box.height;
-  if (((bounding_box.x-page.x) >= (long) page.width) ||
-      ((bounding_box.y-page.y) >= (long) page.height) ||
-      ((page.x-bounding_box.x) > (long) image->columns) ||
-      ((page.y-bounding_box.y) > (long) image->rows))
+  if (((bounding_box.x-page.x) >= (ssize_t) page.width) ||
+      ((bounding_box.y-page.y) >= (ssize_t) page.height) ||
+      ((page.x-bounding_box.x) > (ssize_t) image->columns) ||
+      ((page.y-bounding_box.y) > (ssize_t) image->rows))
     {
       /*
         Crop is not within virtual canvas, return 1 pixel transparent image.
@@ -557,11 +561,11 @@
       if (page.y < 0)
         page.y=0;
     }
-  if ((unsigned long) (page.x+page.width) > image->columns)
+  if ((size_t) (page.x+page.width) > image->columns)
     page.width=image->columns-page.x;
   if ((geometry->width != 0) && (page.width > geometry->width))
     page.width=geometry->width;
-  if ((unsigned long) (page.y+page.height) > image->rows)
+  if ((size_t) (page.y+page.height) > image->rows)
     page.height=image->rows-page.y;
   if ((geometry->height != 0) && (page.height > geometry->height))
     page.height=geometry->height;
@@ -581,8 +585,8 @@
     return((Image *) NULL);
   crop_image->page.width=image->page.width;
   crop_image->page.height=image->page.height;
-  if (((long) (bounding_box.x+bounding_box.width) > (long) image->page.width) ||
-      ((long) (bounding_box.y+bounding_box.height) > (long) image->page.height))
+  if (((ssize_t) (bounding_box.x+bounding_box.width) > (ssize_t) image->page.width) ||
+      ((ssize_t) (bounding_box.y+bounding_box.height) > (ssize_t) image->page.height))
     {
       crop_image->page.width=bounding_box.width;
       crop_image->page.height=bounding_box.height;
@@ -599,7 +603,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) crop_image->rows; y++)
+  for (y=0; y < (ssize_t) crop_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -694,13 +698,15 @@
   Image
     *excerpt_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   /*
     Allocate excerpt image.
   */
@@ -725,7 +731,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) excerpt_image->rows; y++)
+  for (y=0; y < (ssize_t) excerpt_image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -880,13 +886,15 @@
   Image
     *flip_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -906,7 +914,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) flip_image->rows; y++)
+  for (y=0; y < (ssize_t) flip_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -923,7 +931,7 @@
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=QueueCacheViewAuthenticPixels(flip_view,0,(long) (flip_image->rows-y-1),
+    q=QueueCacheViewAuthenticPixels(flip_view,0,(ssize_t) (flip_image->rows-y-1),
       flip_image->columns,1,exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       {
@@ -998,13 +1006,15 @@
   Image
     *flop_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -1024,7 +1034,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT) && defined(MAGICKCORE_FUTURE)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) flop_image->rows; y++)
+  for (y=0; y < (ssize_t) flop_image->rows; y++)
   {
     register const IndexPacket
       *restrict indexes;
@@ -1035,7 +1045,7 @@
     register IndexPacket
       *restrict flop_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1054,7 +1064,7 @@
     q+=flop_image->columns;
     indexes=GetCacheViewVirtualIndexQueue(image_view);
     flop_indexes=GetCacheViewAuthenticIndexQueue(flop_view);
-    for (x=0; x < (long) flop_image->columns; x++)
+    for (x=0; x < (ssize_t) flop_image->columns; x++)
     {
       (*--q)=(*p++);
       if ((indexes != (const IndexPacket *) NULL) &&
@@ -1099,8 +1109,8 @@
 %
 %  The format of the RollImage method is:
 %
-%      Image *RollImage(const Image *image,const long x_offset,
-%        const long y_offset,ExceptionInfo *exception)
+%      Image *RollImage(const Image *image,const ssize_t x_offset,
+%        const ssize_t y_offset,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1115,15 +1125,15 @@
 */
 
 static inline MagickBooleanType CopyImageRegion(Image *destination,
-  const Image *source,const unsigned long columns,const unsigned long rows,
-  const long sx,const long sy,const long dx,const long dy,
+  const Image *source,const size_t columns,const size_t rows,
+  const ssize_t sx,const ssize_t sy,const ssize_t dx,const ssize_t dy,
   ExceptionInfo *exception)
 {
   CacheView
     *source_view,
     *destination_view;
 
-  long
+  ssize_t
     y;
 
   MagickBooleanType
@@ -1135,7 +1145,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(status)
 #endif
-  for (y=0; y < (long) rows; y++)
+  for (y=0; y < (ssize_t) rows; y++)
   {
     MagickBooleanType
       sync;
@@ -1182,8 +1192,8 @@
   return(status);
 }
 
-MagickExport Image *RollImage(const Image *image,const long x_offset,
-  const long y_offset,ExceptionInfo *exception)
+MagickExport Image *RollImage(const Image *image,const ssize_t x_offset,
+  const ssize_t y_offset,ExceptionInfo *exception)
 {
 #define RollImageTag  "Roll/Image"
 
@@ -1212,25 +1222,25 @@
   offset.y=y_offset;
   while (offset.x < 0)
     offset.x+=image->columns;
-  while (offset.x >= (long) image->columns)
+  while (offset.x >= (ssize_t) image->columns)
     offset.x-=image->columns;
   while (offset.y < 0)
     offset.y+=image->rows;
-  while (offset.y >= (long) image->rows)
+  while (offset.y >= (ssize_t) image->rows)
     offset.y-=image->rows;
   /*
     Roll image.
   */
-  status=CopyImageRegion(roll_image,image,(unsigned long) offset.x,
-    (unsigned long) offset.y,(long) image->columns-offset.x,(long) image->rows-
+  status=CopyImageRegion(roll_image,image,(size_t) offset.x,
+    (size_t) offset.y,(ssize_t) image->columns-offset.x,(ssize_t) image->rows-
     offset.y,0,0,exception);
   (void) SetImageProgress(image,RollImageTag,0,3);
   status|=CopyImageRegion(roll_image,image,image->columns-offset.x,
-    (unsigned long) offset.y,0,(long) image->rows-offset.y,offset.x,0,
+    (size_t) offset.y,0,(ssize_t) image->rows-offset.y,offset.x,0,
     exception);
   (void) SetImageProgress(image,RollImageTag,1,3);
-  status|=CopyImageRegion(roll_image,image,(unsigned long) offset.x,image->rows-
-    offset.y,(long) image->columns-offset.x,0,0,offset.y,exception);
+  status|=CopyImageRegion(roll_image,image,(size_t) offset.x,image->rows-
+    offset.y,(ssize_t) image->columns-offset.x,0,0,offset.y,exception);
   (void) SetImageProgress(image,RollImageTag,2,3);
   status|=CopyImageRegion(roll_image,image,image->columns-offset.x,image->rows-
     offset.y,0,0,offset.x,offset.y,exception);
@@ -1294,8 +1304,8 @@
   SetGeometry(image,&geometry);
   geometry.width-=2*shave_info->width;
   geometry.height-=2*shave_info->height;
-  geometry.x=(long) shave_info->width+image->page.x;
-  geometry.y=(long) shave_info->height+image->page.y;
+  geometry.x=(ssize_t) shave_info->width+image->page.x;
+  geometry.y=(ssize_t) shave_info->height+image->page.y;
   shave_image=CropImage(image,&geometry,exception);
   if (shave_image == (Image *) NULL)
     return((Image *) NULL);
@@ -1347,20 +1357,22 @@
   Image
     *splice_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     proceed,
     status;
 
+  MagickOffsetType
+    progress;
+
   RectangleInfo
     splice_geometry;
 
-  register long
+  register ssize_t
     i;
 
+  ssize_t
+    y;
+
   /*
     Allocate splice image.
   */
@@ -1449,7 +1461,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) splice_geometry.y; y++)
+  for (y=0; y < (ssize_t) splice_geometry.y; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -1458,7 +1470,7 @@
       *restrict indexes,
       *restrict splice_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1489,9 +1501,9 @@
       p++;
       q++;
     }
-    for ( ; x < (long) (splice_geometry.x+splice_geometry.width); x++)
+    for ( ; x < (ssize_t) (splice_geometry.x+splice_geometry.width); x++)
       q++;
-    for ( ; x < (long) splice_image->columns; x++)
+    for ( ; x < (ssize_t) splice_image->columns; x++)
     {
       SetRedPixelComponent(q,GetRedPixelComponent(p));
       SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -1506,7 +1518,8 @@
     }
     if (SyncCacheViewAuthenticPixels(splice_view,exception) == MagickFalse)
       status=MagickFalse;
-    proceed=SetImageProgress(image,SpliceImageTag,y,splice_image->rows);
+    proceed=SetImageProgress(image,SpliceImageTag,(MagickOffsetType) y,
+      splice_image->rows);
     if (image->progress_monitor != (MagickProgressMonitor) NULL)
       {
         MagickBooleanType
@@ -1524,8 +1537,8 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=(long) (splice_geometry.y+splice_geometry.height);
-       y < (long) splice_image->rows; y++)
+  for (y=(ssize_t) (splice_geometry.y+splice_geometry.height);
+       y < (ssize_t) splice_image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -1534,7 +1547,7 @@
       *restrict indexes,
       *restrict splice_indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -1566,9 +1579,9 @@
       p++;
       q++;
     }
-    for ( ; x < (long) (splice_geometry.x+splice_geometry.width); x++)
+    for ( ; x < (ssize_t) (splice_geometry.x+splice_geometry.width); x++)
       q++;
-    for ( ; x < (long) splice_image->columns; x++)
+    for ( ; x < (ssize_t) splice_image->columns; x++)
     {
       SetRedPixelComponent(q,GetRedPixelComponent(p));
       SetGreenPixelComponent(q,GetGreenPixelComponent(p));
@@ -1636,14 +1649,14 @@
 %      final size of the image.
 %
 */
-static inline long MagickRound(MagickRealType x)
+static inline ssize_t MagickRound(MagickRealType x)
 {
   /*
     Round the fraction to nearest integer.
   */
   if (x >= 0.0)
-    return((long) (x+0.5));
-  return((long) (x-0.5));
+    return((ssize_t) (x+0.5));
+  return((ssize_t) (x-0.5));
 }
 
 MagickExport MagickBooleanType TransformImage(Image **image,
@@ -1654,7 +1667,7 @@
     *resize_image,
     *transform_image;
 
-  long
+  ssize_t
     x,
     y;
 
@@ -1664,7 +1677,7 @@
   RectangleInfo
     geometry;
 
-  unsigned long
+  size_t
     height,
     width;
 
@@ -1722,18 +1735,18 @@
           {
             if ((flags & AspectValue) == 0)
               {
-                crop.y=(long) MagickRound((MagickRealType) (offset.y-
+                crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
                   (geometry.y > 0 ? 0 : geometry.y)));
                 offset.y+=delta.y;
-                crop.height=(unsigned long) MagickRound((MagickRealType)
+                crop.height=(size_t) MagickRound((MagickRealType)
                   (offset.y+(geometry.y < 0 ? 0 : geometry.y)));
               }
             else
               {
-                crop.y=(long) MagickRound((MagickRealType) (offset.y-
+                crop.y=(ssize_t) MagickRound((MagickRealType) (offset.y-
                   (geometry.y > 0 ? geometry.y : 0)));
                 offset.y+=delta.y;
-                crop.height=(unsigned long) MagickRound((MagickRealType)
+                crop.height=(size_t) MagickRound((MagickRealType)
                   (offset.y+(geometry.y < 0 ? geometry.y : 0)));
               }
             crop.height-=crop.y;
@@ -1742,18 +1755,18 @@
             {
               if ((flags & AspectValue) == 0)
                 {
-                  crop.x=(long) MagickRound((MagickRealType) (offset.x-
+                  crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
                     (geometry.x > 0 ? 0 : geometry.x)));
                   offset.x+=+delta.x;
-                  crop.width=(unsigned long) MagickRound((MagickRealType)
+                  crop.width=(size_t) MagickRound((MagickRealType)
                     (offset.x+(geometry.x < 0 ? 0 : geometry.x)));
                 }
               else
                 {
-                  crop.x=(long) MagickRound((MagickRealType) (offset.x-
+                  crop.x=(ssize_t) MagickRound((MagickRealType) (offset.x-
                     (geometry.x > 0 ? geometry.x : 0)));
                   offset.x+=+delta.x;
-                  crop.width=(unsigned long) MagickRound((MagickRealType)
+                  crop.width=(size_t) MagickRound((MagickRealType)
                     (offset.x+(geometry.x < 0 ? geometry.x : 0)));
                 }
               crop.width-=crop.x;
@@ -1817,12 +1830,12 @@
              proceed=MagickTrue;
              i=0;
              number_images=0;
-             for (y=0; y < (long) transform_image->page.height; y+=height)
-               for (x=0; x < (long) transform_image->page.width; x+=width)
+             for (y=0; y < (ssize_t) transform_image->page.height; y+=height)
+               for (x=0; x < (ssize_t) transform_image->page.width; x+=width)
                  number_images++;
-             for (y=0; y < (long) transform_image->page.height; y+=height)
+             for (y=0; y < (ssize_t) transform_image->page.height; y+=height)
              {
-               for (x=0; x < (long) transform_image->page.width; x+=width)
+               for (x=0; x < (ssize_t) transform_image->page.width; x+=width)
                {
                  progress_monitor=SetImageProgressMonitor(transform_image,
                    (MagickProgressMonitor) NULL,transform_image->client_data);
@@ -1924,7 +1937,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   assert(images != (Image **) NULL);
@@ -1984,16 +1997,18 @@
   Image
     *transpose_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   RectangleInfo
     page;
 
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -2014,7 +2029,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     register const PixelPacket
       *restrict p;
@@ -2028,9 +2043,9 @@
 
     if (status == MagickFalse)
       continue;
-    p=GetCacheViewVirtualPixels(image_view,0,(long) image->rows-y-1,
+    p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-y-1,
       image->columns,1,exception);
-    q=QueueCacheViewAuthenticPixels(transpose_view,(long) (image->rows-y-1),0,
+    q=QueueCacheViewAuthenticPixels(transpose_view,(ssize_t) (image->rows-y-1),0,
       1,transpose_image->rows,exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       {
@@ -2069,7 +2084,7 @@
   Swap(page.width,page.height);
   Swap(page.x,page.y);
   if (page.width != 0)
-    page.x=(long) (page.width-transpose_image->columns-page.x);
+    page.x=(ssize_t) (page.width-transpose_image->columns-page.x);
   transpose_image->page=page;
   if (status == MagickFalse)
     transpose_image=DestroyImage(transpose_image);
@@ -2112,16 +2127,18 @@
   Image
     *transverse_image;
 
-  long
-    progress,
-    y;
-
   MagickBooleanType
     status;
 
+  MagickOffsetType
+    progress;
+
   RectangleInfo
     page;
 
+  ssize_t
+    y;
+
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
@@ -2142,7 +2159,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < (ssize_t) image->rows; y++)
   {
     MagickBooleanType
       sync;
@@ -2154,7 +2171,7 @@
       *restrict transverse_indexes,
       *restrict indexes;
 
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2163,7 +2180,7 @@
     if (status == MagickFalse)
       continue;
     p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
-    q=QueueCacheViewAuthenticPixels(transverse_view,(long) (image->rows-y-
+    q=QueueCacheViewAuthenticPixels(transverse_view,(ssize_t) (image->rows-y-
       1),0,1,transverse_image->rows,exception);
     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
       {
@@ -2171,14 +2188,14 @@
         continue;
       }
     q+=image->columns;
-    for (x=0; x < (long) image->columns; x++)
+    for (x=0; x < (ssize_t) image->columns; x++)
       *--q=(*p++);
     indexes=GetCacheViewAuthenticIndexQueue(image_view);
     if (indexes != (IndexPacket *) NULL)
       {
         transverse_indexes=GetCacheViewAuthenticIndexQueue(transverse_view);
         if (transverse_indexes != (IndexPacket *) NULL)
-          for (x=0; x < (long) image->columns; x++)
+          for (x=0; x < (ssize_t) image->columns; x++)
             transverse_indexes[image->columns-x-1]=indexes[x];
       }
     sync=SyncCacheViewAuthenticPixels(transverse_view,exception);
@@ -2205,7 +2222,7 @@
   Swap(page.width,page.height);
   Swap(page.x,page.y);
   if (page.height != 0)
-    page.y=(long) (page.height-transverse_image->rows-page.y);
+    page.y=(ssize_t) (page.height-transverse_image->rows-page.y);
   transverse_image->page=page;
   if (status == MagickFalse)
     transverse_image=DestroyImage(transverse_image);
diff --git a/magick/transform.h b/magick/transform.h
index 3f466dc..98d83d7 100644
--- a/magick/transform.h
+++ b/magick/transform.h
@@ -30,7 +30,7 @@
   *ExtentImage(const Image *,const RectangleInfo *,ExceptionInfo *),
   *FlipImage(const Image *,ExceptionInfo *),
   *FlopImage(const Image *,ExceptionInfo *),
-  *RollImage(const Image *,const long,const long,ExceptionInfo *),
+  *RollImage(const Image *,const ssize_t,const ssize_t,ExceptionInfo *),
   *ShaveImage(const Image *,const RectangleInfo *,ExceptionInfo *),
   *SpliceImage(const Image *,const RectangleInfo *,ExceptionInfo *),
   *TransposeImage(const Image *,ExceptionInfo *),
diff --git a/magick/type.c b/magick/type.c
index fd0392f..8d48463 100644
--- a/magick/type.c
+++ b/magick/type.c
@@ -193,7 +193,7 @@
 %
 %      const TypeInfo *GetTypeInfoByFamily(const char *family,
 %        const StyleType style,const StretchType stretch,
-%        const unsigned long weight,ExceptionInfo *exception)
+%        const size_t weight,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -209,16 +209,16 @@
 %
 */
 
-static inline unsigned long MagickMax(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMax(const size_t x,
+  const size_t y)
 {
   if (x > y)
     return(x);
   return(y);
 }
 
-static inline unsigned long MagickMin(const unsigned long x,
-  const unsigned long y)
+static inline size_t MagickMin(const size_t x,
+  const size_t y)
 {
   if (x < y)
     return(x);
@@ -226,7 +226,7 @@
 }
 
 MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family,
-  const StyleType style,const StretchType stretch,const unsigned long weight,
+  const StyleType style,const StretchType stretch,const size_t weight,
   ExceptionInfo *exception)
 {
   typedef struct _Fontmap
@@ -239,13 +239,13 @@
   const TypeInfo
     *type_info;
 
-  long
+  ssize_t
     range;
 
   register const TypeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   static const Fontmap
@@ -261,7 +261,7 @@
       { NULL, NULL }
     };
 
-  unsigned long
+  size_t
     max_score,
     score;
 
@@ -358,15 +358,15 @@
     if (weight == 0)
       score+=16;
     else
-      score+=(16*(800-((long) MagickMax(MagickMin(weight,900),p->weight)-
-        (long) MagickMin(MagickMin(weight,900),p->weight))))/800;
+      score+=(16*(800-((ssize_t) MagickMax(MagickMin(weight,900),p->weight)-
+        (ssize_t) MagickMin(MagickMin(weight,900),p->weight))))/800;
     if ((stretch == UndefinedStretch) || (stretch == AnyStretch))
       score+=8;
     else
       {
-        range=(long) UltraExpandedStretch-(long) NormalStretch;
-        score+=(8*(range-((long) MagickMax(stretch,p->stretch)-
-          (long) MagickMin(stretch,p->stretch))))/range;
+        range=(ssize_t) UltraExpandedStretch-(ssize_t) NormalStretch;
+        score+=(8*(range-((ssize_t) MagickMax(stretch,p->stretch)-
+          (ssize_t) MagickMin(stretch,p->stretch))))/range;
       }
     if (score > max_score)
       {
@@ -424,7 +424,7 @@
 %  The format of the GetTypeInfoList function is:
 %
 %      const TypeInfo **GetTypeInfoList(const char *pattern,
-%        unsigned long *number_fonts,ExceptionInfo *exception)
+%        size_t *number_fonts,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -458,7 +458,7 @@
 #endif
 
 MagickExport const TypeInfo **GetTypeInfoList(const char *pattern,
-  unsigned long *number_fonts,ExceptionInfo *exception)
+  size_t *number_fonts,ExceptionInfo *exception)
 {
   const TypeInfo
     **fonts;
@@ -466,7 +466,7 @@
   register const TypeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -474,7 +474,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_fonts != (unsigned long *) NULL);
+  assert(number_fonts != (size_t *) NULL);
   *number_fonts=0;
   p=GetTypeInfo("*",exception);
   if (p == (const TypeInfo *) NULL)
@@ -499,7 +499,7 @@
   UnlockSemaphoreInfo(type_semaphore);
   qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeInfoCompare);
   fonts[i]=(TypeInfo *) NULL;
-  *number_fonts=(unsigned long) i;
+  *number_fonts=(size_t) i;
   return(fonts);
 }
 
@@ -518,7 +518,7 @@
 %
 %  The format of the GetTypeList function is:
 %
-%      char **GetTypeList(const char *pattern,unsigned long *number_fonts,
+%      char **GetTypeList(const char *pattern,size_t *number_fonts,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -550,7 +550,7 @@
 }
 #endif
 
-MagickExport char **GetTypeList(const char *pattern,unsigned long *number_fonts,
+MagickExport char **GetTypeList(const char *pattern,size_t *number_fonts,
   ExceptionInfo *exception)
 {
   char
@@ -559,7 +559,7 @@
   register const TypeInfo
     *p;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -567,7 +567,7 @@
   */
   assert(pattern != (char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
-  assert(number_fonts != (unsigned long *) NULL);
+  assert(number_fonts != (size_t *) NULL);
   *number_fonts=0;
   p=GetTypeInfo("*",exception);
   if (p == (const TypeInfo *) NULL)
@@ -592,7 +592,7 @@
   UnlockSemaphoreInfo(type_semaphore);
   qsort((void *) fonts,(size_t) i,sizeof(*fonts),TypeCompare);
   fonts[i]=(char *) NULL;
-  *number_fonts=(unsigned long) i;
+  *number_fonts=(size_t) i;
   return(fonts);
 }
 
@@ -652,7 +652,7 @@
     width,
     weight;
 
-  register long
+  register ssize_t
     i;
 
   TypeInfo
@@ -683,7 +683,7 @@
       FcConfigDestroy(font_config);
       return(MagickFalse);
     }
-  for (i=0; i < (long) font_set->nfont; i++)
+  for (i=0; i < (ssize_t) font_set->nfont; i++)
   {
     status=FcPatternGetString(font_set->fonts[i],FC_FAMILY,0,&family);
     if (status != FcResultMatch)
@@ -832,10 +832,10 @@
   const TypeInfo
     **type_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     number_fonts;
 
   if (file == (FILE *) NULL)
@@ -846,7 +846,7 @@
     return(MagickFalse);
   *weight='\0';
   path=(const char *) NULL;
-  for (i=0; i < (long) number_fonts; i++)
+  for (i=0; i < (ssize_t) number_fonts; i++)
   {
     if (type_info[i]->stealth != MagickFalse)
       continue;
@@ -896,7 +896,7 @@
 %  The format of the LoadTypeList method is:
 %
 %      MagickBooleanType LoadTypeList(const char *xml,const char *filename,
-%        const unsigned long depth,ExceptionInfo *exception)
+%        const size_t depth,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -938,7 +938,7 @@
 }
 
 static MagickBooleanType LoadTypeList(const char *xml,const char *filename,
-  const unsigned long depth,ExceptionInfo *exception)
+  const size_t depth,ExceptionInfo *exception)
 {
   char
     font_path[MaxTextExtent],
diff --git a/magick/type.h b/magick/type.h
index 0bf5a62..5ae26d8 100644
--- a/magick/type.h
+++ b/magick/type.h
@@ -48,7 +48,7 @@
 
 typedef struct _TypeInfo
 {
-  unsigned long
+  size_t
     face;
 
   char
@@ -63,7 +63,7 @@
   StretchType
     stretch;
 
-  unsigned long
+  size_t
     weight;
 
   char
@@ -80,12 +80,12 @@
     *previous,
     *next;  /* deprecated, use GetTypeInfoList() */
 
-  unsigned long
+  size_t
     signature;
 } TypeInfo;
 
 extern MagickExport char
-  **GetTypeList(const char *,unsigned long *,ExceptionInfo *);
+  **GetTypeList(const char *,size_t *,ExceptionInfo *);
 
 extern MagickExport MagickBooleanType
   ListTypeInfo(FILE *,ExceptionInfo *),
@@ -94,8 +94,8 @@
 extern MagickExport const TypeInfo
   *GetTypeInfo(const char *,ExceptionInfo *),
   *GetTypeInfoByFamily(const char *,const StyleType,const StretchType,
-    const unsigned long,ExceptionInfo *),
-  **GetTypeInfoList(const char *,unsigned long *,ExceptionInfo *);
+    const size_t,ExceptionInfo *),
+  **GetTypeInfoList(const char *,size_t *,ExceptionInfo *);
 
 MagickExport void
   TypeComponentTerminus(void);
diff --git a/magick/utility.c b/magick/utility.c
index f909892..9c036e8 100644
--- a/magick/utility.c
+++ b/magick/utility.c
@@ -500,7 +500,7 @@
   remainder=blob_length % 3;
   if (remainder != 0)
     {
-      long
+      ssize_t
         j;
 
       unsigned char
@@ -509,7 +509,7 @@
       code[0]='\0';
       code[1]='\0';
       code[2]='\0';
-      for (j=0; j < (long) remainder; j++)
+      for (j=0; j < (ssize_t) remainder; j++)
         code[j]=(*p++);
       encode[i++]=Base64[(int) (code[0] >> 2)];
       encode[i++]=Base64[(int) (((code[0] & 0x03) << 4)+(code[1] >> 4))];
@@ -540,7 +540,7 @@
 %
 %  The format of the ChopPathComponents method is:
 %
-%      ChopPathComponents(char *path,unsigned long components)
+%      ChopPathComponents(char *path,size_t components)
 %
 %  A description of each parameter follows:
 %
@@ -549,12 +549,12 @@
 %    o components:  The number of components to chop.
 %
 */
-MagickExport void ChopPathComponents(char *path,const unsigned long components)
+MagickExport void ChopPathComponents(char *path,const size_t components)
 {
-  register long
+  register ssize_t
     i;
 
-  for (i=0; i < (long) components; i++)
+  for (i=0; i < (ssize_t) components; i++)
     GetPathComponent(path,HeadPath,path);
 }
 
@@ -680,15 +680,15 @@
     home_directory[MaxTextExtent],
     **vector;
 
-  long
+  ssize_t
     count,
     parameters;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     number_files;
 
   /*
@@ -706,7 +706,7 @@
   */
   *home_directory='\0';
   count=0;
-  for (i=0; i < (long) *number_arguments; i++)
+  for (i=0; i < (ssize_t) *number_arguments; i++)
   {
     char
       **filelist,
@@ -735,7 +735,7 @@
         for (j=0; j < parameters; j++)
         {
           i++;
-          if (i == (long) *number_arguments)
+          if (i == (ssize_t) *number_arguments)
             break;
           option=(*arguments)[i];
           vector[count++]=ConstantString(option);
@@ -787,23 +787,23 @@
         StripString(files);
         filelist=StringToArgv(files,&number_images);
         files=DestroyString(files);
-        number_files=(unsigned long) number_images;
+        number_files=(size_t) number_images;
         if (filelist != (char **) NULL)
           {
             number_files--;
-            for (j=0; j < (long) number_files; j++)
+            for (j=0; j < (ssize_t) number_files; j++)
               filelist[j]=filelist[j+1];
           }
         count--;
       }
     if (filelist == (char **) NULL)
       continue;
-    for (j=0; j < (long) number_files; j++)
+    for (j=0; j < (ssize_t) number_files; j++)
       if (IsPathDirectory(filelist[j]) <= 0)
         break;
-    if (j == (long) number_files)
+    if (j == (ssize_t) number_files)
       {
-        for (j=0; j < (long) number_files; j++)
+        for (j=0; j < (ssize_t) number_files; j++)
           filelist[j]=DestroyString(filelist[j]);
         filelist=(char **) RelinquishMagickMemory(filelist);
         continue;
@@ -815,13 +815,13 @@
       count+number_files+1,sizeof(*vector));
     if (vector == (char **) NULL)
       return(MagickFalse);
-    for (j=0; j < (long) number_files; j++)
+    for (j=0; j < (ssize_t) number_files; j++)
     {
       option=filelist[j];
       parameters=ParseMagickOption(MagickCommandOptions,MagickFalse,option);
       if (parameters > 0)
         {
-          long
+          ssize_t
             k;
 
           /*
@@ -831,7 +831,7 @@
           for (k=0; k < parameters; k++)
           {
             j++;
-            if (j == (long) number_files)
+            if (j == (ssize_t) number_files)
               break;
             option=filelist[j];
             vector[count++]=ConstantString(option);
@@ -930,7 +930,7 @@
     *cwd;
 
   *path='\0';
-  cwd=getcwd(path,(unsigned long) extent);
+  cwd=getcwd(path,(size_t) extent);
 #if defined(MAGICKCORE_HAVE_GETPID) && defined(MAGICKCORE_HAVE_READLINK) && defined(PATH_MAX)
   {
     char
@@ -941,12 +941,12 @@
       count;
 
     (void) FormatMagickString(link_path,MaxTextExtent,"/proc/%ld/exe",
-      (long) getpid());
+      (ssize_t) getpid());
     count=readlink(link_path,execution_path,PATH_MAX);
     if (count == -1)
       {
         (void) FormatMagickString(link_path,MaxTextExtent,"/proc/%ld/file",
-          (long) getpid());
+          (ssize_t) getpid());
         count=readlink(link_path,execution_path,PATH_MAX);
       }
     if ((count > 0) && (count <= (ssize_t) PATH_MAX))
@@ -994,7 +994,7 @@
       *program_name,
       *execution_path;
 
-    long
+    ssize_t
       count;
 
     count=0;
@@ -1042,12 +1042,12 @@
 %
 %  The format of the GetMagickPageSize method is:
 %
-%      long GetMagickPageSize()
+%      ssize_t GetMagickPageSize()
 %
 */
-MagickExport long GetMagickPageSize(void)
+MagickExport ssize_t GetMagickPageSize(void)
 {
-  static long
+  static ssize_t
     page_size = -1;
 
   if (page_size > 0)
@@ -1184,7 +1184,7 @@
   length=UTF8ToUTF16(source,(wchar_t *) NULL);
   if (length == 0)
     {
-      register long
+      register ssize_t
         i;
 
       /*
@@ -1194,7 +1194,7 @@
       utf16=(wchar_t *) AcquireQuantumMemory(length+1,sizeof(*utf16));
       if (utf16 == (wchar_t *) NULL)
         return((wchar_t *) NULL);
-      for (i=0; i <= (long) length; i++)
+      for (i=0; i <= (ssize_t) length; i++)
         utf16[i]=source[i];
       return(utf16);
     }
@@ -1427,7 +1427,7 @@
 %  The format of the GetPathComponents method is:
 %
 %      char **GetPathComponents(const char *path,
-%        unsigned long *number_componenets)
+%        size_t *number_componenets)
 %
 %  A description of each parameter follows:
 %
@@ -1437,7 +1437,7 @@
 %
 */
 MagickExport char **GetPathComponents(const char *path,
-  unsigned long *number_components)
+  size_t *number_components)
 {
   char
     **components;
@@ -1446,7 +1446,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i;
 
   if (path == (char *) NULL)
@@ -1460,7 +1460,7 @@
   if (components == (char **) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   p=path;
-  for (i=0; i < (long) *number_components; i++)
+  for (i=0; i < (ssize_t) *number_components; i++)
   {
     for (q=p; *q != '\0'; q++)
       if (IsBasenameSeparator(*q))
@@ -1618,7 +1618,7 @@
 %  The format of the ListFiles function is:
 %
 %      char **ListFiles(const char *directory,const char *pattern,
-%        long *number_entries)
+%        ssize_t *number_entries)
 %
 %  A description of each parameter follows:
 %
@@ -1669,7 +1669,7 @@
 }
 
 MagickExport char **ListFiles(const char *directory,const char *pattern,
-  unsigned long *number_entries)
+  size_t *number_entries)
 {
   char
     **filelist;
@@ -1681,7 +1681,7 @@
     *buffer,
     *entry;
 
-  unsigned long
+  size_t
     max_entries;
 
   /*
@@ -1690,7 +1690,7 @@
   assert(directory != (const char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",directory);
   assert(pattern != (const char *) NULL);
-  assert(number_entries != (unsigned long *) NULL);
+  assert(number_entries != (size_t *) NULL);
   *number_entries=0;
   current_directory=opendir(directory);
   if (current_directory == (DIR *) NULL)
@@ -1783,7 +1783,7 @@
 %
 %  The format of the MultilineCenus method is:
 %
-%      unsigned long MultilineCensus(const char *label)
+%      size_t MultilineCensus(const char *label)
 %
 %  A description of each parameter follows.
 %
@@ -1791,9 +1791,9 @@
 %
 %
 */
-MagickExport unsigned long MultilineCensus(const char *label)
+MagickExport size_t MultilineCensus(const char *label)
 {
-  unsigned long
+  size_t
     number_lines;
 
   /*
@@ -1918,7 +1918,7 @@
   PolicyRights
     rights;
 
-  register long
+  register ssize_t
     i;
 
   status=(-1);
diff --git a/magick/utility.h b/magick/utility.h
index 1327d35..2503137 100644
--- a/magick/utility.h
+++ b/magick/utility.h
@@ -37,8 +37,8 @@
 
 extern MagickExport char
   *Base64Encode(const unsigned char *,const size_t,size_t *),
-  **GetPathComponents(const char *,unsigned long *),
-  **ListFiles(const char *,const char *,unsigned long *);
+  **GetPathComponents(const char *,size_t *),
+  **ListFiles(const char *,const char *,size_t *);
 
 extern MagickExport FILE
   *OpenMagickStream(const char *,const char *);
@@ -47,7 +47,7 @@
   SystemCommand(const MagickBooleanType,const MagickBooleanType,const char *,
     ExceptionInfo *);
 
-extern MagickExport long
+extern MagickExport ssize_t
   GetMagickPageSize(void);
 
 extern MagickExport MagickBooleanType
@@ -62,12 +62,12 @@
 extern MagickExport unsigned char
   *Base64Decode(const char *, size_t *);
 
-extern MagickExport unsigned long
+extern MagickExport size_t
   MultilineCensus(const char *);
 
 extern MagickExport void
   AppendImageFormat(const char *,char *),
-  ChopPathComponents(char *,const unsigned long),
+  ChopPathComponents(char *,const size_t),
   ExpandFilename(char *),
   GetPathComponent(const char *,PathType,char *);
 
diff --git a/magick/version.c b/magick/version.c
index d68afd6..6b41bc9 100644
--- a/magick/version.c
+++ b/magick/version.c
@@ -188,17 +188,17 @@
 %
 %  The format of the GetMagickQuantumDepth method is:
 %
-%      const char *GetMagickQuantumDepth(unsigned long *depth)
+%      const char *GetMagickQuantumDepth(size_t *depth)
 %
 %  A description of each parameter follows:
 %
 %    o depth: the quantum depth is returned as a number.
 %
 */
-MagickExport const char *GetMagickQuantumDepth(unsigned long *depth)
+MagickExport const char *GetMagickQuantumDepth(size_t *depth)
 {
-  if (depth != (unsigned long *) NULL)
-    *depth=(unsigned long) MAGICKCORE_QUANTUM_DEPTH;
+  if (depth != (size_t *) NULL)
+    *depth=(size_t) MAGICKCORE_QUANTUM_DEPTH;
   return(MagickQuantumDepth);
 }
 
@@ -217,17 +217,17 @@
 %
 %  The format of the GetMagickQuantumRange method is:
 %
-%      const char *GetMagickQuantumRange(unsigned long *range)
+%      const char *GetMagickQuantumRange(size_t *range)
 %
 %  A description of each parameter follows:
 %
 %    o range: the quantum range is returned as a number.
 %
 */
-MagickExport const char *GetMagickQuantumRange(unsigned long *range)
+MagickExport const char *GetMagickQuantumRange(size_t *range)
 {
-  if (range != (unsigned long *) NULL)
-    *range=(unsigned long) QuantumRange;
+  if (range != (size_t *) NULL)
+    *range=(size_t) QuantumRange;
   return(MagickQuantumRange);
 }
 
@@ -272,16 +272,16 @@
 %
 %  The format of the GetMagickVersion method is:
 %
-%      const char *GetMagickVersion(unsigned long *version)
+%      const char *GetMagickVersion(size_t *version)
 %
 %  A description of each parameter follows:
 %
 %    o version: the ImageMagick version is returned as a number.
 %
 */
-MagickExport const char *GetMagickVersion(unsigned long *version)
+MagickExport const char *GetMagickVersion(size_t *version)
 {
-  if (version != (unsigned long *) NULL)
+  if (version != (size_t *) NULL)
     *version=MagickLibVersion;
   return(MagickVersion);
 }
diff --git a/magick/version.h b/magick/version.h
index 4a4f0ce..a8515f9 100644
--- a/magick/version.h
+++ b/magick/version.h
@@ -33,8 +33,8 @@
 #define MagickLibAddendum  "-1"
 #define MagickLibInterface  3
 #define MagickLibMinInterface  3
-#define MagickReleaseDate  "2010-05-23"
-#define MagickChangeDate   "20100523"
+#define MagickReleaseDate  "2010-05-27"
+#define MagickChangeDate   "20100525"
 #define MagickAuthoritativeURL  "http://www.imagemagick.org"
 #define MagickHomeURL  "file:///usr/local/share/doc/ImageMagick-6.6.2/index.html"
 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
diff --git a/magick/vms.h b/magick/vms.h
index bd24a5f..f8cf037 100644
--- a/magick/vms.h
+++ b/magick/vms.h
@@ -949,7 +949,7 @@
 
 typedef struct _dirdesc
 {
-  long
+  ssize_t
     context;
 
   char
diff --git a/magick/widget.c b/magick/widget.c
index 678d350..b1da74d 100644
--- a/magick/widget.c
+++ b/magick/widget.c
@@ -1098,12 +1098,12 @@
 %
 %    o text: A character string to insert into the text.
 %
-%    o state:  An unsigned long that indicates whether the key symbol is a
+%    o state:  An size_t that indicates whether the key symbol is a
 %      control character or not.
 %
 */
 static void XEditText(Display *display,XWidgetInfo *text_info,
-  const KeySym key_symbol,char *text,const unsigned long state)
+  const KeySym key_symbol,char *text,const size_t state)
 {
   switch ((int) key_symbol)
   {
@@ -1167,7 +1167,7 @@
         break;
       if (*text == '\0')
         break;
-      if ((Extent(text_info->text)+1) >= (long) MaxTextExtent)
+      if ((Extent(text_info->text)+1) >= (ssize_t) MaxTextExtent)
         (void) XBell(display,0);
       else
         {
@@ -1555,7 +1555,7 @@
 static void XSetTextColor(Display *display,const XWindowInfo *window_info,
   const MagickStatusType raised)
 {
-  long
+  ssize_t
     foreground,
     matte;
 
@@ -1572,8 +1572,8 @@
           XWhitePixel(display,window_info->screen));
       return;
     }
-  foreground=(long) XPixelIntensity(&window_info->pixel_info->foreground_color);
-  matte=(long) XPixelIntensity(&window_info->pixel_info->matte_color);
+  foreground=(ssize_t) XPixelIntensity(&window_info->pixel_info->foreground_color);
+  matte=(ssize_t) XPixelIntensity(&window_info->pixel_info->matte_color);
   if (MagickAbsoluteValue(foreground-matte) > (65535L >> 3))
     (void) XSetForeground(display,window_info->widget_context,
       window_info->pixel_info->foreground_color.pixel);
@@ -1654,7 +1654,7 @@
     visible_colors,
     width;
 
-  unsigned long
+  size_t
     colors,
     delay,
     state;
@@ -1724,7 +1724,7 @@
   */
   font_info=windows->widget.font_info;
   text_width=0;
-  for (i=0; i < (long) colors; i++)
+  for (i=0; i < (ssize_t) colors; i++)
     if (WidgetTextWidth(font_info,colorlist[i]) > text_width)
       text_width=WidgetTextWidth(font_info,colorlist[i]);
   width=WidgetTextWidth(font_info,(char *) action);
@@ -1950,7 +1950,7 @@
         char
           **checklist;
 
-        unsigned long
+        size_t
           number_colors;
 
         status=XParseColor(display,windows->widget.map_info->colormap,
@@ -1977,7 +1977,7 @@
           }
         else
           {
-            for (i=0; i < (long) colors; i++)
+            for (i=0; i < (ssize_t) colors; i++)
               colorlist[i]=DestroyString(colorlist[i]);
             if (colorlist != (char **) NULL)
               colorlist=(char **) RelinquishMagickMemory(colorlist);
@@ -2021,7 +2021,7 @@
           Jump scroll to match user color.
         */
         list_info.id=(~0);
-        for (i=0; i < (long) colors; i++)
+        for (i=0; i < (ssize_t) colors; i++)
           if (LocaleCompare(colorlist[i],reply) >= 0)
             {
               list_info.id=LocaleCompare(colorlist[i],reply) == 0 ? i : ~0;
@@ -2059,7 +2059,7 @@
               selection_info.raised=(slider_info.id+i) != list_info.id ?
                 MagickTrue : MagickFalse;
               selection_info.text=(char *) NULL;
-              if ((slider_info.id+i) < (long) colors)
+              if ((slider_info.id+i) < (ssize_t) colors)
                 selection_info.text=colorlist[slider_info.id+i];
               XDrawWidgetText(display,&windows->widget,&selection_info);
               selection_info.y+=(int) selection_info.height;
@@ -2133,7 +2133,7 @@
               state|=RedrawListState;
             }
         if (south_info.raised == MagickFalse)
-          if (slider_info.id < (long) colors)
+          if (slider_info.id < (ssize_t) colors)
             {
               /*
                 Move slider down.
@@ -2168,7 +2168,7 @@
               break;
             }
         if (MatteIsActive(south_info,event.xbutton))
-          if (slider_info.id < (long) colors)
+          if (slider_info.id < (ssize_t) colors)
             {
               /*
                 Move slider down.
@@ -2683,7 +2683,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -2756,7 +2756,7 @@
   /*
     Free color list.
   */
-  for (i=0; i < (long) colors; i++)
+  for (i=0; i < (ssize_t) colors; i++)
     colorlist[i]=DestroyString(colorlist[i]);
   if (colorlist != (char **) NULL)
     colorlist=(char **) RelinquishMagickMemory(colorlist);
@@ -2911,7 +2911,7 @@
   unsigned int
     height;
 
-  unsigned long
+  size_t
     state;
 
   XFontStruct
@@ -3250,7 +3250,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -3664,7 +3664,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -4108,7 +4108,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -4257,7 +4257,7 @@
     visible_files,
     width;
 
-  unsigned long
+  size_t
     delay,
     files,
     state;
@@ -4317,7 +4317,7 @@
   */
   font_info=windows->widget.font_info;
   text_width=0;
-  for (i=0; i < (long) files; i++)
+  for (i=0; i < (ssize_t) files; i++)
     if (WidgetTextWidth(font_info,filelist[i]) > text_width)
       text_width=WidgetTextWidth(font_info,filelist[i]);
   width=WidgetTextWidth(font_info,(char *) action);
@@ -4561,7 +4561,7 @@
         char
           **checklist;
 
-        unsigned long
+        size_t
           number_files;
 
         /*
@@ -4577,7 +4577,7 @@
             XDrawBeveledButton(display,&windows->widget,&action_info);
             break;
           }
-        for (i=0; i < (long) files; i++)
+        for (i=0; i < (ssize_t) files; i++)
           filelist[i]=DestroyString(filelist[i]);
         if (filelist != (char **) NULL)
           filelist=(char **) RelinquishMagickMemory(filelist);
@@ -4627,7 +4627,7 @@
           Jump scroll to match user filename.
         */
         list_info.id=(~0);
-        for (i=0; i < (long) files; i++)
+        for (i=0; i < (ssize_t) files; i++)
           if (LocaleCompare(filelist[i],reply) >= 0)
             {
               list_info.id=LocaleCompare(filelist[i],reply) == 0 ? i : ~0;
@@ -4664,7 +4664,7 @@
               selection_info.raised=(slider_info.id+i) != list_info.id ?
                 MagickTrue : MagickFalse;
               selection_info.text=(char *) NULL;
-              if ((slider_info.id+i) < (long) files)
+              if ((slider_info.id+i) < (ssize_t) files)
                 selection_info.text=filelist[slider_info.id+i];
               XDrawWidgetText(display,&windows->widget,&selection_info);
               selection_info.y+=(int) selection_info.height;
@@ -4715,7 +4715,7 @@
               state|=RedrawListState;
             }
         if (south_info.raised == MagickFalse)
-          if (slider_info.id < (long) files)
+          if (slider_info.id < (ssize_t) files)
             {
               /*
                 Move slider down.
@@ -4750,7 +4750,7 @@
               break;
             }
         if (MatteIsActive(south_info,event.xbutton))
-          if (slider_info.id < (long) files)
+          if (slider_info.id < (ssize_t) files)
             {
               /*
                 Move slider down.
@@ -4782,7 +4782,7 @@
             */
             id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)/
               selection_info.height;
-            if (id >= (long) files)
+            if (id >= (ssize_t) files)
               break;
             (void) CopyMagickString(reply_info.text,filelist[id],MaxTextExtent);
             reply_info.highlight=MagickFalse;
@@ -4961,7 +4961,7 @@
                 ExceptionInfo
                   *exception;
 
-                unsigned long
+                size_t
                   number_formats;
 
                 /*
@@ -5326,7 +5326,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -5398,7 +5398,7 @@
   /*
     Free file list.
   */
-  for (i=0; i < (long) files; i++)
+  for (i=0; i < (ssize_t) files; i++)
     filelist[i]=DestroyString(filelist[i]);
   if (filelist != (char **) NULL)
     filelist=(char **) RelinquishMagickMemory(filelist);
@@ -5511,7 +5511,7 @@
     visible_fonts,
     width;
 
-  unsigned long
+  size_t
     delay,
     state;
 
@@ -6544,7 +6544,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -6777,7 +6777,7 @@
     visible_entries,
     width;
 
-  unsigned long
+  size_t
     delay,
     state;
 
@@ -7551,7 +7551,7 @@
         unsigned char
           *data;
 
-        unsigned long
+        size_t
           after,
           length;
 
@@ -7678,7 +7678,7 @@
     top_offset,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -7739,7 +7739,7 @@
       toggle_info.raised=MagickTrue;
       XDrawTriangleEast(display,&windows->command,&toggle_info);
     }
-  windows->widget.y=submenu_info.active == 0 ? y-(long)
+  windows->widget.y=submenu_info.active == 0 ? y-(ssize_t)
     ((3*title_height) >> 2) : y;
   if (submenu_info.active != 0)
     windows->widget.y=windows->command.y+submenu_info.y;
@@ -7749,7 +7749,7 @@
   */
   window_attributes.override_redirect=MagickTrue;
   (void) XChangeWindowAttributes(display,windows->widget.id,
-    (unsigned long) CWOverrideRedirect,&window_attributes);
+    (size_t) CWOverrideRedirect,&window_attributes);
   window_changes.width=(int) windows->widget.width;
   window_changes.height=(int) windows->widget.height;
   window_changes.x=windows->widget.x;
@@ -8043,7 +8043,7 @@
   (void) XFreeCursor(display,cursor);
   window_attributes.override_redirect=MagickFalse;
   (void) XChangeWindowAttributes(display,windows->widget.id,
-    (unsigned long) CWOverrideRedirect,&window_attributes);
+    (size_t) CWOverrideRedirect,&window_attributes);
   (void) XWithdrawWindow(display,windows->widget.id,windows->widget.screen);
   XCheckRefreshWindows(display,windows);
   if (submenu_info.active != 0)
@@ -8113,7 +8113,7 @@
     height,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -8458,7 +8458,7 @@
     text_width,
     width;
 
-  unsigned long
+  size_t
     state;
 
   XEvent
@@ -8981,7 +8981,7 @@
     visible_lines,
     width;
 
-  unsigned long
+  size_t
     delay,
     state;
 
diff --git a/magick/xml-tree.c b/magick/xml-tree.c
index cd7fb23..0656fba 100644
--- a/magick/xml-tree.c
+++ b/magick/xml-tree.c
@@ -92,7 +92,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -121,7 +121,7 @@
   SemaphoreInfo
     *semaphore;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -215,17 +215,17 @@
     subnode[MaxTextExtent],
     tag[MaxTextExtent];
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   XMLTreeInfo
     *child,
     *node;
 
-  unsigned long
+  size_t
     number_components;
 
   assert(xml_info != (XMLTreeInfo *) NULL);
@@ -236,7 +236,7 @@
   components=GetPathComponents(path,&number_components);
   if (components == (char **) NULL)
     return((XMLTreeInfo *) NULL);
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
     GetPathComponent(components[i],SubimagePath,subnode);
     GetPathComponent(components[i],CanonicalPath,tag);
@@ -256,7 +256,7 @@
       break;
     components[i]=DestroyString(components[i]);
   }
-  for ( ; i < (long) number_components; i++)
+  for ( ; i < (ssize_t) number_components; i++)
     components[i]=DestroyString(components[i]);
   components=(char **) RelinquishMagickMemory(components);
   return(node);
@@ -301,7 +301,7 @@
   register const unsigned char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -340,7 +340,7 @@
   extent=MaxTextExtent;
   for (p=utf8; *p != '\0'; p++)
   {
-    if ((i+MaxTextExtent) > (long) extent)
+    if ((i+MaxTextExtent) > (ssize_t) extent)
       {
         extent+=MaxTextExtent;
         canonical_content=(char *) ResizeQuantumMemory(canonical_content,extent,
@@ -432,7 +432,7 @@
 
 static char **DestroyXMLTreeAttributes(char **attributes)
 {
-  register long
+  register ssize_t
     i;
 
   /*
@@ -459,10 +459,10 @@
   char
     **attributes;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   XMLTreeRoot
@@ -585,10 +585,10 @@
 MagickExport const char *GetXMLTreeAttribute(XMLTreeInfo *xml_info,
   const char *tag)
 {
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   XMLTreeRoot
@@ -653,7 +653,7 @@
 MagickExport MagickBooleanType GetXMLTreeAttributes(const XMLTreeInfo *xml_info,
   SplayTreeInfo *attributes)
 {
-  register long
+  register ssize_t
     i;
 
   assert(xml_info != (XMLTreeInfo *) NULL);
@@ -808,16 +808,16 @@
     subnode[MaxTextExtent],
     tag[MaxTextExtent];
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   XMLTreeInfo
     *node;
 
-  unsigned long
+  size_t
     number_components;
 
   assert(xml_info != (XMLTreeInfo *) NULL);
@@ -828,7 +828,7 @@
   components=GetPathComponents(path,&number_components);
   if (components == (char **) NULL)
     return((XMLTreeInfo *) NULL);
-  for (i=0; i < (long) number_components; i++)
+  for (i=0; i < (ssize_t) number_components; i++)
   {
     GetPathComponent(components[i],SubimagePath,subnode);
     GetPathComponent(components[i],CanonicalPath,tag);
@@ -845,7 +845,7 @@
       break;
     components[i]=DestroyString(components[i]);
   }
-  for ( ; i < (long) number_components; i++)
+  for ( ; i < (ssize_t) number_components; i++)
     components[i]=DestroyString(components[i]);
   components=(char **) RelinquishMagickMemory(components);
   return(node);
@@ -878,7 +878,7 @@
 MagickExport const char **GetXMLTreeProcessingInstructions(
   XMLTreeInfo *xml_info,const char *target)
 {
-  register long
+  register ssize_t
     i;
 
   XMLTreeRoot
@@ -1094,10 +1094,10 @@
     c,
     encoding;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1117,11 +1117,11 @@
     }
   j=0;
   extent=(*length);
-  for (i=2; i < (long) (*length-1); i+=2)
+  for (i=2; i < (ssize_t) (*length-1); i+=2)
   {
     c=(encoding != 0) ? ((content[i] & 0xff) << 8) | (content[i+1] & 0xff) :
       ((content[i+1] & 0xff) << 8) | (content[i] & 0xff);
-    if ((c >= 0xd800) && (c <= 0xdfff) && ((i+=2) < (long) (*length-1)))
+    if ((c >= 0xd800) && (c <= 0xdfff) && ((i+=2) < (ssize_t) (*length-1)))
       {
         byte=(encoding != 0) ? ((content[i] & 0xff) << 8) |
           (content[i+1] & 0xff) : ((content[i+1] & 0xff) << 8) |
@@ -1173,7 +1173,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1311,7 +1311,7 @@
       */
       for (xml=p; *xml != '\0'; xml++)
       {
-        i=(long) strspn(xml," ");
+        i=(ssize_t) strspn(xml," ");
         if (i != 0)
           (void) CopyMagickMemory(xml,xml+i,strlen(xml+i)+1);
         while ((*xml != '\0') && (*xml != ' '))
@@ -1365,7 +1365,7 @@
 
 static MagickBooleanType ValidateEntities(char *tag,char *xml,char **entities)
 {
-  register long
+  register ssize_t
     i;
 
   /*
@@ -1396,10 +1396,10 @@
   char
     *target;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   target=xml;
@@ -1479,10 +1479,10 @@
     *t,
     *v;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   n=(char *) NULL;
@@ -1712,14 +1712,14 @@
     c,
     terminal;
 
-  long
+  ssize_t
     j,
     l;
 
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2119,7 +2119,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  PruneTagFromXMLTree() prunes a tag from the xml-tree along with all its
+%  PruneTagFromXMLTree() prunes a tag from the xml-tree assize_t with all its
 %  subtags.
 %
 %  The format of the PruneTagFromXMLTree method is:
@@ -2207,10 +2207,10 @@
 MagickExport XMLTreeInfo *SetXMLTreeAttribute(XMLTreeInfo *xml_info,
   const char *tag,const char *value)
 {
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2379,10 +2379,10 @@
   const char
     *attribute;
 
-  long
+  ssize_t
     j;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -2481,7 +2481,7 @@
   char
     *xml;
 
-  long
+  ssize_t
     j,
     k;
 
@@ -2489,7 +2489,7 @@
     *p,
     *q;
 
-  register long
+  register ssize_t
     i;
 
   size_t
diff --git a/magick/xwindow-private.h b/magick/xwindow-private.h
index d1c7a9b..e0ef0fb 100644
--- a/magick/xwindow-private.h
+++ b/magick/xwindow-private.h
@@ -208,7 +208,7 @@
 
 typedef struct _XPixelInfo
 {
-  unsigned long
+  size_t
     colors,
     *pixels;
 
@@ -246,7 +246,7 @@
   QuantizeInfo
     *quantize_info;
 
-  unsigned long
+  size_t
     colors;
 
   MagickBooleanType
@@ -266,7 +266,7 @@
   unsigned int
     border_width;
 
-  unsigned long
+  size_t
     delay;
 
   MagickBooleanType
@@ -322,7 +322,7 @@
     use_pixmap,
     use_shared_memory;
 
-  unsigned long
+  size_t
     undo_cache;
 
   char
@@ -384,7 +384,7 @@
     *icon_geometry,
     *crop_geometry;
 
-  unsigned long
+  size_t
     data,
     flags;
 
@@ -431,7 +431,7 @@
   void
     *segment_info;
 
-  unsigned long
+  size_t
     mask;
 
   MagickBooleanType
@@ -536,7 +536,7 @@
   XComponentTerminus(void),
   XConfigureImageColormap(Display *,XResourceInfo *,XWindows *,Image *),
   XConstrainWindowPosition(Display *,XWindowInfo *),
-  XDelay(Display *,const unsigned long),
+  XDelay(Display *,const size_t),
   XDisplayImageInfo(Display *,const XResourceInfo *,XWindows *,Image *,Image *),
   XDestroyResourceInfo(XResourceInfo *),
   XDestroyWindowColors(Display *,Window),
@@ -567,7 +567,7 @@
   XWarning(const ExceptionType,const char *,const char *);
 
 extern MagickExport Window
-  XWindowByID(Display *,const Window,const unsigned long),
+  XWindowByID(Display *,const Window,const size_t),
   XWindowByName(Display *,const Window,const char *),
   XWindowByProperty(Display *,const Window,const Atom);
 
diff --git a/magick/xwindow.c b/magick/xwindow.c
index d22b278..f6dbf19 100644
--- a/magick/xwindow.c
+++ b/magick/xwindow.c
@@ -106,7 +106,7 @@
 #define XBlueGamma(color) ClampToQuantum(blue_gamma == 1.0 ? (double) \
   (color) : ((pow(((double) QuantumScale*(color)),1.0/(double) blue_gamma)* \
   QuantumRange)))
-#define XGammaPixel(map,color)  (unsigned long) (map->base_pixel+ \
+#define XGammaPixel(map,color)  (size_t) (map->base_pixel+ \
   ((ScaleQuantumToShort(XRedGamma((color)->red))*map->red_max/65535L)* \
     map->red_mult)+ \
   ((ScaleQuantumToShort(XGreenGamma((color)->green))*map->green_max/65535L)* \
@@ -119,7 +119,7 @@
 #define XRedGamma(color) ClampToQuantum(red_gamma == 1.0 ? (double) \
   (color) : ((pow(((double) QuantumScale*(color)),1.0/(double) red_gamma)* \
   QuantumRange)))
-#define XStandardPixel(map,color)  (unsigned long) (map->base_pixel+ \
+#define XStandardPixel(map,color)  (size_t) (map->base_pixel+ \
   (((color)->red*map->red_max/65535L)*map->red_mult)+ \
   (((color)->green*map->green_max/65535L)*map->green_mult)+ \
   (((color)->blue*map->blue_max/65535L)*map->blue_mult))
@@ -177,7 +177,7 @@
   unsigned short
     index;
 
-  unsigned long
+  size_t
     count;
 } DiversityPacket;
 
@@ -350,8 +350,8 @@
     RelinquishMagickMemory(windows->icon_resources);
   if (windows->icon_pixel != (XPixelInfo *) NULL)
     {
-      if (windows->icon_pixel->pixels != (unsigned long *) NULL)
-        windows->icon_pixel->pixels=(unsigned long *)
+      if (windows->icon_pixel->pixels != (size_t *) NULL)
+        windows->icon_pixel->pixels=(size_t *)
           RelinquishMagickMemory(windows->icon_pixel->pixels);
       if (windows->icon_pixel->annotate_context != (GC) NULL)
         XFreeGC(windows->display,windows->icon_pixel->annotate_context);
@@ -360,8 +360,8 @@
     }
   if (windows->pixel_info != (XPixelInfo *) NULL)
     {
-      if (windows->pixel_info->pixels != (unsigned long *) NULL)
-        windows->pixel_info->pixels=(unsigned long *)
+      if (windows->pixel_info->pixels != (size_t *) NULL)
+        windows->pixel_info->pixels=(size_t *)
           RelinquishMagickMemory(windows->pixel_info->pixels);
       if (windows->pixel_info->annotate_context != (GC) NULL)
         XFreeGC(windows->display,windows->pixel_info->annotate_context);
@@ -501,9 +501,9 @@
     Initialize graphics info.
   */
   context_values.background=0;
-  context_values.foreground=(unsigned long) (~0);
+  context_values.foreground=(size_t) (~0);
   context_values.font=annotate_info->font_info->fid;
-  annotate_context=XCreateGC(display,root_window,(unsigned long)
+  annotate_context=XCreateGC(display,root_window,(size_t)
     GCBackground | GCFont | GCForeground,&context_values);
   if (annotate_context == (GC) NULL)
     return(MagickFalse);
@@ -545,7 +545,7 @@
   exception=(&image->exception);
   for (y=0; y < (int) annotate_image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -555,7 +555,7 @@
       exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) annotate_image->columns; x++)
+    for (x=0; x < (ssize_t) annotate_image->columns; x++)
     {
       SetOpacityPixelComponent(q,OpaqueOpacity);
       if (XGetPixel(annotate_ximage,x,y) == 0)
@@ -1043,7 +1043,7 @@
           return;
         }
       for (i=0; i < (int) number_colors; i++)
-        colors[i].pixel=(unsigned long) i;
+        colors[i].pixel=(size_t) i;
       if (number_colors > 256)
         number_colors=256;
       (void) XQueryColors(display,colormap,colors,(int) number_colors);
@@ -1127,7 +1127,7 @@
   return(y);
 }
 
-static inline unsigned long MagickMin(const unsigned int x,
+static inline size_t MagickMin(const unsigned int x,
   const unsigned int y)
 {
   if (x < y)
@@ -1148,7 +1148,7 @@
     *map_type,
     *visual_type;
 
-  long
+  ssize_t
     visual_mask;
 
   register int
@@ -1177,7 +1177,7 @@
   visual_template.screen=XDefaultScreen(display);
   visual_template.depth=XDefaultDepth(display,XDefaultScreen(display));
   if ((resource_info->immutable != MagickFalse) && (resource_info->colors != 0))
-    if (resource_info->colors <= (1UL << (unsigned long) visual_template.depth))
+    if (resource_info->colors <= (1UL << (size_t) visual_template.depth))
       visual_mask|=VisualDepthMask;
   if (visual_type != (char *) NULL)
     {
@@ -1543,8 +1543,8 @@
   client_event.window=window;
   client_event.message_type=protocol;
   client_event.format=32;
-  client_event.data.l[0]=(long) reason;
-  client_event.data.l[1]=(long) timestamp;
+  client_event.data.l[0]=(ssize_t) reason;
+  client_event.data.l[1]=(ssize_t) timestamp;
   (void) XSendEvent(display,window,MagickFalse,NoEventMask,(XEvent *) &client_event);
 }
 
@@ -1594,7 +1594,7 @@
   unsigned char
     *data;
 
-  unsigned long
+  size_t
     after,
     number_items;
 
@@ -1761,7 +1761,7 @@
 %
 %  The format of the Delay method is:
 %
-%      void XDelay(Display *display,const unsigned long milliseconds)
+%      void XDelay(Display *display,const size_t milliseconds)
 %
 %  A description of each parameter follows:
 %
@@ -1772,7 +1772,7 @@
 %      returning.
 %
 */
-MagickExport void XDelay(Display *display,const unsigned long milliseconds)
+MagickExport void XDelay(Display *display,const size_t milliseconds)
 {
   assert(display != (Display *) NULL);
   (void) XFlush(display);
@@ -1795,8 +1795,8 @@
     struct timeval
       timer;
 
-    timer.tv_sec=(long) milliseconds/1000;
-    timer.tv_usec=(long) (milliseconds % 1000)*1000;
+    timer.tv_sec=(ssize_t) milliseconds/1000;
+    timer.tv_usec=(ssize_t) (milliseconds % 1000)*1000;
     (void) select(0,(XFD_SET *) NULL,(XFD_SET *) NULL,(XFD_SET *) NULL,&timer);
   }
 #elif defined(MAGICKCORE_HAVE_POLL)
@@ -1888,7 +1888,7 @@
   unsigned char
     *data;
 
-  unsigned long
+  size_t
     after,
     length;
 
@@ -1965,16 +1965,16 @@
   int
     unique_file;
 
-  long
+  ssize_t
     bytes;
 
-  register long
+  register ssize_t
     i;
 
   unsigned int
     levels;
 
-  unsigned long
+  size_t
     number_pixels;
 
   /*
@@ -2044,7 +2044,7 @@
     undo_image=GetPreviousImageInList(undo_image);
   }
   (void) fprintf(file,"Undo Edit Cache\n  levels: %u\n",levels);
-  (void) fprintf(file,"  bytes: %lumb\n",(unsigned long)
+  (void) fprintf(file,"  bytes: %lumb\n",(size_t)
     (bytes+(1 << 19)) >> 20);
   (void) fprintf(file,"  limit: %lumb\n\n",resource_info->undo_cache);
   /*
@@ -2134,7 +2134,7 @@
   int
     y;
 
-  long
+  ssize_t
     value;
 
   register char
@@ -2151,7 +2151,7 @@
   unsigned int
     scanline_pad;
 
-  register unsigned long
+  register size_t
     pixel;
 
   unsigned char
@@ -2202,7 +2202,7 @@
         value=x-32;
         if (x < 112)
           value=x/2+24;
-        value+=((unsigned long) dither_blue[i][j] << 1);
+        value+=((size_t) dither_blue[i][j] << 1);
         blue_map[i][j][x]=(unsigned char)
           ((value < 0) ? 0 : (value > 255) ? 255 : value);
       }
@@ -2210,7 +2210,7 @@
     Dither image.
   */
   scanline_pad=(unsigned int) (ximage->bytes_per_line-
-    ((unsigned long) (ximage->width*ximage->bits_per_pixel) >> 3));
+    ((size_t) (ximage->width*ximage->bits_per_pixel) >> 3));
   i=0;
   j=0;
   q=ximage->data;
@@ -2227,9 +2227,9 @@
         ScaleQuantumToChar(GetGreenPixelComponent(p))] << 8));
       color.blue=ClampToQuantum((MagickRealType) (blue_map[i][j][(int)
         ScaleQuantumToChar(GetBluePixelComponent(p))] << 8));
-      pixel=(unsigned long) (((unsigned long) color.red & 0xe0) |
-        (((unsigned long) color.green & 0xe0) >> 3) |
-        (((unsigned long) color.blue & 0xc0) >> 6));
+      pixel=(size_t) (((size_t) color.red & 0xe0) |
+        (((size_t) color.green & 0xe0) >> 3) |
+        (((size_t) color.blue & 0xc0) >> 6));
       *q++=(char) pixel;
       p++;
       j++;
@@ -2339,10 +2339,10 @@
   /*
     Initialize graphics info.
   */
-  context_values.background=(unsigned long) (~0);
+  context_values.background=(size_t) (~0);
   context_values.foreground=0;
   context_values.line_width=(int) draw_info->line_width;
-  draw_context=XCreateGC(display,root_window,(unsigned long)
+  draw_context=XCreateGC(display,root_window,(size_t)
     (GCBackground | GCForeground | GCLineWidth),&context_values);
   if (draw_context == (GC) NULL)
     return(MagickFalse);
@@ -2355,7 +2355,7 @@
     Draw line to pixmap.
   */
   (void) XSetBackground(display,draw_context,0);
-  (void) XSetForeground(display,draw_context,(unsigned long) (~0));
+  (void) XSetForeground(display,draw_context,(size_t) (~0));
   (void) XSetFillStyle(display,draw_context,FillOpaqueStippled);
   (void) XSetStipple(display,draw_context,draw_info->stipple);
   switch (draw_info->element)
@@ -2464,7 +2464,7 @@
   exception=(&image->exception);
   for (y=0; y < (int) draw_image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2473,7 +2473,7 @@
     q=QueueAuthenticPixels(draw_image,0,y,draw_image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) draw_image->columns; x++)
+    for (x=0; x < (ssize_t) draw_image->columns; x++)
     {
       if (XGetPixel(draw_ximage,x,y) == 0)
         {
@@ -2583,7 +2583,7 @@
   */
   for (y=0; y < (int) draw_image->rows; y++)
   {
-    register long
+    register ssize_t
       x;
 
     register PixelPacket
@@ -2592,7 +2592,7 @@
     q=GetAuthenticPixels(draw_image,0,y,draw_image->columns,1,exception);
     if (q == (PixelPacket *) NULL)
       break;
-    for (x=0; x < (long) draw_image->columns; x++)
+    for (x=0; x < (ssize_t) draw_image->columns; x++)
     {
       if (q->opacity != (Quantum) TransparentOpacity)
         SetOpacityPixelComponent(q,OpaqueOpacity);
@@ -2838,9 +2838,9 @@
   map_info->colormap=(Colormap) NULL;
   if (pixel != (XPixelInfo *) NULL)
     {
-      if (pixel->pixels != (unsigned long *) NULL)
-        pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels);
-      pixel->pixels=(unsigned long *) NULL;
+      if (pixel->pixels != (size_t *) NULL)
+        pixel->pixels=(size_t *) RelinquishMagickMemory(pixel->pixels);
+      pixel->pixels=(size_t *) NULL;
     }
 }
 
@@ -2927,7 +2927,7 @@
   assert(map_info != (XStandardColormap *) NULL);
   map_info->colormap=colormap;
   map_info->red_max=visual_info->red_mask;
-  map_info->red_mult=(unsigned long) (map_info->red_max != 0 ? 1 : 0);
+  map_info->red_mult=(size_t) (map_info->red_max != 0 ? 1 : 0);
   if (map_info->red_max != 0)
     while ((map_info->red_max & 0x01) == 0)
     {
@@ -2935,7 +2935,7 @@
       map_info->red_mult<<=1;
     }
   map_info->green_max=visual_info->green_mask;
-  map_info->green_mult=(unsigned long) (map_info->green_max != 0 ? 1 : 0);
+  map_info->green_mult=(size_t) (map_info->green_max != 0 ? 1 : 0);
   if (map_info->green_max != 0)
     while ((map_info->green_max & 0x01) == 0)
     {
@@ -2943,7 +2943,7 @@
       map_info->green_mult<<=1;
     }
   map_info->blue_max=visual_info->blue_mask;
-  map_info->blue_mult=(unsigned long) (map_info->blue_max != 0 ? 1 : 0);
+  map_info->blue_mult=(size_t) (map_info->blue_max != 0 ? 1 : 0);
   if (map_info->blue_max != 0)
     while ((map_info->blue_max & 0x01) == 0)
     {
@@ -3014,7 +3014,7 @@
   Colormap
     colormap;
 
-  register long
+  register ssize_t
     i;
 
   Status
@@ -3038,11 +3038,11 @@
       pixel->colors=image->colors;
   packets=(unsigned int)
     MagickMax((int) pixel->colors,visual_info->colormap_size)+MaxNumberPens;
-  if (pixel->pixels != (unsigned long *) NULL)
-    pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels);
-  pixel->pixels=(unsigned long *) AcquireQuantumMemory(packets,
+  if (pixel->pixels != (size_t *) NULL)
+    pixel->pixels=(size_t *) RelinquishMagickMemory(pixel->pixels);
+  pixel->pixels=(size_t *) AcquireQuantumMemory(packets,
     sizeof(pixel->pixels));
-  if (pixel->pixels == (unsigned long *) NULL)
+  if (pixel->pixels == (size_t *) NULL)
     ThrowXWindowFatalException(ResourceLimitFatalError,"UnableToGetPixelInfo",
       image->filename);
   /*
@@ -3198,7 +3198,7 @@
           /*
             Initialize pixel array for images of type PseudoClass.
           */
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
             pixel->pixels[i]=
               XGammaPixel(map_info,image->colormap+i);
           for (i=0; i < MaxNumberPens; i++)
@@ -4023,19 +4023,19 @@
   root_window=XRootWindow(display,XDefaultScreen(display));
   (void) XTranslateCoordinates(display,window,root_window,0,0,&x_offset,
     &y_offset,&child);
-  crop_info.x=(long) x_offset;
-  crop_info.y=(long) y_offset;
-  crop_info.width=(unsigned long) window_attributes.width;
-  crop_info.height=(unsigned long) window_attributes.height;
+  crop_info.x=(ssize_t) x_offset;
+  crop_info.y=(ssize_t) y_offset;
+  crop_info.width=(size_t) window_attributes.width;
+  crop_info.height=(size_t) window_attributes.height;
   if (borders != MagickFalse)
     {
       /*
         Include border in image.
       */
-      crop_info.x-=(long) window_attributes.border_width;
-      crop_info.y-=(long) window_attributes.border_width;
-      crop_info.width+=(unsigned long) (window_attributes.border_width << 1);
-      crop_info.height+=(unsigned long) (window_attributes.border_width << 1);
+      crop_info.x-=(ssize_t) window_attributes.border_width;
+      crop_info.y-=(ssize_t) window_attributes.border_width;
+      crop_info.width+=(size_t) (window_attributes.border_width << 1);
+      crop_info.height+=(size_t) (window_attributes.border_width << 1);
     }
   /*
     Crop to root window.
@@ -4052,10 +4052,10 @@
     }
   display_width=XDisplayWidth(display,XDefaultScreen(display));
   if ((int) (crop_info.x+crop_info.width) > display_width)
-    crop_info.width=(unsigned long) (display_width-crop_info.x);
+    crop_info.width=(size_t) (display_width-crop_info.x);
   display_height=XDisplayHeight(display,XDefaultScreen(display));
   if ((int) (crop_info.y+crop_info.height) > display_height)
-    crop_info.height=(unsigned long) (display_height-crop_info.y);
+    crop_info.height=(size_t) (display_height-crop_info.y);
   /*
     Initialize window info attributes.
   */
@@ -4151,7 +4151,7 @@
       register PixelPacket
         *restrict q;
 
-      register unsigned long
+      register size_t
         pixel;
 
       unsigned int
@@ -4245,12 +4245,12 @@
                     (window_info[id].visual->klass != TrueColor))
                   for (i=0; i < (int) number_colors; i++)
                   {
-                    colors[i].pixel=(unsigned long) i;
+                    colors[i].pixel=(size_t) i;
                     colors[i].pad='\0';
                   }
                 else
                   {
-                    unsigned long
+                    size_t
                       blue,
                       blue_bit,
                       green,
@@ -4315,19 +4315,19 @@
         if ((window_info[id].visual->klass != TrueColor) &&
             (window_info[id].visual->klass != DirectColor))
           composite_image->storage_class=PseudoClass;
-        composite_image->columns=(unsigned long) ximage->width;
-        composite_image->rows=(unsigned long) ximage->height;
+        composite_image->columns=(size_t) ximage->width;
+        composite_image->rows=(size_t) ximage->height;
         exception=(&composite_image->exception);
         switch (composite_image->storage_class)
         {
           case DirectClass:
           default:
           {
-            register unsigned long
+            register size_t
               color,
               index;
 
-            unsigned long
+            size_t
               blue_mask,
               blue_shift,
               green_mask,
@@ -4443,7 +4443,7 @@
               {
                 index=(IndexPacket) XGetPixel(ximage,x,y);
                 indexes[x]=index;
-                *q++=composite_image->colormap[(long) index];
+                *q++=composite_image->colormap[(ssize_t) index];
               }
               if (SyncAuthenticPixels(composite_image,exception) == MagickFalse)
                 break;
@@ -4615,7 +4615,7 @@
   if (resource_info->icon_geometry != (char *) NULL)
     (void) CloneString(&window->icon_geometry,resource_info->icon_geometry);
   window->crop_geometry=(char *) NULL;
-  window->flags=(unsigned long) PSize;
+  window->flags=(size_t) PSize;
   window->width=1;
   window->height=1;
   window->min_width=1;
@@ -4632,7 +4632,7 @@
   window->immutable=MagickFalse;
   window->shape=MagickFalse;
   window->data=0;
-  window->mask=(unsigned long) (CWBackingStore | CWBackPixel | CWBackPixmap |
+  window->mask=(size_t) (CWBackingStore | CWBackPixel | CWBackPixmap |
     CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWDontPropagate |
     CWEventMask | CWOverrideRedirect | CWSaveUnder | CWWinGravity);
   window->attributes.background_pixel=pixel->background_color.pixel;
@@ -4971,8 +4971,8 @@
       (void) XTranslateCoordinates(display,target,root,0,0,&x,&y,&child);
       crop_info.x=x;
       crop_info.y=y;
-      crop_info.width=(unsigned long) window_attributes.width;
-      crop_info.height=(unsigned long) window_attributes.height;
+      crop_info.width=(size_t) window_attributes.width;
+      crop_info.height=(size_t) window_attributes.height;
       if (ximage_info->borders != 0)
         {
           /*
@@ -5150,7 +5150,7 @@
     {
       (void) XSynchronize(display,MagickTrue);
       (void) LogMagickEvent(X11Event,GetMagickModule(),"Version: %s",
-        GetMagickVersion((unsigned long *) NULL));
+        GetMagickVersion((size_t *) NULL));
       (void) LogMagickEvent(X11Event,GetMagickModule(),"Protocols:");
       (void) LogMagickEvent(X11Event,GetMagickModule(),
         "  Window Manager: 0x%lx",windows->wm_protocols);
@@ -5188,13 +5188,13 @@
       "MemoryAllocationFailed","...");
   windows->map_info->colormap=(Colormap) NULL;
   windows->icon_map->colormap=(Colormap) NULL;
-  windows->pixel_info->pixels=(unsigned long *) NULL;
+  windows->pixel_info->pixels=(size_t *) NULL;
   windows->pixel_info->annotate_context=(GC) NULL;
   windows->pixel_info->highlight_context=(GC) NULL;
   windows->pixel_info->widget_context=(GC) NULL;
   windows->font_info=(XFontStruct *) NULL;
   windows->icon_pixel->annotate_context=(GC) NULL;
-  windows->icon_pixel->pixels=(unsigned long *) NULL;
+  windows->icon_pixel->pixels=(size_t *) NULL;
   /*
     Allocate visual.
   */
@@ -5474,9 +5474,9 @@
             }
         }
       width=(unsigned int) window->image->columns;
-      assert((unsigned long) width == window->image->columns);
+      assert((size_t) width == window->image->columns);
       height=(unsigned int) window->image->rows;
-      assert((unsigned long) height == window->image->rows);
+      assert((size_t) height == window->image->rows);
     }
   /*
     Create X image.
@@ -5667,8 +5667,8 @@
   matte_image=(XImage *) NULL;
   if ((window->shape != MagickFalse) && (window->image != (Image *) NULL))
     if ((window->image->matte != MagickFalse) &&
-        ((long) width <= XDisplayWidth(display,window->screen)) &&
-        ((long) height <= XDisplayHeight(display,window->screen)))
+        ((ssize_t) width <= XDisplayWidth(display,window->screen)) &&
+        ((ssize_t) height <= XDisplayHeight(display,window->screen)))
       {
         /*
           Create matte image.
@@ -5751,7 +5751,7 @@
           context_values.background=1;
           context_values.foreground=0;
           graphics_context=XCreateGC(display,window->matte_pixmap,
-            (unsigned long) (GCBackground | GCForeground),&context_values);
+            (size_t) (GCBackground | GCForeground),&context_values);
           (void) XPutImage(display,window->matte_pixmap,graphics_context,
             window->matte_image,0,0,0,0,width,height);
           (void) XFreeGC(display,graphics_context);
@@ -5834,7 +5834,7 @@
   unsigned int
     scanline_pad;
 
-  unsigned long
+  size_t
     pixel,
     *pixels;
 
@@ -5955,7 +5955,7 @@
             nibble=0;
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]] & 0x0f;
+              pixel=pixels[(ssize_t) indexes[x]] & 0x0f;
               switch (nibble)
               {
                 case 0:
@@ -6006,7 +6006,7 @@
             nibble=0;
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]] & 0xf;
+              pixel=pixels[(ssize_t) indexes[x]] & 0xf;
               switch (nibble)
               {
                 case 0:
@@ -6048,7 +6048,7 @@
             indexes=GetVirtualIndexQueue(canvas);
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]];
+              pixel=pixels[(ssize_t) indexes[x]];
               *q++=(unsigned char) pixel;
             }
             q+=scanline_pad;
@@ -6064,7 +6064,7 @@
             bytes_per_pixel;
 
           unsigned char
-            channel[sizeof(unsigned long)];
+            channel[sizeof(size_t)];
 
           /*
             Convert to multi-byte color-mapped X canvas.
@@ -6078,7 +6078,7 @@
             indexes=GetVirtualIndexQueue(canvas);
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]];
+              pixel=pixels[(ssize_t) indexes[x]];
               for (k=0; k < (int) bytes_per_pixel; k++)
               {
                 channel[k]=(unsigned char) pixel;
@@ -6315,7 +6315,7 @@
                   bytes_per_pixel;
 
                 unsigned char
-                  channel[sizeof(unsigned long)];
+                  channel[sizeof(size_t)];
 
                 /*
                   Convert to multi-byte continuous-tone X canvas.
@@ -6327,7 +6327,7 @@
                     &canvas->exception);
                   if (p == (PixelPacket *) NULL)
                     break;
-                  for (x=0; x < (long) canvas->columns; x++)
+                  for (x=0; x < (ssize_t) canvas->columns; x++)
                   {
                     pixel=XGammaPixel(map_info,p);
                     for (k=0; k < (int) bytes_per_pixel; k++)
@@ -6363,7 +6363,7 @@
         for (x=(int) canvas->columns-1; x >= 0; x--)
         {
           byte>>=1;
-          if (p->opacity > (long) (QuantumRange/2))
+          if (p->opacity > (ssize_t) (QuantumRange/2))
             byte|=0x80;
           bit++;
           if (bit == 8)
@@ -6447,7 +6447,7 @@
   unsigned int
     scanline_pad;
 
-  unsigned long
+  size_t
     pixel,
     *pixels;
 
@@ -6568,7 +6568,7 @@
             nibble=0;
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]] & 0xf;
+              pixel=pixels[(ssize_t) indexes[x]] & 0xf;
               switch (nibble)
               {
                 case 0:
@@ -6619,7 +6619,7 @@
             nibble=0;
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]] & 0xf;
+              pixel=pixels[(ssize_t) indexes[x]] & 0xf;
               switch (nibble)
               {
                 case 0:
@@ -6661,7 +6661,7 @@
             indexes=GetVirtualIndexQueue(canvas);
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]];
+              pixel=pixels[(ssize_t) indexes[x]];
               *q++=(unsigned char) pixel;
             }
             q+=scanline_pad;
@@ -6677,7 +6677,7 @@
             bytes_per_pixel;
 
           unsigned char
-            channel[sizeof(unsigned long)];
+            channel[sizeof(size_t)];
 
           /*
             Convert to 8 bit color-mapped X canvas.
@@ -6691,7 +6691,7 @@
             indexes=GetVirtualIndexQueue(canvas);
             for (x=0; x < (int) canvas->columns; x++)
             {
-              pixel=pixels[(long) indexes[x]];
+              pixel=pixels[(ssize_t) indexes[x]];
               for (k=(int) bytes_per_pixel-1; k >= 0; k--)
               {
                 channel[k]=(unsigned char) pixel;
@@ -6928,7 +6928,7 @@
                   bytes_per_pixel;
 
                 unsigned char
-                  channel[sizeof(unsigned long)];
+                  channel[sizeof(size_t)];
 
                 /*
                   Convert to multi-byte continuous-tone X canvas.
@@ -6976,7 +6976,7 @@
         for (x=(int) canvas->columns-1; x >= 0; x--)
         {
           byte<<=1;
-          if (p->opacity > (long) (QuantumRange/2))
+          if (p->opacity > (ssize_t) (QuantumRange/2))
             byte|=0x01;
           bit++;
           if (bit == 8)
@@ -7029,7 +7029,7 @@
   int
     y;
 
-  long
+  ssize_t
     n;
 
   MagickPixelPacket
@@ -7038,7 +7038,7 @@
   register int
     x;
 
-  register long
+  register ssize_t
     i;
 
   register unsigned char
@@ -7070,7 +7070,7 @@
   assert(display != (Display *) NULL);
   assert(windows != (XWindows *) NULL);
   magnify=1;
-  for (n=1; n < (long) windows->magnify.data; n++)
+  for (n=1; n < (ssize_t) windows->magnify.data; n++)
     magnify<<=1;
   while ((magnify*windows->image.ximage->width) < windows->magnify.width)
     magnify<<=1;
@@ -7165,7 +7165,7 @@
               if (windows->magnify.depth > 1)
                 Swap(background,foreground);
             }
-          for (i=0; i < (long) height; i+=magnify)
+          for (i=0; i < (ssize_t) height; i+=magnify)
           {
             /*
               Propogate pixel magnify rows.
@@ -7237,7 +7237,7 @@
               if (windows->magnify.depth > 1)
                 Swap(background,foreground);
             }
-          for (i=0; i < (long) height; i+=magnify)
+          for (i=0; i < (ssize_t) height; i+=magnify)
           {
             /*
               Propogate pixel magnify rows.
@@ -7301,7 +7301,7 @@
         /*
           Magnify 8 bit X image.
         */
-        for (i=0; i < (long) height; i+=magnify)
+        for (i=0; i < (ssize_t) height; i+=magnify)
         {
           /*
             Propogate pixel magnify rows.
@@ -7335,7 +7335,7 @@
           Magnify multi-byte X image.
         */
         bytes_per_pixel=(unsigned int) ximage->bits_per_pixel >> 3;
-        for (i=0; i < (long) height; i+=magnify)
+        for (i=0; i < (ssize_t) height; i+=magnify)
         {
           /*
             Propogate pixel magnify rows.
@@ -7395,8 +7395,8 @@
       /*
         Highlight center pixel.
       */
-      highlight_info.x=(long) windows->magnify.width >> 1;
-      highlight_info.y=(long) windows->magnify.height >> 1;
+      highlight_info.x=(ssize_t) windows->magnify.width >> 1;
+      highlight_info.y=(ssize_t) windows->magnify.height >> 1;
       highlight_info.width=magnify;
       highlight_info.height=magnify;
       (void) XDrawRectangle(display,windows->magnify.pixmap,
@@ -7634,8 +7634,8 @@
 }
 #endif
 
-static inline Quantum ScaleXToQuantum(const unsigned long x,
-  const unsigned long scale)
+static inline Quantum ScaleXToQuantum(const size_t x,
+  const size_t scale)
 {
   return((Quantum) (((MagickRealType) QuantumRange*x)/scale+0.5));
 }
@@ -7653,13 +7653,13 @@
   register IndexPacket
     *indexes;
 
-  register long
+  register ssize_t
     i;
 
   Status
     status;
 
-  unsigned long
+  size_t
     number_colors,
     retain_colors;
 
@@ -7715,20 +7715,20 @@
               1,exception);
             if (q != (PixelPacket *) NULL)
               {
-                for (i=0; i < (long) number_colors; i++)
+                for (i=0; i < (ssize_t) number_colors; i++)
                 {
                   q->red=(Quantum) 0;
                   if (map_info->red_max != 0)
-                    q->red=ScaleXToQuantum((unsigned long) (i/
+                    q->red=ScaleXToQuantum((size_t) (i/
                       map_info->red_mult),map_info->red_max);
                   q->green=(Quantum) 0;
                   if (map_info->green_max != 0)
-                    q->green=ScaleXToQuantum((unsigned long) ((i/
+                    q->green=ScaleXToQuantum((size_t) ((i/
                       map_info->green_mult) % (map_info->green_max+1)),
                       map_info->green_max);
                   q->blue=(Quantum) 0;
                   if (map_info->blue_max != 0)
-                    q->blue=ScaleXToQuantum((unsigned long) (i %
+                    q->blue=ScaleXToQuantum((size_t) (i %
                       map_info->green_mult),map_info->blue_max);
                   q->opacity=(Quantum) TransparentOpacity;
                   q++;
@@ -7769,7 +7769,7 @@
           Image has more colors than the visual supports.
         */
         quantize_info=(*resource_info->quantize_info);
-        quantize_info.number_colors=(unsigned long) visual_info->colormap_size;
+        quantize_info.number_colors=(size_t) visual_info->colormap_size;
         (void) QuantizeImage(&quantize_info,image);
       }
   /*
@@ -7808,7 +7808,7 @@
           "UnableToCreateColormap",image->filename);
       p=colors;
       color.flags=(char) (DoRed | DoGreen | DoBlue);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red));
         color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green));
@@ -7863,7 +7863,7 @@
         Determine if image colors will "fit" into X server colormap.
       */
       colormap_type=resource_info->colormap;
-      status=XAllocColorCells(display,colormap,MagickFalse,(unsigned long *)
+      status=XAllocColorCells(display,colormap,MagickFalse,(size_t *)
         NULL,0,pixel->pixels,(unsigned int) image->colors);
       if (status != False)
         colormap_type=PrivateColormap;
@@ -7892,7 +7892,7 @@
           if (diversity == (DiversityPacket *) NULL)
             ThrowXWindowFatalException(ResourceLimitFatalError,
               "UnableToCreateColormap",image->filename);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             diversity[i].red=image->colormap[i].red;
             diversity[i].green=image->colormap[i].green;
@@ -7902,7 +7902,7 @@
           }
           for (y=0; y < (int) image->rows; y++)
           {
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -7912,18 +7912,18 @@
             if (q == (PixelPacket *) NULL)
               break;
             indexes=GetAuthenticIndexQueue(image);
-            for (x=(long) image->columns-1; x >= 0; x--)
-              diversity[(long) indexes[x]].count++;
+            for (x=(ssize_t) image->columns-1; x >= 0; x--)
+              diversity[(ssize_t) indexes[x]].count++;
           }
           /*
             Sort colors by decreasing intensity.
           */
           qsort((void *) diversity,image->colors,sizeof(*diversity),
             IntensityCompare);
-          for (i=0; i < (long) image->colors; )
+          for (i=0; i < (ssize_t) image->colors; )
           {
             diversity[i].count<<=4;  /* increase this colors popularity */
-            i+=MagickMax((long) (image->colors >> 4),2);
+            i+=MagickMax((ssize_t) (image->colors >> 4),2);
           }
           diversity[image->colors-1].count<<=4;
           qsort((void *) diversity,image->colors,sizeof(*diversity),
@@ -7933,7 +7933,7 @@
           */
           p=colors;
           color.flags=(char) (DoRed | DoGreen | DoBlue);
-          for (i=0; i < (long) image->colors; i++)
+          for (i=0; i < (ssize_t) image->colors; i++)
           {
             index=diversity[i].index;
             color.red=
@@ -7964,13 +7964,13 @@
             ThrowXWindowFatalException(ResourceLimitFatalError,
               "UnableToCreateColormap",image->filename);
           for (x=visual_info->colormap_size-1; x >= 0; x--)
-            server_colors[x].pixel=(unsigned long) x;
+            server_colors[x].pixel=(size_t) x;
           (void) XQueryColors(display,colormap,server_colors,
             (int) MagickMin((unsigned int) visual_info->colormap_size,256));
           /*
             Select remaining colors from X server colormap.
           */
-          for (; i < (long) image->colors; i++)
+          for (; i < (ssize_t) image->colors; i++)
           {
             index=diversity[i].index;
             color.red=
@@ -7998,7 +7998,7 @@
               */
               retain_colors=MagickMin((unsigned int)
                (visual_info->colormap_size-image->colors),256);
-              for (i=0; i < (long) retain_colors; i++)
+              for (i=0; i < (ssize_t) retain_colors; i++)
                 *p++=server_colors[i];
               number_colors+=retain_colors;
             }
@@ -8030,9 +8030,9 @@
               retain_colors=MagickMin((unsigned int)
                 (visual_info->colormap_size-image->colors),256);
               p=colors+image->colors;
-              for (i=0; i < (long) retain_colors; i++)
+              for (i=0; i < (ssize_t) retain_colors; i++)
               {
-                p->pixel=(unsigned long) i;
+                p->pixel=(size_t) i;
                 p++;
               }
               (void) XQueryColors(display,
@@ -8042,10 +8042,10 @@
                 Transfer colors from default to private colormap.
               */
               (void) XAllocColorCells(display,colormap,MagickFalse,
-                (unsigned long *) NULL,0,pixel->pixels,(unsigned int)
+                (size_t *) NULL,0,pixel->pixels,(unsigned int)
                 retain_colors);
               p=colors+image->colors;
-              for (i=0; i < (long) retain_colors; i++)
+              for (i=0; i < (ssize_t) retain_colors; i++)
               {
                 p->pixel=pixel->pixels[i];
                 p++;
@@ -8055,7 +8055,7 @@
               number_colors+=retain_colors;
             }
           (void) XAllocColorCells(display,colormap,MagickFalse,
-            (unsigned long *) NULL,0,pixel->pixels,(unsigned int)
+            (size_t *) NULL,0,pixel->pixels,(unsigned int)
             image->colors);
         }
       /*
@@ -8063,7 +8063,7 @@
       */
       p=colors;
       color.flags=(char) (DoRed | DoGreen | DoBlue);
-      for (i=0; i < (long) image->colors; i++)
+      for (i=0; i < (ssize_t) image->colors; i++)
       {
         color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red));
         color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green));
@@ -8100,7 +8100,7 @@
          ((int) (map_info->blue_max+1) == visual_info->colormap_size)) ?
          MagickTrue : MagickFalse;
       if (linear_colormap != MagickFalse)
-        number_colors=(unsigned long) visual_info->colormap_size;
+        number_colors=(size_t) visual_info->colormap_size;
       /*
         Allocate color array.
       */
@@ -8114,11 +8114,11 @@
       p=colors;
       color.flags=(char) (DoRed | DoGreen | DoBlue);
       if (linear_colormap != MagickFalse)
-        for (i=0; i < (long) number_colors; i++)
+        for (i=0; i < (ssize_t) number_colors; i++)
         {
           color.blue=(unsigned short) 0;
           if (map_info->blue_max != 0)
-            color.blue=(unsigned short) ((unsigned long)
+            color.blue=(unsigned short) ((size_t)
               ((65535L*(i % map_info->green_mult))/map_info->blue_max));
           color.green=color.blue;
           color.red=color.blue;
@@ -8126,20 +8126,20 @@
           *p++=color;
         }
       else
-        for (i=0; i < (long) number_colors; i++)
+        for (i=0; i < (ssize_t) number_colors; i++)
         {
           color.red=(unsigned short) 0;
           if (map_info->red_max != 0)
-            color.red=(unsigned short) ((unsigned long)
+            color.red=(unsigned short) ((size_t)
               ((65535L*(i/map_info->red_mult))/map_info->red_max));
           color.green=(unsigned int) 0;
           if (map_info->green_max != 0)
-            color.green=(unsigned short) ((unsigned long)
+            color.green=(unsigned short) ((size_t)
               ((65535L*((i/map_info->green_mult) % (map_info->green_max+1)))/
                 map_info->green_max));
           color.blue=(unsigned short) 0;
           if (map_info->blue_max != 0)
-            color.blue=(unsigned short) ((unsigned long)
+            color.blue=(unsigned short) ((size_t)
               ((65535L*(i % map_info->green_mult))/map_info->blue_max));
           color.pixel=XStandardPixel(map_info,&color);
           *p++=color;
@@ -8148,7 +8148,7 @@
           (colormap != XDefaultColormap(display,visual_info->screen)))
         (void) XStoreColors(display,colormap,colors,(int) number_colors);
       else
-        for (i=0; i < (long) number_colors; i++)
+        for (i=0; i < (ssize_t) number_colors; i++)
           (void) XAllocColor(display,colormap,&colors[i]);
       break;
     }
@@ -8279,7 +8279,7 @@
   size_hints=XAllocSizeHints();
   if (size_hints == (XSizeHints *) NULL)
     ThrowXWindowFatalException(XServerFatalError,"UnableToMakeXWindow",argv[0]);
-  size_hints->flags=(long) window_info->flags;
+  size_hints->flags=(ssize_t) window_info->flags;
   size_hints->x=window_info->x;
   size_hints->y=window_info->y;
   size_hints->width=(int) window_info->width;
@@ -8991,7 +8991,7 @@
   context_values.plane_mask=
     context_values.background ^ context_values.foreground;
   context_values.subwindow_mode=IncludeInferiors;
-  annotate_context=XCreateGC(display,root_window,(unsigned long) (GCBackground |
+  annotate_context=XCreateGC(display,root_window,(size_t) (GCBackground |
     GCForeground | GCFunction | GCSubwindowMode),&context_values);
   if (annotate_context == (GC) NULL)
     return(MagickFalse);
@@ -9393,7 +9393,7 @@
 %
 */
 MagickExport Window XWindowByID(Display *display,const Window root_window,
-  const unsigned long id)
+  const size_t id)
 {
   RectangleInfo
     rectangle_info;
@@ -9566,7 +9566,7 @@
     i,
     number_children;
 
-  unsigned long
+  size_t
     after,
     number_items;
 
diff --git a/tests/validate.c b/tests/validate.c
index d2d9ce6..9f30a61 100644
--- a/tests/validate.c
+++ b/tests/validate.c
@@ -65,9 +65,9 @@
 %
 %  The format of the ValidateCompareCommand method is:
 %
-%      unsigned long ValidateCompareCommand(ImageInfo *image_info,
+%      size_t ValidateCompareCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -82,9 +82,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateCompareCommand(ImageInfo *image_info,
+static size_t ValidateCompareCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -96,11 +96,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -152,9 +152,9 @@
 %
 %  The format of the ValidateCompositeCommand method is:
 %
-%      unsigned long ValidateCompositeCommand(ImageInfo *image_info,
+%      size_t ValidateCompositeCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -169,9 +169,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
+static size_t ValidateCompositeCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -183,11 +183,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -240,9 +240,9 @@
 %
 %  The format of the ValidateConvertCommand method is:
 %
-%      unsigned long ValidateConvertCommand(ImageInfo *image_info,
+%      size_t ValidateConvertCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -257,9 +257,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateConvertCommand(ImageInfo *image_info,
+static size_t ValidateConvertCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -271,11 +271,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -327,9 +327,9 @@
 %
 %  The format of the ValidateIdentifyCommand method is:
 %
-%      unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
+%      size_t ValidateIdentifyCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -344,9 +344,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
+static size_t ValidateIdentifyCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -358,11 +358,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   (void) output_filename;
@@ -415,9 +415,9 @@
 %
 %  The format of the ValidateImageFormatsInMemory method is:
 %
-%      unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
+%      size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -432,9 +432,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
+static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     size[MaxTextExtent];
@@ -454,7 +454,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -464,7 +464,7 @@
   unsigned char
     *blob;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -631,9 +631,9 @@
 %
 %  The format of the ValidateImageFormatsOnDisk method is:
 %
-%      unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
+%      size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -648,9 +648,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
+static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     size[MaxTextExtent];
@@ -670,11 +670,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -838,9 +838,9 @@
 %
 %  The format of the ValidateImportExportPixels method is:
 %
-%      unsigned long ValidateImportExportPixels(ImageInfo *image_info,
+%      size_t ValidateImportExportPixels(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -855,9 +855,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
+static size_t ValidateImportExportPixels(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   double
     distortion;
@@ -870,7 +870,7 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -880,7 +880,7 @@
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     test;
 
   (void) output_filename;
@@ -1008,9 +1008,9 @@
 %
 %  The format of the ValidateMontageCommand method is:
 %
-%      unsigned long ValidateMontageCommand(ImageInfo *image_info,
+%      size_t ValidateMontageCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1025,9 +1025,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateMontageCommand(ImageInfo *image_info,
+static size_t ValidateMontageCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -1039,11 +1039,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -1096,9 +1096,9 @@
 %
 %  The format of the ValidateStreamCommand method is:
 %
-%      unsigned long ValidateStreamCommand(ImageInfo *image_info,
+%      size_t ValidateStreamCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1113,9 +1113,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateStreamCommand(ImageInfo *image_info,
+static size_t ValidateStreamCommand(ImageInfo *image_info,
   const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+  size_t *fail,ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -1127,11 +1127,11 @@
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   test=0;
@@ -1203,7 +1203,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n\n",GetMagickCopyright());
   (void) printf("Features: %s\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] reference-file\n",GetClientName());
@@ -1254,13 +1254,13 @@
     regard_warnings,
     status;
 
-  register long
+  register ssize_t
     i;
 
   TimerInfo
     *timer;
 
-  unsigned long
+  size_t
     fail,
     iterations,
     tests;
@@ -1279,7 +1279,7 @@
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
   (void) CopyMagickString(image_info->filename,ReferenceFilename,MaxTextExtent);
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (IsMagickOption(option) == MagickFalse)
@@ -1339,13 +1339,13 @@
       {
         if (LocaleCompare("validate",option+1) == 0)
           {
-            long
+            ssize_t
               validate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowValidateException(OptionError,"MissingArgument",option);
             validate=ParseMagickOption(MagickValidateOptions,MagickFalse,
               argv[i]);
@@ -1359,7 +1359,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             return(0);
@@ -1395,11 +1395,11 @@
       else
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n\n",
             GetMagickCopyright());
           (void) fprintf(stdout,"ImageMagick Validation Suite (%s)\n\n",
-            MagickOptionToMnemonic(MagickValidateOptions,(long) type));
+            MagickOptionToMnemonic(MagickValidateOptions,(ssize_t) type));
           if ((type & CompareValidate) != 0)
             tests+=ValidateCompareCommand(image_info,reference_filename,
               output_filename,&fail,exception);
@@ -1441,9 +1441,9 @@
       user_time=GetUserTime(timer);
       (void) fprintf(stderr,
         "Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",
-        iterations,1.0*iterations/elapsed_time,user_time,(long)
-        (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),
-        (long) (1000.0*(elapsed_time-floor(elapsed_time))));
+        iterations,1.0*iterations/elapsed_time,user_time,(ssize_t)
+        (elapsed_time/60.0),(ssize_t) ceil(fmod(elapsed_time,60.0)),
+        (ssize_t) (1000.0*(elapsed_time-floor(elapsed_time))));
       timer=DestroyTimerInfo(timer);
     }
   DestroyValidate();
diff --git a/tests/validate.h b/tests/validate.h
index dacd320..c7c34ca 100644
--- a/tests/validate.h
+++ b/tests/validate.h
@@ -418,7 +418,7 @@
     { DoublePixel, sizeof(double) },
     { FloatPixel, sizeof(float) },
     { IntegerPixel, sizeof(unsigned int) },
-    { LongPixel, sizeof(unsigned long) },
+    { LongPixel, sizeof(size_t) },
     { ShortPixel, sizeof(unsigned short) },
     { UndefinedPixel, 0 }
   };
@@ -428,7 +428,7 @@
   ImageType
     type;
 
-  unsigned long
+  size_t
     depth;
 };
 
diff --git a/wand/MagickWand.h b/wand/MagickWand.h
index 7a03ffc..d326cc1 100644
--- a/wand/MagickWand.h
+++ b/wand/MagickWand.h
@@ -147,13 +147,13 @@
 extern WandExport ExceptionType
   MagickGetExceptionType(const MagickWand *);
 
-extern WandExport long
+extern WandExport ssize_t
   MagickGetIteratorIndex(MagickWand *);
 
 extern WandExport MagickBooleanType
   IsMagickWand(const MagickWand *),
   MagickClearException(MagickWand *),
-  MagickSetIteratorIndex(MagickWand *,const long);
+  MagickSetIteratorIndex(MagickWand *,const ssize_t);
 
 extern WandExport MagickWand
   *CloneMagickWand(const MagickWand *),
diff --git a/wand/animate.c b/wand/animate.c
index cb55609..bd09fbf 100644
--- a/wand/animate.c
+++ b/wand/animate.c
@@ -186,7 +186,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
@@ -239,7 +239,7 @@
     } \
   XDestroyResourceInfo(&resource_info); \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -274,7 +274,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
@@ -288,7 +288,7 @@
   QuantizeInfo
     *quantize_info;
 
-  register long
+  register ssize_t
     i;
 
   XResourceInfo
@@ -312,7 +312,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -338,7 +338,7 @@
   if (status == MagickFalse)
     ThrowAnimateException(ResourceLimitError,"MemoryAllocationFailed",
       image_info->filename);
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     /*
       Check command line for server name.
@@ -350,7 +350,7 @@
           User specified server name.
         */
         i++;
-        if (i == (long) argc)
+        if (i == (ssize_t) argc)
           ThrowAnimateException(OptionError,"MissingArgument",option);
         server_name=argv[i];
       }
@@ -387,9 +387,9 @@
   /*
     Parse command line.
   */
-  for (i=1; i <= (long) argc; i++)
+  for (i=1; i <= (ssize_t) argc; i++)
   {
-    if (i < (long) argc)
+    if (i < (ssize_t) argc)
       option=argv[i];
     else
       if (image != (Image *) NULL)
@@ -465,13 +465,13 @@
       {
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -484,7 +484,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -502,7 +502,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.background_color=argv[i];
             break;
@@ -512,7 +512,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.border_color=argv[i];
             break;
@@ -523,7 +523,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (IsGeometry(argv[i]) == MagickFalse))
+            if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.border_width=(unsigned int)
               StringToUnsignedLong(argv[i]);
@@ -538,7 +538,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -546,13 +546,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -576,7 +576,7 @@
             else
               {
                 i++;
-                if (i == (long) (argc-1))
+                if (i == (ssize_t) (argc-1))
                   ThrowAnimateException(OptionError,"MissingArgument",option);
                 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
                   ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -595,7 +595,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.colormap=UndefinedColormap;
             if (LocaleCompare("private",argv[i]) == 0)
@@ -613,7 +613,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -622,13 +622,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -644,7 +644,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -656,13 +656,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -676,14 +676,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -702,7 +702,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -713,7 +713,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -724,7 +724,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -735,19 +735,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -757,14 +757,14 @@
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             quantize_info->dither=MagickFalse;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -779,7 +779,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -794,7 +794,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -806,13 +806,13 @@
       {
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -827,7 +827,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.font=XGetResourceClass(resource_database,
               GetClientName(),"font",argv[i]);
@@ -838,7 +838,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.foreground_color=argv[i];
             break;
@@ -848,7 +848,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -859,7 +859,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -871,7 +871,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -880,13 +880,13 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
               argv[i]);
@@ -912,7 +912,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -933,13 +933,13 @@
           }
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -950,13 +950,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -974,7 +974,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -986,13 +986,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -1000,7 +1000,7 @@
               ThrowAnimateException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -1009,13 +1009,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -1030,7 +1030,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
@@ -1040,7 +1040,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1057,7 +1057,7 @@
               break;
             (void) CopyMagickString(argv[i]+1,"san",MaxTextExtent);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.map_type=argv[i];
             break;
@@ -1069,7 +1069,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.matte_color=argv[i];
             break;
@@ -1094,7 +1094,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.name=ConstantString(argv[i]);
             break;
@@ -1111,7 +1111,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1123,14 +1123,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1140,13 +1140,13 @@
       {
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -1166,7 +1166,7 @@
         if (LocaleCompare("remote",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
               return(MagickFalse);
@@ -1178,7 +1178,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1189,7 +1189,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1200,7 +1200,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1214,7 +1214,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1229,7 +1229,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1240,7 +1240,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1251,7 +1251,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1260,12 +1260,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1280,7 +1280,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1303,7 +1303,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.text_font=XGetResourceClass(resource_database,
               GetClientName(),"font",argv[i]);
@@ -1314,7 +1314,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1326,7 +1326,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.title=argv[i];
             break;
@@ -1336,7 +1336,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowAnimateException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1346,7 +1346,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowAnimateInvalidArgumentException(option,argv[i]);
@@ -1365,20 +1365,20 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -1393,7 +1393,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.visual_type=argv[i];
             break;
@@ -1408,7 +1408,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowAnimateException(OptionError,"MissingArgument",option);
             resource_info.window_id=argv[i];
             break;
diff --git a/wand/compare.c b/wand/compare.c
index 674c792..2e0094d 100644
--- a/wand/compare.c
+++ b/wand/compare.c
@@ -147,7 +147,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] image reconstruct difference\n",
@@ -181,7 +181,7 @@
   if (difference_image != (Image *) NULL) \
     difference_image=DestroyImageList(difference_image); \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -225,7 +225,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
@@ -242,7 +242,7 @@
   RectangleInfo
     offset;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -260,7 +260,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -290,7 +290,7 @@
   if (status == MagickFalse)
     ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -338,13 +338,13 @@
       {
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -357,7 +357,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -370,7 +370,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -378,13 +378,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -395,13 +395,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
               argv[i]);
@@ -412,13 +412,13 @@
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-            long
+            ssize_t
               compose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
               argv[i]);
@@ -429,13 +429,13 @@
           }
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -458,7 +458,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             event_mask=SetLogEventMask(argv[i]);
             if (event_mask == UndefinedEvents)
@@ -471,14 +471,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -497,7 +497,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -508,7 +508,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -519,7 +519,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -534,7 +534,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -549,7 +549,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -558,7 +558,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -573,7 +573,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             format=argv[i];
             break;
@@ -583,7 +583,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -601,7 +601,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -613,13 +613,13 @@
           break;
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -640,13 +640,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -654,7 +654,7 @@
               ThrowCompareException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -663,13 +663,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -684,7 +684,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL))
+            if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -693,7 +693,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -705,13 +705,13 @@
           break;
         if (LocaleCompare("metric",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickMetricOptions,MagickTrue,argv[i]);
             if (type < 0)
@@ -731,14 +731,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -751,7 +751,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -759,13 +759,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -796,7 +796,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -807,7 +807,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -816,12 +816,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
@@ -830,7 +830,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompareInvalidArgumentException(option,argv[i]);
@@ -845,19 +845,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompareException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -875,20 +875,20 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompareException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -911,7 +911,7 @@
   }
   if (k != 0)
     ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]);
-  if (i-- != (long) (argc-1))
+  if (i-- != (ssize_t) (argc-1))
     ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]);
   if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
     ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]);
@@ -1029,7 +1029,7 @@
             (void) fprintf(stderr,"Offset: %ld,%ld\n",difference_image->page.x,
               difference_image->page.y);
           (void) fprintf(stderr,"  Channel distortion: %s\n",
-            MagickOptionToMnemonic(MagickMetricOptions,(long) metric));
+            MagickOptionToMnemonic(MagickMetricOptions,(ssize_t) metric));
           switch (metric)
           {
             case MeanAbsoluteErrorMetric:
diff --git a/wand/composite.c b/wand/composite.c
index ffc553d..2993126 100644
--- a/wand/composite.c
+++ b/wand/composite.c
@@ -63,7 +63,7 @@
   GravityType
     gravity;
 
-  long
+  ssize_t
     stegano;
 
   RectangleInfo
@@ -174,11 +174,11 @@
         else
           if (composite_options->tile != MagickFalse)
             {
-              long
+              ssize_t
                 x,
                 y;
 
-              unsigned long
+              size_t
                 columns;
 
               /*
@@ -187,8 +187,8 @@
               (void) SetImageArtifact(composite_image,"compose:outside-overlay",
                 "false");
               columns=composite_image->columns;
-              for (y=0; y < (long) (*image)->rows; y+=composite_image->rows)
-                for (x=0; x < (long) (*image)->columns; x+=columns)
+              for (y=0; y < (ssize_t) (*image)->rows; y+=composite_image->rows)
+                for (x=0; x < (ssize_t) (*image)->columns; x+=columns)
                   status&=CompositeImageChannel(*image,
                     composite_options->channel,composite_options->compose,
                     composite_image,x,y);
@@ -333,7 +333,7 @@
     };
 
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] image [options ...] composite\n"
@@ -385,7 +385,7 @@
 { \
   RelinquishCompositeOptions(&composite_options); \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -430,11 +430,11 @@
   MagickStatusType
     status;
 
-  long
+  ssize_t
     j,
     k;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -452,7 +452,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -480,7 +480,7 @@
   if (status == MagickFalse)
     ThrowCompositeException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -531,7 +531,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -539,13 +539,13 @@
           }
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -558,7 +558,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -571,7 +571,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -581,7 +581,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -595,7 +595,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -608,7 +608,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -619,7 +619,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -630,7 +630,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -643,7 +643,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -651,7 +651,7 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
@@ -660,7 +660,7 @@
                 break;
               }
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -674,7 +674,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -682,13 +682,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -702,20 +702,20 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-            long
+            ssize_t
               compose;
 
             composite_options.compose=UndefinedCompositeOp;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
               argv[i]);
@@ -727,13 +727,13 @@
           }
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -750,13 +750,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -770,14 +770,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -796,7 +796,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -807,7 +807,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -819,7 +819,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -832,19 +832,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -858,7 +858,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -872,7 +872,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -882,13 +882,13 @@
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -901,7 +901,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -916,7 +916,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -925,19 +925,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
               argv[i]);
@@ -951,7 +951,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -963,13 +963,13 @@
       {
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -982,7 +982,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -991,7 +991,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             format=argv[i];
             break;
@@ -1006,7 +1006,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1015,14 +1015,14 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             composite_options.gravity=UndefinedGravity;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
               argv[i]);
@@ -1037,7 +1037,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1058,13 +1058,13 @@
           break;
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -1075,13 +1075,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -1099,7 +1099,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1111,13 +1111,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -1125,7 +1125,7 @@
               ThrowCompositeException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -1134,13 +1134,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -1156,7 +1156,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL))
+            if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1187,7 +1187,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1196,7 +1196,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1207,14 +1207,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1227,7 +1227,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1235,13 +1235,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -1261,7 +1261,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1276,7 +1276,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1292,7 +1292,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1301,7 +1301,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1316,7 +1316,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1327,7 +1327,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1338,7 +1338,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1347,7 +1347,7 @@
         if (LocaleCompare("sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1358,7 +1358,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1369,7 +1369,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1381,7 +1381,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1397,7 +1397,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1419,7 +1419,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1434,7 +1434,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1453,7 +1453,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1462,7 +1462,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1470,13 +1470,13 @@
           }
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -1490,13 +1490,13 @@
       {
         if (LocaleCompare("units",option+1) == 0)
           {
-            long
+            ssize_t
               units;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -1511,7 +1511,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1529,20 +1529,20 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -1561,7 +1561,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1574,7 +1574,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowCompositeInvalidArgumentException(option,argv[i]);
@@ -1583,7 +1583,7 @@
         if (LocaleCompare("write",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowCompositeException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1601,7 +1601,7 @@
   }
   if (k != 0)
     ThrowCompositeException(OptionError,"UnbalancedParenthesis",argv[i]);
-  if (i-- != (long) (argc-1))
+  if (i-- != (ssize_t) (argc-1))
     ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[i]);
   if ((image == (Image *) NULL) || (GetImageListLength(image) < 2))
     ThrowCompositeException(OptionError,"MissingAnImageFilename",argv[argc-1]);
diff --git a/wand/conjure.c b/wand/conjure.c
index 2bb19a2..df1c29a 100644
--- a/wand/conjure.c
+++ b/wand/conjure.c
@@ -112,7 +112,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
@@ -135,7 +135,7 @@
 #define DestroyConjure() \
 { \
   image=DestroyImageList(image); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -160,13 +160,13 @@
   Image
     *image;
 
-  long
+  ssize_t
     number_images;
 
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -191,7 +191,7 @@
   if (status == MagickFalse)
     ThrowConjureException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (IsMagickOption(option) != MagickFalse)
@@ -200,13 +200,13 @@
           break;
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConjureException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -220,7 +220,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConjureException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConjureInvalidArgumentException(option,argv[i]);
@@ -238,7 +238,7 @@
             if (*option == '-')
               {
                 i++;
-                if (i == (long) argc)
+                if (i == (ssize_t) argc)
                   ThrowConjureException(OptionError,"MissingLogFormat",option);
                 (void) SetLogFormat(argv[i]);
               }
@@ -255,7 +255,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConjureException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConjureInvalidArgumentException(option,argv[i]);
@@ -270,7 +270,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             return(MagickFalse);
@@ -307,7 +307,7 @@
     ThrowConjureException(OptionError,"MissingAnImageFilename",argv[argc-1]);
   if (image != (Image *) NULL)
     image=DestroyImageList(image);
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
     argv[i]=DestroyString(argv[i]);
   argv=(char **) RelinquishMagickMemory(argv);
   return(status != 0 ? MagickTrue : MagickFalse);
diff --git a/wand/convert.c b/wand/convert.c
index 28578d4..5b7101c 100644
--- a/wand/convert.c
+++ b/wand/convert.c
@@ -100,7 +100,7 @@
   int
     c;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -113,7 +113,7 @@
         argv[argc-1]);
       return(MagickFalse);
     }
-  for (i=2; i < (long) (argc-1); i++)
+  for (i=2; i < (ssize_t) (argc-1); i++)
   {
     input=OpenMagickStream(argv[i],"rb");
     if (input == (FILE *) NULL)
@@ -167,9 +167,9 @@
       "-charcoal radius     simulate a charcoal drawing",
       "-chop geometry       remove pixels from the image interior",
       "-clamp               restrict pixel range from 0 to the quantum depth",
-      "-clip                clip along the first path from the 8BIM profile",
+      "-clip                clip assize_t the first path from the 8BIM profile",
       "-clip-mask filename  associate a clip mask with the image",
-      "-clip-path id        clip along a named path from the 8BIM profile",
+      "-clip-path id        clip assize_t a named path from the 8BIM profile",
       "-colorize value      colorize the image with the fill color",
       "-color-matrix matrix apply color correction to the image",
       "-contrast            enhance or reduce the image contrast",
@@ -259,7 +259,7 @@
       "-shadow geometry     simulate an image shadow",
       "-sharpen geometry    sharpen the image",
       "-shave geometry      shave pixels from the image edges",
-      "-shear geometry      slide one edge of the image along the X or Y axis",
+      "-shear geometry      slide one edge of the image assize_t the X or Y axis",
       "-sigmoidal-contrast geometry",
       "                     increase the contrast without saturating highlights or shadows",
       "-sketch geometry     simulate a pencil sketch",
@@ -283,7 +283,7 @@
       "-unique-colors       discard all but one of any pixel color",
       "-unsharp geometry    sharpen the image",
       "-vignette geometry   soften the edges of the image in vignette style",
-      "-wave geometry       alter an image along a sine wave",
+      "-wave geometry       alter an image assize_t a sine wave",
       "-white-threshold value",
       "                     force all pixels above the threshold into white",
       (char *) NULL
@@ -416,7 +416,7 @@
   const char
     **p;
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] "
@@ -455,7 +455,7 @@
 #define DestroyConvert() \
 { \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -487,7 +487,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
@@ -498,7 +498,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -516,7 +516,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -542,7 +542,7 @@
       GetExceptionMessage(errno));
   if ((argc > 2) && (LocaleCompare("-concatenate",argv[1]) == 0))
     return(ConcatenateImages(argc,argv,exception));
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -594,7 +594,7 @@
         if (LocaleCompare("adaptive-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -603,7 +603,7 @@
         if (LocaleCompare("adaptive-resize",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -612,7 +612,7 @@
         if (LocaleCompare("adaptive-sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -625,7 +625,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -633,13 +633,13 @@
           }
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -652,12 +652,12 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -670,7 +670,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -681,7 +681,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -702,7 +702,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -711,7 +711,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -722,7 +722,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -735,7 +735,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -746,7 +746,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -757,7 +757,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -768,7 +768,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -779,7 +779,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -790,7 +790,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -799,14 +799,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("brightness-contrast",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -821,7 +821,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -832,7 +832,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -841,19 +841,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -866,7 +866,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -877,7 +877,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -892,14 +892,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("clip-path",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -919,7 +919,7 @@
             else
               {
                 i++;
-                if (i == (long) (argc-1))
+                if (i == (ssize_t) (argc-1))
                   ThrowConvertException(OptionError,"MissingArgument",option);
                 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
                   ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -939,7 +939,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -950,7 +950,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -961,20 +961,20 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) (argc-1)) ||
+            if ((i == (ssize_t) (argc-1)) ||
                 (IsGeometry(argv[i]) == MagickFalse))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -990,19 +990,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-            long
+            ssize_t
               compose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             compose=ParseMagickOption(MagickComposeOptions,MagickFalse,
               argv[i]);
@@ -1015,13 +1015,13 @@
           break;
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -1037,7 +1037,7 @@
         if (LocaleCompare("contrast-stretch",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1051,7 +1051,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
 #if 1
             (void) token;
@@ -1064,7 +1064,7 @@
             GetMagickToken(argv[i],NULL,token);
             if (isalpha((int) (unsigned char) *token) != 0)
               {
-                long
+                ssize_t
                 op;
 
                 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
@@ -1083,7 +1083,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1094,7 +1094,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1109,7 +1109,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1117,13 +1117,13 @@
           break;
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -1135,7 +1135,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -1154,7 +1154,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1165,7 +1165,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1176,7 +1176,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1187,7 +1187,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1198,7 +1198,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1208,13 +1208,13 @@
           break;
         if (LocaleCompare("direction",option+1) == 0)
           {
-            long
+            ssize_t
               direction;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
               argv[i]);
@@ -1228,19 +1228,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -1250,30 +1250,30 @@
           }
         if (LocaleCompare("distort",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowConvertException(OptionError,"UnrecognizedDistortMethod",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -1286,7 +1286,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1295,7 +1295,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1310,7 +1310,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1321,7 +1321,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1332,7 +1332,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1341,19 +1341,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
               argv[i]);
@@ -1368,20 +1368,20 @@
           break;
         if (LocaleCompare("evaluate",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowConvertException(OptionError,"UnrecognizedEvaluateOperator",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1389,13 +1389,13 @@
           }
         if (LocaleCompare("evaluate-sequence",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
             if (op < 0)
@@ -1408,7 +1408,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1419,7 +1419,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1434,7 +1434,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1445,19 +1445,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -1476,12 +1476,12 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1490,7 +1490,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1499,7 +1499,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             format=argv[i];
             break;
@@ -1509,7 +1509,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1517,19 +1517,19 @@
           }
         if (LocaleCompare("function",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowConvertException(OptionError,"UnrecognizedFunction",argv[i]);
              i++;
-             if (i == (long) (argc-1))
+             if (i == (ssize_t) (argc-1))
                ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1538,7 +1538,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1549,7 +1549,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1560,7 +1560,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1570,7 +1570,7 @@
             (LocaleCompare("gaussian",option+1) == 0))
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1581,7 +1581,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1589,13 +1589,13 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
               argv[i]);
@@ -1609,7 +1609,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1637,7 +1637,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1648,7 +1648,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1656,13 +1656,13 @@
           }
         if (LocaleCompare("intent",option+1) == 0)
           {
-            long
+            ssize_t
               intent;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
               argv[i]);
@@ -1673,13 +1673,13 @@
           }
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -1693,7 +1693,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1701,13 +1701,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -1721,7 +1721,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1736,7 +1736,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1751,7 +1751,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1760,7 +1760,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1768,13 +1768,13 @@
           }
         if (LocaleCompare("layers",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -1785,7 +1785,7 @@
         if (LocaleCompare("level",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1794,7 +1794,7 @@
         if (LocaleCompare("level-colors",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1803,7 +1803,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1812,7 +1812,7 @@
         if (LocaleCompare("liquid-rescale",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1826,13 +1826,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -1840,7 +1840,7 @@
               ThrowConvertException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -1850,7 +1850,7 @@
         if (LocaleCompare("linear-stretch",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1858,13 +1858,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -1879,7 +1879,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
@@ -1889,7 +1889,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1904,7 +1904,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1913,7 +1913,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1924,7 +1924,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1935,7 +1935,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1948,7 +1948,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1963,7 +1963,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -1974,11 +1974,11 @@
             char
               token[MaxTextExtent];
 
-            long
+            ssize_t
               op;
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             GetMagickToken(argv[i],NULL,token);
             op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
@@ -1986,7 +1986,7 @@
               ThrowConvertException(OptionError,"UnrecognizedMorphologyMethod",
                 token);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             GetMagickToken(argv[i],NULL,token);
             if (isalpha((int) ((unsigned char) *token)) != 0)
@@ -2012,7 +2012,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2027,11 +2027,11 @@
         if (LocaleCompare("noise",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
-                long
+                ssize_t
                   noise;
 
                 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
@@ -2055,7 +2055,7 @@
         if (LocaleCompare("opaque",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2064,19 +2064,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("orient",option+1) == 0)
           {
-            long
+            ssize_t
               orientation;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             orientation=ParseMagickOption(MagickOrientationOptions,
               MagickFalse,argv[i]);
@@ -2094,7 +2094,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2103,7 +2103,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2116,7 +2116,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2127,7 +2127,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2138,7 +2138,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2149,7 +2149,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2157,13 +2157,13 @@
           }
         if (LocaleCompare("preview",option+1) == 0)
           {
-            long
+            ssize_t
               preview;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             preview=ParseMagickOption(MagickPreviewOptions,MagickFalse,
               argv[i]);
@@ -2177,7 +2177,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2186,14 +2186,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2206,7 +2206,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2214,13 +2214,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -2238,7 +2238,7 @@
         if (LocaleCompare("radial-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2247,7 +2247,7 @@
         if (LocaleCompare("raise",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2258,7 +2258,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2269,7 +2269,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2280,7 +2280,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2293,7 +2293,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2304,7 +2304,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2315,7 +2315,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2326,7 +2326,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2337,7 +2337,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2355,7 +2355,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2364,7 +2364,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2379,7 +2379,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2390,7 +2390,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2401,7 +2401,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2412,7 +2412,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2423,7 +2423,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2434,7 +2434,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2443,7 +2443,7 @@
         if (LocaleCompare("selective-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2456,7 +2456,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2465,19 +2465,19 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("shade",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2488,7 +2488,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2497,7 +2497,7 @@
         if (LocaleCompare("sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2508,7 +2508,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2517,7 +2517,7 @@
         if (LocaleCompare("shear",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2526,7 +2526,7 @@
         if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2537,7 +2537,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2548,7 +2548,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2559,7 +2559,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2567,18 +2567,18 @@
           }
         if (LocaleCompare("sparse-color",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowConvertException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowConvertException(OptionError,"UnrecognizedSparseColorMethod",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2587,7 +2587,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2598,20 +2598,20 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) (argc-1)) ||
+            if ((i == (ssize_t) (argc-1)) ||
                 (IsGeometry(argv[i]) == MagickFalse))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("stretch",option+1) == 0)
           {
-            long
+            ssize_t
               stretch;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,
               argv[i]);
@@ -2627,7 +2627,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2636,7 +2636,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2644,13 +2644,13 @@
           }
         if (LocaleCompare("style",option+1) == 0)
           {
-            long
+            ssize_t
               style;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
             if (style < 0)
@@ -2668,7 +2668,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2679,7 +2679,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2696,7 +2696,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2705,7 +2705,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2716,7 +2716,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2727,7 +2727,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2736,7 +2736,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2747,7 +2747,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2758,7 +2758,7 @@
         if (LocaleCompare("transparent",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2767,7 +2767,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2780,7 +2780,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2790,13 +2790,13 @@
           break;
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -2813,7 +2813,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2821,13 +2821,13 @@
           break;
         if (LocaleCompare("units",option+1) == 0)
           {
-            long
+            ssize_t
               units;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -2841,7 +2841,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2857,7 +2857,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
@@ -2867,7 +2867,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2876,7 +2876,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2884,13 +2884,13 @@
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -2906,7 +2906,7 @@
         if (LocaleCompare("wave",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2917,7 +2917,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2926,7 +2926,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2937,7 +2937,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowConvertInvalidArgumentException(option,argv[i]);
@@ -2946,7 +2946,7 @@
         if (LocaleCompare("write",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowConvertException(OptionError,"MissingArgument",option);
             break;
           }
@@ -2964,7 +2964,7 @@
   }
   if (k != 0)
     ThrowConvertException(OptionError,"UnbalancedParenthesis",argv[i]);
-  if (i-- != (long) (argc-1))
+  if (i-- != (ssize_t) (argc-1))
     ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
   if (image == (Image *) NULL)
     ThrowConvertException(OptionError,"MissingAnImageFilename",argv[argc-1]);
diff --git a/wand/deprecate.c b/wand/deprecate.c
index 9c28881..269ad5b 100644
--- a/wand/deprecate.c
+++ b/wand/deprecate.c
@@ -139,7 +139,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  MagickClipPathImage() clips along the named paths from the 8BIM profile, if
+%  MagickClipPathImage() clips assize_t the named paths from the 8BIM profile, if
 %  present. Later operations take effect inside the path.  Id may be a number
 %  if preceded with #, to work on a numbered path, e.g., "#1" to use the first
 %  path.
@@ -385,7 +385,7 @@
 %
 %      MagickBooleanType MagickColorFloodfillImage(MagickWand *wand,
 %        const PixelWand *fill,const double fuzz,const PixelWand *bordercolor,
-%        const long x,const long y)
+%        const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -407,7 +407,7 @@
 */
 WandExport MagickBooleanType MagickColorFloodfillImage(MagickWand *wand,
   const PixelWand *fill,const double fuzz,const PixelWand *bordercolor,
-  const long x,const long y)
+  const ssize_t x,const ssize_t y)
 {
   DrawInfo
     *draw_info;
@@ -553,14 +553,14 @@
 %
 %  The format of the MagickGetImageIndex method is:
 %
-%      long MagickGetImageIndex(MagickWand *wand)
+%      ssize_t MagickGetImageIndex(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport long MagickGetImageIndex(MagickWand *wand)
+WandExport ssize_t MagickGetImageIndex(MagickWand *wand)
 {
   return(MagickGetIteratorIndex(wand));
 }
@@ -582,7 +582,7 @@
 %  The format of the MagickGetImageChannelExtrema method is:
 %
 %      MagickBooleanType MagickGetImageChannelExtrema(MagickWand *wand,
-%        const ChannelType channel,unsigned long *minima,unsigned long *maxima)
+%        const ChannelType channel,size_t *minima,size_t *maxima)
 %
 %  A description of each parameter follows:
 %
@@ -596,7 +596,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetImageChannelExtrema(MagickWand *wand,
-  const ChannelType channel,unsigned long *minima,unsigned long *maxima)
+  const ChannelType channel,size_t *minima,size_t *maxima)
 {
   MagickBooleanType
     status;
@@ -628,7 +628,7 @@
 %  The format of the MagickGetImageExtrema method is:
 %
 %      MagickBooleanType MagickGetImageExtrema(MagickWand *wand,
-%        unsigned long *minima,unsigned long *maxima)
+%        size_t *minima,size_t *maxima)
 %
 %  A description of each parameter follows:
 %
@@ -640,7 +640,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetImageExtrema(MagickWand *wand,
-  unsigned long *minima,unsigned long *maxima)
+  size_t *minima,size_t *maxima)
 {
   MagickBooleanType
     status;
@@ -671,7 +671,7 @@
 %
 %  The format of the MagickGetImageMatte method is:
 %
-%      unsigned long MagickGetImageMatte(MagickWand *wand)
+%      size_t MagickGetImageMatte(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
@@ -702,7 +702,7 @@
 %
 %  MagickGetImagePixels() extracts pixel data from an image and returns it to
 %  you.  The method returns MagickTrue on success otherwise MagickFalse if an
-%  error is encountered.  The data is returned as char, short int, int, long,
+%  error is encountered.  The data is returned as char, short int, int, ssize_t,
 %  float, or double in the order specified by map.
 %
 %  Suppose you want to extract the first scanline of a 640x480 image as
@@ -713,8 +713,8 @@
 %  The format of the MagickGetImagePixels method is:
 %
 %      MagickBooleanType MagickGetImagePixels(MagickWand *wand,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType storage,
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,const char *map,const StorageType storage,
 %        void *pixels)
 %
 %  A description of each parameter follows:
@@ -741,8 +741,8 @@
 %
 */
 WandExport MagickBooleanType MagickGetImagePixels(MagickWand *wand,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType storage,
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,const char *map,const StorageType storage,
   void *pixels)
 {
   return(MagickExportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
@@ -851,7 +851,7 @@
 %
 %      MagickBooleanType MagickMatteFloodfillImage(MagickWand *wand,
 %        const double alpha,const double fuzz,const PixelWand *bordercolor,
-%        const long x,const long y)
+%        const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -874,7 +874,7 @@
 */
 WandExport MagickBooleanType MagickMatteFloodfillImage(MagickWand *wand,
   const double alpha,const double fuzz,const PixelWand *bordercolor,
-  const long x,const long y)
+  const ssize_t x,const ssize_t y)
 {
   DrawInfo
     *draw_info;
@@ -1090,7 +1090,7 @@
 %
 %      MagickBooleanType MagickPaintFloodfillImage(MagickWand *wand,
 %        const ChannelType channel,const PixelWand *fill,const double fuzz,
-%        const PixelWand *bordercolor,const long x,const long y)
+%        const PixelWand *bordercolor,const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -1114,7 +1114,7 @@
 */
 WandExport MagickBooleanType MagickPaintFloodfillImage(MagickWand *wand,
   const ChannelType channel,const PixelWand *fill,const double fuzz,
-  const PixelWand *bordercolor,const long x,const long y)
+  const PixelWand *bordercolor,const ssize_t x,const ssize_t y)
 {
   MagickBooleanType
     status;
@@ -1248,7 +1248,7 @@
 %  The format of the MagickRecolorImage method is:
 %
 %      MagickBooleanType MagickRecolorImage(MagickWand *wand,
-%        const unsigned long order,const double *color_matrix)
+%        const size_t order,const double *color_matrix)
 %
 %  A description of each parameter follows:
 %
@@ -1260,7 +1260,7 @@
 %
 */
 WandExport MagickBooleanType MagickRecolorImage(MagickWand *wand,
-  const unsigned long order,const double *color_matrix)
+  const size_t order,const double *color_matrix)
 {
   Image
     *transform_image;
@@ -1330,7 +1330,7 @@
 %
 %  The format of the MagickSetImageIndex method is:
 %
-%      MagickBooleanType MagickSetImageIndex(MagickWand *wand,const long index)
+%      MagickBooleanType MagickSetImageIndex(MagickWand *wand,const ssize_t index)
 %
 %  A description of each parameter follows:
 %
@@ -1340,7 +1340,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageIndex(MagickWand *wand,
-  const long index)
+  const ssize_t index)
 {
   return(MagickSetIteratorIndex(wand,index));
 }
@@ -1449,8 +1449,8 @@
 %  The format of the MagickRegionOfInterestImage method is:
 %
 %      MagickWand *MagickRegionOfInterestImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -1466,8 +1466,8 @@
 %
 */
 WandExport MagickWand *MagickRegionOfInterestImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   return(MagickGetImageRegion(wand,width,height,x,y));
 }
@@ -1486,7 +1486,7 @@
 %  MagickSetImagePixels() accepts pixel datand stores it in the image at the
 %  location you specify.  The method returns MagickFalse on success otherwise
 %  MagickTrue if an error is encountered.  The pixel data can be either char,
-%  short int, int, long, float, or double in the order specified by map.
+%  short int, int, ssize_t, float, or double in the order specified by map.
 %
 %  Suppose your want to upload the first scanline of a 640x480 image from
 %  character data in red-green-blue order:
@@ -1496,8 +1496,8 @@
 %  The format of the MagickSetImagePixels method is:
 %
 %      MagickBooleanType MagickSetImagePixels(MagickWand *wand,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType storage,
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,const char *map,const StorageType storage,
 %        const void *pixels)
 %
 %  A description of each parameter follows:
@@ -1524,8 +1524,8 @@
 %
 */
 WandExport MagickBooleanType MagickSetImagePixels(MagickWand *wand,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType storage,
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,const char *map,const StorageType storage,
   const void *pixels)
 {
   return(MagickImportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
@@ -1581,7 +1581,7 @@
 %  The format of the PixelGetNextRow method is:
 %
 %      PixelWand **PixelGetNextRow(PixelIterator *iterator,
-%        unsigned long *number_wands)
+%        size_t *number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -1592,7 +1592,7 @@
 */
 WandExport PixelWand **PixelGetNextRow(PixelIterator *iterator)
 {
-  unsigned long
+  size_t
     number_wands;
 
   return(PixelGetNextIteratorRow(iterator,&number_wands));
diff --git a/wand/deprecate.h b/wand/deprecate.h
index 8ad710b..1541460 100644
--- a/wand/deprecate.h
+++ b/wand/deprecate.h
@@ -46,30 +46,30 @@
   *PixelIteratorGetException(const PixelIterator *,ExceptionType *)
     magick_attribute((deprecated));
 
-extern WandExport long
+extern WandExport ssize_t
   MagickGetImageIndex(MagickWand *) magick_attribute((deprecated));
 
 extern WandExport MagickBooleanType
   MagickClipPathImage(MagickWand *,const char *,const MagickBooleanType)
     magick_attribute((deprecated)),
   MagickColorFloodfillImage(MagickWand *,const PixelWand *,const double,
-    const PixelWand *,const long,const long) magick_attribute((deprecated)),
-  MagickGetImageChannelExtrema(MagickWand *,const ChannelType,unsigned long *,
-    unsigned long *) magick_attribute((deprecated)),
-  MagickGetImageExtrema(MagickWand *,unsigned long *,unsigned long *)
+    const PixelWand *,const ssize_t,const ssize_t) magick_attribute((deprecated)),
+  MagickGetImageChannelExtrema(MagickWand *,const ChannelType,size_t *,
+    size_t *) magick_attribute((deprecated)),
+  MagickGetImageExtrema(MagickWand *,size_t *,size_t *)
     magick_attribute((deprecated)),
   MagickGetImageMatte(MagickWand *) magick_attribute((deprecated)),
-  MagickGetImagePixels(MagickWand *,const long,const long,const unsigned long,
-    const unsigned long,const char *,const StorageType,void *)
+  MagickGetImagePixels(MagickWand *,const ssize_t,const ssize_t,const size_t,
+    const size_t,const char *,const StorageType,void *)
     magick_attribute((deprecated)),
   MagickMapImage(MagickWand *,const MagickWand *,const MagickBooleanType)
     magick_attribute((deprecated)),
   MagickMatteFloodfillImage(MagickWand *,const double,const double,
-    const PixelWand *,const long,const long) magick_attribute((deprecated)),
+    const PixelWand *,const ssize_t,const ssize_t) magick_attribute((deprecated)),
   MagickOpaqueImage(MagickWand *,const PixelWand *,const PixelWand *,
     const double) magick_attribute((deprecated)),
   MagickPaintFloodfillImage(MagickWand *,const ChannelType,const PixelWand *,
-    const double,const PixelWand *,const long,const long)
+    const double,const PixelWand *,const ssize_t,const ssize_t)
     magick_attribute((deprecated)),
   MagickPaintOpaqueImage(MagickWand *,const PixelWand *,const PixelWand *,
     const double) magick_attribute((deprecated)),
@@ -78,15 +78,15 @@
     magick_attribute((deprecated)),
   MagickPaintTransparentImage(MagickWand *,const PixelWand *,const double,
     const double) magick_attribute((deprecated)),
-  MagickRecolorImage(MagickWand *,const unsigned long,const double *)
+  MagickRecolorImage(MagickWand *,const size_t,const double *)
     magick_attribute((deprecated)),
   MagickSetImageAttribute(MagickWand *,const char *,const char *)
     magick_attribute((deprecated)),
-  MagickSetImageIndex(MagickWand *,const long) magick_attribute((deprecated)),
+  MagickSetImageIndex(MagickWand *,const ssize_t) magick_attribute((deprecated)),
   MagickSetImageOption(MagickWand *,const char *,const char *,const char *)
     magick_attribute((deprecated)),
-  MagickSetImagePixels(MagickWand *,const long,const long,const unsigned long,
-    const unsigned long,const char *,const StorageType,const void *)
+  MagickSetImagePixels(MagickWand *,const ssize_t,const ssize_t,const size_t,
+    const size_t,const char *,const StorageType,const void *)
     magick_attribute((deprecated)),
   MagickTransparentImage(MagickWand *,const PixelWand *,const double,
     const double) magick_attribute((deprecated));
@@ -97,8 +97,8 @@
   *MagickMaximumImages(MagickWand *),
   *MagickMinimumImages(MagickWand *),
   *MagickMosaicImages(MagickWand *) magick_attribute((deprecated)),
-  *MagickRegionOfInterestImage(MagickWand *,const unsigned long,
-    const unsigned long,const long,const long) magick_attribute((deprecated));
+  *MagickRegionOfInterestImage(MagickWand *,const size_t,
+    const size_t,const ssize_t,const ssize_t) magick_attribute((deprecated));
 
 extern WandExport MagickSizeType
   MagickGetImageSize(MagickWand *) magick_attribute((deprecated));
diff --git a/wand/display.c b/wand/display.c
index d43ba03..cf87de1 100644
--- a/wand/display.c
+++ b/wand/display.c
@@ -117,8 +117,8 @@
     {
       "-auto-orient         automagically orient image",
       "-border geometry     surround image with a border of color",
-      "-clip                clip along the first path from the 8BIM profile",
-      "-clip-path id        clip along a named path from the 8BIM profile",
+      "-clip                clip assize_t the first path from the 8BIM profile",
+      "-clip-path id        clip assize_t a named path from the 8BIM profile",
       "-colors value        preferred number of colors in the image",
       "-contrast            enhance or reduce the image contrast",
       "-crop geometry       preferred size and location of the cropped image",
@@ -221,7 +221,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
@@ -275,9 +275,9 @@
     } \
   XDestroyResourceInfo(&resource_info); \
   DestroyImageStack(); \
-  if (image_marker != (unsigned long *) NULL) \
-    image_marker=(unsigned long *) RelinquishMagickMemory(image_marker); \
-  for (i=0; i < (long) argc; i++) \
+  if (image_marker != (size_t *) NULL) \
+    image_marker=(size_t *) RelinquishMagickMemory(image_marker); \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -312,7 +312,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     image_number,
     iteration,
     j,
@@ -329,10 +329,10 @@
   QuantizeInfo
     *quantize_info;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     *image_marker,
     iterations,
     last_image,
@@ -359,7 +359,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -369,7 +369,7 @@
   display=(Display *) NULL;
   j=1;
   k=0;
-  image_marker=(unsigned long *) NULL;
+  image_marker=(size_t *) NULL;
   image_number=0;
   last_image=0;
   NewImageStack();
@@ -385,17 +385,17 @@
   if (status == MagickFalse)
     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  image_marker=(unsigned long *) AcquireQuantumMemory((size_t) argc+1UL,
+  image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL,
     sizeof(*image_marker));
-  if (image_marker == (unsigned long *) NULL)
+  if (image_marker == (size_t *) NULL)
     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
   for (i=0; i <= argc; i++)
-    image_marker[i]=(unsigned long) argc;
+    image_marker[i]=(size_t) argc;
   /*
     Check for server name specified on the command line.
   */
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     /*
       Check command line for server name.
@@ -407,7 +407,7 @@
           User specified server name.
         */
         i++;
-        if (i == (long) argc)
+        if (i == (ssize_t) argc)
           ThrowDisplayException(OptionError,"MissingArgument",option);
         server_name=argv[i];
       }
@@ -450,9 +450,9 @@
     Parse command line.
   */
   iteration=0;
-  for (i=1; ((i <= (long) argc) && ((state & ExitState) == 0)); i++)
+  for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++)
   {
-    if (i < (long) argc)
+    if (i < (ssize_t) argc)
       option=argv[i];
     else
       if (image != (Image *) NULL)
@@ -620,8 +620,8 @@
         RemoveAllImageStack();
         if ((state & FormerImageState) == 0)
           {
-            last_image=(unsigned long) image_number;
-            image_marker[i]=(unsigned long) image_number++;
+            last_image=(size_t) image_number;
+            image_marker[i]=(size_t) image_number++;
           }
         else
           {
@@ -629,11 +629,11 @@
               Proceed to previous image.
             */
             for (i--; i > 0; i--)
-              if (image_marker[i] == (unsigned long) (image_number-2))
+              if (image_marker[i] == (size_t) (image_number-2))
                 break;
             image_number--;
           }
-        if ((i == (long) (argc-1)) && ((state & ExitState) == 0))
+        if ((i == (ssize_t) (argc-1)) && ((state & ExitState) == 0))
           i=0;
         if ((state & ExitState) != 0)
           break;
@@ -648,13 +648,13 @@
                 for (i=1; i < (argc-2); i++)
                   if (last_image == image_marker[i])
                     break;
-                image_number=(long) image_marker[i]+1;
+                image_number=(ssize_t) image_marker[i]+1;
               }
             continue;
           }
         if (resource_info.window_id != (char *) NULL)
           state|=ExitState;
-        if ((iterations != 0) && (++iteration == (long) iterations))
+        if ((iterations != 0) && (++iteration == (ssize_t) iterations))
           state|=ExitState;
         if (LocaleCompare(filename,"-") == 0)
           state|=ExitState;
@@ -667,13 +667,13 @@
       {
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -688,7 +688,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -708,7 +708,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.background_color=argv[i];
             break;
@@ -718,7 +718,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -729,7 +729,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.border_color=argv[i];
             break;
@@ -740,7 +740,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -756,7 +756,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -764,13 +764,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -783,7 +783,7 @@
         if (LocaleCompare("clip-path",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -795,7 +795,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.colormap=UndefinedColormap;
             if (LocaleCompare("private",argv[i]) == 0)
@@ -813,7 +813,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -822,13 +822,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -842,19 +842,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -872,7 +872,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -884,13 +884,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -904,14 +904,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -930,7 +930,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -941,7 +941,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -952,7 +952,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -963,7 +963,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -976,19 +976,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -998,14 +998,14 @@
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             quantize_info->dither=MagickFalse;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -1020,7 +1020,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1035,7 +1035,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1043,13 +1043,13 @@
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
               argv[i]);
@@ -1067,7 +1067,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1079,13 +1079,13 @@
       {
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -1104,7 +1104,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.font=XGetResourceClass(resource_database,
               GetClientName(),"font",argv[i]);
@@ -1115,7 +1115,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.foreground_color=argv[i];
             break;
@@ -1125,7 +1125,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1134,7 +1134,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1145,7 +1145,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1158,7 +1158,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1171,7 +1171,7 @@
               break;
             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1180,13 +1180,13 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
               argv[i]);
@@ -1214,7 +1214,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1233,13 +1233,13 @@
           }
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -1250,13 +1250,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -1274,7 +1274,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1286,13 +1286,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -1300,7 +1300,7 @@
               ThrowDisplayException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -1309,13 +1309,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -1330,7 +1330,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
@@ -1340,7 +1340,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1357,7 +1357,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1371,7 +1371,7 @@
               break;
             (void) strcpy(argv[i]+1,"san");
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.map_type=argv[i];
             break;
@@ -1383,7 +1383,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.matte_color=argv[i];
             break;
@@ -1408,7 +1408,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.name=ConstantString(argv[i]);
             break;
@@ -1429,7 +1429,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.image_geometry=ConstantString(argv[i]);
             break;
@@ -1437,7 +1437,7 @@
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1450,7 +1450,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1458,13 +1458,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -1482,7 +1482,7 @@
         if (LocaleCompare("raise",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1493,7 +1493,7 @@
         if (LocaleCompare("remote",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
               return(MagickFalse);
@@ -1505,7 +1505,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1516,7 +1516,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1527,7 +1527,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1543,7 +1543,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1552,7 +1552,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1567,7 +1567,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1578,7 +1578,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1589,7 +1589,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1600,7 +1600,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1611,7 +1611,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1620,12 +1620,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1634,7 +1634,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1651,7 +1651,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1674,7 +1674,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.text_font=XGetResourceClass(resource_database,
               GetClientName(),"font",argv[i]);
@@ -1685,7 +1685,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1694,7 +1694,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1705,7 +1705,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1717,7 +1717,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.title=argv[i];
             break;
@@ -1727,7 +1727,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1737,7 +1737,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1756,7 +1756,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1779,7 +1779,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
@@ -1790,20 +1790,20 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.visual_type=argv[i];
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowDisplayException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -1822,7 +1822,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.window_id=argv[i];
             break;
@@ -1833,7 +1833,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             if (strtod(argv[i],(char **) NULL) != 0)
               resource_info.window_group=argv[i];
@@ -1845,7 +1845,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
             resource_info.write_filename=argv[i];
             if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
diff --git a/wand/drawing-wand.c b/wand/drawing-wand.c
index 020e8f7..e1eeb20 100644
--- a/wand/drawing-wand.c
+++ b/wand/drawing-wand.c
@@ -89,7 +89,7 @@
 
 struct _DrawingWand
 {
-  unsigned long
+  size_t
     id;
 
   char
@@ -110,7 +110,7 @@
     mvg_alloc,          /* total allocated memory */
     mvg_length;         /* total MVG length */
 
-  unsigned long
+  size_t
     mvg_width;          /* current line width */
 
   /* Pattern support */
@@ -124,7 +124,7 @@
     pattern_offset;
 
   /* Graphic wand */
-  unsigned long
+  size_t
     index;              /* array index */
 
   DrawInfo
@@ -134,7 +134,7 @@
     filter_off;         /* true if not filtering attributes */
 
   /* Pretty-printing depth */
-  unsigned long
+  size_t
     indent_depth;       /* number of left-hand pad characters */
 
   /* Path operation support */
@@ -148,7 +148,7 @@
     destroy,
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -160,7 +160,7 @@
     const unsigned char *);
   void (*DrawArc)(DrawingWand *,const double,const double,const double,
     const double,const double,const double);
-  void (*DrawBezier)(DrawingWand *,const unsigned long,const PointInfo *);
+  void (*DrawBezier)(DrawingWand *,const size_t,const PointInfo *);
   void (*DrawCircle)(DrawingWand *,const double,const double,const double,
     const double);
   void (*DrawColor)(DrawingWand *,const double,const double,const PaintMethod);
@@ -206,8 +206,8 @@
   void (*DrawPathMoveToRelative)(DrawingWand *,const double,const double);
   void (*DrawPathStart)(DrawingWand *);
   void (*DrawPoint)(DrawingWand *,const double,const double);
-  void (*DrawPolygon)(DrawingWand *,const unsigned long,const PointInfo *);
-  void (*DrawPolyline)(DrawingWand *,const unsigned long,const PointInfo *);
+  void (*DrawPolygon)(DrawingWand *,const size_t,const PointInfo *);
+  void (*DrawPolyline)(DrawingWand *,const size_t,const PointInfo *);
   void (*DrawPopClipPath)(DrawingWand *);
   void (*DrawPopDefs)(DrawingWand *);
   MagickBooleanType (*DrawPopPattern)(DrawingWand *);
@@ -236,7 +236,7 @@
   void (*DrawSetFontSize)(DrawingWand *,const double);
   void (*DrawSetFontStretch)(DrawingWand *,const StretchType);
   void (*DrawSetFontStyle)(DrawingWand *,const StyleType);
-  void (*DrawSetFontWeight)(DrawingWand *,const unsigned long);
+  void (*DrawSetFontWeight)(DrawingWand *,const size_t);
   void (*DrawSetGravity)(DrawingWand *,const GravityType);
   void (*DrawRotate)(DrawingWand *,const double);
   void (*DrawScale)(DrawingWand *,const double,const double);
@@ -248,15 +248,15 @@
   void (*DrawSetStrokeDashOffset)(DrawingWand *,const double);
   void (*DrawSetStrokeLineCap)(DrawingWand *,const LineCap);
   void (*DrawSetStrokeLineJoin)(DrawingWand *,const LineJoin);
-  void (*DrawSetStrokeMiterLimit)(DrawingWand *,const unsigned long);
+  void (*DrawSetStrokeMiterLimit)(DrawingWand *,const size_t);
   MagickBooleanType (*DrawSetStrokePatternURL)(DrawingWand *,const char *);
   void (*DrawSetStrokeWidth)(DrawingWand *,const double);
   void (*DrawSetTextAntialias)(DrawingWand *,const MagickBooleanType);
   void (*DrawSetTextDecoration)(DrawingWand *,const DecorationType);
   void (*DrawSetTextUnderColor)(DrawingWand *,const PixelWand *);
   void (*DrawTranslate)(DrawingWand *,const double,const double);
-  void (*DrawSetViewbox)(DrawingWand *,unsigned long,unsigned long,
-    unsigned long,unsigned long);
+  void (*DrawSetViewbox)(DrawingWand *,size_t,size_t,
+    size_t,size_t);
   void (*PeekDrawingWand)(DrawingWand *);
   MagickBooleanType (*PopDrawingWand)(DrawingWand *);
   MagickBooleanType (*PushDrawingWand)(DrawingWand *);
@@ -411,12 +411,12 @@
 }
 
 static void MvgAppendPointsCommand(DrawingWand *wand,const char *command,
-  const unsigned long number_coordinates,const PointInfo *coordinates)
+  const size_t number_coordinates,const PointInfo *coordinates)
 {
   const PointInfo
     *coordinate;
 
-  unsigned long
+  size_t
     i;
 
   (void) MvgPrintf(wand,"%s",command);
@@ -549,7 +549,7 @@
   DrawingWand
     *clone_wand;
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (DrawingWand *) NULL);
@@ -579,7 +579,7 @@
   if (clone_wand->graphic_context == (DrawInfo **) NULL)
     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=0; i <= (long) wand->index; i++)
+  for (i=0; i <= (ssize_t) wand->index; i++)
     clone_wand->graphic_context[i]=
       CloneDrawInfo((ImageInfo *) NULL,wand->graphic_context[i]);
   clone_wand->filter_off=wand->filter_off;
@@ -837,7 +837,7 @@
 %  The format of the DrawBezier method is:
 %
 %      void DrawBezier(DrawingWand *wand,
-%        const unsigned long number_coordinates,const PointInfo *coordinates)
+%        const size_t number_coordinates,const PointInfo *coordinates)
 %
 %  A description of each parameter follows:
 %
@@ -849,7 +849,7 @@
 %
 */
 WandExport void DrawBezier(DrawingWand *wand,
-  const unsigned long number_coordinates,const PointInfo *coordinates)
+  const size_t number_coordinates,const PointInfo *coordinates)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -995,7 +995,7 @@
   register char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1039,12 +1039,12 @@
         wand->name);
       return(MagickFalse);
     }
-  mode=MagickOptionToMnemonic(MagickComposeOptions,(long) compose);
+  mode=MagickOptionToMnemonic(MagickComposeOptions,(ssize_t) compose);
   media_type=MagickToMime(image->magick);
   (void) MvgPrintf(wand,"image %s %g,%g %g,%g 'data:%s;base64,\n",
     mode,x,y,width,height,media_type);
   p=base64;
-  for (i=(long) encoded_length; i > 0; i-=76)
+  for (i=(ssize_t) encoded_length; i > 0; i-=76)
   {
     (void) MvgPrintf(wand,"%.76s",p);
     p+=76;
@@ -1101,7 +1101,7 @@
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   (void) MvgPrintf(wand,"color %g,%g '%s'\n",x,y,MagickOptionToMnemonic(
-    MagickMethodOptions,(long) paint_method));
+    MagickMethodOptions,(ssize_t) paint_method));
 }
 
 /*
@@ -1228,7 +1228,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DrawGetClipPath() obtains the current clipping path ID. The value returned
-%  must be deallocated by the user when it is no longer needed.
+%  must be deallocated by the user when it is no ssize_ter needed.
 %
 %  The format of the DrawGetClipPath method is:
 %
@@ -1519,7 +1519,7 @@
 %
 %  DrawGetFont() returns a null-terminaged string specifying the font used
 %  when annotating with text. The value returned must be freed by the user
-%  when no longer needed.
+%  when no ssize_ter needed.
 %
 %  The format of the DrawGetFont method is:
 %
@@ -1553,7 +1553,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DrawGetFontFamily() returns the font family to use when annotating with text.
-%  The value returned must be freed by the user when it is no longer needed.
+%  The value returned must be freed by the user when it is no ssize_ter needed.
 %
 %  The format of the DrawGetFontFamily method is:
 %
@@ -1683,14 +1683,14 @@
 %
 %  The format of the DrawGetFontWeight method is:
 %
-%      unsigned long DrawGetFontWeight(const DrawingWand *wand)
+%      size_t DrawGetFontWeight(const DrawingWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the drawing wand.
 %
 */
-WandExport unsigned long DrawGetFontWeight(const DrawingWand *wand)
+WandExport size_t DrawGetFontWeight(const DrawingWand *wand)
 {
   assert(wand != (const DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -1850,12 +1850,12 @@
 %
 %  DrawGetStrokeDashArray() returns an array representing the pattern of
 %  dashes and gaps used to stroke paths (see DrawSetStrokeDashArray). The
-%  array must be freed once it is no longer required by the user.
+%  array must be freed once it is no ssize_ter required by the user.
 %
 %  The format of the DrawGetStrokeDashArray method is:
 %
 %      double *DrawGetStrokeDashArray(const DrawingWand *wand,
-%        unsigned long *number_elements)
+%        size_t *number_elements)
 %
 %  A description of each parameter follows:
 %
@@ -1865,7 +1865,7 @@
 %
 */
 WandExport double *DrawGetStrokeDashArray(const DrawingWand *wand,
-  unsigned long *number_elements)
+  size_t *number_elements)
 {
   double
     *dash_array;
@@ -1876,17 +1876,17 @@
   register double
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     n;
 
   assert(wand != (const DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
-  assert(number_elements != (unsigned long *) NULL);
+  assert(number_elements != (size_t *) NULL);
   n=0;
   p=CurrentContext->dash_pattern;
   if (p != (const double *) NULL)
@@ -1900,7 +1900,7 @@
         sizeof(*dash_array));
       p=CurrentContext->dash_pattern;
       q=dash_array;
-      for (i=0; i < (long) n; i++)
+      for (i=0; i < (ssize_t) n; i++)
         *q++=(*p++);
     }
   return(dash_array);
@@ -2024,14 +2024,14 @@
 %
 %  The format of the DrawGetStrokeMiterLimit method is:
 %
-%      unsigned long DrawGetStrokeMiterLimit(const DrawingWand *wand)
+%      size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the drawing wand.
 %
 */
-WandExport unsigned long DrawGetStrokeMiterLimit(const DrawingWand *wand)
+WandExport size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
 {
   assert(wand != (const DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -2216,7 +2216,7 @@
 %
 %  DrawGetTextEncoding() returns a null-terminated string which specifies the
 %  code set used for text annotations. The string must be freed by the user
-%  once it is no longer required.
+%  once it is no ssize_ter required.
 %
 %  The format of the DrawGetTextEncoding method is:
 %
@@ -2345,7 +2345,7 @@
 %
 %  DrawGetVectorGraphics() returns a null-terminated string which specifies the
 %  vector graphics generated by any graphics calls made since the wand was
-%  instantiated.  The string must be freed by the user once it is no longer
+%  instantiated.  The string must be freed by the user once it is no ssize_ter
 %  required.
 %
 %  The format of the DrawGetVectorGraphics method is:
@@ -2381,7 +2381,7 @@
   MagickPixelPacket
     pixel;
 
-  register long
+  register ssize_t
     i;
 
   XMLTreeInfo
@@ -2403,14 +2403,14 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickClipPathOptions,(long) CurrentContext->clip_units),MaxTextExtent);
+        MagickClipPathOptions,(ssize_t) CurrentContext->clip_units),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"decorate",0);
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickDecorateOptions,(long) CurrentContext->decorate),MaxTextExtent);
+        MagickDecorateOptions,(ssize_t) CurrentContext->decorate),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"encoding",0);
@@ -2438,7 +2438,7 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickFillRuleOptions,(long) CurrentContext->fill_rule),MaxTextExtent);
+        MagickFillRuleOptions,(ssize_t) CurrentContext->fill_rule),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"font",0);
@@ -2458,14 +2458,14 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickStretchOptions,(long) CurrentContext->stretch),MaxTextExtent);
+        MagickStretchOptions,(ssize_t) CurrentContext->stretch),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"font-style",0);
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickStyleOptions,(long) CurrentContext->style),MaxTextExtent);
+        MagickStyleOptions,(ssize_t) CurrentContext->style),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"font-weight",0);
@@ -2479,7 +2479,7 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(MagickGravityOptions,
-        (long) CurrentContext->gravity),MaxTextExtent);
+        (ssize_t) CurrentContext->gravity),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"stroke",0);
@@ -2530,14 +2530,14 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(MagickLineCapOptions,
-        (long) CurrentContext->linecap),MaxTextExtent);
+        (ssize_t) CurrentContext->linecap),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"stroke-linejoin",0);
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(
-        MagickLineJoinOptions,(long) CurrentContext->linejoin),MaxTextExtent);
+        MagickLineJoinOptions,(ssize_t) CurrentContext->linejoin),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"stroke-miterlimit",0);
@@ -2565,7 +2565,7 @@
   if (child != (XMLTreeInfo *) NULL)
     {
       (void) CopyMagickString(value,MagickOptionToMnemonic(MagickAlignOptions,
-        (long) CurrentContext->align),MaxTextExtent);
+        (ssize_t) CurrentContext->align),MaxTextExtent);
       (void) SetXMLTreeContent(child,value);
     }
   child=AddChildToXMLTree(xml_info,"text-antialias",0);
@@ -2720,7 +2720,7 @@
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   (void) MvgPrintf(wand,"matte %g,%g '%s'\n",x,y,MagickOptionToMnemonic(
-    MagickMethodOptions,(long) paint_method));
+    MagickMethodOptions,(ssize_t) paint_method));
 }
 
 /*
@@ -3859,7 +3859,7 @@
 %  The format of the DrawPolygon method is:
 %
 %      void DrawPolygon(DrawingWand *wand,
-%        const unsigned long number_coordinates,const PointInfo *coordinates)
+%        const size_t number_coordinates,const PointInfo *coordinates)
 %
 %  A description of each parameter follows:
 %
@@ -3871,7 +3871,7 @@
 %
 */
 WandExport void DrawPolygon(DrawingWand *wand,
-  const unsigned long number_coordinates,const PointInfo *coordinates)
+  const size_t number_coordinates,const PointInfo *coordinates)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -3897,7 +3897,7 @@
 %  The format of the DrawPolyline method is:
 %
 %      void DrawPolyline(DrawingWand *wand,
-%        const unsigned long number_coordinates,const PointInfo *coordinates)
+%        const size_t number_coordinates,const PointInfo *coordinates)
 %
 %  A description of each parameter follows:
 %
@@ -3909,7 +3909,7 @@
 %
 */
 WandExport void DrawPolyline(DrawingWand *wand,
-  const unsigned long number_coordinates,const PointInfo *coordinates)
+  const size_t number_coordinates,const PointInfo *coordinates)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4173,10 +4173,10 @@
     x,y,width,height);
   wand->indent_depth++;
   wand->pattern_id=AcquireString(pattern_id);
-  wand->pattern_bounds.x=(long) ceil(x-0.5);
-  wand->pattern_bounds.y=(long) ceil(y-0.5);
-  wand->pattern_bounds.width=(unsigned long) floor(width+0.5);
-  wand->pattern_bounds.height=(unsigned long) floor(height+0.5);
+  wand->pattern_bounds.x=(ssize_t) ceil(x-0.5);
+  wand->pattern_bounds.y=(ssize_t) ceil(y-0.5);
+  wand->pattern_bounds.width=(size_t) floor(width+0.5);
+  wand->pattern_bounds.height=(size_t) floor(height+0.5);
   wand->pattern_offset=wand->mvg_length;
   return(MagickTrue);
 }
@@ -4509,7 +4509,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DrawSetClipPath() associates a named clipping path with the image.  Only
-%  the areas drawn on by the clipping path will be modified as long as it
+%  the areas drawn on by the clipping path will be modified as ssize_t as it
 %  remains in effect.
 %
 %  The format of the DrawSetClipPath method is:
@@ -4582,7 +4582,7 @@
     {
       CurrentContext->fill_rule=fill_rule;
       (void) MvgPrintf(wand, "clip-rule '%s'\n",MagickOptionToMnemonic(
-        MagickFillRuleOptions,(long) fill_rule));
+        MagickFillRuleOptions,(ssize_t) fill_rule));
     }
 }
 
@@ -4636,7 +4636,7 @@
           AdjustAffine(wand,&affine);
         }
       (void) MvgPrintf(wand, "clip-units '%s'\n",MagickOptionToMnemonic(
-        MagickClipPathOptions,(long) clip_units));
+        MagickClipPathOptions,(ssize_t) clip_units));
     }
 }
 
@@ -4874,7 +4874,7 @@
     {
       CurrentContext->fill_rule=fill_rule;
       (void) MvgPrintf(wand, "fill-rule '%s'\n",MagickOptionToMnemonic(
-        MagickFillRuleOptions,(long) fill_rule));
+        MagickFillRuleOptions,(ssize_t) fill_rule));
     }
 }
 
@@ -5043,7 +5043,7 @@
     {
       CurrentContext->stretch=font_stretch;
       (void) MvgPrintf(wand, "font-stretch '%s'\n",MagickOptionToMnemonic(
-        MagickStretchOptions,(long) font_stretch));
+        MagickStretchOptions,(ssize_t) font_stretch));
     }
 }
 
@@ -5083,7 +5083,7 @@
     {
       CurrentContext->style=style;
       (void) MvgPrintf(wand, "font-style '%s'\n",MagickOptionToMnemonic(
-        MagickStyleOptions,(long) style));
+        MagickStyleOptions,(ssize_t) style));
     }
 }
 
@@ -5103,7 +5103,7 @@
 %  The format of the DrawSetFontWeight method is:
 %
 %      void DrawSetFontWeight(DrawingWand *wand,
-%        const unsigned long font_weight)
+%        const size_t font_weight)
 %
 %  A description of each parameter follows:
 %
@@ -5113,7 +5113,7 @@
 %
 */
 WandExport void DrawSetFontWeight(DrawingWand *wand,
-  const unsigned long font_weight)
+  const size_t font_weight)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5166,7 +5166,7 @@
     {
       CurrentContext->gravity=gravity;
       (void) MvgPrintf(wand,"gravity '%s'\n",MagickOptionToMnemonic(
-        MagickGravityOptions,(long) gravity));
+        MagickGravityOptions,(ssize_t) gravity));
     }
 }
 
@@ -5345,7 +5345,7 @@
 %  The format of the DrawSetStrokeDashArray method is:
 %
 %      MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
-%        const unsigned long number_elements,const double *dash_array)
+%        const size_t number_elements,const double *dash_array)
 %
 %  A description of each parameter follows:
 %
@@ -5357,7 +5357,7 @@
 %
 */
 WandExport MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
-  const unsigned long number_elements,const double *dash_array)
+  const size_t number_elements,const double *dash_array)
 {
   MagickBooleanType
     update;
@@ -5368,10 +5368,10 @@
   register double
     *q;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     n_new,
     n_old;
 
@@ -5397,7 +5397,7 @@
         {
           p=dash_array;
           q=CurrentContext->dash_pattern;
-          for (i=0; i < (long) n_new; i++)
+          for (i=0; i < (ssize_t) n_new; i++)
           {
             if (fabs((*p)-(*q)) > MagickEpsilon)
               {
@@ -5425,7 +5425,7 @@
             }
           q=CurrentContext->dash_pattern;
           p=dash_array;
-          for (i=0; i < (long) n_new; i++)
+          for (i=0; i < (ssize_t) n_new; i++)
             *q++=(*p++);
           *q=0;
         }
@@ -5436,7 +5436,7 @@
         {
           p=dash_array;
           (void) MvgPrintf(wand,"%g",*p++);
-          for (i=1; i < (long) n_new; i++)
+          for (i=1; i < (ssize_t) n_new; i++)
             (void) MvgPrintf(wand,",%g",*p++);
           (void) MvgPrintf(wand,"\n");
         }
@@ -5523,7 +5523,7 @@
     {
       CurrentContext->linecap=linecap;
       (void) MvgPrintf(wand,"stroke-linecap '%s'\n",MagickOptionToMnemonic(
-        MagickLineCapOptions,(long) linecap));
+        MagickLineCapOptions,(ssize_t) linecap));
     }
 }
 
@@ -5565,7 +5565,7 @@
     {
       CurrentContext->linejoin=linejoin;
       (void) MvgPrintf(wand, "stroke-linejoin '%s'\n",MagickOptionToMnemonic(
-        MagickLineJoinOptions,(long) linejoin));
+        MagickLineJoinOptions,(ssize_t) linejoin));
     }
 }
 
@@ -5589,7 +5589,7 @@
 %  The format of the DrawSetStrokeMiterLimit method is:
 %
 %      void DrawSetStrokeMiterLimit(DrawingWand *wand,
-%        const unsigned long miterlimit)
+%        const size_t miterlimit)
 %
 %  A description of each parameter follows:
 %
@@ -5599,7 +5599,7 @@
 %
 */
 WandExport void DrawSetStrokeMiterLimit(DrawingWand *wand,
-  const unsigned long miterlimit)
+  const size_t miterlimit)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5734,7 +5734,7 @@
     {
       CurrentContext->align=alignment;
       (void) MvgPrintf(wand,"text-align '%s'\n",MagickOptionToMnemonic(
-        MagickAlignOptions,(long) alignment));
+        MagickAlignOptions,(ssize_t) alignment));
     }
 }
 
@@ -5819,7 +5819,7 @@
     {
       CurrentContext->decorate=decoration;
       (void) MvgPrintf(wand,"decorate '%s'\n",MagickOptionToMnemonic(
-        MagickDecorateOptions,(long) decoration));
+        MagickDecorateOptions,(ssize_t) decoration));
     }
 }
 
@@ -6070,7 +6070,7 @@
   char
     *p;
 
-  long
+  ssize_t
     value;
 
   value=strtol(point,&p,10);
@@ -6212,10 +6212,10 @@
       const char
         *q;
 
-      long
+      ssize_t
         j;
 
-      register long
+      register ssize_t
         x;
 
       value=GetXMLTreeContent(child);
@@ -6484,8 +6484,8 @@
 %
 %  The format of the DrawSetViewbox method is:
 %
-%      void DrawSetViewbox(DrawingWand *wand,unsigned long x1,
-%        unsigned long y1,unsigned long x2,unsigned long y2)
+%      void DrawSetViewbox(DrawingWand *wand,size_t x1,
+%        size_t y1,size_t x2,size_t y2)
 %
 %  A description of each parameter follows:
 %
@@ -6500,8 +6500,8 @@
 %    o y2: bottom y ordinate
 %
 */
-WandExport void DrawSetViewbox(DrawingWand *wand,unsigned long x1,
-  unsigned long y1,unsigned long x2,unsigned long y2)
+WandExport void DrawSetViewbox(DrawingWand *wand,size_t x1,
+  size_t y1,size_t x2,size_t y2)
 {
   assert(wand != (DrawingWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -6570,7 +6570,7 @@
   DrawingWand
     *wand;
 
-  unsigned long
+  size_t
     depth;
 
   quantum=GetMagickQuantumDepth(&depth);
diff --git a/wand/drawing-wand.h b/wand/drawing-wand.h
index a7eec39..e1af4e6 100644
--- a/wand/drawing-wand.h
+++ b/wand/drawing-wand.h
@@ -48,7 +48,7 @@
   DrawGetFillOpacity(const DrawingWand *),
   DrawGetFontSize(const DrawingWand *),
   DrawGetOpacity(const DrawingWand *),
-  *DrawGetStrokeDashArray(const DrawingWand *,unsigned long *),
+  *DrawGetStrokeDashArray(const DrawingWand *,size_t *),
   DrawGetStrokeDashOffset(const DrawingWand *),
   DrawGetStrokeOpacity(const DrawingWand *),
   DrawGetStrokeWidth(const DrawingWand *),
@@ -95,7 +95,7 @@
   DrawSetFillPatternURL(DrawingWand *,const char *),
   DrawSetFont(DrawingWand *,const char *),
   DrawSetFontFamily(DrawingWand *,const char *),
-  DrawSetStrokeDashArray(DrawingWand *,const unsigned long,const double *),
+  DrawSetStrokeDashArray(DrawingWand *,const size_t,const double *),
   DrawSetStrokePatternURL(DrawingWand *,const char *),
   DrawSetVectorGraphics(DrawingWand *,const char *),
   IsDrawingWand(const DrawingWand *),
@@ -108,7 +108,7 @@
 extern WandExport StyleType
   DrawGetFontStyle(const DrawingWand *);
 
-extern WandExport unsigned long
+extern WandExport size_t
   DrawGetFontWeight(const DrawingWand *),
   DrawGetStrokeMiterLimit(const DrawingWand *);
 
@@ -118,7 +118,7 @@
   DrawAnnotation(DrawingWand *,const double,const double,const unsigned char *),
   DrawArc(DrawingWand *,const double,const double,const double,const double,
     const double,const double),
-  DrawBezier(DrawingWand *,const unsigned long,const PointInfo *),
+  DrawBezier(DrawingWand *,const size_t,const PointInfo *),
   DrawGetBorderColor(const DrawingWand *,PixelWand *),
   DrawCircle(DrawingWand *,const double,const double,const double,const double),
   DrawColor(DrawingWand *,const double,const double,const PaintMethod),
@@ -167,8 +167,8 @@
   DrawPathMoveToRelative(DrawingWand *,const double,const double),
   DrawPathStart(DrawingWand *),
   DrawPoint(DrawingWand *,const double,const double),
-  DrawPolygon(DrawingWand *,const unsigned long,const PointInfo *),
-  DrawPolyline(DrawingWand *,const unsigned long,const PointInfo *),
+  DrawPolygon(DrawingWand *,const size_t,const PointInfo *),
+  DrawPolyline(DrawingWand *,const size_t,const PointInfo *),
   DrawPopClipPath(DrawingWand *),
   DrawPopDefs(DrawingWand *),
   DrawPushClipPath(DrawingWand *,const char *),
@@ -188,7 +188,7 @@
   DrawSetFontSize(DrawingWand *,const double),
   DrawSetFontStretch(DrawingWand *,const StretchType),
   DrawSetFontStyle(DrawingWand *,const StyleType),
-  DrawSetFontWeight(DrawingWand *,const unsigned long),
+  DrawSetFontWeight(DrawingWand *,const size_t),
   DrawSetGravity(DrawingWand *,const GravityType),
   DrawSetOpacity(DrawingWand *,const double),
   DrawSetStrokeAntialias(DrawingWand *,const MagickBooleanType),
@@ -196,7 +196,7 @@
   DrawSetStrokeDashOffset(DrawingWand *,const double dashoffset),
   DrawSetStrokeLineCap(DrawingWand *,const LineCap),
   DrawSetStrokeLineJoin(DrawingWand *,const LineJoin),
-  DrawSetStrokeMiterLimit(DrawingWand *,const unsigned long),
+  DrawSetStrokeMiterLimit(DrawingWand *,const size_t),
   DrawSetStrokeOpacity(DrawingWand *, const double),
   DrawSetStrokeWidth(DrawingWand *,const double),
   DrawSetTextAlignment(DrawingWand *,const AlignType),
@@ -204,8 +204,8 @@
   DrawSetTextDecoration(DrawingWand *,const DecorationType),
   DrawSetTextEncoding(DrawingWand *,const char *),
   DrawSetTextUnderColor(DrawingWand *,const PixelWand *),
-  DrawSetViewbox(DrawingWand *,unsigned long,unsigned long,unsigned long,
-    unsigned long),
+  DrawSetViewbox(DrawingWand *,size_t,size_t,size_t,
+    size_t),
   DrawSkewX(DrawingWand *,const double),
   DrawSkewY(DrawingWand *,const double),
   DrawTranslate(DrawingWand *,const double,const double);
diff --git a/wand/identify.c b/wand/identify.c
index 541024a..df4927b 100644
--- a/wand/identify.c
+++ b/wand/identify.c
@@ -150,7 +150,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] "
@@ -182,7 +182,7 @@
 #define DestroyIdentify() \
 { \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -211,7 +211,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
@@ -222,10 +222,10 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
-  unsigned long
+  size_t
     count;
 
   /*
@@ -243,7 +243,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -268,7 +268,7 @@
     ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
   image_info->ping=MagickTrue;
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -354,13 +354,13 @@
       {
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -375,7 +375,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -388,7 +388,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -396,13 +396,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -412,13 +412,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -432,7 +432,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -447,13 +447,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -465,7 +465,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -484,7 +484,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -495,7 +495,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -506,7 +506,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -521,7 +521,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -533,7 +533,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             format=argv[i];
             break;
@@ -543,7 +543,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -556,7 +556,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -575,13 +575,13 @@
       {
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -592,13 +592,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -619,13 +619,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -633,7 +633,7 @@
               ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -642,13 +642,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -664,7 +664,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             break;
@@ -715,7 +715,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -726,7 +726,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -735,12 +735,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -749,7 +749,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -762,7 +762,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowIdentifyInvalidArgumentException(option,argv[i]);
@@ -776,13 +776,13 @@
           break;
         if (LocaleCompare("units",option+1) == 0)
           {
-            long
+            ssize_t
               units;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -799,13 +799,13 @@
           break;
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowIdentifyException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
diff --git a/wand/import.c b/wand/import.c
index 521d303..669131e 100644
--- a/wand/import.c
+++ b/wand/import.c
@@ -182,7 +182,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] [ file ]\n",
@@ -208,7 +208,7 @@
   return(MagickFalse);
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
@@ -230,7 +230,7 @@
   DestroyImageStack(); \
   if (target_window != (char *) NULL) \
     target_window=DestroyString(target_window); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -265,7 +265,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k,
     snapshots;
@@ -280,7 +280,7 @@
   QuantizeInfo
     *quantize_info;
 
-  register long
+  register ssize_t
     i;
 
   XImportInfo
@@ -307,7 +307,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -333,7 +333,7 @@
   if (status == MagickFalse)
     ThrowImportException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     /*
       Check command line for server name.
@@ -345,7 +345,7 @@
           User specified server name.
         */
         i++;
-        if (i == (long) argc)
+        if (i == (ssize_t) argc)
           ThrowImportException(OptionError,"MissingArgument",option);
         server_name=argv[i];
       }
@@ -420,7 +420,7 @@
   /*
     Check command syntax.
   */
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -445,7 +445,7 @@
         Image
           *images;
 
-        unsigned long
+        size_t
           scene;
 
         /*
@@ -456,7 +456,7 @@
         if (target_window != (char *) NULL)
           (void) CopyMagickString(image_info->filename,target_window,
             MaxTextExtent);
-        for (scene=0; scene < (unsigned long) MagickMax(snapshots,1); scene++)
+        for (scene=0; scene < (size_t) MagickMax(snapshots,1); scene++)
         {
           (void) sleep(resource_info.pause);
           images=XImportImage(image_info,&ximage_info);
@@ -483,11 +483,11 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             i++;
             break;
@@ -507,7 +507,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -520,7 +520,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -528,13 +528,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -548,7 +548,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -557,13 +557,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
               argv[i]);
@@ -577,7 +577,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             status=SetImageOption(image_info,"comment",argv[i]);
             if (status == MagickFalse)
@@ -586,13 +586,13 @@
           }
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -608,7 +608,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -620,13 +620,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -637,7 +637,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -656,7 +656,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -670,7 +670,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -681,7 +681,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -697,19 +697,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -719,14 +719,14 @@
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             quantize_info->dither=MagickFalse;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -741,7 +741,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -756,7 +756,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -765,19 +765,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
               argv[i]);
@@ -792,13 +792,13 @@
       {
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -817,7 +817,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -830,7 +830,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -838,13 +838,13 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
             if (gravity < 0)
@@ -866,13 +866,13 @@
           break;
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -883,13 +883,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -907,7 +907,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             status=SetImageOption(image_info,"label",argv[i]);
             if (status == MagickFalse)
@@ -922,13 +922,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -936,7 +936,7 @@
               ThrowImportException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -945,13 +945,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -966,7 +966,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL))
+            if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -999,7 +999,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             status=SetImageOption(image_info,"page",argv[i]);
             if (status == MagickFalse)
@@ -1012,7 +1012,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1026,7 +1026,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1041,7 +1041,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1049,13 +1049,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -1077,7 +1077,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1088,7 +1088,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1102,7 +1102,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1117,7 +1117,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1128,7 +1128,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1137,12 +1137,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1156,7 +1156,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1171,7 +1171,7 @@
           {
             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1194,7 +1194,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1203,7 +1203,7 @@
         if (LocaleCompare("transparent",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1212,7 +1212,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowImportException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1222,7 +1222,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowImportInvalidArgumentException(option,argv[i]);
@@ -1233,13 +1233,13 @@
           break;
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowImportException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -1251,7 +1251,7 @@
       case 'w':
       {
         i++;
-        if (i == (long) argc)
+        if (i == (ssize_t) argc)
           ThrowImportException(OptionError,"MissingArgument",option);
         (void) CloneString(&target_window,argv[i]);
         break;
@@ -1264,7 +1264,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
diff --git a/wand/magick-image.c b/wand/magick-image.c
index eccbb51..7c2a292 100644
--- a/wand/magick-image.c
+++ b/wand/magick-image.c
@@ -239,7 +239,7 @@
 %  triangulation.
 %
 %      MagickBooleanType MagickAdaptiveResizeImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -251,7 +251,7 @@
 %
 */
 WandExport MagickBooleanType MagickAdaptiveResizeImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Image
     *resize_image;
@@ -356,7 +356,7 @@
 %  The format of the AdaptiveThresholdImage method is:
 %
 %      MagickBooleanType MagickAdaptiveThresholdImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long offset)
+%        const size_t width,const size_t height,const ssize_t offset)
 %
 %  A description of each parameter follows:
 %
@@ -370,7 +370,7 @@
 %
 */
 WandExport MagickBooleanType MagickAdaptiveThresholdImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long offset)
+  const size_t width,const size_t height,const ssize_t offset)
 {
   Image
     *threshold_image;
@@ -1026,8 +1026,8 @@
 %  The format of the MagickBorderImage method is:
 %
 %      MagickBooleanType MagickBorderImage(MagickWand *wand,
-%        const PixelWand *bordercolor,const unsigned long width,
-%        const unsigned long height)
+%        const PixelWand *bordercolor,const size_t width,
+%        const size_t height)
 %
 %  A description of each parameter follows:
 %
@@ -1041,8 +1041,8 @@
 %
 */
 WandExport MagickBooleanType MagickBorderImage(MagickWand *wand,
-  const PixelWand *bordercolor,const unsigned long width,
-  const unsigned long height)
+  const PixelWand *bordercolor,const size_t width,
+  const size_t height)
 {
   Image
     *border_image;
@@ -1199,8 +1199,8 @@
 %  The format of the MagickChopImage method is:
 %
 %      MagickBooleanType MagickChopImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -1217,8 +1217,8 @@
 %
 */
 WandExport MagickBooleanType MagickChopImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   Image
     *chop_image;
@@ -1308,7 +1308,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  MagickClipImage() clips along the first path from the 8BIM profile, if
+%  MagickClipImage() clips assize_t the first path from the 8BIM profile, if
 %  present.
 %
 %  The format of the MagickClipImage method is:
@@ -1348,7 +1348,7 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  MagickClipImagePath() clips along the named paths from the 8BIM profile, if
+%  MagickClipImagePath() clips assize_t the named paths from the 8BIM profile, if
 %  present. Later operations take effect inside the path.  Id may be a number
 %  if preceded with #, to work on a numbered path, e.g., "#1" to use the first
 %  path.
@@ -1924,10 +1924,10 @@
 %
 %      MagickBooleanType MagickCompositeImage(MagickWand *wand,
 %        const MagickWand *composite_wand,const CompositeOperator compose,
-%        const long x,const long y)
+%        const ssize_t x,const ssize_t y)
 %      MagickBooleanType MagickCompositeImageChannel(MagickWand *wand,
 %        const ChannelType channel,const MagickWand *composite_wand,
-%        const CompositeOperator compose,const long x,const long y)
+%        const CompositeOperator compose,const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -1951,8 +1951,8 @@
 */
 
 WandExport MagickBooleanType MagickCompositeImage(MagickWand *wand,
-  const MagickWand *composite_wand,const CompositeOperator compose,const long x,
-  const long y)
+  const MagickWand *composite_wand,const CompositeOperator compose,const ssize_t x,
+  const ssize_t y)
 {
   MagickBooleanType
     status;
@@ -1964,7 +1964,7 @@
 
 WandExport MagickBooleanType MagickCompositeImageChannel(MagickWand *wand,
   const ChannelType channel,const MagickWand *composite_wand,
-  const CompositeOperator compose,const long x,const long y)
+  const CompositeOperator compose,const ssize_t x,const ssize_t y)
 {
   MagickBooleanType
     status;
@@ -2111,9 +2111,9 @@
 %  The format of the MagickConvolveImage method is:
 %
 %      MagickBooleanType MagickConvolveImage(MagickWand *wand,
-%        const unsigned long order,const double *kernel)
+%        const size_t order,const double *kernel)
 %      MagickBooleanType MagickConvolveImageChannel(MagickWand *wand,
-%        const ChannelType channel,const unsigned long order,
+%        const ChannelType channel,const size_t order,
 %        const double *kernel)
 %
 %  A description of each parameter follows:
@@ -2129,7 +2129,7 @@
 */
 
 WandExport MagickBooleanType MagickConvolveImage(MagickWand *wand,
-  const unsigned long order,const double *kernel)
+  const size_t order,const double *kernel)
 {
   MagickBooleanType
     status;
@@ -2139,7 +2139,7 @@
 }
 
 WandExport MagickBooleanType MagickConvolveImageChannel(MagickWand *wand,
-  const ChannelType channel,const unsigned long order,const double *kernel)
+  const ChannelType channel,const size_t order,const double *kernel)
 {
   Image
     *convolve_image;
@@ -2176,8 +2176,8 @@
 %  The format of the MagickCropImage method is:
 %
 %      MagickBooleanType MagickCropImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -2193,8 +2193,8 @@
 %
 */
 WandExport MagickBooleanType MagickCropImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   Image
     *crop_image;
@@ -2237,7 +2237,7 @@
 %  The format of the MagickCycleColormapImage method is:
 %
 %      MagickBooleanType MagickCycleColormapImage(MagickWand *wand,
-%        const long displace)
+%        const ssize_t displace)
 %
 %  A description of each parameter follows:
 %
@@ -2247,7 +2247,7 @@
 %
 */
 WandExport MagickBooleanType MagickCycleColormapImage(MagickWand *wand,
-  const long displace)
+  const ssize_t displace)
 {
   MagickBooleanType
     status;
@@ -2288,7 +2288,7 @@
 %  The format of the MagickConstituteImage method is:
 %
 %      MagickBooleanType MagickConstituteImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,const char *map,
+%        const size_t columns,const size_t rows,const char *map,
 %        const StorageType storage,void *pixels)
 %
 %  A description of each parameter follows:
@@ -2317,7 +2317,7 @@
 %
 */
 WandExport MagickBooleanType MagickConstituteImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows,const char *map,
+  const size_t columns,const size_t rows,const char *map,
   const StorageType storage,const void *pixels)
 {
   Image
@@ -2645,7 +2645,7 @@
 %  The format of the MagickDistortImage method is:
 %
 %      MagickBooleanType MagickDistortImage(MagickWand *wand,
-%        const DistortImageMethod method,const unsigned long number_arguments,
+%        const DistortImageMethod method,const size_t number_arguments,
 %        const double *arguments,const MagickBooleanType bestfit)
 %
 %  A description of each parameter follows:
@@ -2681,7 +2681,7 @@
 %
 */
 WandExport MagickBooleanType MagickDistortImage(MagickWand *wand,
-  const DistortImageMethod method,const unsigned long number_arguments,
+  const DistortImageMethod method,const size_t number_arguments,
   const double *arguments,const MagickBooleanType bestfit)
 {
   Image
@@ -3092,7 +3092,7 @@
 %  MagickExportImagePixels() extracts pixel data from an image and returns it
 %  to you.  The method returns MagickTrue on success otherwise MagickFalse if
 %  an error is encountered.  The data is returned as char, short int, int,
-%  long, float, or double in the order specified by map.
+%  ssize_t, float, or double in the order specified by map.
 %
 %  Suppose you want to extract the first scanline of a 640x480 image as
 %  character data in red-green-blue order:
@@ -3102,8 +3102,8 @@
 %  The format of the MagickExportImagePixels method is:
 %
 %      MagickBooleanType MagickExportImagePixels(MagickWand *wand,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType storage,
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,const char *map,const StorageType storage,
 %        void *pixels)
 %
 %  A description of each parameter follows:
@@ -3130,8 +3130,8 @@
 %
 */
 WandExport MagickBooleanType MagickExportImagePixels(MagickWand *wand,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType storage,
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,const char *map,const StorageType storage,
   void *pixels)
 {
   MagickBooleanType
@@ -3168,8 +3168,8 @@
 %  The format of the MagickExtentImage method is:
 %
 %      MagickBooleanType MagickExtentImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -3185,8 +3185,8 @@
 %
 */
 WandExport MagickBooleanType MagickExtentImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   Image
     *extent_image;
@@ -3333,7 +3333,7 @@
 %
 %      MagickBooleanType MagickFloodfillPaintImage(MagickWand *wand,
 %        const ChannelType channel,const PixelWand *fill,const double fuzz,
-%        const PixelWand *bordercolor,const long x,const long y,
+%        const PixelWand *bordercolor,const ssize_t x,const ssize_t y,
 %        const MagickBooleanType invert)
 %
 %  A description of each parameter follows:
@@ -3360,7 +3360,7 @@
 */
 WandExport MagickBooleanType MagickFloodfillPaintImage(MagickWand *wand,
   const ChannelType channel,const PixelWand *fill,const double fuzz,
-  const PixelWand *bordercolor,const long x,const long y,
+  const PixelWand *bordercolor,const ssize_t x,const ssize_t y,
   const MagickBooleanType invert)
 {
   DrawInfo
@@ -3501,9 +3501,9 @@
 %  The format of the MagickFrameImage method is:
 %
 %      MagickBooleanType MagickFrameImage(MagickWand *wand,
-%        const PixelWand *matte_color,const unsigned long width,
-%        const unsigned long height,const long inner_bevel,
-%        const long outer_bevel)
+%        const PixelWand *matte_color,const size_t width,
+%        const size_t height,const ssize_t inner_bevel,
+%        const ssize_t outer_bevel)
 %
 %  A description of each parameter follows:
 %
@@ -3521,8 +3521,8 @@
 %
 */
 WandExport MagickBooleanType MagickFrameImage(MagickWand *wand,
-  const PixelWand *matte_color,const unsigned long width,
-  const unsigned long height,const long inner_bevel,const long outer_bevel)
+  const PixelWand *matte_color,const size_t width,
+  const size_t height,const ssize_t inner_bevel,const ssize_t outer_bevel)
 {
   Image
     *frame_image;
@@ -3539,8 +3539,8 @@
   (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info));
   frame_info.width=wand->images->columns+2*width;
   frame_info.height=wand->images->rows+2*height;
-  frame_info.x=(long) width;
-  frame_info.y=(long) height;
+  frame_info.x=(ssize_t) width;
+  frame_info.y=(ssize_t) height;
   frame_info.inner_bevel=inner_bevel;
   frame_info.outer_bevel=outer_bevel;
   PixelGetQuantumColor(matte_color,&wand->images->matte_color);
@@ -3570,11 +3570,11 @@
 %  The format of the MagickFunctionImage method is:
 %
 %      MagickBooleanType MagickFunctionImage(MagickWand *wand,
-%        const MagickFunction function,const unsigned long number_arguments,
+%        const MagickFunction function,const size_t number_arguments,
 %        const double *arguments)
 %      MagickBooleanType MagickFunctionImageChannel(MagickWand *wand,
 %        const ChannelType channel,const MagickFunction function,
-%        const unsigned long number_arguments,const double *arguments)
+%        const size_t number_arguments,const double *arguments)
 %
 %  A description of each parameter follows:
 %
@@ -3591,7 +3591,7 @@
 */
 
 WandExport MagickBooleanType MagickFunctionImage(MagickWand *wand,
-  const MagickFunction function,const unsigned long number_arguments,
+  const MagickFunction function,const size_t number_arguments,
   const double *arguments)
 {
   MagickBooleanType
@@ -3612,7 +3612,7 @@
 
 WandExport MagickBooleanType MagickFunctionImageChannel(MagickWand *wand,
   const ChannelType channel,const MagickFunction function,
-  const unsigned long number_arguments,const double *arguments)
+  const size_t number_arguments,const double *arguments)
 {
   MagickBooleanType
     status;
@@ -3874,7 +3874,7 @@
 %
 %  The format of the MagickGetImageAlphaChannel method is:
 %
-%      unsigned long MagickGetImageAlphaChannel(MagickWand *wand)
+%      size_t MagickGetImageAlphaChannel(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
@@ -4162,7 +4162,7 @@
 %
 %  The format of the MagickGetImageChannelDepth method is:
 %
-%      unsigned long MagickGetImageChannelDepth(MagickWand *wand,
+%      size_t MagickGetImageChannelDepth(MagickWand *wand,
 %        const ChannelType channel)
 %
 %  A description of each parameter follows:
@@ -4172,7 +4172,7 @@
 %    o channel: the image channel(s).
 %
 */
-WandExport unsigned long MagickGetImageChannelDepth(MagickWand *wand,
+WandExport size_t MagickGetImageChannelDepth(MagickWand *wand,
   const ChannelType channel)
 {
   assert(wand != (MagickWand *) NULL);
@@ -4319,7 +4319,7 @@
 %  The format of the MagickGetImageChannelFeatures method is:
 %
 %      ChannelFeatures *MagickGetImageChannelFeatures(MagickWand *wand,
-%        const unsigned long distance)
+%        const size_t distance)
 %
 %  A description of each parameter follows:
 %
@@ -4329,7 +4329,7 @@
 %
 */
 WandExport ChannelFeatures *MagickGetImageChannelFeatures(MagickWand *wand,
-  const unsigned long distance)
+  const size_t distance)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4546,7 +4546,7 @@
 %  The format of the MagickGetImageColormapColor method is:
 %
 %      MagickBooleanType MagickGetImageColormapColor(MagickWand *wand,
-%        const unsigned long index,PixelWand *color)
+%        const size_t index,PixelWand *color)
 %
 %  A description of each parameter follows:
 %
@@ -4558,7 +4558,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetImageColormapColor(MagickWand *wand,
-  const unsigned long index,PixelWand *color)
+  const size_t index,PixelWand *color)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4592,14 +4592,14 @@
 %
 %  The format of the MagickGetImageColors method is:
 %
-%      unsigned long MagickGetImageColors(MagickWand *wand)
+%      size_t MagickGetImageColors(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageColors(MagickWand *wand)
+WandExport size_t MagickGetImageColors(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4741,14 +4741,14 @@
 %
 %  The format of the MagickGetImageCompression method is:
 %
-%      unsigned long MagickGetImageCompression(MagickWand *wand)
+%      size_t MagickGetImageCompression(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageCompressionQuality(MagickWand *wand)
+WandExport size_t MagickGetImageCompressionQuality(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4778,14 +4778,14 @@
 %
 %  The format of the MagickGetImageDelay method is:
 %
-%      unsigned long MagickGetImageDelay(MagickWand *wand)
+%      size_t MagickGetImageDelay(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageDelay(MagickWand *wand)
+WandExport size_t MagickGetImageDelay(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -4811,14 +4811,14 @@
 %
 %  The format of the MagickGetImageDepth method is:
 %
-%      unsigned long MagickGetImageDepth(MagickWand *wand)
+%      size_t MagickGetImageDepth(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageDepth(MagickWand *wand)
+WandExport size_t MagickGetImageDepth(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5158,14 +5158,14 @@
 %
 %  The format of the MagickGetImageHeight method is:
 %
-%      unsigned long MagickGetImageHeight(MagickWand *wand)
+%      size_t MagickGetImageHeight(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageHeight(MagickWand *wand)
+WandExport size_t MagickGetImageHeight(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5193,7 +5193,7 @@
 %  The format of the MagickGetImageHistogram method is:
 %
 %      PixelWand **MagickGetImageHistogram(MagickWand *wand,
-%        unsigned long *number_colors)
+%        size_t *number_colors)
 %
 %  A description of each parameter follows:
 %
@@ -5204,7 +5204,7 @@
 %
 */
 WandExport PixelWand **MagickGetImageHistogram(MagickWand *wand,
-  unsigned long *number_colors)
+  size_t *number_colors)
 {
   ColorPacket
     *histogram;
@@ -5212,7 +5212,7 @@
   PixelWand
     **pixel_wands;
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (MagickWand *) NULL);
@@ -5229,11 +5229,11 @@
   if (histogram == (ColorPacket *) NULL)
     return((PixelWand **) NULL);
   pixel_wands=NewPixelWands(*number_colors);
-  for (i=0; i < (long) *number_colors; i++)
+  for (i=0; i < (ssize_t) *number_colors; i++)
   {
     PixelSetQuantumColor(pixel_wands[i],&histogram[i].pixel);
     PixelSetIndex(pixel_wands[i],histogram[i].index);
-    PixelSetColorCount(pixel_wands[i],(unsigned long) histogram[i].count);
+    PixelSetColorCount(pixel_wands[i],(size_t) histogram[i].count);
   }
   histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
   return(pixel_wands);
@@ -5330,14 +5330,14 @@
 %
 %  The format of the MagickGetImageIterations method is:
 %
-%      unsigned long MagickGetImageIterations(MagickWand *wand)
+%      size_t MagickGetImageIterations(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageIterations(MagickWand *wand)
+WandExport size_t MagickGetImageIterations(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5477,7 +5477,7 @@
 %  The format of the MagickGetImagePage method is:
 %
 %      MagickBooleanType MagickGetImagePage(MagickWand *wand,
-%        unsigned long *width,unsigned long *height,long *x,long *y)
+%        size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 %
 %  A description of each parameter follows:
 %
@@ -5493,7 +5493,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetImagePage(MagickWand *wand,
-  unsigned long *width,unsigned long *height,long *x,long *y)
+  size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 {
   assert(wand != (const MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5524,7 +5524,7 @@
 %  The format of the MagickGetImagePixelColor method is:
 %
 %      MagickBooleanType MagickGetImagePixelColor(MagickWand *wand,
-%        const long x,const long y,PixelWand *color)
+%        const ssize_t x,const ssize_t y,PixelWand *color)
 %
 %  A description of each parameter follows:
 %
@@ -5536,7 +5536,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetImagePixelColor(MagickWand *wand,
-  const long x,const long y,PixelWand *color)
+  const ssize_t x,const ssize_t y,PixelWand *color)
 {
   IndexPacket
     *indexes;
@@ -5672,8 +5672,8 @@
 %  The format of the MagickGetImageRegion method is:
 %
 %      MagickWand *MagickGetImageRegion(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -5689,8 +5689,8 @@
 %
 */
 WandExport MagickWand *MagickGetImageRegion(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   Image
     *region_image;
@@ -5807,14 +5807,14 @@
 %
 %  The format of the MagickGetImageScene method is:
 %
-%      unsigned long MagickGetImageScene(MagickWand *wand)
+%      size_t MagickGetImageScene(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageScene(MagickWand *wand)
+WandExport size_t MagickGetImageScene(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5891,14 +5891,14 @@
 %
 %  The format of the MagickGetImageTicksPerSecond method is:
 %
-%      unsigned long MagickGetImageTicksPerSecond(MagickWand *wand)
+%      size_t MagickGetImageTicksPerSecond(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageTicksPerSecond(MagickWand *wand)
+WandExport size_t MagickGetImageTicksPerSecond(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -5906,7 +5906,7 @@
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   if (wand->images == (Image *) NULL)
     ThrowWandException(WandError,"ContainsNoImages",wand->name);
-  return((unsigned long) wand->images->ticks_per_second);
+  return((size_t) wand->images->ticks_per_second);
 }
 
 /*
@@ -6085,14 +6085,14 @@
 %
 %  The format of the MagickGetImageWidth method is:
 %
-%      unsigned long MagickGetImageWidth(MagickWand *wand)
+%      size_t MagickGetImageWidth(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetImageWidth(MagickWand *wand)
+WandExport size_t MagickGetImageWidth(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -6119,14 +6119,14 @@
 %
 %  The format of the MagickGetNumberImages method is:
 %
-%      unsigned long MagickGetNumberImages(MagickWand *wand)
+%      size_t MagickGetNumberImages(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetNumberImages(MagickWand *wand)
+WandExport size_t MagickGetNumberImages(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -6428,7 +6428,7 @@
 %  MagickImportImagePixels() accepts pixel datand stores it in the image at the
 %  location you specify.  The method returns MagickFalse on success otherwise
 %  MagickTrue if an error is encountered.  The pixel data can be either char,
-%  short int, int, long, float, or double in the order specified by map.
+%  short int, int, ssize_t, float, or double in the order specified by map.
 %
 %  Suppose your want to upload the first scanline of a 640x480 image from
 %  character data in red-green-blue order:
@@ -6438,8 +6438,8 @@
 %  The format of the MagickImportImagePixels method is:
 %
 %      MagickBooleanType MagickImportImagePixels(MagickWand *wand,
-%        const long x,const long y,const unsigned long columns,
-%        const unsigned long rows,const char *map,const StorageType storage,
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,const char *map,const StorageType storage,
 %        const void *pixels)
 %
 %  A description of each parameter follows:
@@ -6466,8 +6466,8 @@
 %
 */
 WandExport MagickBooleanType MagickImportImagePixels(MagickWand *wand,
-  const long x,const long y,const unsigned long columns,
-  const unsigned long rows,const char *map,const StorageType storage,
+  const ssize_t x,const ssize_t y,const size_t columns,
+  const size_t rows,const char *map,const StorageType storage,
   const void *pixels)
 {
   MagickBooleanType
@@ -6721,7 +6721,7 @@
 %  MagickLiquidRescaleImage() rescales image with seam carving.
 %
 %      MagickBooleanType MagickLiquidRescaleImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,
+%        const size_t columns,const size_t rows,
 %        const double delta_x,const double rigidity)
 %
 %  A description of each parameter follows:
@@ -6738,7 +6738,7 @@
 %
 */
 WandExport MagickBooleanType MagickLiquidRescaleImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows,const double delta_x,
+  const size_t columns,const size_t rows,const double delta_x,
   const double rigidity)
 {
   Image
@@ -7137,7 +7137,7 @@
 %  The format of the MagickMorphImages method is:
 %
 %      MagickWand *MagickMorphImages(MagickWand *wand,
-%        const unsigned long number_frames)
+%        const size_t number_frames)
 %
 %  A description of each parameter follows:
 %
@@ -7147,7 +7147,7 @@
 %
 */
 WandExport MagickWand *MagickMorphImages(MagickWand *wand,
-  const unsigned long number_frames)
+  const size_t number_frames)
 {
   Image
     *morph_image;
@@ -7181,9 +7181,9 @@
 %  The format of the MagickMorphologyImage method is:
 %
 %      MagickBooleanType MagickMorphologyImage(MagickWand *wand,
-%        MorphologyMethod method,const long iterations,KernelInfo *kernel)
+%        MorphologyMethod method,const ssize_t iterations,KernelInfo *kernel)
 %      MagickBooleanType MagickMorphologyImageChannel(MagickWand *wand,
-%        ChannelType channel,MorphologyMethod method,const long iterations,
+%        ChannelType channel,MorphologyMethod method,const ssize_t iterations,
 %        KernelInfo *kernel)
 %
 %  A description of each parameter follows:
@@ -7203,7 +7203,7 @@
 */
 
 WandExport MagickBooleanType MagickMorphologyImage(MagickWand *wand,
-  MorphologyMethod method,const long iterations,KernelInfo *kernel)
+  MorphologyMethod method,const ssize_t iterations,KernelInfo *kernel)
 {
   MagickBooleanType
     status;
@@ -7214,7 +7214,7 @@
 }
 
 WandExport MagickBooleanType MagickMorphologyImageChannel(MagickWand *wand,
-  const ChannelType channel,MorphologyMethod method,const long iterations,
+  const ChannelType channel,MorphologyMethod method,const ssize_t iterations,
   KernelInfo *kernel)
 {
   Image
@@ -7272,7 +7272,7 @@
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 */
 
@@ -7387,7 +7387,7 @@
 %  The format of the MagickNewImage method is:
 %
 %      MagickBooleanType MagickNewImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,
+%        const size_t columns,const size_t rows,
 %        const PixelWand *background)
 %
 %  A description of each parameter follows:
@@ -7402,7 +7402,7 @@
 %
 */
 WandExport MagickBooleanType MagickNewImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,
+  const size_t width,const size_t height,
   const PixelWand *background)
 {
   Image
@@ -7945,7 +7945,7 @@
 %
 %    o drawing_wand: the draw wand.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 */
 WandExport MagickBooleanType MagickPolaroidImage(MagickWand *wand,
@@ -8003,7 +8003,7 @@
 %
 */
 WandExport MagickBooleanType MagickPosterizeImage(MagickWand *wand,
-  const unsigned long levels,const MagickBooleanType dither)
+  const size_t levels,const MagickBooleanType dither)
 {
   MagickBooleanType
     status;
@@ -8130,8 +8130,8 @@
 %  The format of the MagickQuantizeImage method is:
 %
 %      MagickBooleanType MagickQuantizeImage(MagickWand *wand,
-%        const unsigned long number_colors,const ColorspaceType colorspace,
-%        const unsigned long treedepth,const MagickBooleanType dither,
+%        const size_t number_colors,const ColorspaceType colorspace,
+%        const size_t treedepth,const MagickBooleanType dither,
 %        const MagickBooleanType measure_error)
 %
 %  A description of each parameter follows:
@@ -8153,7 +8153,7 @@
 %
 %    o dither: A value other than zero distributes the difference between an
 %      original image and the corresponding color reduced image to
-%      neighboring pixels along a Hilbert curve.
+%      neighboring pixels assize_t a Hilbert curve.
 %
 %    o measure_error: A value other than zero measures the difference between
 %      the original and quantized images.  This difference is the total
@@ -8163,8 +8163,8 @@
 %
 */
 WandExport MagickBooleanType MagickQuantizeImage(MagickWand *wand,
-  const unsigned long number_colors,const ColorspaceType colorspace,
-  const unsigned long treedepth,const MagickBooleanType dither,
+  const size_t number_colors,const ColorspaceType colorspace,
+  const size_t treedepth,const MagickBooleanType dither,
   const MagickBooleanType measure_error)
 {
   MagickBooleanType
@@ -8211,8 +8211,8 @@
 %  The format of the MagickQuantizeImages method is:
 %
 %      MagickBooleanType MagickQuantizeImages(MagickWand *wand,
-%        const unsigned long number_colors,const ColorspaceType colorspace,
-%        const unsigned long treedepth,const MagickBooleanType dither,
+%        const size_t number_colors,const ColorspaceType colorspace,
+%        const size_t treedepth,const MagickBooleanType dither,
 %        const MagickBooleanType measure_error)
 %
 %  A description of each parameter follows:
@@ -8234,7 +8234,7 @@
 %
 %    o dither: A value other than zero distributes the difference between an
 %      original image and the corresponding color reduced algorithm to
-%      neighboring pixels along a Hilbert curve.
+%      neighboring pixels assize_t a Hilbert curve.
 %
 %    o measure_error: A value other than zero measures the difference between
 %      the original and quantized images.  This difference is the total
@@ -8244,8 +8244,8 @@
 %
 */
 WandExport MagickBooleanType MagickQuantizeImages(MagickWand *wand,
-  const unsigned long number_colors,const ColorspaceType colorspace,
-  const unsigned long treedepth,const MagickBooleanType dither,
+  const size_t number_colors,const ColorspaceType colorspace,
+  const size_t treedepth,const MagickBooleanType dither,
   const MagickBooleanType measure_error)
 {
   MagickBooleanType
@@ -8351,8 +8351,8 @@
 %  The format of the MagickRaiseImage method is:
 %
 %      MagickBooleanType MagickRaiseImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y,const MagickBooleanType raise)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y,const MagickBooleanType raise)
 %
 %  A description of each parameter follows:
 %
@@ -8365,8 +8365,8 @@
 %
 */
 WandExport MagickBooleanType MagickRaiseImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y,const MagickBooleanType raise)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y,const MagickBooleanType raise)
 {
   MagickBooleanType
     status;
@@ -8869,7 +8869,7 @@
 %  The format of the MagickResizeImage method is:
 %
 %      MagickBooleanType MagickResizeImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,
+%        const size_t columns,const size_t rows,
 %        const FilterTypes filter,const double blur)
 %
 %  A description of each parameter follows:
@@ -8886,7 +8886,7 @@
 %
 */
 WandExport MagickBooleanType MagickResizeImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows,const FilterTypes filter,
+  const size_t columns,const size_t rows,const FilterTypes filter,
   const double blur)
 {
   Image
@@ -8921,8 +8921,8 @@
 %
 %  The format of the MagickRollImage method is:
 %
-%      MagickBooleanType MagickRollImage(MagickWand *wand,const long x,
-%        const unsigned long y)
+%      MagickBooleanType MagickRollImage(MagickWand *wand,const ssize_t x,
+%        const size_t y)
 %
 %  A description of each parameter follows:
 %
@@ -8935,7 +8935,7 @@
 %
 */
 WandExport MagickBooleanType MagickRollImage(MagickWand *wand,
-  const long x,const long y)
+  const ssize_t x,const ssize_t y)
 {
   Image
     *roll_image;
@@ -9021,7 +9021,7 @@
 %  The format of the MagickSampleImage method is:
 %
 %      MagickBooleanType MagickSampleImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -9034,7 +9034,7 @@
 %
 */
 WandExport MagickBooleanType MagickSampleImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Image
     *sample_image;
@@ -9068,7 +9068,7 @@
 %  The format of the MagickScaleImage method is:
 %
 %      MagickBooleanType MagickScaleImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -9081,7 +9081,7 @@
 %
 */
 WandExport MagickBooleanType MagickScaleImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Image
     *scale_image;
@@ -9582,7 +9582,7 @@
 %  The format of the MagickSetImageChannelDepth method is:
 %
 %      MagickBooleanType MagickSetImageChannelDepth(MagickWand *wand,
-%        const ChannelType channel,const unsigned long depth)
+%        const ChannelType channel,const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -9594,7 +9594,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageChannelDepth(MagickWand *wand,
-  const ChannelType channel,const unsigned long depth)
+  const ChannelType channel,const size_t depth)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -9708,7 +9708,7 @@
 %  The format of the MagickSetImageColormapColor method is:
 %
 %      MagickBooleanType MagickSetImageColormapColor(MagickWand *wand,
-%        const unsigned long index,const PixelWand *color)
+%        const size_t index,const PixelWand *color)
 %
 %  A description of each parameter follows:
 %
@@ -9720,7 +9720,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageColormapColor(MagickWand *wand,
-  const unsigned long index,const PixelWand *color)
+  const size_t index,const PixelWand *color)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -9870,7 +9870,7 @@
 %  The format of the MagickSetImageCompressionQuality method is:
 %
 %      MagickBooleanType MagickSetImageCompressionQuality(MagickWand *wand,
-%        const unsigned long quality)
+%        const size_t quality)
 %
 %  A description of each parameter follows:
 %
@@ -9880,7 +9880,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageCompressionQuality(MagickWand *wand,
-  const unsigned long quality)
+  const size_t quality)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -9908,7 +9908,7 @@
 %  The format of the MagickSetImageDelay method is:
 %
 %      MagickBooleanType MagickSetImageDelay(MagickWand *wand,
-%        const unsigned long delay)
+%        const size_t delay)
 %
 %  A description of each parameter follows:
 %
@@ -9918,7 +9918,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageDelay(MagickWand *wand,
-  const unsigned long delay)
+  const size_t delay)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -9946,7 +9946,7 @@
 %  The format of the MagickSetImageDepth method is:
 %
 %      MagickBooleanType MagickSetImageDepth(MagickWand *wand,
-%        const unsigned long depth)
+%        const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -9956,7 +9956,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageDepth(MagickWand *wand,
-  const unsigned long depth)
+  const size_t depth)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -10022,7 +10022,7 @@
 %  The format of the MagickSetImageExtent method is:
 %
 %      MagickBooleanType MagickSetImageExtent(MagickWand *wand,
-%        const unsigned long columns,const unsigned rows)
+%        const size_t columns,const unsigned rows)
 %
 %  A description of each parameter follows:
 %
@@ -10034,7 +10034,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageExtent(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -10388,7 +10388,7 @@
 %  The format of the MagickSetImageIterations method is:
 %
 %      MagickBooleanType MagickSetImageIterations(MagickWand *wand,
-%        const unsigned long iterations)
+%        const size_t iterations)
 %
 %  A description of each parameter follows:
 %
@@ -10398,7 +10398,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageIterations(MagickWand *wand,
-  const unsigned long iterations)
+  const size_t iterations)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -10588,8 +10588,8 @@
 %  The format of the MagickSetImagePage method is:
 %
 %      MagickBooleanType MagickSetImagePage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -10605,8 +10605,8 @@
 %
 */
 WandExport MagickBooleanType MagickSetImagePage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -10816,7 +10816,7 @@
 %  The format of the MagickSetImageScene method is:
 %
 %      MagickBooleanType MagickSetImageScene(MagickWand *wand,
-%        const unsigned long scene)
+%        const size_t scene)
 %
 %  A description of each parameter follows:
 %
@@ -10826,7 +10826,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageScene(MagickWand *wand,
-  const unsigned long scene)
+  const size_t scene)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -10854,7 +10854,7 @@
 %  The format of the MagickSetImageTicksPerSecond method is:
 %
 %      MagickBooleanType MagickSetImageTicksPerSecond(MagickWand *wand,
-%        const long ticks_per-second)
+%        const ssize_t ticks_per-second)
 %
 %  A description of each parameter follows:
 %
@@ -10864,7 +10864,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetImageTicksPerSecond(MagickWand *wand,
-  const long ticks_per_second)
+  const ssize_t ticks_per_second)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -11101,7 +11101,7 @@
 %  The format of the MagickShadowImage method is:
 %
 %      MagickBooleanType MagickShadowImage(MagickWand *wand,
-%        const double opacity,const double sigma,const long x,const long y)
+%        const double opacity,const double sigma,const ssize_t x,const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -11117,7 +11117,7 @@
 %
 */
 WandExport MagickBooleanType MagickShadowImage(MagickWand *wand,
-  const double opacity,const double sigma,const long x,const long y)
+  const double opacity,const double sigma,const ssize_t x,const ssize_t y)
 {
   Image
     *shadow_image;
@@ -11219,7 +11219,7 @@
 %  The format of the MagickShaveImage method is:
 %
 %      MagickBooleanType MagickShaveImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -11232,7 +11232,7 @@
 %
 */
 WandExport MagickBooleanType MagickShaveImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Image
     *shave_image;
@@ -11268,9 +11268,9 @@
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  MagickShearImage() slides one edge of an image along the X or Y axis,
-%  creating a parallelogram.  An X direction shear slides an edge along the X
-%  axis, while a Y direction shear slides an edge along the Y axis.  The amount
+%  MagickShearImage() slides one edge of an image assize_t the X or Y axis,
+%  creating a parallelogram.  An X direction shear slides an edge assize_t the X
+%  axis, while a Y direction shear slides an edge assize_t the Y axis.  The amount
 %  of the shear is controlled by a shear angle.  For X direction shears, x_shear
 %  is measured relative to the Y axis, and similarly, for Y direction shears
 %  y_shear is measured relative to the X axis.  Empty triangles left over from
@@ -11470,7 +11470,7 @@
 %
 %    o sigma: the standard deviation of the Gaussian, in pixels.
 %
-%    o angle: Apply the effect along this angle.
+%    o angle: Apply the effect assize_t this angle.
 %
 */
 WandExport MagickBooleanType MagickSketchImage(MagickWand *wand,
@@ -11557,7 +11557,7 @@
 %
 %      MagickBooleanType MagickSparseColorImage(MagickWand *wand,
 %        const ChannelType channel,const SparseColorMethod method,
-%        const unsigned long number_arguments,const double *arguments)
+%        const size_t number_arguments,const double *arguments)
 %
 %  A description of each parameter follows:
 %
@@ -11591,7 +11591,7 @@
 */
 WandExport MagickBooleanType MagickSparseColorImage(MagickWand *wand,
   const ChannelType channel,const SparseColorMethod method,
-  const unsigned long number_arguments,const double *arguments)
+  const size_t number_arguments,const double *arguments)
 {
   Image
     *sparse_image;
@@ -11626,8 +11626,8 @@
 %  The format of the MagickSpliceImage method is:
 %
 %      MagickBooleanType MagickSpliceImage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -11643,8 +11643,8 @@
 %
 */
 WandExport MagickBooleanType MagickSpliceImage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   Image
     *splice_image;
@@ -11732,7 +11732,7 @@
 %  The format of the MagickSteganoImage method is:
 %
 %      MagickWand *MagickSteganoImage(MagickWand *wand,
-%        const MagickWand *watermark_wand,const long offset)
+%        const MagickWand *watermark_wand,const ssize_t offset)
 %
 %  A description of each parameter follows:
 %
@@ -11744,7 +11744,7 @@
 %
 */
 WandExport MagickWand *MagickSteganoImage(MagickWand *wand,
-  const MagickWand *watermark_wand,const long offset)
+  const MagickWand *watermark_wand,const ssize_t offset)
 {
   Image
     *stegano_image;
@@ -12037,7 +12037,7 @@
 %  The format of the MagickThumbnailImage method is:
 %
 %      MagickBooleanType MagickThumbnailImage(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -12049,7 +12049,7 @@
 %
 */
 WandExport MagickBooleanType MagickThumbnailImage(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   Image
     *thumbnail_image;
@@ -12557,8 +12557,8 @@
 %  The format of the MagickVignetteImage method is:
 %
 %      MagickBooleanType MagickVignetteImage(MagickWand *wand,
-%        const double black_point,const double white_point,const long x,
-%        const long y)
+%        const double black_point,const double white_point,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -12572,7 +12572,7 @@
 %
 */
 WandExport MagickBooleanType MagickVignetteImage(MagickWand *wand,
-  const double black_point,const double white_point,const long x,const long y)
+  const double black_point,const double white_point,const ssize_t x,const ssize_t y)
 {
   Image
     *vignette_image;
@@ -12603,7 +12603,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  MagickWaveImage()  creates a "ripple" effect in the image by shifting
-%  the pixels vertically along a sine wave whose amplitude and wavelength
+%  the pixels vertically assize_t a sine wave whose amplitude and wavelength
 %  is specified by the given parameters.
 %
 %  The format of the MagickWaveImage method is:
diff --git a/wand/magick-image.h b/wand/magick-image.h
index 207f750..4edc373 100644
--- a/wand/magick-image.h
+++ b/wand/magick-image.h
@@ -24,7 +24,7 @@
 #endif
 
 extern WandExport ChannelFeatures
-  *MagickGetImageChannelFeatures(MagickWand *,const unsigned long);
+  *MagickGetImageChannelFeatures(MagickWand *,const size_t);
 
 extern WandExport ChannelStatistics
   *MagickGetImageChannelStatistics(MagickWand *);
@@ -74,13 +74,13 @@
   MagickAdaptiveBlurImage(MagickWand *,const double,const double),
   MagickAdaptiveBlurImageChannel(MagickWand *,const ChannelType,const double,
     const double),
-  MagickAdaptiveResizeImage(MagickWand *,const unsigned long,
-    const unsigned long),
+  MagickAdaptiveResizeImage(MagickWand *,const size_t,
+    const size_t),
   MagickAdaptiveSharpenImage(MagickWand *,const double,const double),
   MagickAdaptiveSharpenImageChannel(MagickWand *,const ChannelType,const double,
     const double),
-  MagickAdaptiveThresholdImage(MagickWand *,const unsigned long,
-    const unsigned long,const long),
+  MagickAdaptiveThresholdImage(MagickWand *,const size_t,
+    const size_t,const ssize_t),
   MagickAddImage(MagickWand *,const MagickWand *),
   MagickAddNoiseImage(MagickWand *,const NoiseType),
   MagickAddNoiseImageChannel(MagickWand *,const ChannelType,const NoiseType),
@@ -97,14 +97,14 @@
   MagickBlurImage(MagickWand *,const double,const double),
   MagickBlurImageChannel(MagickWand *,const ChannelType,const double,
     const double),
-  MagickBorderImage(MagickWand *,const PixelWand *,const unsigned long,
-    const unsigned long),
+  MagickBorderImage(MagickWand *,const PixelWand *,const size_t,
+    const size_t),
   MagickBrightnessContrastImage(MagickWand *,const double,const double),
   MagickBrightnessContrastImageChannel(MagickWand *,const ChannelType,
     const double,const double),
   MagickCharcoalImage(MagickWand *,const double,const double),
-  MagickChopImage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+  MagickChopImage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   MagickClampImage(MagickWand *),
   MagickClampImageChannel(MagickWand *,const ChannelType),
   MagickClipImage(MagickWand *),
@@ -116,26 +116,26 @@
   MagickColorMatrixImage(MagickWand *,const KernelInfo *),
   MagickCommentImage(MagickWand *,const char *),
   MagickCompositeImage(MagickWand *,const MagickWand *,const CompositeOperator,
-    const long,const long),
-  MagickCompositeImageChannel(MagickWand *,const ChannelType,const MagickWand *,    const CompositeOperator,const long,const long),
-  MagickConstituteImage(MagickWand *,const unsigned long,const unsigned long,
+    const ssize_t,const ssize_t),
+  MagickCompositeImageChannel(MagickWand *,const ChannelType,const MagickWand *,    const CompositeOperator,const ssize_t,const ssize_t),
+  MagickConstituteImage(MagickWand *,const size_t,const size_t,
     const char *,const StorageType,const void *),
   MagickContrastImage(MagickWand *,const MagickBooleanType),
   MagickContrastStretchImage(MagickWand *,const double,const double),
   MagickContrastStretchImageChannel(MagickWand *,const ChannelType,const double,
     const double),
-  MagickConvolveImage(MagickWand *,const unsigned long,const double *),
-  MagickConvolveImageChannel(MagickWand *,const ChannelType,const unsigned long,
+  MagickConvolveImage(MagickWand *,const size_t,const double *),
+  MagickConvolveImageChannel(MagickWand *,const ChannelType,const size_t,
     const double *),
-  MagickCropImage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
-  MagickCycleColormapImage(MagickWand *,const long),
+  MagickCropImage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
+  MagickCycleColormapImage(MagickWand *,const ssize_t),
   MagickDecipherImage(MagickWand *,const char *),
   MagickDeskewImage(MagickWand *,const double),
   MagickDespeckleImage(MagickWand *),
   MagickDisplayImage(MagickWand *,const char *),
   MagickDisplayImages(MagickWand *,const char *),
-  MagickDistortImage(MagickWand *,const DistortImageMethod,const unsigned long,
+  MagickDistortImage(MagickWand *,const DistortImageMethod,const size_t,
     const double *,const MagickBooleanType),
   MagickDrawImage(MagickWand *,const DrawingWand *),
   MagickEdgeImage(MagickWand *,const double),
@@ -147,25 +147,25 @@
   MagickEvaluateImage(MagickWand *,const MagickEvaluateOperator,const double),
   MagickEvaluateImageChannel(MagickWand *,const ChannelType,
     const MagickEvaluateOperator,const double),
-  MagickExportImagePixels(MagickWand *,const long,const long,
-    const unsigned long,const unsigned long,const char *,const StorageType,
+  MagickExportImagePixels(MagickWand *,const ssize_t,const ssize_t,
+    const size_t,const size_t,const char *,const StorageType,
     void *),
-  MagickExtentImage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+  MagickExtentImage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   MagickFilterImage(MagickWand *,const KernelInfo *),
   MagickFilterImageChannel(MagickWand *,const ChannelType,const KernelInfo *),
   MagickFlipImage(MagickWand *),
   MagickFloodfillPaintImage(MagickWand *,const ChannelType,const PixelWand *,
-    const double,const PixelWand *,const long,const long,
+    const double,const PixelWand *,const ssize_t,const ssize_t,
     const MagickBooleanType),
   MagickFlopImage(MagickWand *),
   MagickForwardFourierTransformImage(MagickWand *,const MagickBooleanType),
-  MagickFrameImage(MagickWand *,const PixelWand *,const unsigned long,
-    const unsigned long,const long,const long),
-  MagickFunctionImage(MagickWand *,const MagickFunction,const unsigned long,
+  MagickFrameImage(MagickWand *,const PixelWand *,const size_t,
+    const size_t,const ssize_t,const ssize_t),
+  MagickFunctionImage(MagickWand *,const MagickFunction,const size_t,
     const double *),
   MagickFunctionImageChannel(MagickWand *,const ChannelType,
-    const MagickFunction,const unsigned long,const double *),
+    const MagickFunction,const size_t,const double *),
   MagickGammaImage(MagickWand *,const double),
   MagickGammaImageChannel(MagickWand *,const ChannelType,const double),
   MagickGaussianBlurImage(MagickWand *,const double,const double),
@@ -181,15 +181,15 @@
     double *),
   MagickGetImageChannelMean(MagickWand *,const ChannelType,double *,double *),
   MagickGetImageChannelRange(MagickWand *,const ChannelType,double *,double *),
-  MagickGetImageColormapColor(MagickWand *,const unsigned long,PixelWand *),
+  MagickGetImageColormapColor(MagickWand *,const size_t,PixelWand *),
   MagickGetImageDistortion(MagickWand *,const MagickWand *,const MetricType,
     double *),
   MagickGetImageGreenPrimary(MagickWand *,double *,double *),
   MagickGetImageMatteColor(MagickWand *,PixelWand *),
   MagickGetImageLength(MagickWand *,MagickSizeType *),
-  MagickGetImagePage(MagickWand *,unsigned long *,unsigned long *,long *,
-    long *),
-  MagickGetImagePixelColor(MagickWand *,const long,const long,PixelWand *),
+  MagickGetImagePage(MagickWand *,size_t *,size_t *,ssize_t *,
+    ssize_t *),
+  MagickGetImagePixelColor(MagickWand *,const ssize_t,const ssize_t,PixelWand *),
   MagickGetImageRange(MagickWand *,double *,double *),
   MagickGetImageRedPrimary(MagickWand *,double *,double *),
   MagickGetImageResolution(MagickWand *,double *,double *),
@@ -199,8 +199,8 @@
   MagickHasNextImage(MagickWand *),
   MagickHasPreviousImage(MagickWand *),
   MagickImplodeImage(MagickWand *,const double),
-  MagickImportImagePixels(MagickWand *,const long,const long,
-    const unsigned long,const unsigned long,const char *,const StorageType,
+  MagickImportImagePixels(MagickWand *,const ssize_t,const ssize_t,
+    const size_t,const size_t,const char *,const StorageType,
     const void *),
   MagickInverseFourierTransformImage(MagickWand *,MagickWand *,
     const MagickBooleanType),
@@ -209,22 +209,22 @@
   MagickLevelImageChannel(MagickWand *,const ChannelType,const double,
     const double,const double),
   MagickLinearStretchImage(MagickWand *,const double,const double),
-  MagickLiquidRescaleImage(MagickWand *,const unsigned long,const unsigned long,
+  MagickLiquidRescaleImage(MagickWand *,const size_t,const size_t,
     const double,const double),
   MagickMagnifyImage(MagickWand *),
   MagickMedianFilterImage(MagickWand *,const double),
   MagickMinifyImage(MagickWand *),
   MagickModulateImage(MagickWand *,const double,const double,const double),
-  MagickMorphologyImage(MagickWand *,MorphologyMethod,const long,KernelInfo *),
+  MagickMorphologyImage(MagickWand *,MorphologyMethod,const ssize_t,KernelInfo *),
   MagickMorphologyImageChannel(MagickWand *,const ChannelType,MorphologyMethod,
-    const long,KernelInfo *),
+    const ssize_t,KernelInfo *),
   MagickMotionBlurImage(MagickWand *,const double,const double,const double),
   MagickMotionBlurImageChannel(MagickWand *,const ChannelType,const double,
     const double,const double),
   MagickNegateImage(MagickWand *,const MagickBooleanType),
   MagickNegateImageChannel(MagickWand *,const ChannelType,
     const MagickBooleanType),
-  MagickNewImage(MagickWand *,const unsigned long,const unsigned long,
+  MagickNewImage(MagickWand *,const size_t,const size_t,
     const PixelWand *),
   MagickNextImage(MagickWand *),
   MagickNormalizeImage(MagickWand *),
@@ -243,17 +243,17 @@
   MagickPingImageBlob(MagickWand *,const void *,const size_t),
   MagickPingImageFile(MagickWand *,FILE *),
   MagickPolaroidImage(MagickWand *,const DrawingWand *,const double),
-  MagickPosterizeImage(MagickWand *,const unsigned long,
+  MagickPosterizeImage(MagickWand *,const size_t,
     const MagickBooleanType),
   MagickPreviousImage(MagickWand *),
-  MagickQuantizeImage(MagickWand *,const unsigned long,const ColorspaceType,
-    const unsigned long,const MagickBooleanType,const MagickBooleanType),
-  MagickQuantizeImages(MagickWand *,const unsigned long,const ColorspaceType,
-    const unsigned long,const MagickBooleanType,const MagickBooleanType),
+  MagickQuantizeImage(MagickWand *,const size_t,const ColorspaceType,
+    const size_t,const MagickBooleanType,const MagickBooleanType),
+  MagickQuantizeImages(MagickWand *,const size_t,const ColorspaceType,
+    const size_t,const MagickBooleanType,const MagickBooleanType),
   MagickRadialBlurImage(MagickWand *,const double),
   MagickRadialBlurImageChannel(MagickWand *,const ChannelType,const double),
-  MagickRaiseImage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long,const MagickBooleanType),
+  MagickRaiseImage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t,const MagickBooleanType),
   MagickRandomThresholdImage(MagickWand *,const double,const double),
   MagickRandomThresholdImageChannel(MagickWand *,const ChannelType,const double,
     const double),
@@ -266,12 +266,12 @@
   MagickResampleImage(MagickWand *,const double,const double,const FilterTypes,
     const double),
   MagickResetImagePage(MagickWand *,const char *),
-  MagickResizeImage(MagickWand *,const unsigned long,const unsigned long,
+  MagickResizeImage(MagickWand *,const size_t,const size_t,
     const FilterTypes,const double),
-  MagickRollImage(MagickWand *,const long,const long),
+  MagickRollImage(MagickWand *,const ssize_t,const ssize_t),
   MagickRotateImage(MagickWand *,const PixelWand *,const double),
-  MagickSampleImage(MagickWand *,const unsigned long,const unsigned long),
-  MagickScaleImage(MagickWand *,const unsigned long,const unsigned long),
+  MagickSampleImage(MagickWand *,const size_t,const size_t),
+  MagickScaleImage(MagickWand *,const size_t,const size_t),
   MagickSegmentImage(MagickWand *,const ColorspaceType,const MagickBooleanType,
     const double,const double),
   MagickSelectiveBlurImage(MagickWand *,const double,const double,const double),
@@ -286,19 +286,19 @@
   MagickSetImageBluePrimary(MagickWand *,const double,const double),
   MagickSetImageBorderColor(MagickWand *,const PixelWand *),
   MagickSetImageChannelDepth(MagickWand *,const ChannelType,
-    const unsigned long),
+    const size_t),
   MagickSetImageClipMask(MagickWand *,const MagickWand *),
   MagickSetImageColor(MagickWand *,const PixelWand *),
-  MagickSetImageColormapColor(MagickWand *,const unsigned long,
+  MagickSetImageColormapColor(MagickWand *,const size_t,
     const PixelWand *),
   MagickSetImageColorspace(MagickWand *,const ColorspaceType),
   MagickSetImageCompose(MagickWand *,const CompositeOperator),
   MagickSetImageCompression(MagickWand *,const CompressionType),
-  MagickSetImageDelay(MagickWand *,const unsigned long),
-  MagickSetImageDepth(MagickWand *,const unsigned long),
+  MagickSetImageDelay(MagickWand *,const size_t),
+  MagickSetImageDepth(MagickWand *,const size_t),
   MagickSetImageDispose(MagickWand *,const DisposeType),
-  MagickSetImageCompressionQuality(MagickWand *,const unsigned long),
-  MagickSetImageExtent(MagickWand *,const unsigned long,const unsigned long),
+  MagickSetImageCompressionQuality(MagickWand *,const size_t),
+  MagickSetImageExtent(MagickWand *,const size_t,const size_t),
   MagickSetImageFilename(MagickWand *,const char *),
   MagickSetImageFormat(MagickWand *,const char *),
   MagickSetImageFuzz(MagickWand *,const double),
@@ -307,29 +307,29 @@
   MagickSetImageGreenPrimary(MagickWand *,const double,const double),
   MagickSetImageInterlaceScheme(MagickWand *,const InterlaceType),
   MagickSetImageInterpolateMethod(MagickWand *,const InterpolatePixelMethod),
-  MagickSetImageIterations(MagickWand *,const unsigned long),
+  MagickSetImageIterations(MagickWand *,const size_t),
   MagickSetImageMatte(MagickWand *,const MagickBooleanType),
   MagickSetImageMatteColor(MagickWand *,const PixelWand *),
   MagickSetImageOpacity(MagickWand *,const double),
   MagickSetImageOrientation(MagickWand *,const OrientationType),
-  MagickSetImagePage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+  MagickSetImagePage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   MagickSetImageRedPrimary(MagickWand *,const double,const double),
   MagickSetImageRenderingIntent(MagickWand *,const RenderingIntent),
   MagickSetImageResolution(MagickWand *,const double,const double),
-  MagickSetImageScene(MagickWand *,const unsigned long),
-  MagickSetImageTicksPerSecond(MagickWand *,const long),
+  MagickSetImageScene(MagickWand *,const size_t),
+  MagickSetImageTicksPerSecond(MagickWand *,const ssize_t),
   MagickSetImageType(MagickWand *,const ImageType),
   MagickSetImageUnits(MagickWand *,const ResolutionType),
   MagickSetImageWhitePoint(MagickWand *,const double,const double),
   MagickShadeImage(MagickWand *,const MagickBooleanType,const double,
     const double),
-  MagickShadowImage(MagickWand *,const double,const double,const long,
-    const long),
+  MagickShadowImage(MagickWand *,const double,const double,const ssize_t,
+    const ssize_t),
   MagickSharpenImage(MagickWand *,const double,const double),
   MagickSharpenImageChannel(MagickWand *,const ChannelType,const double,
     const double),
-  MagickShaveImage(MagickWand *,const unsigned long,const unsigned long),
+  MagickShaveImage(MagickWand *,const size_t,const size_t),
   MagickShearImage(MagickWand *,const PixelWand *,const double,const double),
   MagickSigmoidalContrastImage(MagickWand *,const MagickBooleanType,
     const double,const double),
@@ -338,9 +338,9 @@
   MagickSketchImage(MagickWand *,const double,const double,const double),
   MagickSolarizeImage(MagickWand *,const double),
   MagickSparseColorImage(MagickWand *,const ChannelType,const SparseColorMethod,
-    const unsigned long,const double *),
-  MagickSpliceImage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+    const size_t,const double *),
+  MagickSpliceImage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   MagickSpreadImage(MagickWand *,const double),
   MagickStripImage(MagickWand *),
   MagickSwirlImage(MagickWand *,const double),
@@ -350,7 +350,7 @@
   MagickTransverseImage(MagickWand *),
   MagickThresholdImage(MagickWand *,const double),
   MagickThresholdImageChannel(MagickWand *,const ChannelType,const double),
-  MagickThumbnailImage(MagickWand *,const unsigned long,const unsigned long),
+  MagickThumbnailImage(MagickWand *,const size_t,const size_t),
   MagickTrimImage(MagickWand *,const double),
   MagickUniqueImageColors(MagickWand *),
   MagickUnsharpMaskImage(MagickWand *,const double,const double,const double,
@@ -358,7 +358,7 @@
   MagickUnsharpMaskImageChannel(MagickWand *,const ChannelType,const double,
     const double,const double,const double),
   MagickVignetteImage(MagickWand *,const double,const double,
-    const long,const long),
+    const ssize_t,const ssize_t),
   MagickWaveImage(MagickWand *,const double,const double),
   MagickWhiteThresholdImage(MagickWand *,const PixelWand *),
   MagickWriteImage(MagickWand *,const char *),
@@ -385,17 +385,17 @@
   *MagickFxImageChannel(MagickWand *,const ChannelType,const char *),
   *MagickGetImage(MagickWand *),
   *MagickGetImageClipMask(MagickWand *),
-  *MagickGetImageRegion(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+  *MagickGetImageRegion(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   *MagickMergeImageLayers(MagickWand *,const ImageLayerMethod),
-  *MagickMorphImages(MagickWand *,const unsigned long),
+  *MagickMorphImages(MagickWand *,const size_t),
   *MagickMontageImage(MagickWand *,const DrawingWand *,const char *,
     const char *,const MontageMode,const char *),
   *MagickOptimizeImageLayers(MagickWand *),
   *MagickPreviewImages(MagickWand *wand,const PreviewType),
   *MagickSimilarityImage(MagickWand *,const MagickWand *,RectangleInfo *,
     double *),
-  *MagickSteganoImage(MagickWand *,const MagickWand *,const long),
+  *MagickSteganoImage(MagickWand *,const MagickWand *,const ssize_t),
   *MagickStereoImage(MagickWand *,const MagickWand *),
   *MagickTextureImage(MagickWand *,const MagickWand *),
   *MagickTransformImage(MagickWand *,const char *,const char *);
@@ -404,7 +404,7 @@
   MagickGetImageOrientation(MagickWand *);
 
 extern WandExport PixelWand
-  **MagickGetImageHistogram(MagickWand *,unsigned long *);
+  **MagickGetImageHistogram(MagickWand *,size_t *);
 
 extern WandExport RenderingIntent
   MagickGetImageRenderingIntent(MagickWand *);
@@ -416,7 +416,7 @@
   *MagickGetImageBlob(MagickWand *,size_t *),
   *MagickGetImagesBlob(MagickWand *,size_t *);
 
-extern WandExport unsigned long
+extern WandExport size_t
   MagickGetImageColors(MagickWand *),
   MagickGetImageCompressionQuality(MagickWand *),
   MagickGetImageDelay(MagickWand *),
diff --git a/wand/magick-property.c b/wand/magick-property.c
index 3f7ff2d..0a5f300 100644
--- a/wand/magick-property.c
+++ b/wand/magick-property.c
@@ -324,14 +324,14 @@
 %
 %  The format of the MagickGetCompressionQuality method is:
 %
-%      unsigned long MagickGetCompressionQuality(MagickWand *wand)
+%      size_t MagickGetCompressionQuality(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport unsigned long MagickGetCompressionQuality(MagickWand *wand)
+WandExport size_t MagickGetCompressionQuality(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -589,7 +589,7 @@
 %  The format of the MagickGetImageArtifacts method is:
 %
 %      char *MagickGetImageArtifacts(MagickWand *wand,
-%        const char *pattern,unsigned long *number_artifacts)
+%        const char *pattern,size_t *number_artifacts)
 %
 %  A description of each parameter follows:
 %
@@ -601,7 +601,7 @@
 %
 */
 WandExport char **MagickGetImageArtifacts(MagickWand *wand,
-  const char *pattern,unsigned long *number_artifacts)
+  const char *pattern,size_t *number_artifacts)
 {
   char
     **artifacts;
@@ -609,7 +609,7 @@
   const char
     *artifact;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -637,7 +637,7 @@
     if ((*artifact != '[') &&
         (GlobExpression(artifact,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             artifacts=(char **) ResizeQuantumMemory(artifacts,length,
@@ -656,7 +656,7 @@
     artifact=GetNextImageProperty(wand->images);
   }
   artifacts[i]=(char *) NULL;
-  *number_artifacts=(unsigned long) i;
+  *number_artifacts=(size_t) i;
   return(artifacts);
 }
 
@@ -718,7 +718,7 @@
     return((unsigned char *) NULL);
   (void) CopyMagickMemory(datum,GetStringInfoDatum(profile),
     GetStringInfoLength(profile));
-  *length=(unsigned long) GetStringInfoLength(profile);
+  *length=(size_t) GetStringInfoLength(profile);
   return(datum);
 }
 
@@ -741,7 +741,7 @@
 %  The format of the MagickGetImageProfiles method is:
 %
 %      char *MagickGetImageProfiles(MagickWand *wand,
-%        unsigned long *number_profiles)
+%        size_t *number_profiles)
 %
 %  A description of each parameter follows:
 %
@@ -753,7 +753,7 @@
 %
 */
 WandExport char **MagickGetImageProfiles(MagickWand *wand,const char *pattern,
-  unsigned long *number_profiles)
+  size_t *number_profiles)
 {
   char
     **profiles;
@@ -761,7 +761,7 @@
   const char
     *property;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -789,7 +789,7 @@
     if ((*property != '[') &&
         (GlobExpression(property,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             profiles=(char **) ResizeQuantumMemory(profiles,length,
@@ -808,7 +808,7 @@
     property=GetNextImageProfile(wand->images);
   }
   profiles[i]=(char *) NULL;
-  *number_profiles=(unsigned long) i;
+  *number_profiles=(size_t) i;
   return(profiles);
 }
 
@@ -878,7 +878,7 @@
 %  The format of the MagickGetImageProperties method is:
 %
 %      char *MagickGetImageProperties(MagickWand *wand,
-%        const char *pattern,unsigned long *number_properties)
+%        const char *pattern,size_t *number_properties)
 %
 %  A description of each parameter follows:
 %
@@ -890,7 +890,7 @@
 %
 */
 WandExport char **MagickGetImageProperties(MagickWand *wand,
-  const char *pattern,unsigned long *number_properties)
+  const char *pattern,size_t *number_properties)
 {
   char
     **properties;
@@ -898,7 +898,7 @@
   const char
     *property;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -926,7 +926,7 @@
     if ((*property != '[') &&
         (GlobExpression(property,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             properties=(char **) ResizeQuantumMemory(properties,length,
@@ -945,7 +945,7 @@
     property=GetNextImageProperty(wand->images);
   }
   properties[i]=(char *) NULL;
-  *number_properties=(unsigned long) i;
+  *number_properties=(size_t) i;
   return(properties);
 }
 
@@ -1079,7 +1079,7 @@
 %
 %  The format of the MagickGetOptions method is:
 %
-%      char *MagickGetOptions(MagickWand *wand,unsigned long *number_options)
+%      char *MagickGetOptions(MagickWand *wand,size_t *number_options)
 %
 %  A description of each parameter follows:
 %
@@ -1091,7 +1091,7 @@
 %
 */
 WandExport char **MagickGetOptions(MagickWand *wand,const char *pattern,
-  unsigned long *number_options)
+  size_t *number_options)
 {
   char
     **options;
@@ -1099,7 +1099,7 @@
   const char
     *option;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -1126,7 +1126,7 @@
     if ((*option != '[') &&
         (GlobExpression(option,pattern,MagickFalse) != MagickFalse))
       {
-        if ((i+1) >= (long) length)
+        if ((i+1) >= (ssize_t) length)
           {
             length<<=1;
             options=(char **) ResizeQuantumMemory(options,length,
@@ -1145,7 +1145,7 @@
     option=GetNextImageOption(wand->image_info);
   }
   options[i]=(char *) NULL;
-  *number_options=(unsigned long) i;
+  *number_options=(size_t) i;
   return(options);
 }
 
@@ -1221,7 +1221,7 @@
 %  The format of the MagickGetPage method is:
 %
 %      MagickBooleanType MagickGetPage(const MagickWand *wand,
-%        unsigned long *width,unsigned long *height,long *x,long *y)
+%        size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 %
 %  A description of each parameter follows:
 %
@@ -1237,7 +1237,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetPage(const MagickWand *wand,
-  unsigned long *width,unsigned long *height,long *x,long *y)
+  size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 {
   RectangleInfo
     geometry;
@@ -1303,14 +1303,14 @@
 %
 %  The format of the MagickGetQuantumDepth method is:
 %
-%      const char *MagickGetQuantumDepth(unsigned long *depth)
+%      const char *MagickGetQuantumDepth(size_t *depth)
 %
 %  A description of each parameter follows:
 %
 %    o depth: the quantum depth is returned as a number.
 %
 */
-WandExport const char *MagickGetQuantumDepth(unsigned long *depth)
+WandExport const char *MagickGetQuantumDepth(size_t *depth)
 {
   return(GetMagickQuantumDepth(depth));
 }
@@ -1331,14 +1331,14 @@
 %
 %  The format of the MagickGetQuantumRange method is:
 %
-%      const char *MagickGetQuantumRange(unsigned long *range)
+%      const char *MagickGetQuantumRange(size_t *range)
 %
 %  A description of each parameter follows:
 %
 %    o range: the quantum range is returned as a number.
 %
 */
-WandExport const char *MagickGetQuantumRange(unsigned long *range)
+WandExport const char *MagickGetQuantumRange(size_t *range)
 {
   return(GetMagickQuantumRange(range));
 }
@@ -1437,7 +1437,7 @@
 %  The format of the MagickGetSamplingFactors method is:
 %
 %      double *MagickGetSamplingFactor(MagickWand *wand,
-%        unsigned long *number_factors)
+%        size_t *number_factors)
 %
 %  A description of each parameter follows:
 %
@@ -1447,7 +1447,7 @@
 %
 */
 WandExport double *MagickGetSamplingFactors(MagickWand *wand,
-  unsigned long *number_factors)
+  size_t *number_factors)
 {
   double
     *sampling_factors;
@@ -1455,7 +1455,7 @@
   register const char
     *p;
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (MagickWand *) NULL);
@@ -1488,7 +1488,7 @@
     sampling_factors[i]=StringToDouble(p);
     i++;
   }
-  *number_factors=(unsigned long) i;
+  *number_factors=(size_t) i;
   return(sampling_factors);
 }
 
@@ -1508,7 +1508,7 @@
 %  The format of the MagickGetSize method is:
 %
 %      MagickBooleanType MagickGetSize(const MagickWand *wand,
-%        unsigned long *columns,unsigned long *rows)
+%        size_t *columns,size_t *rows)
 %
 %  A description of each parameter follows:
 %
@@ -1520,7 +1520,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetSize(const MagickWand *wand,
-  unsigned long *columns,unsigned long *rows)
+  size_t *columns,size_t *rows)
 {
   RectangleInfo
     geometry;
@@ -1553,7 +1553,7 @@
 %  The format of the MagickGetSizeOffset method is:
 %
 %      MagickBooleanType MagickGetSizeOffset(const MagickWand *wand,
-%        long *offset)
+%        ssize_t *offset)
 %
 %  A description of each parameter follows:
 %
@@ -1563,7 +1563,7 @@
 %
 */
 WandExport MagickBooleanType MagickGetSizeOffset(const MagickWand *wand,
-  long *offset)
+  ssize_t *offset)
 {
   RectangleInfo
     geometry;
@@ -1625,14 +1625,14 @@
 %
 %  The format of the MagickGetVersion method is:
 %
-%      const char *MagickGetVersion(unsigned long *version)
+%      const char *MagickGetVersion(size_t *version)
 %
 %  A description of each parameter follows:
 %
 %    o version: the ImageMagick version is returned as a number.
 %
 */
-WandExport const char *MagickGetVersion(unsigned long *version)
+WandExport const char *MagickGetVersion(size_t *version)
 {
   return(GetMagickVersion(version));
 }
@@ -1908,7 +1908,7 @@
 %  The format of the MagickSetCompressionQuality method is:
 %
 %      MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
-%        const unsigned long quality)
+%        const size_t quality)
 %
 %  A description of each parameter follows:
 %
@@ -1918,7 +1918,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
-  const unsigned long quality)
+  const size_t quality)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -1944,7 +1944,7 @@
 %  The format of the MagickSetDepth method is:
 %
 %      MagickBooleanType MagickSetDepth(MagickWand *wand,
-%        const unsigned long depth)
+%        const size_t depth)
 %
 %  A description of each parameter follows:
 %
@@ -1954,7 +1954,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetDepth(MagickWand *wand,
-  const unsigned long depth)
+  const size_t depth)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -2159,7 +2159,7 @@
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   status=SetImageOption(wand->image_info,"gravity",MagickOptionToMnemonic(
-    MagickGravityOptions,(long) type));
+    MagickGravityOptions,(ssize_t) type));
   return(status);
 }
 
@@ -2382,7 +2382,7 @@
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   status=SetImageOption(wand->image_info,"interpolate",
-    MagickOptionToMnemonic(MagickInterpolateOptions,(long) method));
+    MagickOptionToMnemonic(MagickInterpolateOptions,(ssize_t) method));
   return(status);
 }
 
@@ -2476,8 +2476,8 @@
 %  The format of the MagickSetPage method is:
 %
 %      MagickBooleanType MagickSetPage(MagickWand *wand,
-%        const unsigned long width,const unsigned long height,const long x,
-%        const long y)
+%        const size_t width,const size_t height,const ssize_t x,
+%        const ssize_t y)
 %
 %  A description of each parameter follows:
 %
@@ -2493,8 +2493,8 @@
 %
 */
 WandExport MagickBooleanType MagickSetPage(MagickWand *wand,
-  const unsigned long width,const unsigned long height,const long x,
-  const long y)
+  const size_t width,const size_t height,const ssize_t x,
+  const ssize_t y)
 {
   char
     geometry[MaxTextExtent];
@@ -2725,7 +2725,7 @@
 %  The format of the MagickSetSamplingFactors method is:
 %
 %      MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
-%        const unsigned long number_factors,const double *sampling_factors)
+%        const size_t number_factors,const double *sampling_factors)
 %
 %  A description of each parameter follows:
 %
@@ -2738,12 +2738,12 @@
 %
 */
 WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
-  const unsigned long number_factors,const double *sampling_factors)
+  const size_t number_factors,const double *sampling_factors)
 {
   char
     sampling_factor[MaxTextExtent];
 
-  register long
+  register ssize_t
     i;
 
   assert(wand != (MagickWand *) NULL);
@@ -2755,7 +2755,7 @@
       RelinquishMagickMemory(wand->image_info->sampling_factor);
   if (number_factors == 0)
     return(MagickTrue);
-  for (i=0; i < (long) (number_factors-1); i++)
+  for (i=0; i < (ssize_t) (number_factors-1); i++)
   {
     (void) FormatMagickString(sampling_factor,MaxTextExtent,"%g,",
       sampling_factors[i]);
@@ -2785,7 +2785,7 @@
 %  The format of the MagickSetSize method is:
 %
 %      MagickBooleanType MagickSetSize(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows)
+%        const size_t columns,const size_t rows)
 %
 %  A description of each parameter follows:
 %
@@ -2797,7 +2797,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetSize(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows)
+  const size_t columns,const size_t rows)
 {
   char
     geometry[MaxTextExtent];
@@ -2828,8 +2828,8 @@
 %  The format of the MagickSetSizeOffset method is:
 %
 %      MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
-%        const unsigned long columns,const unsigned long rows,
-%        const long offset)
+%        const size_t columns,const size_t rows,
+%        const ssize_t offset)
 %
 %  A description of each parameter follows:
 %
@@ -2843,7 +2843,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
-  const unsigned long columns,const unsigned long rows,const long offset)
+  const size_t columns,const size_t rows,const ssize_t offset)
 {
   char
     geometry[MaxTextExtent];
diff --git a/wand/magick-property.h b/wand/magick-property.h
index ca6141b..c399ae6 100644
--- a/wand/magick-property.h
+++ b/wand/magick-property.h
@@ -29,16 +29,16 @@
   *MagickGetFont(MagickWand *),
   *MagickGetHomeURL(void),
   *MagickGetImageArtifact(MagickWand *,const char *),
-  **MagickGetImageArtifacts(MagickWand *,const char *,unsigned long *),
-  **MagickGetImageProfiles(MagickWand *,const char *,unsigned long *),
+  **MagickGetImageArtifacts(MagickWand *,const char *,size_t *),
+  **MagickGetImageProfiles(MagickWand *,const char *,size_t *),
   *MagickGetImageProperty(MagickWand *,const char *),
-  **MagickGetImageProperties(MagickWand *,const char *,unsigned long *),
+  **MagickGetImageProperties(MagickWand *,const char *,size_t *),
   *MagickGetOption(MagickWand *,const char *),
-  **MagickGetOptions(MagickWand *,const char *,unsigned long *),
+  **MagickGetOptions(MagickWand *,const char *,size_t *),
   *MagickQueryConfigureOption(const char *),
-  **MagickQueryConfigureOptions(const char *,unsigned long *),
-  **MagickQueryFonts(const char *,unsigned long *),
-  **MagickQueryFormats(const char *,unsigned long *);
+  **MagickQueryConfigureOptions(const char *,size_t *),
+  **MagickQueryFonts(const char *,size_t *),
+  **MagickQueryFormats(const char *,size_t *);
 
 extern WandExport ColorspaceType
   MagickGetColorspace(MagickWand *);
@@ -49,14 +49,14 @@
 extern WandExport const char
   *MagickGetCopyright(void),
   *MagickGetPackageName(void),
-  *MagickGetQuantumDepth(unsigned long *),
-  *MagickGetQuantumRange(unsigned long *),
+  *MagickGetQuantumDepth(size_t *),
+  *MagickGetQuantumRange(size_t *),
   *MagickGetReleaseDate(void),
-  *MagickGetVersion(unsigned long *);
+  *MagickGetVersion(size_t *);
 
 extern WandExport double
   MagickGetPointsize(MagickWand *),
-  *MagickGetSamplingFactors(MagickWand *,unsigned long *),
+  *MagickGetSamplingFactors(MagickWand *,size_t *),
   *MagickQueryFontMetrics(MagickWand *,const DrawingWand *,const char *),
   *MagickQueryMultilineFontMetrics(MagickWand *,const DrawingWand *,
     const char *);
@@ -81,17 +81,17 @@
   MagickDeleteImageProperty(MagickWand *,const char *),
   MagickDeleteOption(MagickWand *,const char *),
   MagickGetAntialias(const MagickWand *),
-  MagickGetPage(const MagickWand *,unsigned long *,unsigned long *,long *,
-    long *),
-  MagickGetSize(const MagickWand *,unsigned long *,unsigned long *),
-  MagickGetSizeOffset(const MagickWand *,long *),
+  MagickGetPage(const MagickWand *,size_t *,size_t *,ssize_t *,
+    ssize_t *),
+  MagickGetSize(const MagickWand *,size_t *,size_t *),
+  MagickGetSizeOffset(const MagickWand *,ssize_t *),
   MagickProfileImage(MagickWand *,const char *,const void *,const size_t),
   MagickSetAntialias(MagickWand *,const MagickBooleanType),
   MagickSetBackgroundColor(MagickWand *,const PixelWand *),
   MagickSetColorspace(MagickWand *,const ColorspaceType),
   MagickSetCompression(MagickWand *,const CompressionType),
-  MagickSetCompressionQuality(MagickWand *,const unsigned long),
-  MagickSetDepth(MagickWand *,const unsigned long),
+  MagickSetCompressionQuality(MagickWand *,const size_t),
+  MagickSetDepth(MagickWand *,const size_t),
   MagickSetExtract(MagickWand *,const char *),
   MagickSetFilename(MagickWand *,const char *),
   MagickSetFormat(MagickWand *,const char *),
@@ -104,16 +104,16 @@
   MagickSetInterpolateMethod(MagickWand *,const InterpolatePixelMethod),
   MagickSetOption(MagickWand *,const char *,const char *),
   MagickSetOrientation(MagickWand *,const OrientationType),
-  MagickSetPage(MagickWand *,const unsigned long,const unsigned long,
-    const long,const long),
+  MagickSetPage(MagickWand *,const size_t,const size_t,
+    const ssize_t,const ssize_t),
   MagickSetPassphrase(MagickWand *,const char *),
   MagickSetPointsize(MagickWand *,const double),
   MagickSetResolution(MagickWand *,const double,const double),
   MagickSetResourceLimit(const ResourceType type,const MagickSizeType limit),
-  MagickSetSamplingFactors(MagickWand *,const unsigned long,const double *),
-  MagickSetSize(MagickWand *,const unsigned long,const unsigned long),
-  MagickSetSizeOffset(MagickWand *,const unsigned long,const unsigned long,
-    const long),
+  MagickSetSamplingFactors(MagickWand *,const size_t,const double *),
+  MagickSetSize(MagickWand *,const size_t,const size_t),
+  MagickSetSizeOffset(MagickWand *,const size_t,const size_t,
+    const ssize_t),
   MagickSetType(MagickWand *,const ImageType);
 
 extern WandExport MagickProgressMonitor
@@ -133,7 +133,7 @@
   *MagickGetImageProfile(MagickWand *,const char *,size_t *),
   *MagickRemoveImageProfile(MagickWand *,const char *,size_t *);
 
-extern WandExport unsigned long
+extern WandExport size_t
   MagickGetCompressionQuality(MagickWand *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/wand/magick-wand-private.h b/wand/magick-wand-private.h
index 4f3d19e..59f9648 100644
--- a/wand/magick-wand-private.h
+++ b/wand/magick-wand-private.h
@@ -33,7 +33,7 @@
 
 struct _MagickWand
 {
-  unsigned long
+  size_t
     id;
 
   char
@@ -56,7 +56,7 @@
     pend,
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
diff --git a/wand/magick-wand.c b/wand/magick-wand.c
index 82f6ce8..8f8e516 100644
--- a/wand/magick-wand.c
+++ b/wand/magick-wand.c
@@ -359,14 +359,14 @@
 %
 %  The format of the MagickGetIteratorIndex method is:
 %
-%      long MagickGetIteratorIndex(MagickWand *wand)
+%      ssize_t MagickGetIteratorIndex(MagickWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the magick wand.
 %
 */
-WandExport long MagickGetIteratorIndex(MagickWand *wand)
+WandExport ssize_t MagickGetIteratorIndex(MagickWand *wand)
 {
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -415,7 +415,7 @@
   ExceptionInfo
     *exception;
 
-  unsigned long
+  size_t
     number_options;
 
   exception=AcquireExceptionInfo();
@@ -447,7 +447,7 @@
 %  The format of the MagickQueryConfigureOptions function is:
 %
 %      char **MagickQueryConfigureOptions(const char *pattern,
-%        unsigned long *number_options)
+%        size_t *number_options)
 %
 %  A description of each parameter follows:
 %
@@ -458,7 +458,7 @@
 %
 */
 WandExport char **MagickQueryConfigureOptions(const char *pattern,
-  unsigned long *number_options)
+  size_t *number_options)
 {
   char
     **options;
@@ -701,7 +701,7 @@
 %
 %  The format of the MagickQueryFonts function is:
 %
-%      char **MagickQueryFonts(const char *pattern,unsigned long *number_fonts)
+%      char **MagickQueryFonts(const char *pattern,size_t *number_fonts)
 %
 %  A description of each parameter follows:
 %
@@ -712,7 +712,7 @@
 %
 */
 WandExport char **MagickQueryFonts(const char *pattern,
-  unsigned long *number_fonts)
+  size_t *number_fonts)
 {
   char
     **fonts;
@@ -743,7 +743,7 @@
 %  The format of the MagickQueryFonts function is:
 %
 %      char **MagickQueryFonts(const char *pattern,
-%        unsigned long *number_formats)
+%        size_t *number_formats)
 %
 %  A description of each parameter follows:
 %
@@ -754,7 +754,7 @@
 %
 */
 WandExport char **MagickQueryFormats(const char *pattern,
-  unsigned long *number_formats)
+  size_t *number_formats)
 {
   char
     **formats;
@@ -882,7 +882,7 @@
 %  The format of the MagickSetIteratorIndex method is:
 %
 %      MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
-%        const long index)
+%        const ssize_t index)
 %
 %  A description of each parameter follows:
 %
@@ -892,7 +892,7 @@
 %
 */
 WandExport MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
-  const long index)
+  const ssize_t index)
 {
   Image
     *image;
@@ -1021,7 +1021,7 @@
   MagickWand
     *wand;
 
-  unsigned long
+  size_t
     depth;
 
   depth=MAGICKCORE_QUANTUM_DEPTH;
diff --git a/wand/mogrify.c b/wand/mogrify.c
index 48c9f7b..0bb4c58 100644
--- a/wand/mogrify.c
+++ b/wand/mogrify.c
@@ -117,13 +117,13 @@
     regard_warnings,
     status;
 
-  register long
+  register ssize_t
     i;
 
   TimerInfo
     *timer;
 
-  unsigned long
+  size_t
     iterations;
 
   (void) setlocale(LC_ALL,"");
@@ -133,7 +133,7 @@
   iterations=1;
   status=MagickFalse;
   regard_warnings=MagickFalse;
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
@@ -152,7 +152,7 @@
   timer=AcquireTimerInfo();
   if (concurrent == MagickFalse)
     {
-      for (i=0; i < (long) iterations; i++)
+      for (i=0; i < (ssize_t) iterations; i++)
       {
         if (status != MagickFalse)
           continue;
@@ -184,7 +184,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   # pragma omp parallel for shared(status)
 #endif
-      for (i=0; i < (long) iterations; i++)
+      for (i=0; i < (ssize_t) iterations; i++)
       {
         if (status != MagickFalse)
           continue;
@@ -221,9 +221,9 @@
       user_time=GetUserTime(timer);
       (void) fprintf(stderr,
         "Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",
-        iterations,1.0*iterations/elapsed_time,user_time,(long)
-        (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
-        (long) (1000.0*(elapsed_time-floor(elapsed_time))));
+        iterations,1.0*iterations/elapsed_time,user_time,(ssize_t)
+        (elapsed_time/60.0),(ssize_t) floor(fmod(elapsed_time,60.0)),
+        (ssize_t) (1000.0*(elapsed_time-floor(elapsed_time))));
     }
   timer=DestroyTimerInfo(timer);
   return(status);
@@ -303,7 +303,7 @@
   return(MagickTrue);
 }
 
-static inline long MagickMax(const long x,const long y)
+static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
 {
   if (x > y)
     return(x);
@@ -336,10 +336,10 @@
     locale_message=tag;
   if (p == (char *) NULL)
     (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
-      (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
+      (ssize_t) offset,(size_t) extent,(ssize_t) (100L*offset/(extent-1)));
   else
     (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
-      locale_message,p+1,(long) offset,(unsigned long) extent,(long)
+      locale_message,p+1,(ssize_t) offset,(size_t) extent,(ssize_t)
       (100L*offset/(extent-1)));
   if (offset == (MagickOffsetType) (extent-1))
     (void) fprintf(stderr,"\n");
@@ -363,13 +363,13 @@
   double
     *sparse_arguments;
 
-  register unsigned long
+  register size_t
     x;
 
-  unsigned long
+  size_t
     number_arguments;
 
-  unsigned long
+  size_t
     number_colors;
 
   Image
@@ -588,7 +588,7 @@
   Image
     *region_image;
 
-  long
+  ssize_t
     count;
 
   MagickBooleanType
@@ -607,7 +607,7 @@
     geometry,
     region_geometry;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -634,7 +634,7 @@
   /*
     Transmogrify the image.
   */
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (IsMagickOption(option) == MagickFalse)
@@ -1058,10 +1058,10 @@
             Image
               *mask;
 
-            long
+            ssize_t
               y;
 
-            register long
+            register ssize_t
               x;
 
             register PixelPacket
@@ -1083,12 +1083,12 @@
             mask=GetImageCache(image_info,argv[i+1],exception);
             if (mask == (Image *) NULL)
               break;
-            for (y=0; y < (long) mask->rows; y++)
+            for (y=0; y < (ssize_t) mask->rows; y++)
             {
               q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception);
               if (q == (PixelPacket *) NULL)
                 break;
-              for (x=0; x < (long) mask->columns; x++)
+              for (x=0; x < (ssize_t) mask->columns; x++)
               {
                 if (mask->matte == MagickFalse)
                   q->opacity=PixelIntensityToQuantum(q);
@@ -1236,7 +1236,7 @@
             KernelInfo
               *kernel;
 
-            register long
+            register ssize_t
               j;
 
             (void) SyncImageSettings(image_info,*image);
@@ -1244,10 +1244,10 @@
             if (kernel == (KernelInfo *) NULL)
               break;
             gamma=0.0;
-            for (j=0; j < (long) (kernel->width*kernel->height); j++)
+            for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
               gamma+=kernel->values[j];
             gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
-            for (j=0; j < (long) (kernel->width*kernel->height); j++)
+            for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++)
               kernel->values[j]*=gamma;
             convolve_image=FilterImageChannel(*image,channel,kernel,exception);
             kernel=DestroyKernelInfo(kernel);
@@ -1380,10 +1380,10 @@
             Image
               *distort_image;
 
-            register long
+            register ssize_t
               x;
 
-            unsigned long
+            size_t
               number_arguments;
 
             /*
@@ -1403,7 +1403,7 @@
               if (*token == ',')
                 GetMagickToken(p,&p,token);
             }
-            number_arguments=(unsigned long) x;
+            number_arguments=(size_t) x;
             arguments=(double *) AcquireQuantumMemory(number_arguments,
               sizeof(*arguments));
             if (arguments == (double *) NULL)
@@ -1412,7 +1412,7 @@
             (void) ResetMagickMemory(arguments,0,number_arguments*
               sizeof(*arguments));
             p=(char *) args;
-            for (x=0; (x < (long) number_arguments) && (*p != '\0'); x++)
+            for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
             {
               GetMagickToken(p,&p,token);
               if (*token == ',')
@@ -1714,8 +1714,8 @@
               frame_info.height=geometry.width;
             frame_info.outer_bevel=geometry.x;
             frame_info.inner_bevel=geometry.y;
-            frame_info.x=(long) frame_info.width;
-            frame_info.y=(long) frame_info.height;
+            frame_info.x=(ssize_t) frame_info.width;
+            frame_info.y=(ssize_t) frame_info.height;
             frame_info.width=(*image)->columns+2*frame_info.width;
             frame_info.height=(*image)->rows+2*frame_info.height;
             frame_image=FrameImage(*image,&frame_info,exception);
@@ -1740,10 +1740,10 @@
             MagickFunction
               function;
 
-            register long
+            register ssize_t
               x;
 
-            unsigned long
+            size_t
               number_parameters;
 
             /*
@@ -1763,7 +1763,7 @@
               if (*token == ',')
                 GetMagickToken(p,&p,token);
             }
-            number_parameters=(unsigned long) x;
+            number_parameters=(size_t) x;
             parameters=(double *) AcquireQuantumMemory(number_parameters,
               sizeof(*parameters));
             if (parameters == (double *) NULL)
@@ -1772,7 +1772,7 @@
             (void) ResetMagickMemory(parameters,0,number_parameters*
               sizeof(*parameters));
             p=(char *) arguments;
-            for (x=0; (x < (long) number_parameters) && (*p != '\0'); x++)
+            for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++)
             {
               GetMagickToken(p,&p,token);
               if (*token == ',')
@@ -1967,9 +1967,9 @@
             flags=ParseGeometry(argv[i+1],&geometry_info);
             if ((flags & PercentValue) != 0)
               geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
-            threshold_image=AdaptiveThresholdImage(*image,(unsigned long)
-              geometry_info.rho,(unsigned long) geometry_info.sigma,
-              (long) geometry_info.xi,exception);
+            threshold_image=AdaptiveThresholdImage(*image,(size_t)
+              geometry_info.rho,(size_t) geometry_info.sigma,
+              (ssize_t) geometry_info.xi,exception);
             if (threshold_image == (Image *) NULL)
               break;
             *image=DestroyImage(*image);
@@ -2224,7 +2224,7 @@
             KernelInfo
               *kernel;
 
-            long
+            ssize_t
               iterations;
 
             MorphologyMethod
@@ -2502,7 +2502,7 @@
                 if (profile != (StringInfo *) NULL)
                   {
                     (void) ProfileImage(*image,profile_info->magick,
-                      GetStringInfoDatum(profile),(unsigned long)
+                      GetStringInfoDatum(profile),(size_t)
                       GetStringInfoLength(profile),MagickFalse);
                     profile=DestroyStringInfo(profile);
                   }
@@ -2516,7 +2516,7 @@
               profile=GetImageProfile(profile_image,name);
               if (profile != (StringInfo *) NULL)
                 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
-                  (unsigned long) GetStringInfoLength(profile),MagickFalse);
+                  (size_t) GetStringInfoLength(profile),MagickFalse);
               name=GetNextImageProfile(profile_image);
             }
             profile_image=DestroyImage(profile_image);
@@ -2949,7 +2949,7 @@
             if ((flags & PsiValue) == 0)
               geometry_info.psi=4.0;
             shadow_image=ShadowImage(*image,geometry_info.rho,
-              geometry_info.sigma,(long) ceil(geometry_info.xi-0.5),(long)
+              geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
               ceil(geometry_info.psi-0.5),exception);
             if (shadow_image == (Image *) NULL)
               break;
@@ -3455,7 +3455,7 @@
             if ((flags & PsiValue) == 0)
               geometry_info.psi=0.1*(*image)->rows;
             vignette_image=VignetteImage(*image,geometry_info.rho,
-              geometry_info.sigma,(long) ceil(geometry_info.xi-0.5),(long)
+              geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
               ceil(geometry_info.psi-0.5),exception);
             if (vignette_image == (Image *) NULL)
               break;
@@ -3632,9 +3632,9 @@
       "-charcoal radius     simulate a charcoal drawing",
       "-chop geometry       remove pixels from the image interior",
       "-clamp               restrict pixel range from 0 to the quantum depth",
-      "-clip                clip along the first path from the 8BIM profile",
+      "-clip                clip assize_t the first path from the 8BIM profile",
       "-clip-mask filename  associate a clip mask with the image",
-      "-clip-path id        clip along a named path from the 8BIM profile",
+      "-clip-path id        clip assize_t a named path from the 8BIM profile",
       "-colorize value      colorize the image with the fill color",
       "-color-matrix matrix apply color correction to the image",
       "-contrast            enhance or reduce the image contrast",
@@ -3724,7 +3724,7 @@
       "-shadow geometry     simulate an image shadow",
       "-sharpen geometry    sharpen the image",
       "-shave geometry      shave pixels from the image edges",
-      "-shear geometry      slide one edge of the image along the X or Y axis",
+      "-shear geometry      slide one edge of the image assize_t the X or Y axis",
       "-sigmoidal-contrast geometry",
       "                     increase the contrast without saturating highlights or shadows",
       "-sketch geometry     simulate a pencil sketch",
@@ -3748,7 +3748,7 @@
       "-unique-colors       discard all but one of any pixel color",
       "-unsharp geometry    sharpen the image",
       "-vignette geometry   soften the edges of the image in vignette style",
-      "-wave geometry       alter an image along a sine wave",
+      "-wave geometry       alter an image assize_t a sine wave",
       "-white-threshold value",
       "                     force all pixels above the threshold into white",
       (char *) NULL
@@ -3881,7 +3881,7 @@
   const char
     **p;
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
@@ -3923,7 +3923,7 @@
   if (path != (char *) NULL) \
     path=DestroyString(path); \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -3953,11 +3953,11 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
-  register long
+  register ssize_t
     i;
 
   MagickBooleanType
@@ -3985,7 +3985,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -4010,7 +4010,7 @@
   if (status == MagickFalse)
     ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -4075,7 +4075,7 @@
         if ((LocaleCompare(image->filename,"-") != 0) &&
             (IsPathWritable(image->filename) != MagickFalse))
           {
-            register long
+            register ssize_t
               i;
 
             /*
@@ -4111,7 +4111,7 @@
         if (LocaleCompare("adaptive-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4120,7 +4120,7 @@
         if (LocaleCompare("adaptive-resize",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4129,7 +4129,7 @@
         if (LocaleCompare("adaptive-sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4140,7 +4140,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4148,13 +4148,13 @@
           }
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -4167,11 +4167,11 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             i++;
             break;
@@ -4185,7 +4185,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4196,7 +4196,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4217,7 +4217,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4226,7 +4226,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4239,7 +4239,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4250,7 +4250,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4259,7 +4259,7 @@
         if (LocaleCompare("blue-shift",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4268,7 +4268,7 @@
         if (LocaleCompare("blur",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4279,7 +4279,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4290,7 +4290,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4299,14 +4299,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("brightness-contrast",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4321,7 +4321,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4332,19 +4332,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -4357,7 +4357,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4366,7 +4366,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4377,7 +4377,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4392,7 +4392,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4405,7 +4405,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4416,7 +4416,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4427,7 +4427,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4435,13 +4435,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
               argv[i]);
@@ -4457,7 +4457,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4465,13 +4465,13 @@
           break;
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -4487,7 +4487,7 @@
         if (LocaleCompare("contrast-stretch",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4501,7 +4501,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
 #if 1
             (void) token;
@@ -4514,7 +4514,7 @@
             GetMagickToken(argv[i],NULL,token);
             if ( isalpha((int)token[0]) )
               {
-                long
+                ssize_t
                 op;
 
                 op=ParseMagickOption(MagickKernelOptions,MagickFalse,token);
@@ -4533,7 +4533,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4544,7 +4544,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4559,7 +4559,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4567,13 +4567,13 @@
           break;
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -4585,7 +4585,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -4604,7 +4604,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4615,7 +4615,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4626,7 +4626,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4637,7 +4637,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4649,13 +4649,13 @@
           break;
         if (LocaleCompare("direction",option+1) == 0)
           {
-            long
+            ssize_t
               direction;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             direction=ParseMagickOption(MagickDirectionOptions,MagickFalse,
               argv[i]);
@@ -4669,19 +4669,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -4691,30 +4691,30 @@
           }
         if (LocaleCompare("distort",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -4727,7 +4727,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4736,7 +4736,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4751,7 +4751,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4762,7 +4762,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4773,7 +4773,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4782,19 +4782,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
             if (endian < 0)
@@ -4808,20 +4808,20 @@
           break;
         if (LocaleCompare("evaluate",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4829,13 +4829,13 @@
           }
         if (LocaleCompare("evaluate-sequence",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
             if (op < 0)
@@ -4848,7 +4848,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4859,7 +4859,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4874,7 +4874,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4883,19 +4883,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -4914,12 +4914,12 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4928,7 +4928,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4939,7 +4939,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             (void) CloneString(&format,argv[i]);
             (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
@@ -4956,7 +4956,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4964,19 +4964,19 @@
           }
         if (LocaleCompare("function",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
              i++;
-             if (i == (long) (argc-1))
+             if (i == (ssize_t) (argc-1))
                ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -4985,7 +4985,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -4996,7 +4996,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5007,7 +5007,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5017,7 +5017,7 @@
             (LocaleCompare("gaussian",option+1) == 0))
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5028,7 +5028,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5036,13 +5036,13 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
             if (gravity < 0)
@@ -5055,7 +5055,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5083,7 +5083,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5091,13 +5091,13 @@
           }
         if (LocaleCompare("intent",option+1) == 0)
           {
-            long
+            ssize_t
               intent;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
             if (intent < 0)
@@ -5107,13 +5107,13 @@
           }
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -5127,7 +5127,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5135,13 +5135,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -5155,7 +5155,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5170,7 +5170,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5185,7 +5185,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5194,20 +5194,20 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
           }
         if (LocaleCompare("layers",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -5218,7 +5218,7 @@
         if (LocaleCompare("level",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5227,7 +5227,7 @@
         if (LocaleCompare("level-colors",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5236,7 +5236,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5250,13 +5250,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -5264,7 +5264,7 @@
               ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -5274,7 +5274,7 @@
         if (LocaleCompare("liquid-rescale",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5282,13 +5282,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -5302,7 +5302,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
@@ -5312,7 +5312,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5328,7 +5328,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5337,7 +5337,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5348,7 +5348,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5361,7 +5361,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5372,7 +5372,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5387,7 +5387,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5395,14 +5395,14 @@
           }
         if (LocaleCompare("morphology",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             char
               token[MaxTextExtent];
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             GetMagickToken(argv[i],NULL,token);
             op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token);
@@ -5410,7 +5410,7 @@
               ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod",
                 token);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             GetMagickToken(argv[i],NULL,token);
             if (isalpha((int) ((unsigned char) *token)) != 0)
@@ -5429,7 +5429,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5444,11 +5444,11 @@
         if (LocaleCompare("noise",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
-                long
+                ssize_t
                   noise;
 
                 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
@@ -5472,7 +5472,7 @@
         if (LocaleCompare("opaque",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5481,20 +5481,20 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("orient",option+1) == 0)
           {
-            long
+            ssize_t
               orientation;
 
             orientation=UndefinedOrientation;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
               argv[i]);
@@ -5512,7 +5512,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5521,7 +5521,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5533,7 +5533,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             (void) CloneString(&path,argv[i]);
             break;
@@ -5543,7 +5543,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5554,7 +5554,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5565,7 +5565,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5576,7 +5576,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5587,7 +5587,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5596,14 +5596,14 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5616,7 +5616,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5624,13 +5624,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
               argv[i]);
@@ -5648,7 +5648,7 @@
         if (LocaleCompare("radial-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5657,7 +5657,7 @@
         if (LocaleCompare("raise",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5668,7 +5668,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5679,7 +5679,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5690,7 +5690,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5702,7 +5702,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5713,7 +5713,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5724,7 +5724,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5735,7 +5735,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5746,7 +5746,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5759,7 +5759,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5768,7 +5768,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5783,7 +5783,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5794,7 +5794,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5805,7 +5805,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5816,7 +5816,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5827,7 +5827,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5838,7 +5838,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5847,7 +5847,7 @@
         if (LocaleCompare("selective-blur",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5860,7 +5860,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5869,19 +5869,19 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("shade",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5892,7 +5892,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5901,7 +5901,7 @@
         if (LocaleCompare("sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5912,7 +5912,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5921,7 +5921,7 @@
         if (LocaleCompare("shear",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5930,7 +5930,7 @@
         if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5941,7 +5941,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5952,7 +5952,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5963,7 +5963,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5971,18 +5971,18 @@
           }
         if (LocaleCompare("sparse-color",option+1) == 0)
           {
-            long
+            ssize_t
               op;
 
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]);
             if (op < 0)
               ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod",
                 argv[i]);
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -5991,7 +5991,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -5999,13 +5999,13 @@
           }
         if (LocaleCompare("stretch",option+1) == 0)
           {
-            long
+            ssize_t
               stretch;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]);
             if (stretch < 0)
@@ -6020,7 +6020,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6029,7 +6029,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6037,13 +6037,13 @@
           }
         if (LocaleCompare("style",option+1) == 0)
           {
-            long
+            ssize_t
               style;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]);
             if (style < 0)
@@ -6056,7 +6056,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6073,7 +6073,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6082,7 +6082,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6091,7 +6091,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6102,7 +6102,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6119,7 +6119,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6130,7 +6130,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6139,7 +6139,7 @@
         if (LocaleCompare("transparent",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6148,7 +6148,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6157,7 +6157,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6167,13 +6167,13 @@
           break;
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -6190,7 +6190,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6198,13 +6198,13 @@
           break;
         if (LocaleCompare("units",option+1) == 0)
           {
-            long
+            ssize_t
               units;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -6216,7 +6216,7 @@
         if (LocaleCompare("unsharp",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6235,7 +6235,7 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
@@ -6245,7 +6245,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6254,7 +6254,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6262,13 +6262,13 @@
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -6284,7 +6284,7 @@
         if (LocaleCompare("wave",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6295,7 +6295,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6304,7 +6304,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6315,7 +6315,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMogrifyInvalidArgumentException(option,argv[i]);
@@ -6324,7 +6324,7 @@
         if (LocaleCompare("write",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMogrifyException(OptionError,"MissingArgument",option);
             break;
           }
@@ -6389,10 +6389,10 @@
   GeometryInfo
     geometry_info;
 
-  long
+  ssize_t
     count;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -6408,7 +6408,7 @@
   /*
     Set the image settings.
   */
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
   {
     option=argv[i];
     if (IsMagickOption(option) == MagickFalse)
@@ -6962,7 +6962,7 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             /*
@@ -7294,12 +7294,12 @@
           }
         if (LocaleCompare("seed",option+1) == 0)
           {
-            unsigned long
+            size_t
               seed;
 
             if (*option == '+')
               {
-                seed=(unsigned long) time((time_t *) NULL);
+                seed=(size_t) time((time_t *) NULL);
                 SeedPseudoRandomGenerator(seed);
                 break;
               }
@@ -7533,7 +7533,7 @@
   const char
     *option;
 
-  long
+  ssize_t
     count,
     index;
 
@@ -7543,7 +7543,7 @@
   QuantizeInfo
     *quantize_info;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -7561,7 +7561,7 @@
   quantize_info=AcquireQuantizeInfo(image_info);
   channel=image_info->channel;
   status=MagickTrue;
-  for (i=0; i < (long) argc; i++)
+  for (i=0; i < (ssize_t) argc; i++)
   {
     if (*images == (Image *) NULL)
       break;
@@ -7959,7 +7959,7 @@
             if (index == 0)
               PrependImageToList(images,q);
             else
-              if (index == (long) GetImageListLength(*images))
+              if (index == (ssize_t) GetImageListLength(*images))
                 AppendImageToList(images,q);
               else
                 {
@@ -8342,7 +8342,7 @@
               *q,
               *swap;
 
-            long
+            ssize_t
               swap_index;
 
             index=(-1);
@@ -8357,9 +8357,9 @@
 
                 swap_index=(-1);
                 flags=ParseGeometry(argv[i+1],&geometry_info);
-                index=(long) geometry_info.rho;
+                index=(ssize_t) geometry_info.rho;
                 if ((flags & SigmaValue) != 0)
-                  swap_index=(long) geometry_info.sigma;
+                  swap_index=(ssize_t) geometry_info.sigma;
               }
             p=GetImageFromList(*images,index);
             q=GetImageFromList(*images,swap_index);
@@ -8473,7 +8473,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -8496,7 +8496,7 @@
   status=0;
   if (post == MagickFalse)
     status&=MogrifyImageList(image_info,argc,argv,images,exception);
-  for (i=0; i < (long) number_images; i++)
+  for (i=0; i < (ssize_t) number_images; i++)
   {
     image=RemoveFirstImageFromList(images);
     if (image == (Image *) NULL)
diff --git a/wand/montage.c b/wand/montage.c
index 72f7efd..6014980 100644
--- a/wand/montage.c
+++ b/wand/montage.c
@@ -213,7 +213,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...] file\n",
@@ -259,7 +259,7 @@
   if (montage_image != (Image *) NULL) \
     montage_image=DestroyImageList(montage_image); \
   DestroyImageStack(); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -292,7 +292,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     first_scene,
     j,
     k,
@@ -309,7 +309,7 @@
   MontageInfo
     *montage_info;
 
-  register long
+  register ssize_t
     i;
 
   /*
@@ -327,7 +327,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -356,7 +356,7 @@
   if (status == MagickFalse)
     ThrowMontageException(ResourceLimitError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -428,7 +428,7 @@
         if (LocaleCompare("adaptive-sharpen",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -441,7 +441,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -449,13 +449,13 @@
           }
         if (LocaleCompare("alpha",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -468,11 +468,11 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             i++;
             break;
@@ -484,7 +484,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -497,7 +497,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) QueryColorDatabase(argv[i],
               &montage_info->background_color,exception);
@@ -508,7 +508,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -519,7 +519,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -535,7 +535,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -548,7 +548,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) QueryColorDatabase(argv[i],&montage_info->border_color,
               exception);
@@ -560,7 +560,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -576,7 +576,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -587,19 +587,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -623,7 +623,7 @@
             else
               {
                 i++;
-                if (i == (long) (argc-1))
+                if (i == (ssize_t) (argc-1))
                   ThrowMontageException(OptionError,"MissingArgument",option);
                 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
                   ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -641,7 +641,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -649,13 +649,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -669,19 +669,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-            long
+            ssize_t
               compose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             compose=ParseMagickOption(MagickComposeOptions,MagickFalse,argv[i]);
             if (compose < 0)
@@ -693,13 +693,13 @@
           break;
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -715,7 +715,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -727,13 +727,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -745,7 +745,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -764,7 +764,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -775,7 +775,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -786,19 +786,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("dispose",option+1) == 0)
           {
-            long
+            ssize_t
               dispose;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
             if (dispose < 0)
@@ -808,13 +808,13 @@
           }
         if (LocaleCompare("dither",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
             if (method < 0)
@@ -827,7 +827,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -836,7 +836,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -851,19 +851,19 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
         if (LocaleCompare("endian",option+1) == 0)
           {
-            long
+            ssize_t
               endian;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
               argv[i]);
@@ -877,7 +877,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -893,7 +893,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) QueryColorDatabase(argv[i],&montage_info->fill,
               exception);
@@ -901,13 +901,13 @@
           }
         if (LocaleCompare("filter",option+1) == 0)
           {
-            long
+            ssize_t
               filter;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
             if (filter < 0)
@@ -926,7 +926,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) CloneString(&montage_info->font,argv[i]);
             break;
@@ -936,7 +936,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             format=argv[i];
             break;
@@ -951,7 +951,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -966,7 +966,7 @@
         if (LocaleCompare("gamma",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -978,7 +978,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -987,14 +987,14 @@
           }
         if (LocaleCompare("gravity",option+1) == 0)
           {
-            long
+            ssize_t
               gravity;
 
             montage_info->gravity=UndefinedGravity;
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,
               argv[i]);
@@ -1009,7 +1009,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1030,13 +1030,13 @@
           break;
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -1047,13 +1047,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -1071,7 +1071,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1083,13 +1083,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -1097,7 +1097,7 @@
               ThrowMontageException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -1106,13 +1106,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -1127,7 +1127,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) ||
+            if ((i == (ssize_t) argc) ||
                 (strchr(argv[i],'%') == (char *) NULL))
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
@@ -1143,7 +1143,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) QueryColorDatabase(argv[i],&montage_info->matte_color,
               exception);
@@ -1157,7 +1157,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             mode=UndefinedMode;
             if (LocaleCompare("frame",argv[i]) == 0)
@@ -1213,7 +1213,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1228,7 +1228,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1238,7 +1238,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1250,7 +1250,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1259,7 +1259,7 @@
         if (LocaleCompare("profile",option+1) == 0)
           {
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1272,7 +1272,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1280,13 +1280,13 @@
           }
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -1306,7 +1306,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1321,7 +1321,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1332,7 +1332,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1346,7 +1346,7 @@
         if (LocaleCompare("rotate",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1361,7 +1361,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1372,7 +1372,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1385,7 +1385,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1397,12 +1397,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1418,7 +1418,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1429,7 +1429,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (IsGeometry(argv[i]) == MagickFalse))
+            if ((i == (ssize_t) argc) || (IsGeometry(argv[i]) == MagickFalse))
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1438,7 +1438,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1450,7 +1450,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) QueryColorDatabase(argv[i],&montage_info->stroke,
               exception);
@@ -1463,7 +1463,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1484,7 +1484,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) CloneString(&montage_info->texture,argv[i]);
             break;
@@ -1494,7 +1494,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1510,7 +1510,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1523,7 +1523,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1534,7 +1534,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1550,7 +1550,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) CloneString(&montage_info->title,argv[i]);
             break;
@@ -1561,7 +1561,7 @@
           {
             transparent_color=(char *) NULL;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             (void) CloneString(&transparent_color,argv[i]);
             break;
@@ -1571,7 +1571,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             break;
           }
@@ -1580,7 +1580,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1590,13 +1590,13 @@
           break;
         if (LocaleCompare("type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -1610,13 +1610,13 @@
       {
         if (LocaleCompare("units",option+1) == 0)
           {
-            long
+            ssize_t
               units;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
               argv[i]);
@@ -1630,7 +1630,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1648,20 +1648,20 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -1679,7 +1679,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowMontageException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowMontageInvalidArgumentException(option,argv[i]);
@@ -1699,7 +1699,7 @@
   }
   if (k != 0)
     ThrowMontageException(OptionError,"UnbalancedParenthesis",argv[i]);
-  if (i-- != (long) (argc-1))
+  if (i-- != (ssize_t) (argc-1))
     ThrowMontageException(OptionError,"MissingAnImageFilename",argv[i]);
   if (image == (Image *) NULL)
     ThrowMontageException(OptionError,"MissingAnImageFilename",argv[argc-1]);
diff --git a/wand/pixel-iterator.c b/wand/pixel-iterator.c
index e0f8cd1..91a7d0d 100644
--- a/wand/pixel-iterator.c
+++ b/wand/pixel-iterator.c
@@ -63,7 +63,7 @@
 */
 struct _PixelIterator
 {
-  unsigned long
+  size_t
     id;
 
   char
@@ -81,7 +81,7 @@
   MagickBooleanType
     active;
 
-  long
+  ssize_t
     y;
 
   PixelWand
@@ -90,7 +90,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -295,7 +295,7 @@
   PixelIterator
     *iterator;
 
-  unsigned long
+  size_t
     depth;
 
   CacheView
@@ -385,8 +385,8 @@
 %
 %  The format of the NewPixelRegionIterator method is:
 %
-%      PixelIterator NewPixelRegionIterator(MagickWand *wand,const long x,
-%        const long y,const unsigned long width,const unsigned long height)
+%      PixelIterator NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
+%        const ssize_t y,const size_t width,const size_t height)
 %
 %  A description of each parameter follows:
 %
@@ -396,8 +396,8 @@
 %      pixels.
 %
 */
-WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,const long x,
-  const long y,const unsigned long width,const unsigned long height)
+WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
+  const ssize_t y,const size_t width,const size_t height)
 {
   const char
     *quantum;
@@ -408,7 +408,7 @@
   PixelIterator
     *iterator;
 
-  unsigned long
+  size_t
     depth;
 
   CacheView
@@ -468,7 +468,7 @@
 %  The format of the PixelGetCurrentIteratorRow method is:
 %
 %      PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
-%        unsigned long *number_wands)
+%        size_t *number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -478,7 +478,7 @@
 %
 */
 WandExport PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
-  unsigned long *number_wands)
+  size_t *number_wands)
 {
   register const IndexPacket
     *indexes;
@@ -486,7 +486,7 @@
   register const PixelPacket
     *pixels;
 
-  register long
+  register ssize_t
     x;
 
   assert(iterator != (PixelIterator *) NULL);
@@ -505,13 +505,13 @@
       return((PixelWand **) NULL);
     }
   indexes=GetCacheViewVirtualIndexQueue(iterator->view);
-  for (x=0; x < (long) iterator->region.width; x++)
+  for (x=0; x < (ssize_t) iterator->region.width; x++)
     PixelSetQuantumColor(iterator->pixel_wands[x],pixels+x);
   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]);
   if (GetCacheViewStorageClass(iterator->view) == PseudoClass)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       PixelSetIndex(iterator->pixel_wands[x],indexes[x]);
   *number_wands=iterator->region.width;
   return(iterator->pixel_wands);
@@ -630,7 +630,7 @@
 %    o iterator: the pixel iterator.
 %
 */
-WandExport long PixelGetIteratorRow(PixelIterator *iterator)
+WandExport ssize_t PixelGetIteratorRow(PixelIterator *iterator)
 {
   assert(iterator != (const PixelIterator *) NULL);
   assert(iterator->signature == WandSignature);
@@ -656,7 +656,7 @@
 %  The format of the PixelGetNextIteratorRow method is:
 %
 %      PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
-%        unsigned long *number_wands)
+%        size_t *number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -666,7 +666,7 @@
 %
 */
 WandExport PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
-  unsigned long *number_wands)
+  size_t *number_wands)
 {
   register const IndexPacket
     *indexes;
@@ -674,7 +674,7 @@
   register const PixelPacket
     *pixels;
 
-  register long
+  register ssize_t
     x;
 
   assert(iterator != (PixelIterator *) NULL);
@@ -696,13 +696,13 @@
       return((PixelWand **) NULL);
     }
   indexes=GetCacheViewVirtualIndexQueue(iterator->view);
-  for (x=0; x < (long) iterator->region.width; x++)
+  for (x=0; x < (ssize_t) iterator->region.width; x++)
     PixelSetQuantumColor(iterator->pixel_wands[x],pixels+x);
   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]);
   if (GetCacheViewStorageClass(iterator->view) == PseudoClass)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
         PixelSetIndex(iterator->pixel_wands[x],indexes[x]);
   *number_wands=iterator->region.width;
   return(iterator->pixel_wands);
@@ -725,7 +725,7 @@
 %  The format of the PixelGetPreviousIteratorRow method is:
 %
 %      PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
-%        unsigned long *number_wands)
+%        size_t *number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -737,14 +737,14 @@
 
 WandExport PixelWand **PixelGetPreviousRow(PixelIterator *iterator)
 {
-  unsigned long
+  size_t
     number_wands;
 
   return(PixelGetPreviousIteratorRow(iterator,&number_wands));
 }
 
 WandExport PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
-  unsigned long *number_wands)
+  size_t *number_wands)
 {
   register const IndexPacket
     *indexes;
@@ -752,7 +752,7 @@
   register const PixelPacket
     *pixels;
 
-  register long
+  register ssize_t
     x;
 
   assert(iterator != (PixelIterator *) NULL);
@@ -774,13 +774,13 @@
       return((PixelWand **) NULL);
     }
   indexes=GetCacheViewVirtualIndexQueue(iterator->view);
-  for (x=0; x < (long) iterator->region.width; x++)
+  for (x=0; x < (ssize_t) iterator->region.width; x++)
     PixelSetQuantumColor(iterator->pixel_wands[x],pixels+x);
   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       PixelSetBlackQuantum(iterator->pixel_wands[x],indexes[x]);
   if (GetCacheViewStorageClass(iterator->view) == PseudoClass)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       PixelSetIndex(iterator->pixel_wands[x],indexes[x]);
   *number_wands=iterator->region.width;
   return(iterator->pixel_wands);
@@ -868,7 +868,7 @@
 %  The format of the PixelSetIteratorRow method is:
 %
 %      MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
-%        const long row)
+%        const ssize_t row)
 %
 %  A description of each parameter follows:
 %
@@ -876,13 +876,13 @@
 %
 */
 WandExport MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
-  const long row)
+  const ssize_t row)
 {
   assert(iterator != (const PixelIterator *) NULL);
   assert(iterator->signature == WandSignature);
   if (iterator->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
-  if ((row < 0) || (row >= (long) iterator->region.height))
+  if ((row < 0) || (row >= (ssize_t) iterator->region.height))
     return(MagickFalse);
   iterator->active=MagickTrue;
   iterator->y=row;
@@ -918,7 +918,7 @@
   if (iterator->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name);
   iterator->active=MagickFalse;
-  iterator->y=(long) iterator->region.height-1;
+  iterator->y=(ssize_t) iterator->region.height-1;
 }
 
 /*
@@ -951,7 +951,7 @@
   register IndexPacket
     *restrict indexes;
 
-  register long
+  register ssize_t
     x;
 
   register PixelPacket
@@ -973,10 +973,10 @@
       return(MagickFalse);
     }
   indexes=GetCacheViewAuthenticIndexQueue(iterator->view);
-  for (x=0; x < (long) iterator->region.width; x++)
+  for (x=0; x < (ssize_t) iterator->region.width; x++)
     PixelGetQuantumColor(iterator->pixel_wands[x],pixels+x);
   if (GetCacheViewColorspace(iterator->view) == CMYKColorspace)
-    for (x=0; x < (long) iterator->region.width; x++)
+    for (x=0; x < (ssize_t) iterator->region.width; x++)
       indexes[x]=PixelGetBlackQuantum(iterator->pixel_wands[x]);
   if (SyncCacheViewAuthenticPixels(iterator->view,exception) == MagickFalse)
     {
diff --git a/wand/pixel-iterator.h b/wand/pixel-iterator.h
index 049bf21..7a695ee 100644
--- a/wand/pixel-iterator.h
+++ b/wand/pixel-iterator.h
@@ -34,26 +34,26 @@
 extern WandExport ExceptionType
   PixelGetIteratorExceptionType(const PixelIterator *);
 
-extern WandExport long
+extern WandExport ssize_t
   PixelGetIteratorRow(PixelIterator *);
 
 extern WandExport MagickBooleanType
   IsPixelIterator(const PixelIterator *),
   PixelClearIteratorException(PixelIterator *),
-  PixelSetIteratorRow(PixelIterator *,const long),
+  PixelSetIteratorRow(PixelIterator *,const ssize_t),
   PixelSyncIterator(PixelIterator *);
 
 extern WandExport PixelIterator
   *ClonePixelIterator(const PixelIterator *),
   *DestroyPixelIterator(PixelIterator *),
   *NewPixelIterator(MagickWand *),
-  *NewPixelRegionIterator(MagickWand *,const long,const long,
-    const unsigned long,const unsigned long);
+  *NewPixelRegionIterator(MagickWand *,const ssize_t,const ssize_t,
+    const size_t,const size_t);
 
 extern WandExport PixelWand
-  **PixelGetCurrentIteratorRow(PixelIterator *,unsigned long *),
-  **PixelGetNextIteratorRow(PixelIterator *,unsigned long *),
-  **PixelGetPreviousIteratorRow(PixelIterator *,unsigned long *);
+  **PixelGetCurrentIteratorRow(PixelIterator *,size_t *),
+  **PixelGetNextIteratorRow(PixelIterator *,size_t *),
+  **PixelGetPreviousIteratorRow(PixelIterator *,size_t *);
 
 extern WandExport void
   ClearPixelIterator(PixelIterator *),
diff --git a/wand/pixel-view.c b/wand/pixel-view.c
index de049e7..430455c 100644
--- a/wand/pixel-view.c
+++ b/wand/pixel-view.c
@@ -62,7 +62,7 @@
 */
 struct _PixelView
 {
-  unsigned long
+  size_t
     id;
 
   char
@@ -80,7 +80,7 @@
   RectangleInfo
     region;
 
-  unsigned long
+  size_t
     number_threads;
 
   PixelWand
@@ -89,7 +89,7 @@
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -120,7 +120,7 @@
   PixelView
     *clone_view;
 
-  register long
+  register ssize_t
     i;
 
   assert(pixel_view != (PixelView *) NULL);
@@ -140,7 +140,7 @@
   clone_view->view=CloneCacheView(pixel_view->view);
   clone_view->region=pixel_view->region;
   clone_view->number_threads=pixel_view->number_threads;
-  for (i=0; i < (long) pixel_view->number_threads; i++)
+  for (i=0; i < (ssize_t) pixel_view->number_threads; i++)
     clone_view->pixel_wands[i]=ClonePixelWands((const PixelWand **)
       pixel_view->pixel_wands[i],pixel_view->region.width);
   clone_view->debug=pixel_view->debug;
@@ -166,7 +166,7 @@
 %  The format of the DestroyPixelView method is:
 %
 %      PixelView *DestroyPixelView(PixelView *pixel_view,
-%        const unsigned long number_wands,const unsigned long number_threads)
+%        const size_t number_wands,const size_t number_threads)
 %
 %  A description of each parameter follows:
 %
@@ -179,13 +179,13 @@
 */
 
 static PixelWand ***DestroyPixelsThreadSet(PixelWand ***pixel_wands,
-  const unsigned long number_wands,const unsigned long number_threads)
+  const size_t number_wands,const size_t number_threads)
 {
-  register long
+  register ssize_t
     i;
 
   assert(pixel_wands != (PixelWand ***) NULL);
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
     if (pixel_wands[i] != (PixelWand **) NULL)
       pixel_wands[i]=DestroyPixelWands(pixel_wands[i],number_wands);
   pixel_wands=(PixelWand ***) RelinquishAlignedMemory(pixel_wands);
@@ -265,7 +265,7 @@
     *duplex_image,
     *source_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -287,7 +287,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(static,1) shared(progress,status)
 #endif
-  for (y=source->region.y; y < (long) source->region.height; y++)
+  for (y=source->region.y; y < (ssize_t) source->region.height; y++)
   {
     MagickBooleanType
       sync;
@@ -303,7 +303,7 @@
     register IndexPacket
       *restrict destination_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -321,13 +321,13 @@
         continue;
       }
     indexes=GetCacheViewVirtualIndexQueue(source->view);
-    for (x=0; x < (long) source->region.width; x++)
+    for (x=0; x < (ssize_t) source->region.width; x++)
       PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
     if (source_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
     if (source_image->storage_class == PseudoClass)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
     duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->region.x,y,
       duplex->region.width,1,duplex->exception);
@@ -337,13 +337,13 @@
         continue;
       }
     duplex_indexes=GetCacheViewVirtualIndexQueue(duplex->view);
-    for (x=0; x < (long) duplex->region.width; x++)
+    for (x=0; x < (ssize_t) duplex->region.width; x++)
       PixelSetQuantumColor(duplex->pixel_wands[id][x],duplex_pixels+x);
     if (duplex_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) duplex->region.width; x++)
+      for (x=0; x < (ssize_t) duplex->region.width; x++)
         PixelSetBlackQuantum(duplex->pixel_wands[id][x],duplex_indexes[x]);
     if (duplex_image->storage_class == PseudoClass)
-      for (x=0; x < (long) duplex->region.width; x++)
+      for (x=0; x < (ssize_t) duplex->region.width; x++)
         PixelSetIndex(duplex->pixel_wands[id][x],duplex_indexes[x]);
     destination_pixels=GetCacheViewAuthenticPixels(destination->view,
       destination->region.x,y,destination->region.width,1,exception);
@@ -353,23 +353,23 @@
         continue;
       }
     destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
-    for (x=0; x < (long) destination->region.width; x++)
+    for (x=0; x < (ssize_t) destination->region.width; x++)
       PixelSetQuantumColor(destination->pixel_wands[id][x],
         destination_pixels+x);
     if (destination_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         PixelSetBlackQuantum(destination->pixel_wands[id][x],
           destination_indexes[x]);
     if (destination_image->storage_class == PseudoClass)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         PixelSetIndex(destination->pixel_wands[id][x],destination_indexes[x]);
     if (transfer(source,duplex,destination,context) == MagickFalse)
       status=MagickFalse;
-    for (x=0; x < (long) destination->region.width; x++)
+    for (x=0; x < (ssize_t) destination->region.width; x++)
       PixelGetQuantumColor(destination->pixel_wands[id][x],
         destination_pixels+x);
     if (destination_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         destination_indexes[x]=PixelGetBlackQuantum(
           destination->pixel_wands[id][x]);
     sync=SyncCacheViewAuthenticPixels(destination->view,exception);
@@ -470,14 +470,14 @@
 %
 %  The format of the GetPixelViewHeight method is:
 %
-%      unsigned long GetPixelViewHeight(const PixelView *pixel_view)
+%      size_t GetPixelViewHeight(const PixelView *pixel_view)
 %
 %  A description of each parameter follows:
 %
 %    o pixel_view: the pixel view.
 %
 */
-WandExport unsigned long GetPixelViewHeight(const PixelView *pixel_view)
+WandExport size_t GetPixelViewHeight(const PixelView *pixel_view)
 {
   assert(pixel_view != (PixelView *) NULL);
   assert(pixel_view->signature == WandSignature);
@@ -530,7 +530,7 @@
   Image
     *source_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -547,7 +547,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=source->region.y; y < (long) source->region.height; y++)
+  for (y=source->region.y; y < (ssize_t) source->region.height; y++)
   {
     register const IndexPacket
       *indexes;
@@ -555,7 +555,7 @@
     register const PixelPacket
       *pixels;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -570,13 +570,13 @@
         continue;
       }
     indexes=GetCacheViewVirtualIndexQueue(source->view);
-    for (x=0; x < (long) source->region.width; x++)
+    for (x=0; x < (ssize_t) source->region.width; x++)
       PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
     if (source_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
     if (source_image->storage_class == PseudoClass)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
     if (get(source,context) == MagickFalse)
       status=MagickFalse;
@@ -621,7 +621,7 @@
 */
 WandExport PixelWand **GetPixelViewPixels(const PixelView *pixel_view)
 {
-  long
+  ssize_t
     id;
 
   assert(pixel_view != (PixelView *) NULL);
@@ -674,14 +674,14 @@
 %
 %  The format of the GetPixelViewWidth method is:
 %
-%      unsigned long GetPixelViewWidth(const PixelView *pixel_view)
+%      size_t GetPixelViewWidth(const PixelView *pixel_view)
 %
 %  A description of each parameter follows:
 %
 %    o pixel_view: the pixel view.
 %
 */
-WandExport unsigned long GetPixelViewWidth(const PixelView *pixel_view)
+WandExport size_t GetPixelViewWidth(const PixelView *pixel_view)
 {
   assert(pixel_view != (PixelView *) NULL);
   assert(pixel_view->signature == WandSignature);
@@ -703,14 +703,14 @@
 %
 %  The format of the GetPixelViewX method is:
 %
-%      long GetPixelViewX(const PixelView *pixel_view)
+%      ssize_t GetPixelViewX(const PixelView *pixel_view)
 %
 %  A description of each parameter follows:
 %
 %    o pixel_view: the pixel view.
 %
 */
-WandExport long GetPixelViewX(const PixelView *pixel_view)
+WandExport ssize_t GetPixelViewX(const PixelView *pixel_view)
 {
   assert(pixel_view != (PixelView *) NULL);
   assert(pixel_view->signature == WandSignature);
@@ -732,14 +732,14 @@
 %
 %  The format of the GetPixelViewY method is:
 %
-%      long GetPixelViewY(const PixelView *pixel_view)
+%      ssize_t GetPixelViewY(const PixelView *pixel_view)
 %
 %  A description of each parameter follows:
 %
 %    o pixel_view: the pixel view.
 %
 */
-WandExport long GetPixelViewY(const PixelView *pixel_view)
+WandExport ssize_t GetPixelViewY(const PixelView *pixel_view)
 {
   assert(pixel_view != (PixelView *) NULL);
   assert(pixel_view->signature == WandSignature);
@@ -808,13 +808,13 @@
 %
 */
 
-static PixelWand ***AcquirePixelsThreadSet(const unsigned long number_wands,
-  const unsigned long number_threads)
+static PixelWand ***AcquirePixelsThreadSet(const size_t number_wands,
+  const size_t number_threads)
 {
   PixelWand
     ***pixel_wands;
 
-  register long
+  register ssize_t
     i;
 
   pixel_wands=(PixelWand ***) AcquireAlignedMemory(number_threads,
@@ -822,7 +822,7 @@
   if (pixel_wands == (PixelWand ***) NULL)
     return((PixelWand ***) NULL);
   (void) ResetMagickMemory(pixel_wands,0,number_threads*sizeof(*pixel_wands));
-  for (i=0; i < (long) number_threads; i++)
+  for (i=0; i < (ssize_t) number_threads; i++)
   {
     pixel_wands[i]=NewPixelWands(number_wands);
     if (pixel_wands[i] == (PixelWand **) NULL)
@@ -878,8 +878,8 @@
 %
 %  The format of the NewPixelViewRegion method is:
 %
-%      PixelView *NewPixelViewRegion(MagickWand *wand,const long x,
-%        const long y,const unsigned long width,const unsigned long height)
+%      PixelView *NewPixelViewRegion(MagickWand *wand,const ssize_t x,
+%        const ssize_t y,const size_t width,const size_t height)
 %
 %  A description of each parameter follows:
 %
@@ -889,8 +889,8 @@
 %      pixel_wands view.
 %
 */
-WandExport PixelView *NewPixelViewRegion(MagickWand *wand,const long x,
-  const long y,const unsigned long width,const unsigned long height)
+WandExport PixelView *NewPixelViewRegion(MagickWand *wand,const ssize_t x,
+  const ssize_t y,const size_t width,const size_t height)
 {
   PixelView
     *pixel_view;
@@ -973,7 +973,7 @@
   Image
     *destination_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -993,7 +993,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=destination->region.y; y < (long) destination->region.height; y++)
+  for (y=destination->region.y; y < (ssize_t) destination->region.height; y++)
   {
     MagickBooleanType
       sync;
@@ -1001,7 +1001,7 @@
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -1023,10 +1023,10 @@
     indexes=GetCacheViewAuthenticIndexQueue(destination->view);
     if (set(destination,context) == MagickFalse)
       status=MagickFalse;
-    for (x=0; x < (long) destination->region.width; x++)
+    for (x=0; x < (ssize_t) destination->region.width; x++)
       PixelGetQuantumColor(destination->pixel_wands[id][x],pixels+x);
     if (destination_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         indexes[x]=PixelGetBlackQuantum(destination->pixel_wands[id][x]);
     sync=SyncCacheViewAuthenticPixels(destination->view,exception);
     if (sync == MagickFalse)
@@ -1106,7 +1106,7 @@
     *destination_image,
     *source_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1127,7 +1127,7 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=source->region.y; y < (long) source->region.height; y++)
+  for (y=source->region.y; y < (ssize_t) source->region.height; y++)
   {
     MagickBooleanType
       sync;
@@ -1141,7 +1141,7 @@
     register IndexPacket
       *restrict destination_indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -1159,13 +1159,13 @@
         continue;
       }
     indexes=GetCacheViewVirtualIndexQueue(source->view);
-    for (x=0; x < (long) source->region.width; x++)
+    for (x=0; x < (ssize_t) source->region.width; x++)
       PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
     if (source_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
     if (source_image->storage_class == PseudoClass)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
     destination_pixels=GetCacheViewAuthenticPixels(destination->view,
       destination->region.x,y,destination->region.width,1,exception);
@@ -1175,21 +1175,21 @@
         continue;
       }
     destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
-    for (x=0; x < (long) destination->region.width; x++)
+    for (x=0; x < (ssize_t) destination->region.width; x++)
       PixelSetQuantumColor(destination->pixel_wands[id][x],pixels+x);
     if (destination_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         PixelSetBlackQuantum(destination->pixel_wands[id][x],indexes[x]);
     if (destination_image->storage_class == PseudoClass)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         PixelSetIndex(destination->pixel_wands[id][x],indexes[x]);
     if (transfer(source,destination,context) == MagickFalse)
       status=MagickFalse;
-    for (x=0; x < (long) destination->region.width; x++)
+    for (x=0; x < (ssize_t) destination->region.width; x++)
       PixelGetQuantumColor(destination->pixel_wands[id][x],
         destination_pixels+x);
     if (destination_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) destination->region.width; x++)
+      for (x=0; x < (ssize_t) destination->region.width; x++)
         destination_indexes[x]=PixelGetBlackQuantum(
           destination->pixel_wands[id][x]);
     sync=SyncCacheViewAuthenticPixels(destination->view,exception);
@@ -1265,7 +1265,7 @@
   Image
     *source_image;
 
-  long
+  ssize_t
     progress,
     y;
 
@@ -1285,12 +1285,12 @@
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
 #endif
-  for (y=source->region.y; y < (long) source->region.height; y++)
+  for (y=source->region.y; y < (ssize_t) source->region.height; y++)
   {
     register IndexPacket
       *restrict indexes;
 
-    register long
+    register ssize_t
       id,
       x;
 
@@ -1310,17 +1310,17 @@
         continue;
       }
     indexes=GetCacheViewAuthenticIndexQueue(source->view);
-    for (x=0; x < (long) source->region.width; x++)
+    for (x=0; x < (ssize_t) source->region.width; x++)
       PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
     if (source_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
     if (update(source,context) == MagickFalse)
       status=MagickFalse;
-    for (x=0; x < (long) source->region.width; x++)
+    for (x=0; x < (ssize_t) source->region.width; x++)
       PixelGetQuantumColor(source->pixel_wands[id][x],pixels+x);
     if (source_image->colorspace == CMYKColorspace)
-      for (x=0; x < (long) source->region.width; x++)
+      for (x=0; x < (ssize_t) source->region.width; x++)
         indexes[x]=PixelGetBlackQuantum(source->pixel_wands[id][x]);
     if (SyncCacheViewAuthenticPixels(source->view,exception) == MagickFalse)
       {
diff --git a/wand/pixel-view.h b/wand/pixel-view.h
index 76bb59f..cce9b0a 100644
--- a/wand/pixel-view.h
+++ b/wand/pixel-view.h
@@ -36,7 +36,7 @@
 extern WandExport char
   *GetPixelViewException(const PixelView *,ExceptionType *);
 
-extern WandExport long
+extern WandExport ssize_t
   GetPixelViewX(const PixelView *),
   GetPixelViewY(const PixelView *);
 
@@ -57,13 +57,13 @@
   *ClonePixelView(const PixelView *),
   *DestroyPixelView(PixelView *),
   *NewPixelView(MagickWand *),
-  *NewPixelViewRegion(MagickWand *,const long,const long,
-    const unsigned long,const unsigned long);
+  *NewPixelViewRegion(MagickWand *,const ssize_t,const ssize_t,
+    const size_t,const size_t);
 
 extern WandExport PixelWand
   **GetPixelViewPixels(const PixelView *);
 
-extern WandExport unsigned long
+extern WandExport size_t
   GetPixelViewHeight(const PixelView *),
   GetPixelViewWidth(const PixelView *);
 
diff --git a/wand/pixel-wand.c b/wand/pixel-wand.c
index 932fe84..3c8f323 100644
--- a/wand/pixel-wand.c
+++ b/wand/pixel-wand.c
@@ -62,7 +62,7 @@
 */
 struct _PixelWand
 {
-  unsigned long
+  size_t
     id;
 
   char
@@ -74,13 +74,13 @@
   MagickPixelPacket
     pixel;
 
-  unsigned long
+  size_t
     count;
 
   MagickBooleanType
     debug;
 
-  unsigned long
+  size_t
     signature;
 };
 
@@ -183,7 +183,7 @@
 %  The format of the ClonePixelWands method is:
 %
 %      PixelWand **ClonePixelWands(const PixelWand **wands,
-%        const unsigned long number_wands)
+%        const size_t number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -193,9 +193,9 @@
 %
 */
 WandExport PixelWand **ClonePixelWands(const PixelWand **wands,
-  const unsigned long number_wands)
+  const size_t number_wands)
 {
-  register long
+  register ssize_t
     i;
 
   PixelWand
@@ -206,7 +206,7 @@
   if (clone_wands == (PixelWand **) NULL)
     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=0; i < (long) number_wands; i++)
+  for (i=0; i < (ssize_t) number_wands; i++)
     clone_wands[i]=ClonePixelWand(wands[i]);
   return(clone_wands);
 }
@@ -263,7 +263,7 @@
 %  The format of the DestroyPixelWands method is:
 %
 %      PixelWand **DestroyPixelWands(PixelWand **wand,
-%        const unsigned long number_wands)
+%        const size_t number_wands)
 %
 %  A description of each parameter follows:
 %
@@ -273,9 +273,9 @@
 %
 */
 WandExport PixelWand **DestroyPixelWands(PixelWand **wand,
-  const unsigned long number_wands)
+  const size_t number_wands)
 {
-  register long
+  register ssize_t
     i;
 
   assert(wand != (PixelWand **) NULL);
@@ -283,7 +283,7 @@
   assert((*wand)->signature == WandSignature);
   if ((*wand)->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",(*wand)->name);
-  for (i=(long) number_wands-1; i >= 0; i--)
+  for (i=(ssize_t) number_wands-1; i >= 0; i--)
     wand[i]=DestroyPixelWand(wand[i]);
   wand=(PixelWand **) RelinquishMagickMemory(wand);
   return(wand);
@@ -393,7 +393,7 @@
   PixelWand
     *wand;
 
-  unsigned long
+  size_t
     depth;
 
   depth=MAGICKCORE_QUANTUM_DEPTH;
@@ -432,16 +432,16 @@
 %
 %  The format of the NewPixelWands method is:
 %
-%      PixelWand **NewPixelWands(const unsigned long number_wands)
+%      PixelWand **NewPixelWands(const size_t number_wands)
 %
 %  A description of each parameter follows:
 %
 %    o number_wands: the number of wands.
 %
 */
-WandExport PixelWand **NewPixelWands(const unsigned long number_wands)
+WandExport PixelWand **NewPixelWands(const size_t number_wands)
 {
-  register long
+  register ssize_t
     i;
 
   PixelWand
@@ -452,7 +452,7 @@
   if (wands == (PixelWand **) NULL)
     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
       GetExceptionMessage(errno));
-  for (i=0; i < (long) number_wands; i++)
+  for (i=0; i < (ssize_t) number_wands; i++)
     wands[i]=NewPixelWand();
   return(wands);
 }
@@ -775,14 +775,14 @@
 %
 %  The format of the PixelGetColorCount method is:
 %
-%      unsigned long PixelGetColorCount(const PixelWand *wand)
+%      size_t PixelGetColorCount(const PixelWand *wand)
 %
 %  A description of each parameter follows:
 %
 %    o wand: the pixel wand.
 %
 */
-WandExport unsigned long PixelGetColorCount(const PixelWand *wand)
+WandExport size_t PixelGetColorCount(const PixelWand *wand)
 {
   assert(wand != (const PixelWand *) NULL);
   assert(wand->signature == WandSignature);
@@ -1694,7 +1694,7 @@
 %
 %  The format of the PixelSetColorCount method is:
 %
-%      void PixelSetColorCount(PixelWand *wand,const unsigned long count)
+%      void PixelSetColorCount(PixelWand *wand,const size_t count)
 %
 %  A description of each parameter follows:
 %
@@ -1703,7 +1703,7 @@
 %    o count: the number of this particular color.
 %
 */
-WandExport void PixelSetColorCount(PixelWand *wand,const unsigned long count)
+WandExport void PixelSetColorCount(PixelWand *wand,const size_t count)
 {
   assert(wand != (const PixelWand *) NULL);
   assert(wand->signature == WandSignature);
diff --git a/wand/pixel-wand.h b/wand/pixel-wand.h
index 274755c..faa634b 100644
--- a/wand/pixel-wand.h
+++ b/wand/pixel-wand.h
@@ -56,11 +56,11 @@
 
 extern WandExport PixelWand
   *ClonePixelWand(const PixelWand *),
-  **ClonePixelWands(const PixelWand **,const unsigned long),
+  **ClonePixelWands(const PixelWand **,const size_t),
   *DestroyPixelWand(PixelWand *),
-  **DestroyPixelWands(PixelWand **,const unsigned long),
+  **DestroyPixelWands(PixelWand **,const size_t),
   *NewPixelWand(void),
-  **NewPixelWands(const unsigned long);
+  **NewPixelWands(const size_t);
 
 extern WandExport Quantum
   PixelGetAlphaQuantum(const PixelWand *),
@@ -73,7 +73,7 @@
   PixelGetRedQuantum(const PixelWand *),
   PixelGetYellowQuantum(const PixelWand *);
 
-extern WandExport unsigned long
+extern WandExport size_t
   PixelGetColorCount(const PixelWand *);
 
 extern WandExport void
@@ -87,7 +87,7 @@
   PixelSetBlue(PixelWand *,const double),
   PixelSetBlueQuantum(PixelWand *,const Quantum),
   PixelSetColorFromWand(PixelWand *,const PixelWand *),
-  PixelSetColorCount(PixelWand *,const unsigned long),
+  PixelSetColorCount(PixelWand *,const size_t),
   PixelSetCyan(PixelWand *,const double),
   PixelSetCyanQuantum(PixelWand *,const Quantum),
   PixelSetFuzz(PixelWand *,const double),
diff --git a/wand/stream.c b/wand/stream.c
index 7d62ff4..877e5c3 100644
--- a/wand/stream.c
+++ b/wand/stream.c
@@ -135,7 +135,7 @@
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n",GetMagickCopyright());
   (void) printf("Features: %s\n\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] input-image raw-image\n",
@@ -165,7 +165,7 @@
 { \
   DestroyImageStack(); \
   stream_info=DestroyStreamInfo(stream_info); \
-  for (i=0; i < (long) argc; i++) \
+  for (i=0; i < (ssize_t) argc; i++) \
     argv[i]=DestroyString(argv[i]); \
   argv=(char **) RelinquishMagickMemory(argv); \
 }
@@ -197,7 +197,7 @@
   ImageStack
     image_stack[MaxImageStackDepth+1];
 
-  long
+  ssize_t
     j,
     k;
 
@@ -208,7 +208,7 @@
   MagickStatusType
     status;
 
-  register long
+  register ssize_t
     i;
 
   StreamInfo
@@ -230,7 +230,7 @@
           (LocaleCompare("-version",option+1) == 0))
         {
           (void) fprintf(stdout,"Version: %s\n",
-            GetMagickVersion((unsigned long *) NULL));
+            GetMagickVersion((size_t *) NULL));
           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
           return(MagickFalse);
@@ -260,7 +260,7 @@
       DestroyStream();
       return(MagickFalse);
     }
-  for (i=1; i < (long) (argc-1); i++)
+  for (i=1; i < (ssize_t) (argc-1); i++)
   {
     option=argv[i];
     if (LocaleCompare(option,"(") == 0)
@@ -310,7 +310,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             break;
           }
@@ -323,7 +323,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -331,13 +331,13 @@
           }
         if (LocaleCompare("channel",option+1) == 0)
           {
-            long
+            ssize_t
               channel;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             channel=ParseChannelOption(argv[i]);
             if (channel < 0)
@@ -347,13 +347,13 @@
           }
         if (LocaleCompare("colorspace",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
               argv[i]);
@@ -364,13 +364,13 @@
           }
         if (LocaleCompare("compress",option+1) == 0)
           {
-            long
+            ssize_t
               compress;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
               argv[i]);
@@ -387,13 +387,13 @@
       {
         if (LocaleCompare("debug",option+1) == 0)
           {
-            long
+            ssize_t
               event;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
             if (event < 0)
@@ -404,7 +404,7 @@
         if (LocaleCompare("define",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (*option == '+')
               {
@@ -423,7 +423,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -434,7 +434,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -445,7 +445,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -460,7 +460,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -481,13 +481,13 @@
           break;
         if (LocaleCompare("interlace",option+1) == 0)
           {
-            long
+            ssize_t
               interlace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
               argv[i]);
@@ -498,13 +498,13 @@
           }
         if (LocaleCompare("interpolate",option+1) == 0)
           {
-            long
+            ssize_t
               interpolate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
               argv[i]);
@@ -525,13 +525,13 @@
             double
               value;
 
-            long
+            ssize_t
               resource;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
               argv[i]);
@@ -539,7 +539,7 @@
               ThrowStreamException(OptionError,"UnrecognizedResourceType",
                 argv[i]);
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             value=strtod(argv[i],&p);
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
@@ -548,13 +548,13 @@
           }
         if (LocaleCompare("list",option+1) == 0)
           {
-            long
+            ssize_t
               list;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
             if (list < 0)
@@ -569,7 +569,7 @@
             if (*option == '+')
               break;
             i++;
-            if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL))
+            if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
               ThrowStreamException(OptionError,"MissingArgument",option);
             break;
           }
@@ -594,13 +594,13 @@
       {
         if (LocaleCompare("quantize",option+1) == 0)
           {
-            long
+            ssize_t
               colorspace;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             colorspace=ParseMagickOption(MagickColorspaceOptions,
               MagickFalse,argv[i]);
@@ -631,7 +631,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -642,7 +642,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -651,12 +651,12 @@
         if (LocaleCompare("set",option+1) == 0)
           {
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             break;
           }
@@ -665,7 +665,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowStreamException(OptionError,"MissingArgument",option);
             if (IsGeometry(argv[i]) == MagickFalse)
               ThrowStreamInvalidArgumentException(option,argv[i]);
@@ -673,13 +673,13 @@
           }
         if (LocaleCompare("storage-type",option+1) == 0)
           {
-            long
+            ssize_t
               type;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             type=ParseMagickOption(MagickStorageOptions,MagickFalse,argv[i]);
             if (type < 0)
@@ -697,7 +697,7 @@
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             break;
           }
@@ -711,20 +711,20 @@
             (LocaleCompare("-version",option+1) == 0))
           {
             (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
+              GetMagickVersion((size_t *) NULL));
             (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
             (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
             break;
           }
         if (LocaleCompare("virtual-pixel",option+1) == 0)
           {
-            long
+            ssize_t
               method;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) (argc-1))
+            if (i == (ssize_t) (argc-1))
               ThrowStreamException(OptionError,"MissingArgument",option);
             method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
               argv[i]);
@@ -747,7 +747,7 @@
   }
   if (k != 0)
     ThrowStreamException(OptionError,"UnbalancedParenthesis",argv[i]);
-  if (i-- != (long) (argc-1))
+  if (i-- != (ssize_t) (argc-1))
     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
   if (image == (Image *) NULL)
     ThrowStreamException(OptionError,"MissingAnImageFilename",argv[i]);
diff --git a/wand/wand.c b/wand/wand.c
index 028cb97..a473d93 100644
--- a/wand/wand.c
+++ b/wand/wand.c
@@ -68,12 +68,12 @@
 %
 %  The format of the AcquireWandId() method is:
 %
-%      unsigned long AcquireWandId()
+%      size_t AcquireWandId()
 %
 */
-WandExport unsigned long AcquireWandId(void)
+WandExport size_t AcquireWandId(void)
 {
-  static unsigned long
+  static size_t
     id = 0;
 
   if (wand_semaphore == (SemaphoreInfo *) NULL)
@@ -138,14 +138,14 @@
 %
 %  The format of the RelinquishWandId() method is:
 %
-%      void RelinquishWandId(const unsigned long *id)
+%      void RelinquishWandId(const size_t *id)
 %
 %  A description of each parameter follows:
 %
 %    o id: a unique wand id.
 %
 */
-WandExport void RelinquishWandId(const unsigned long id)
+WandExport void RelinquishWandId(const size_t id)
 {
   LockSemaphoreInfo(wand_semaphore);
   if (wand_ids != (SplayTreeInfo *) NULL)
diff --git a/wand/wand.h b/wand/wand.h
index 09e7666..8c9d07e 100644
--- a/wand/wand.h
+++ b/wand/wand.h
@@ -22,12 +22,12 @@
 extern "C" {
 #endif
 
-extern WandExport unsigned long
+extern WandExport size_t
   AcquireWandId(void);
 
 extern WandExport void
   DestroyWandIds(void),
-  RelinquishWandId(const unsigned long);
+  RelinquishWandId(const size_t);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
diff --git a/wand/wandtest.c b/wand/wandtest.c
index d8ada0d..86e554a 100644
--- a/wand/wandtest.c
+++ b/wand/wandtest.c
@@ -397,7 +397,7 @@
     *fill,
     **pixels;
 
-  register long
+  register ssize_t
     i;
 
   size_t
@@ -409,7 +409,7 @@
   unsigned int
     status;
 
-  unsigned long
+  size_t
     columns,
     delay,
     number_options,
@@ -450,7 +450,7 @@
     ThrowAPIException(magick_wand);
   if (MagickGetNumberImages(magick_wand) != 5)
     (void) fprintf(stderr,"read %lu images; expected 5\n",
-      (unsigned long) MagickGetNumberImages(magick_wand));
+      (size_t) MagickGetNumberImages(magick_wand));
   (void) fprintf(stdout,"Iterate forward...\n");
   MagickResetIterator(magick_wand);
   while (MagickNextImage(magick_wand) != MagickFalse)
@@ -623,7 +623,7 @@
   options=MagickGetOptions(magick_wand,"*",&number_options);
   if (options != (char **) NULL)
     {
-      for (i=0; i < (long) number_options; i++)
+      for (i=0; i < (ssize_t) number_options; i++)
       {
         (void) fprintf(stdout,"  %s\n",options[i]);
         options[i]=(char *) MagickRelinquishMemory(options[i]);
@@ -649,7 +649,7 @@
   properties=MagickGetImageProperties(magick_wand,"*",&number_properties);
   if (properties != (char **) NULL)
     {
-      for (i=0; i < (long) number_properties; i++)
+      for (i=0; i < (ssize_t) number_properties; i++)
       {
         (void) fprintf(stdout,"  %s\n",properties[i]);
         properties[i]=(char *) MagickRelinquishMemory(properties[i]);
@@ -675,7 +675,7 @@
   profiles=MagickGetImageProfiles(magick_wand,"*",&number_profiles);
   if (profiles != (char **) NULL)
     {
-      for (i=0; i < (long) number_profiles; i++)
+      for (i=0; i < (ssize_t) number_profiles; i++)
       {
         (void) fprintf(stdout,"  %s\n",profiles[i]);
         profiles[i]=(char *) MagickRelinquishMemory(profiles[i]);
diff --git a/www/ImageMagickObject.html b/www/ImageMagickObject.html
index da81058..fa03212 100644
--- a/www/ImageMagickObject.html
+++ b/www/ImageMagickObject.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -207,7 +207,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/advanced-unix-installation.html b/www/advanced-unix-installation.html
index fb6765e..631caf7 100644
--- a/www/advanced-unix-installation.html
+++ b/www/advanced-unix-installation.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
diff --git a/www/advanced-windows-installation.html b/www/advanced-windows-installation.html
index 2bb4a50..1f0c896 100644
--- a/www/advanced-windows-installation.html
+++ b/www/advanced-windows-installation.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -483,7 +483,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/animate.html b/www/animate.html
index 1c13861..d7b40bd 100644
--- a/www/animate.html
+++ b/www/animate.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/api.html b/www/api.html
index 79ea018..e3c7186 100644
--- a/www/api.html
+++ b/www/api.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -141,9 +141,6 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
-<div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
-</div>
 </div>
 </div>
 

@@ -160,7 +157,7 @@
   <h2><a name="ada"></a>Ada</h2>
 </div>
 
-<p><a href="https://gna.org/projects/g2f/" target="1089492569">G2F</a> implements an Ada 95 binding to a subset of the low-level MagickCore library.</p>
+<p><a href="https://gna.org/projects/g2f/" target="252018901">G2F</a> implements an Ada 95 binding to a subset of the low-level MagickCore library.</p>
 
 <div style="margin: auto;">
   <h2><a name="c"></a>C</h2>
@@ -172,7 +169,7 @@
   <h2><a name="ch"></a>Ch</h2>
 </div>
 
-<p><a href="http://www.imagemagick.org/ChMagick" target="1526012439">ChMagick</a> is a <a href="http://www.softintegration.com/" target="2070652580">Ch</a> binding to the MagickCore and MagickWand API.  Ch is an embeddable C/C++ interpreter for cross-platform scripting.</p>
+<p><a href="http://www.imagemagick.org/ChMagick" target="1163532140">ChMagick</a> is a <a href="http://www.softintegration.com/" target="969238561">Ch</a> binding to the MagickCore and MagickWand API.  Ch is an embeddable C/C++ interpreter for cross-platform scripting.</p>
 
 <div style="margin: auto;">
   <h2><a name="com+"></a>COM+</h2>
@@ -184,31 +181,31 @@
   <h2><a name="c++"></a>C++</h2>
 </div>
 
-<p><a href="http://www.imagemagick.org/Magick++" target="221498895">Magick++</a> provides an object-oriented C++ interface to ImageMagick.  See <a href="http://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.pdf" target="1382875650">A Gentle Introduction to Magick++</a> for an introductory tutorial to Magick++.  We include the <a href="http://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.odt" target="509302388">source</a> if you want to correct, enhance, or expand the tutorial.</p>
+<p><a href="http://www.imagemagick.org/Magick++" target="1408775084">Magick++</a> provides an object-oriented C++ interface to ImageMagick.  See <a href="http://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.pdf" target="1260603179">A Gentle Introduction to Magick++</a> for an introductory tutorial to Magick++.  We include the <a href="http://www.imagemagick.org/Magick++/tutorial/Magick++_tutorial.odt" target="335777325">source</a> if you want to correct, enhance, or expand the tutorial.</p>
 
 <div style="margin: auto;">
   <h2><a name="java"></a>Java</h2>
 </div>
 
-<p><a href="http://www.jmagick.org" target="1056892485">JMagick</a> provides an object-oriented Java interface to ImageMagick.  <a href="http://im4java.sourceforge.net" target="381935970">Im4java</a> is a pure-java interface to the ImageMagick command-line.</p>
+<p><a href="http://www.jmagick.org" target="1471945007">JMagick</a> provides an object-oriented Java interface to ImageMagick.  <a href="http://im4java.sourceforge.net" target="1212024219">Im4java</a> is a pure-java interface to the ImageMagick command-line.</p>
 
 <div style="margin: auto;">
   <h2><a name="labview"></a>LabVIEW</h2>
 </div>
 
-<p><a href="http://forums.lavag.org/downloads-file90.html" target="1231756940">LVOOP ImageMagick</a> is an object-oriented LabVIEW interface to ImageMagick.</p>
+<p><a href="http://forums.lavag.org/downloads-file90.html" target="1090126260">LVOOP ImageMagick</a> is an object-oriented LabVIEW interface to ImageMagick.</p>
 
 <div style="margin: auto;">
   <h2><a name="lisp"></a>Lisp</h2>
 </div>
 
-<p><a href="http://common-lisp.net/project/cl-magick/" target="733737925">CL-Magick</a> provides a Common Lisp interface to the ImageMagick library.</p>
+<p><a href="http://common-lisp.net/project/cl-magick/" target="1180952957">CL-Magick</a> provides a Common Lisp interface to the ImageMagick library.</p>
 
 <div style="margin: auto;">
   <h2><a name="neko"></a>Neko</h2>
 </div>
 
-<p><a href="http://code.google.com/p/nmagick" target="421823795">NMagick</a> is a port of the ImageMagick library to the haXe and Neko platforms. It provides image manipulation capabilities to both web and desktop applications using Neko.</p>
+<p><a href="http://code.google.com/p/nmagick" target="1150271294">NMagick</a> is a port of the ImageMagick library to the haXe and Neko platforms. It provides image manipulation capabilities to both web and desktop applications using Neko.</p>
 
 <div style="margin: auto;">
   <h2><a name="dot-net"></a>.NET</h2>
@@ -222,7 +219,7 @@
   <h2><a name="pascal"></a>Pascal</h2>
 </div>
 
-<p><a href="http://wiki.lazarus.freepascal.org/PascalMagick" target="1845812914">PascalMagick</a> a Pascal binding for the MagickWand API and also the low-level MagickCore library. It works with Free Pascal / Lazarus and Delphi.</p>
+<p><a href="http://wiki.lazarus.freepascal.org/PascalMagick" target="535693969">PascalMagick</a> a Pascal binding for the MagickWand API and also the low-level MagickCore library. It works with Free Pascal / Lazarus and Delphi.</p>
 
 <div style="margin: auto;">
   <h2><a name="perl"></a>Perl</h2>
@@ -234,50 +231,50 @@
   <h2><a name="php"></a>PHP</h2>
 </div>
 
-<p><a href="http://www.magickwand.org/" target="1909089755">MagickWand for PHP</a> a native PHP-extension to the ImageMagick MagickWand API.</p>
+<p><a href="http://www.magickwand.org/" target="21697294">MagickWand for PHP</a> a native PHP-extension to the ImageMagick MagickWand API.</p>
 
-<p><a href="http://pecl.html.net/package/imagick" target="1329356494">IMagick</a> is a native PHP extension to create and modify images using the ImageMagick API.  Documentation for the extension is available <a href="http://php.net/imagick" target="1622970808">here</a>.</p>
+<p><a href="http://pecl.html.net/package/imagick" target="1691491463">IMagick</a> is a native PHP extension to create and modify images using the ImageMagick API.  Documentation for the extension is available <a href="http://php.net/imagick" target="539913456">here</a>.</p>
 
-<p><a href="http://www.francodacosta.com/phmagick" target="484738604">phMagick</a> is a wrapper class for ImageMagick, wrapping the most common web image manipulation actions in easy to use functions, but allowing full access to ImageMagick's power by issuing system calls to it's command-line programs.</p>
+<p><a href="http://www.francodacosta.com/phmagick" target="822290100">phMagick</a> is a wrapper class for ImageMagick, wrapping the most common web image manipulation actions in easy to use functions, but allowing full access to ImageMagick's power by issuing system calls to it's command-line programs.</p>
 
 <div style="margin: auto;">
 
   <h2><a name="python"></a>Python</h2>
 </div>
 
-<p><a href="http://www.assembla.com/wiki/show/pythonmagickwand" target="1261903444">PythonMagickWand</a> is an object-oriented Python interface to MagickWand based on ctypes.</p>
+<p><a href="http://www.assembla.com/wiki/show/pythonmagickwand" target="1716975902">PythonMagickWand</a> is an object-oriented Python interface to MagickWand based on ctypes.</p>
 
-<p><a href="http://www.imagemagick.org/download/python/" target="843387501">PythonMagick</a> is an object-oriented Python interface to ImageMagick.</p>
+<p><a href="http://www.imagemagick.org/download/python/" target="1506316023">PythonMagick</a> is an object-oriented Python interface to ImageMagick.</p>
 
 <div style="margin: auto;">
   <h2><a name="realbasic"></a>REALbasic</h2>
 </div>
 
-<p>The <a href="http://www.monkeybreadsoftware.de/realbasic/plugin-imagemagick.shtml" target="1137551136">MBS Realbasic ImageMagick</a> is a plugin that utilizes the power of ImageMagick from within the RealBasic environment.</p>
+<p>The <a href="http://www.monkeybreadsoftware.de/realbasic/plugin-imagemagick.shtml" target="311378014">MBS Realbasic ImageMagick</a> is a plugin that utilizes the power of ImageMagick from within the RealBasic environment.</p>
 
 <div style="margin: auto;">
   <h2><a name="ruby"></a>Ruby</h2>
 </div>
 
-<p><a href="http://rmagick.rubyforge.org/" target="1026532304">RMagick</a> is an interface between the Ruby programming language and the <a href="../www/magick-core.html">MagickCore</a> image processing libraries.  Get started with RMagick by perusing the <a href="http://www.imagemagick.org/RMagick/doc/" target="357098599">documentation</a>.</p>
+<p><a href="http://rmagick.rubyforge.org/" target="1631698702">RMagick</a> is an interface between the Ruby programming language and the <a href="../www/magick-core.html">MagickCore</a> image processing libraries.  Get started with RMagick by perusing the <a href="http://www.imagemagick.org/RMagick/doc/" target="1022802532">documentation</a>.</p>
 
-<p><a href="http://magickwand.rubyforge.org/" target="1784725015">MagickWand for Ruby</a> is an interface between the Ruby programming language and the <a href="../www/magick-wand.html">MagickWand</a> image processing libraries.  Get started with MagickWand for PHP by perusing the <a href="http://magickwand.rubyforge.org/" target="891616272">documentation</a>.</p>
+<p><a href="http://magickwand.rubyforge.org/" target="1774790553">MagickWand for Ruby</a> is an interface between the Ruby programming language and the <a href="../www/magick-wand.html">MagickWand</a> image processing libraries.  Get started with MagickWand for PHP by perusing the <a href="http://magickwand.rubyforge.org/" target="1984775743">documentation</a>.</p>
 
-<p><a href="http://rubyforge.org/projects/mini-magick" target="1368413405">MiniMagick</a> is a Ruby wrapper for ImageMagick command line. MiniMagick gives you convenient access to all the command line options ImageMagick supports.</p>
+<p><a href="http://rubyforge.org/projects/mini-magick" target="624540314">MiniMagick</a> is a Ruby wrapper for ImageMagick command line. MiniMagick gives you convenient access to all the command line options ImageMagick supports.</p>
 
-<p><a href="http://quickmagick.rubyforge.org/quick_magick" target="1140801860">QuickMagick</a> is a gem for easily accessing ImageMagick command line tools from Ruby programs.</p>
+<p><a href="http://quickmagick.rubyforge.org/quick_magick" target="984741906">QuickMagick</a> is a gem for easily accessing ImageMagick command line tools from Ruby programs.</p>
 
 <div style="margin: auto;">
   <h2><a name="tcl"></a>Tcl/Tk</h2>
 </div>
 
-<p><a href="http://tclmagick.sourceforge.net/" target="720267735">TclMagick</a> a native Tcl-extension to the ImageMagick MagickWand API.</p>
+<p><a href="http://tclmagick.sourceforge.net/" target="7010582">TclMagick</a> a native Tcl-extension to the ImageMagick MagickWand API.</p>
 
 <div style="margin: auto;">
   <h2><a name="xml-rpc"></a>XML RPC</h2>
 </div>
 
-<p><a href="http://code.google.com/p/remotemagick/" target="1736047389">RemoteMagick</a> is an XML-RPC web service that creates image thumbnails.</p>
+<p><a href="http://code.google.com/p/remotemagick/" target="1255506170">RemoteMagick</a> is an XML-RPC web service that creates image thumbnails.</p>
 

 </div>

 

diff --git a/www/api/animate.html b/www/api/animate.html
index 348f6dc..40a4eda 100644
--- a/www/api/animate.html
+++ b/www/api/animate.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/api/annotate.html b/www/api/annotate.html
index 8f4f521..7a3bcd4 100644
--- a/www/api/annotate.html
+++ b/www/api/annotate.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -208,7 +208,7 @@
 <p>The format of the FormatMagickCaption method is:</p>
 
 <pre class="code">
-  long FormatMagickCaption(Image *image,DrawInfo *draw_info,
+  ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
     TypeMetric *metrics,char **caption)
 </pre>
 
@@ -322,7 +322,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/attribute.html b/www/api/attribute.html
index ec4cab5..fff56ef 100644
--- a/www/api/attribute.html
+++ b/www/api/attribute.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -163,8 +163,8 @@
 <p>The format of the GetImageChannelDepth method is:</p>
 
 <pre class="code">
-  unsigned long GetImageDepth(const Image *image,ExceptionInfo *exception)
-  unsigned long GetImageChannelDepth(const Image *image,
+  size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
+  size_t GetImageChannelDepth(const Image *image,
     const ChannelType channel,ExceptionInfo *exception)
 </pre>
 
@@ -189,7 +189,7 @@
 <p>The format of the GetImageQuantumDepth method is:</p>
 
 <pre class="code">
-  unsigned long GetImageQuantumDepth(const Image *image,
+  size_t GetImageQuantumDepth(const Image *image,
     const MagickBooleanType constrain)
 </pre>
 
@@ -306,9 +306,9 @@
 <p>The format of the SetImageChannelDepth method is:</p>
 
 <pre class="code">
-  MagickBooleanType SetImageDepth(Image *image,const unsigned long depth)
+  MagickBooleanType SetImageDepth(Image *image,const size_t depth)
   MagickBooleanType SetImageChannelDepth(Image *image,
-    const ChannelType channel,const unsigned long depth)
+    const ChannelType channel,const size_t depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/blob.html b/www/api/blob.html
index 9fc2941..73e410c 100644
--- a/www/api/blob.html
+++ b/www/api/blob.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -343,7 +343,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/cache-view.html b/www/api/cache-view.html
index fde7ae0..c781c02 100644
--- a/www/api/cache-view.html
+++ b/www/api/cache-view.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -272,8 +272,8 @@
 
 <pre class="code">
   PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -295,7 +295,7 @@
 
 <pre class="code">
   MagickBooleaNType GetOneCacheViewAuthenticPixel(
-    const CacheView *cache_view,const long x,const long y,
+    const CacheView *cache_view,const ssize_t x,const ssize_t y,
     Pixelpacket *pixel,ExceptionInfo *exception)
 </pre>
 
@@ -398,8 +398,8 @@
 
 <pre class="code">
   const PixelPacket *GetCacheViewVirtualPixels(
-    const CacheView *cache_view,const long x,const long y,
-    const unsigned long columns,const unsigned long rows,
+    const CacheView *cache_view,const ssize_t x,const ssize_t y,
+    const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
@@ -425,7 +425,7 @@
 
 <pre class="code">
   MagickBooleanType GetOneCacheViewVirtualPixel(
-    const CacheView *cache_view,const long x,const long y,
+    const CacheView *cache_view,const ssize_t x,const ssize_t y,
     PixelPacket *pixel,ExceptionInfo *exception)
 </pre>
 
@@ -455,8 +455,8 @@
 <pre class="code">
   MagickBooleanType GetOneCacheViewVirtualMethodPixel(
     const CacheView *cache_view,
-    const VirtualPixelMethod virtual_pixel_method,const long x,
-    const long y,PixelPacket *pixel,ExceptionInfo *exception)
+    const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+    const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -487,8 +487,8 @@
 
 <pre class="code">
   PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/cache.html b/www/api/cache.html
index 5669047..d8ce27e 100644
--- a/www/api/cache.html
+++ b/www/api/cache.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -163,7 +163,7 @@
 <p>The format of the AcquirePixelCacheNexus method is:</p>
 
 <pre class="code">
-  NexusInfo **AcquirePixelCacheNexus(const unsigned long number_threads)
+  NexusInfo **AcquirePixelCacheNexus(const size_t number_threads)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -221,8 +221,8 @@
 <p>The format of the GetAuthenticPixels() method is:</p>
 
 <pre class="code">
-  PixelPacket *GetAuthenticPixels(Image *image,const long x,const long y,
-    const unsigned long columns,const unsigned long rows,
+  PixelPacket *GetAuthenticPixels(Image *image,const ssize_t x,const ssize_t y,
+    const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
@@ -247,8 +247,8 @@
 <p>The format of the GetOneAuthenticPixel() method is:</p>
 
 <pre class="code">
-  MagickBooleanType GetOneAuthenticPixel(const Image image,const long x,
-    const long y,PixelPacket *pixel,ExceptionInfo *exception)
+  MagickBooleanType GetOneAuthenticPixel(const Image image,const ssize_t x,
+    const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -276,7 +276,7 @@
 
 <pre class="code">
   MagickBooleanType GetOneVirtualMagickPixel(const Image image,
-    const long x,const long y,MagickPixelPacket *pixel,
+    const ssize_t x,const ssize_t y,MagickPixelPacket *pixel,
     ExceptionInfo exception)
 </pre>
 
@@ -305,8 +305,8 @@
 
 <pre class="code">
   MagickBooleanType GetOneVirtualMethodPixel(const Image image,
-    const VirtualPixelMethod virtual_pixel_method,const long x,
-    const long y,Pixelpacket *pixel,ExceptionInfo exception)
+    const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+    const ssize_t y,Pixelpacket *pixel,ExceptionInfo exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -336,8 +336,8 @@
 <p>The format of the GetOneVirtualPixel() method is:</p>
 
 <pre class="code">
-  MagickBooleanType GetOneVirtualPixel(const Image image,const long x,
-    const long y,PixelPacket *pixel,ExceptionInfo exception)
+  MagickBooleanType GetOneVirtualPixel(const Image image,const ssize_t x,
+    const ssize_t y,PixelPacket *pixel,ExceptionInfo exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -412,8 +412,8 @@
 <p>The format of the GetVirtualPixels() method is:</p>
 
 <pre class="code">
-  const PixelPacket *GetVirtualPixels(const Image *image,const long x,
-    const long y,const unsigned long columns,const unsigned long rows,
+  const PixelPacket *GetVirtualPixels(const Image *image,const ssize_t x,
+    const ssize_t y,const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
@@ -444,8 +444,8 @@
 <p>The format of the QueueAuthenticPixels() method is:</p>
 
 <pre class="code">
-  PixelPacket *QueueAuthenticPixels(Image *image,const long x,const long y,
-    const unsigned long columns,const unsigned long rows,
+  PixelPacket *QueueAuthenticPixels(Image *image,const ssize_t x,const ssize_t y,
+    const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
diff --git a/www/api/cipher.html b/www/api/cipher.html
index 9814314..ff2657f 100644
--- a/www/api/cipher.html
+++ b/www/api/cipher.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/api/color.html b/www/api/color.html
index 99a642e..05ec67a 100644
--- a/www/api/color.html
+++ b/www/api/color.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -164,7 +164,7 @@
 
 <pre class="text">
   const ColorInfo **GetColorInfoList(const char *pattern,
-    unsigned long *number_colors,ExceptionInfo *exception)
+    size_t *number_colors,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -188,7 +188,7 @@
 <p>The format of the GetColorList function is:</p>
 
 <pre class="text">
-  char **GetColorList(const char *pattern,unsigned long *number_colors,
+  char **GetColorList(const char *pattern,size_t *number_colors,
     ExceptionInfo *exception)
 </pre>
 
@@ -368,7 +368,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/colormap.html b/www/api/colormap.html
index 90cc78b..be7c193 100644
--- a/www/api/colormap.html
+++ b/www/api/colormap.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -164,7 +164,7 @@
 
 <pre class="code">
   MagickBooleanType AcquireImageColormap(Image *image,
-    const unsigned long colors)
+    const size_t colors)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -185,7 +185,7 @@
 <p>The format of the CycleColormapImage method is:</p>
 
 <pre class="code">
-  MagickBooleanType CycleColormapImage(Image *image,const long displace)
+  MagickBooleanType CycleColormapImage(Image *image,const ssize_t displace)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/compare.html b/www/api/compare.html
index 871423a..74cf34a 100644
--- a/www/api/compare.html
+++ b/www/api/compare.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -325,7 +325,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/composite.html b/www/api/composite.html
index 4e93c32..4671038 100644
--- a/www/api/composite.html
+++ b/www/api/composite.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -165,10 +165,10 @@
 <pre class="code">
   MagickBooleanType CompositeImage(Image *image,
     const CompositeOperator compose,Image *composite_image,
-    const long x_offset,const long y_offset)
+    const ssize_t x_offset,const ssize_t y_offset)
   MagickBooleanType CompositeImageChannel(Image *image,
     const ChannelType channel,const CompositeOperator compose,
-    Image *composite_image,const long x_offset,const long y_offset)
+    Image *composite_image,const ssize_t x_offset,const ssize_t y_offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -232,7 +232,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/constitute.html b/www/api/constitute.html
index e06b8a0..be09170 100644
--- a/www/api/constitute.html
+++ b/www/api/constitute.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -167,8 +167,8 @@
 <p>The format of the ConstituteImage method is:</p>
 
 <pre class="code">
-  Image *ConstituteImage(const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType storage,
+  Image *ConstituteImage(const size_t columns,
+    const size_t rows,const char *map,const StorageType storage,
     const void *pixels,ExceptionInfo *exception)
 </pre>
 
@@ -333,7 +333,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/decorate.html b/www/api/decorate.html
index c84cdfa..c441812 100644
--- a/www/api/decorate.html
+++ b/www/api/decorate.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -236,7 +236,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/deprecate.html b/www/api/deprecate.html
index 94a9144..980a684 100644
--- a/www/api/deprecate.html
+++ b/www/api/deprecate.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -194,8 +194,8 @@
 
 <pre class="code">
   const PixelPacket *AcquireCacheViewPixels(const CacheView *cache_view,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -231,8 +231,8 @@
 <p>The format of the AcquireImagePixels() method is:</p>
 
 <pre class="code">
-  const PixelPacket *AcquireImagePixels(const Image *image,const long x,
-    const long y,const unsigned long columns,const unsigned long rows,
+  const PixelPacket *AcquireImagePixels(const Image *image,const ssize_t x,
+    const ssize_t y,const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
@@ -309,7 +309,7 @@
 
 <pre class="code">
   MagickBooleanType AcquireOneCacheViewPixel(const CacheView *cache_view,
-    const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
+    const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -345,8 +345,8 @@
 <pre class="code">
   MagickBooleanType AcquireOneCacheViewVirtualPixel(
     const CacheView *cache_view,
-    const VirtualPixelMethod virtual_pixel_method,const long x,
-    const long y,PixelPacket *pixel,ExceptionInfo *exception)
+    const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+    const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -383,8 +383,8 @@
 <p>The format of the AcquireOneMagickPixel() method is:</p>
 
 <pre class="code">
-  MagickPixelPacket AcquireOneMagickPixel(const Image image,const long x,
-    const long y,ExceptionInfo exception)
+  MagickPixelPacket AcquireOneMagickPixel(const Image image,const ssize_t x,
+    const ssize_t y,ExceptionInfo exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -415,8 +415,8 @@
 <p>The format of the AcquireOnePixel() method is:</p>
 
 <pre class="code">
-  PixelPacket AcquireOnePixel(const Image image,const long x,
-    const long y,ExceptionInfo exception)
+  PixelPacket AcquireOnePixel(const Image image,const ssize_t x,
+    const ssize_t y,ExceptionInfo exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -448,8 +448,8 @@
 
 <pre class="code">
   PixelPacket AcquireOneVirtualPixel(const Image image,
-    const VirtualPixelMethod virtual_pixel_method,const long x,
-    const long y,ExceptionInfo exception)
+    const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
+    const ssize_t y,ExceptionInfo exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -593,7 +593,7 @@
 
 <pre class="code">
   MagickBooleanType AllocateImageColormap(Image *image,
-    const unsigned long colors)
+    const size_t colors)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -819,7 +819,7 @@
 <pre class="code">
   MagickBooleanType ColorFloodfillImage(Image *image,
     const DrawInfo *draw_info,const PixelPacket target,
-    const long x_offset,const long y_offset,const PaintMethod method)
+    const ssize_t x_offset,const ssize_t y_offset,const PaintMethod method)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -876,7 +876,7 @@
 <p>The format of the DeleteImageList method is:</p>
 
 <pre class="code">
-  unsigned int DeleteImageList(Image *images,const long offset)
+  unsigned int DeleteImageList(Image *images,const ssize_t offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -905,7 +905,7 @@
 <p>The format of the DeleteMagickRegistry method is:</p>
 
 <pre class="code">
-  MagickBooleanType DeleteMagickRegistry(const long id)
+  MagickBooleanType DeleteMagickRegistry(const ssize_t id)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1010,7 +1010,7 @@
 _8c.html" target="source" name="DispatchImage">DispatchImage</a></h2>
 <div class="doc-section">
 
-<p>DispatchImage() extracts pixel data from an image and returns it to you. The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The data is returned as char, short int, int, long, float, or double in the order specified by map.</p></ol>
+<p>DispatchImage() extracts pixel data from an image and returns it to you. The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The data is returned as char, short int, int, ssize_t, float, or double in the order specified by map.</p></ol>
 
 <p>Suppose you want to extract the first scanline of a 640x480 image as character data in red-green-blue order:</p>
 
@@ -1028,9 +1028,9 @@
 <p>The format of the DispatchImage method is:</p>
 
 <pre class="code">
-  unsigned int DispatchImage(const Image *image,const long x_offset,
-    const long y_offset,const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType type,
+  unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
+    const ssize_t y_offset,const size_t columns,
+    const size_t rows,const char *map,const StorageType type,
     void *pixels,ExceptionInfo *exception)
 </pre>
 
@@ -1196,8 +1196,8 @@
 <p>The format of the GetCacheView method is:</p>
 
 <pre class="code">
-  PixelPacket *GetCacheView(CacheView *cache_view,const long x,
-    const long y,const unsigned long columns,const unsigned long rows)
+  PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
+    const ssize_t y,const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1249,8 +1249,8 @@
 <p>The format of the GetCacheViewPixels method is:</p>
 
 <pre class="code">
-  PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
-    const long y,const unsigned long columns,const unsigned long rows)
+  PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+    const ssize_t y,const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1326,7 +1326,7 @@
 <p>The format of the GetImageFromMagickRegistry method is:</p>
 
 <pre class="code">
-  Image *GetImageFromMagickRegistry(const char *name,long *id,
+  Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
     ExceptionInfo *exception)
 </pre>
 
@@ -1351,7 +1351,7 @@
 <p>The format of the GetMagickRegistry method is:</p>
 
 <pre class="code">
-  const void *GetMagickRegistry(const long id,RegistryType *type,
+  const void *GetMagickRegistry(const ssize_t id,RegistryType *type,
     size_t *length,ExceptionInfo *exception)
 </pre>
 
@@ -1415,14 +1415,14 @@
 <p>Deprecated, replace with:</p>
 
 <pre class="text">
-      CloneImage(GetImageFromList(images,(long) offset),0,0,MagickTrue,
+      CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
   exception);
 </pre>
 
 <p>The format of the GetImageList method is:</p>
 
 <pre class="code">
-  Image *GetImageList(const Image *images,const long offset,
+  Image *GetImageList(const Image *images,const ssize_t offset,
     ExceptionInfo *exception)
 </pre>
 
@@ -1453,7 +1453,7 @@
 <p>The format of the GetImageListIndex method is:</p>
 
 <pre class="code">
-  long GetImageListIndex(const Image *images)
+  ssize_t GetImageListIndex(const Image *images)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1477,7 +1477,7 @@
 <p>The format of the GetImageListSize method is:</p>
 
 <pre class="code">
-  unsigned long GetImageListSize(const Image *images)
+  size_t GetImageListSize(const Image *images)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1505,8 +1505,8 @@
 <p>The format of the GetImagePixels() method is:</p>
 
 <pre class="code">
-  PixelPacket *GetImagePixels(Image *image,const long x,const long y,
-    const unsigned long columns,const unsigned long rows)
+  PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1635,7 +1635,7 @@
 <p>The format of the GetOnePixel() method is:</p>
 
 <pre class="code">
-  PixelPacket GetOnePixel(const Image image,const long x,const long y)
+  PixelPacket GetOnePixel(const Image image,const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2037,8 +2037,8 @@
 
 <pre class="code">
   MagickBooleanType MatteFloodfillImage(Image *image,
-    const PixelPacket target,const Quantum opacity,const long x_offset,
-    const long y_offset,const PaintMethod method)
+    const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
+    const ssize_t y_offset,const PaintMethod method)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2210,8 +2210,8 @@
 
 <pre class="code">
   MagickBooleanType PaintFloodfillImage(Image *image,
-    const ChannelType channel,const MagickPixelPacket target,const long x,
-    const long y,const DrawInfo *draw_info,const PaintMethod method)
+    const ChannelType channel,const MagickPixelPacket target,const ssize_t x,
+    const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2560,7 +2560,7 @@
 <p>The format of the RecolorImage method is:</p>
 
 <pre class="code">
-  Image *RecolorImage(const Image *image,const unsigned long order,
+  Image *RecolorImage(const Image *image,const size_t order,
     const double *color_matrix,ExceptionInfo *exception)
 </pre>
 
@@ -2619,8 +2619,8 @@
 <p>The format of the SetCacheViewPixels method is:</p>
 
 <pre class="code">
-  PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
-    const long y,const unsigned long columns,const unsigned long rows)
+  PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
+    const ssize_t y,const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2716,7 +2716,7 @@
 
 <pre class="code">
   unsigned int SetImageList(Image *images,const Image *image,
-    const long offset,ExceptionInfo *exception)
+    const ssize_t offset,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2755,8 +2755,8 @@
 <p>The format of the SetImagePixels() method is:</p>
 
 <pre class="code">
-  PixelPacket *SetImagePixels(Image *image,const long x,const long y,
-    const unsigned long columns,const unsigned long rows)
+  PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2780,7 +2780,7 @@
 <p>The format of the SetMagickRegistry method is:</p>
 
 <pre class="code">
-  long SetMagickRegistry(const RegistryType type,const void *blob,
+  ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
     const size_t length,ExceptionInfo *exception)
 </pre>
 
@@ -2850,8 +2850,8 @@
 <p>The format of the SpliceImageList method is:</p>
 
 <pre class="code">
-  Image *SpliceImageList(Image *images,const long offset,
-    const unsigned long length,const Image *splices,
+  Image *SpliceImageList(Image *images,const ssize_t offset,
+    const size_t length,const Image *splices,
     ExceptionInfo *exception)
 </pre>
 
@@ -3144,7 +3144,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/display.html b/www/api/display.html
index e63c4cb..860baed 100644
--- a/www/api/display.html
+++ b/www/api/display.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -236,7 +236,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/distort.html b/www/api/distort.html
index c003a62..3b16298 100644
--- a/www/api/distort.html
+++ b/www/api/distort.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -168,7 +168,7 @@
 
 <pre class="code">
   Image *DistortImage(const Image *image,const DistortImageMethod method,
-    const unsigned long number_arguments,const double *arguments,
+    const size_t number_arguments,const double *arguments,
     MagickBooleanType bestfit, ExceptionInfo *exception)
 </pre>
 
@@ -223,7 +223,7 @@
 
 <pre class="code">
   Image *SparseColorImage(const Image *image,const ChannelType channel,
-    const SparseColorMethod method,const unsigned long number_arguments,
+    const SparseColorMethod method,const size_t number_arguments,
     const double *arguments,ExceptionInfo *exception)
 </pre>
 
@@ -257,7 +257,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/draw.html b/www/api/draw.html
index a39b2d6..c940302 100644
--- a/www/api/draw.html
+++ b/www/api/draw.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,6 +141,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+</div>
 </div>
 </div>
 

diff --git a/www/api/drawing-wand.html b/www/api/drawing-wand.html
index a72e501..61e8576 100644
--- a/www/api/drawing-wand.html
+++ b/www/api/drawing-wand.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -304,7 +304,7 @@
 
 <pre class="code">
   void DrawBezier(DrawingWand *wand,
-    const unsigned long number_coordinates,const PointInfo *coordinates)
+    const size_t number_coordinates,const PointInfo *coordinates)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -526,7 +526,7 @@
 _8c.html" target="source" name="DrawGetClipPath">DrawGetClipPath</a></h2>
 <div class="doc-section">
 
-<p>DrawGetClipPath() obtains the current clipping path ID. The value returned must be deallocated by the user when it is no longer needed.</p></ol>
+<p>DrawGetClipPath() obtains the current clipping path ID. The value returned must be deallocated by the user when it is no ssize_ter needed.</p></ol>
 
 <p>The format of the DrawGetClipPath method is:</p>
 
@@ -678,7 +678,7 @@
 _8c.html" target="source" name="DrawGetFont">DrawGetFont</a></h2>
 <div class="doc-section">
 
-<p>DrawGetFont() returns a null-terminaged string specifying the font used when annotating with text. The value returned must be freed by the user when no longer needed.</p></ol>
+<p>DrawGetFont() returns a null-terminaged string specifying the font used when annotating with text. The value returned must be freed by the user when no ssize_ter needed.</p></ol>
 
 <p>The format of the DrawGetFont method is:</p>
 
@@ -696,7 +696,7 @@
 _8c.html" target="source" name="DrawGetFontFamily">DrawGetFontFamily</a></h2>
 <div class="doc-section">
 
-<p>DrawGetFontFamily() returns the font family to use when annotating with text. The value returned must be freed by the user when it is no longer needed.</p></ol>
+<p>DrawGetFontFamily() returns the font family to use when annotating with text. The value returned must be freed by the user when it is no ssize_ter needed.</p></ol>
 
 <p>The format of the DrawGetFontFamily method is:</p>
 
@@ -773,7 +773,7 @@
 <p>The format of the DrawGetFontWeight method is:</p>
 
 <pre class="code">
-  unsigned long DrawGetFontWeight(const DrawingWand *wand)
+  size_t DrawGetFontWeight(const DrawingWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -862,13 +862,13 @@
 _8c.html" target="source" name="DrawGetStrokeDashArray">DrawGetStrokeDashArray</a></h2>
 <div class="doc-section">
 
-<p>DrawGetStrokeDashArray() returns an array representing the pattern of dashes and gaps used to stroke paths (see DrawSetStrokeDashArray). The array must be freed once it is no longer required by the user.</p></ol>
+<p>DrawGetStrokeDashArray() returns an array representing the pattern of dashes and gaps used to stroke paths (see DrawSetStrokeDashArray). The array must be freed once it is no ssize_ter required by the user.</p></ol>
 
 <p>The format of the DrawGetStrokeDashArray method is:</p>
 
 <pre class="code">
   double *DrawGetStrokeDashArray(const DrawingWand *wand,
-    unsigned long *number_elements)
+    size_t *number_elements)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -943,7 +943,7 @@
 <p>The format of the DrawGetStrokeMiterLimit method is:</p>
 
 <pre class="code">
-  unsigned long DrawGetStrokeMiterLimit(const DrawingWand *wand)
+  size_t DrawGetStrokeMiterLimit(const DrawingWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1046,7 +1046,7 @@
 _8c.html" target="source" name="DrawGetTextEncoding">DrawGetTextEncoding</a></h2>
 <div class="doc-section">
 
-<p>DrawGetTextEncoding() returns a null-terminated string which specifies the code set used for text annotations. The string must be freed by the user once it is no longer required.</p></ol>
+<p>DrawGetTextEncoding() returns a null-terminated string which specifies the code set used for text annotations. The string must be freed by the user once it is no ssize_ter required.</p></ol>
 
 <p>The format of the DrawGetTextEncoding method is:</p>
 
@@ -1118,7 +1118,7 @@
 _8c.html" target="source" name="DrawGetVectorGraphics">DrawGetVectorGraphics</a></h2>
 <div class="doc-section">
 
-<p>DrawGetVectorGraphics() returns a null-terminated string which specifies the vector graphics generated by any graphics calls made since the wand was instantiated.  The string must be freed by the user once it is no longer required.</p></ol>
+<p>DrawGetVectorGraphics() returns a null-terminated string which specifies the vector graphics generated by any graphics calls made since the wand was instantiated.  The string must be freed by the user once it is no ssize_ter required.</p></ol>
 
 <p>The format of the DrawGetVectorGraphics method is:</p>
 
@@ -1821,7 +1821,7 @@
 
 <pre class="code">
   void DrawPolygon(DrawingWand *wand,
-    const unsigned long number_coordinates,const PointInfo *coordinates)
+    const size_t number_coordinates,const PointInfo *coordinates)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1846,7 +1846,7 @@
 
 <pre class="code">
   void DrawPolyline(DrawingWand *wand,
-    const unsigned long number_coordinates,const PointInfo *coordinates)
+    const size_t number_coordinates,const PointInfo *coordinates)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2142,7 +2142,7 @@
 _8c.html" target="source" name="DrawSetClipPath">DrawSetClipPath</a></h2>
 <div class="doc-section">
 
-<p>DrawSetClipPath() associates a named clipping path with the image.  Only the areas drawn on by the clipping path will be modified as long as it remains in effect.</p></ol>
+<p>DrawSetClipPath() associates a named clipping path with the image.  Only the areas drawn on by the clipping path will be modified as ssize_t as it remains in effect.</p></ol>
 
 <p>The format of the DrawSetClipPath method is:</p>
 
@@ -2426,7 +2426,7 @@
 
 <pre class="code">
   void DrawSetFontWeight(DrawingWand *wand,
-    const unsigned long font_weight)
+    const size_t font_weight)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2535,7 +2535,7 @@
 
 <pre class="code">
   MagickBooleanType DrawSetStrokeDashArray(DrawingWand *wand,
-    const unsigned long number_elements,const double *dash_array)
+    const size_t number_elements,const double *dash_array)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2626,7 +2626,7 @@
 
 <pre class="code">
   void DrawSetStrokeMiterLimit(DrawingWand *wand,
-    const unsigned long miterlimit)
+    const size_t miterlimit)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2953,8 +2953,8 @@
 <p>The format of the DrawSetViewbox method is:</p>
 
 <pre class="code">
-  void DrawSetViewbox(DrawingWand *wand,unsigned long x1,
-    unsigned long y1,unsigned long x2,unsigned long y2)
+  void DrawSetViewbox(DrawingWand *wand,size_t x1,
+    size_t y1,size_t x2,size_t y2)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -3067,7 +3067,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/effect.html b/www/api/effect.html
index 46c24bd..84839e9 100644
--- a/www/api/effect.html
+++ b/www/api/effect.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -266,10 +266,10 @@
 <p>The format of the ConvolveImage method is:</p>
 
 <pre class="code">
-  Image *ConvolveImage(const Image *image,const unsigned long order,
+  Image *ConvolveImage(const Image *image,const size_t order,
     const double *kernel,ExceptionInfo *exception)
   Image *ConvolveImageChannel(const Image *image,const ChannelType channel,
-    const unsigned long order,const double *kernel,
+    const size_t order,const double *kernel,
     ExceptionInfo *exception)
 </pre>
 
@@ -491,7 +491,7 @@
 <ol><p>the standard deviation of the Gaussian, in pixels.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
 <h5>exception</h5>
 <ol><p>return any errors or warnings in this structure.</p></ol>
@@ -752,7 +752,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/enhance.html b/www/api/enhance.html
index 4c69786..75af7a1 100644
--- a/www/api/enhance.html
+++ b/www/api/enhance.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,9 +141,6 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
-<div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
-</div>
 </div>
 </div>
 

@@ -274,7 +271,7 @@
 _8c.html" target="source" name="ClutImage">ClutImage</a></h2>
 <div class="doc-section">
 
-<p>ClutImage() replaces each color value in the given image, by using it as an index to lookup a replacement color value in a Color Look UP Table in the form of an image.  The values are extracted along a diagonal of the CLUT image so either a horizontal or vertial gradient image can be used.</p></ol>
+<p>ClutImage() replaces each color value in the given image, by using it as an index to lookup a replacement color value in a Color Look UP Table in the form of an image.  The values are extracted assize_t a diagonal of the CLUT image so either a horizontal or vertial gradient image can be used.</p></ol>
 
 <p>Typically this is used to either re-color a gray-scale image according to a color gradient in the CLUT image, or to perform a freeform histogram (level) adjustment according to the (typically gray-scale) gradient in the CLUT image.</p></ol>
 
@@ -334,7 +331,7 @@
   MagickBooleanType ContrastStretchImage(Image *image,
     const char *levels)
   MagickBooleanType ContrastStretchImageChannel(Image *image,
-    const unsigned long channel,const double black_point,
+    const size_t channel,const double black_point,
     const double white_point)
 </pre>
 
@@ -726,7 +723,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/exception.html b/www/api/exception.html
index 8e39436..e17678f 100644
--- a/www/api/exception.html
+++ b/www/api/exception.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -465,7 +465,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/feature.html b/www/api/feature.html
index 1e4e238..93c58d2 100644
--- a/www/api/feature.html
+++ b/www/api/feature.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -171,7 +171,7 @@
 
 <pre class="code">
   ChannelFeatures *GetImageChannelFeatures(const Image *image,
-    const unsigned long distance,ExceptionInfo *exception)
+    const size_t distance,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -193,7 +193,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/fx.html b/www/api/fx.html
index 39fb82f..d4b5c39 100644
--- a/www/api/fx.html
+++ b/www/api/fx.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -357,7 +357,7 @@
 <p>The format of the MorphImage method is:</p>
 
 <pre class="code">
-  Image *MorphImages(const Image *image,const unsigned long number_frames,
+  Image *MorphImages(const Image *image,const size_t number_frames,
     ExceptionInfo *exception)
 </pre>
 
@@ -383,7 +383,7 @@
 
 <pre class="code">
   MagickBooleanType PlasmaImage(Image *image,const SegmentInfo *segment,
-    unsigned long attenuate,unsigned long depth)
+    size_t attenuate,size_t depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -423,7 +423,7 @@
 <ol><p>the draw info.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
 <h5>exception</h5>
 <ol><p>return any errors or warnings in this structure.</p></ol>
@@ -464,7 +464,7 @@
 
 <pre class="code">
   Image *ShadowImage(const Image *image,const double opacity,
-    const double sigma,const long x_offset,const long y_offset,
+    const double sigma,const ssize_t x_offset,const ssize_t y_offset,
     ExceptionInfo *exception)
 </pre>
 
@@ -514,7 +514,7 @@
 <ol><p>the standard deviation of the Gaussian, in pixels.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
 <h5>exception</h5>
 <ol><p>return any errors or warnings in this structure.</p></ol>
@@ -578,7 +578,7 @@
   Image *StereoImage(const Image *left_image,const Image *right_image,
     ExceptionInfo *exception)
   Image *StereoAnaglyphImage(const Image *left_image,
-    const Image *right_image,const long x_offset,const long y_offset,
+    const Image *right_image,const ssize_t x_offset,const ssize_t y_offset,
     ExceptionInfo *exception)
 </pre>
 
@@ -664,7 +664,7 @@
 
 <pre class="code">
   Image *VignetteImage(const Image *image,const double radius,
-    const double sigma,const long x,const long y,ExceptionInfo *exception)
+    const double sigma,const ssize_t x,const ssize_t y,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -689,7 +689,7 @@
 _8c.html" target="source" name="WaveImage">WaveImage</a></h2>
 <div class="doc-section">
 
-<p>WaveImage() creates a "ripple" effect in the image by shifting the pixels vertically along a sine wave whose amplitude and wavelength is specified by the given parameters.</p></ol>
+<p>WaveImage() creates a "ripple" effect in the image by shifting the pixels vertically assize_t a sine wave whose amplitude and wavelength is specified by the given parameters.</p></ol>
 
 <p>The format of the WaveImage method is:</p>
 
diff --git a/www/api/histogram.html b/www/api/histogram.html
index e92591c..228661a93 100644
--- a/www/api/histogram.html
+++ b/www/api/histogram.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -163,8 +163,8 @@
 <p>The format of the GetImageHistogram method is:</p>
 
 <pre class="code">
-  unsigned long GetImageHistogram(const Image *image,
-    unsigned long *number_colors,ExceptionInfo *exception)
+  size_t GetImageHistogram(const Image *image,
+    size_t *number_colors,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows.</p></ol>
@@ -266,7 +266,7 @@
 <p>The format of the GetNumberColors method is:</p>
 
 <pre class="code">
-  unsigned long GetNumberColors(const Image *image,FILE *file,
+  size_t GetNumberColors(const Image *image,FILE *file,
     ExceptionInfo *exception)
 </pre>
 
@@ -310,7 +310,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/image.html b/www/api/image.html
index 03c2224..b12e86c 100644
--- a/www/api/image.html
+++ b/www/api/image.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -285,8 +285,8 @@
 <p>The format of the CloneImage method is:</p>
 
 <pre class="code">
-  Image *CloneImage(const Image *image,const unsigned long columns,
-    const unsigned long rows,const MagickBooleanType orphan,
+  Image *CloneImage(const Image *image,const size_t columns,
+    const size_t rows,const MagickBooleanType orphan,
     ExceptionInfo *exception)
 </pre>
 
@@ -633,7 +633,7 @@
 
 <pre class="code">
   Image *NewMagickImage(const ImageInfo *image_info,
-    const unsigned long width,const unsigned long height,
+    const size_t width,const size_t height,
     const MagickPixelPacket *background)
 </pre>
 
@@ -853,7 +853,7 @@
 
 <pre class="code">
   MagickBooleanType SetImageExtent(Image *image,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/layer.html b/www/api/layer.html
index 58a550f..3b686e6 100644
--- a/www/api/layer.html
+++ b/www/api/layer.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,6 +141,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+</div>
 </div>
 </div>
 

@@ -381,7 +384,7 @@
 <pre class="code">
   void CompositeLayers(Image *destination,
       const CompositeOperator compose, Image *source,
-      const long x_offset, const long y_offset,
+      const ssize_t x_offset, const ssize_t y_offset,
       ExceptionInfo *exception);
 </pre>
 
diff --git a/www/api/list.html b/www/api/list.html
index 6b066f5..a470329 100644
--- a/www/api/list.html
+++ b/www/api/list.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -316,7 +316,7 @@
 <p>The format of the GetImageFromList method is:</p>
 
 <pre class="code">
-  Image *GetImageFromList(const Image *images,const long index)
+  Image *GetImageFromList(const Image *images,const ssize_t index)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -337,7 +337,7 @@
 <p>The format of the GetImageIndexInList method is:</p>
 
 <pre class="code">
-  long GetImageIndexInList(const Image *images)
+  ssize_t GetImageIndexInList(const Image *images)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -355,7 +355,7 @@
 <p>The format of the GetImageListLength method is:</p>
 
 <pre class="code">
-  unsigned long GetImageListLength(const Image *images)
+  size_t GetImageListLength(const Image *images)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -604,7 +604,7 @@
 <p>The format of the SpliceImageIntoList method is:</p>
 
 <pre class="code">
-  SpliceImageIntoList(Image **images,const unsigned long,
+  SpliceImageIntoList(Image **images,const size_t,
     const Image *splice)
 </pre>
 
diff --git a/www/api/magick-deprecate.html b/www/api/magick-deprecate.html
index 0c137e8..596a98d 100644
--- a/www/api/magick-deprecate.html
+++ b/www/api/magick-deprecate.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -176,7 +176,7 @@
 _8c.html" target="source" name="MagickClipPathImage">MagickClipPathImage</a></h2>
 <div class="doc-section">
 
-<p>MagickClipPathImage() clips along the named paths from the 8BIM profile, if present. Later operations take effect inside the path.  Id may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.</p></ol>
+<p>MagickClipPathImage() clips assize_t the named paths from the 8BIM profile, if present. Later operations take effect inside the path.  Id may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.</p></ol>
 
 <p>The format of the MagickClipPathImage method is:</p>
 
@@ -339,7 +339,7 @@
 <pre class="code">
   MagickBooleanType MagickColorFloodfillImage(MagickWand *wand,
     const PixelWand *fill,const double fuzz,const PixelWand *bordercolor,
-    const long x,const long y)
+    const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -426,7 +426,7 @@
 <p>The format of the MagickGetImageMatte method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageMatte(MagickWand *wand)
+  size_t MagickGetImageMatte(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -439,7 +439,7 @@
 _8c.html" target="source" name="MagickGetImagePixels">MagickGetImagePixels</a></h2>
 <div class="doc-section">
 
-<p>MagickGetImagePixels() extracts pixel data from an image and returns it to you.  The method returns MagickTrue on success otherwise MagickFalse if an error is encountered.  The data is returned as char, short int, int, long, float, or double in the order specified by map.</p></ol>
+<p>MagickGetImagePixels() extracts pixel data from an image and returns it to you.  The method returns MagickTrue on success otherwise MagickFalse if an error is encountered.  The data is returned as char, short int, int, ssize_t, float, or double in the order specified by map.</p></ol>
 
 <p>Suppose you want to extract the first scanline of a 640x480 image as character data in red-green-blue order:</p>
 
@@ -451,8 +451,8 @@
 
 <pre class="code">
   MagickBooleanType MagickGetImagePixels(MagickWand *wand,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType storage,
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,const char *map,const StorageType storage,
     void *pixels)
 </pre>
 
@@ -532,7 +532,7 @@
 <pre class="code">
   MagickBooleanType MagickMatteFloodfillImage(MagickWand *wand,
     const double alpha,const double fuzz,const PixelWand *bordercolor,
-    const long x,const long y)
+    const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -649,7 +649,7 @@
 <pre class="code">
   MagickBooleanType MagickPaintFloodfillImage(MagickWand *wand,
     const ChannelType channel,const PixelWand *fill,const double fuzz,
-    const PixelWand *bordercolor,const long x,const long y)
+    const PixelWand *bordercolor,const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -745,7 +745,7 @@
 
 <pre class="code">
   MagickBooleanType MagickRecolorImage(MagickWand *wand,
-    const unsigned long order,const double *color_matrix)
+    const size_t order,const double *color_matrix)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -794,7 +794,7 @@
 <p>The format of the MagickSetImageIndex method is:</p>
 
 <pre class="code">
-  MagickBooleanType MagickSetImageIndex(MagickWand *wand,const long index)
+  MagickBooleanType MagickSetImageIndex(MagickWand *wand,const ssize_t index)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -844,8 +844,8 @@
 
 <pre class="code">
   MagickWand *MagickRegionOfInterestImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -870,7 +870,7 @@
 _8c.html" target="source" name="MagickSetImagePixels">MagickSetImagePixels</a></h2>
 <div class="doc-section">
 
-<p>MagickSetImagePixels() accepts pixel datand stores it in the image at the location you specify.  The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The pixel data can be either char, short int, int, long, float, or double in the order specified by map.</p></ol>
+<p>MagickSetImagePixels() accepts pixel datand stores it in the image at the location you specify.  The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The pixel data can be either char, short int, int, ssize_t, float, or double in the order specified by map.</p></ol>
 
 <p>Suppose your want to upload the first scanline of a 640x480 image from character data in red-green-blue order:</p>
 
@@ -882,8 +882,8 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImagePixels(MagickWand *wand,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType storage,
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,const char *map,const StorageType storage,
     const void *pixels)
 </pre>
 
@@ -938,7 +938,7 @@
 
 <pre class="code">
   PixelWand **PixelGetNextRow(PixelIterator *iterator,
-    unsigned long *number_wands)
+    size_t *number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/magick-image.html b/www/api/magick-image.html
index d28d8c9..b271641 100644
--- a/www/api/magick-image.html
+++ b/www/api/magick-image.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -208,7 +208,7 @@
 
 <p>MagickAdaptiveResizeImage() adaptively resize image with data dependent triangulation.</p></ol>
 
-<p>MagickBooleanType MagickAdaptiveResizeImage(MagickWand *wand, const unsigned long columns,const unsigned long rows)</p></ol>
+<p>MagickBooleanType MagickAdaptiveResizeImage(MagickWand *wand, const size_t columns,const size_t rows)</p></ol>
 
 <p>A description of each parameter follows:</p></ol>
 
@@ -262,7 +262,7 @@
 
 <pre class="code">
   MagickBooleanType MagickAdaptiveThresholdImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long offset)
+    const size_t width,const size_t height,const ssize_t offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -560,8 +560,8 @@
 
 <pre class="code">
   MagickBooleanType MagickBorderImage(MagickWand *wand,
-    const PixelWand *bordercolor,const unsigned long width,
-    const unsigned long height)
+    const PixelWand *bordercolor,const size_t width,
+    const size_t height)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -646,8 +646,8 @@
 
 <pre class="code">
   MagickBooleanType MagickChopImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -696,7 +696,7 @@
 _8c.html" target="source" name="MagickClipImage">MagickClipImage</a></h2>
 <div class="doc-section">
 
-<p>MagickClipImage() clips along the first path from the 8BIM profile, if present.</p></ol>
+<p>MagickClipImage() clips assize_t the first path from the 8BIM profile, if present.</p></ol>
 
 <p>The format of the MagickClipImage method is:</p>
 
@@ -714,7 +714,7 @@
 _8c.html" target="source" name="MagickClipImagePath">MagickClipImagePath</a></h2>
 <div class="doc-section">
 
-<p>MagickClipImagePath() clips along the named paths from the 8BIM profile, if present. Later operations take effect inside the path.  Id may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.</p></ol>
+<p>MagickClipImagePath() clips assize_t the named paths from the 8BIM profile, if present. Later operations take effect inside the path.  Id may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path.</p></ol>
 
 <p>The format of the MagickClipImagePath method is:</p>
 
@@ -1001,10 +1001,10 @@
 <pre class="code">
   MagickBooleanType MagickCompositeImage(MagickWand *wand,
     const MagickWand *composite_wand,const CompositeOperator compose,
-    const long x,const long y)
+    const ssize_t x,const ssize_t y)
   MagickBooleanType MagickCompositeImageChannel(MagickWand *wand,
     const ChannelType channel,const MagickWand *composite_wand,
-    const CompositeOperator compose,const long x,const long y)
+    const CompositeOperator compose,const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1097,9 +1097,9 @@
 
 <pre class="code">
   MagickBooleanType MagickConvolveImage(MagickWand *wand,
-    const unsigned long order,const double *kernel)
+    const size_t order,const double *kernel)
   MagickBooleanType MagickConvolveImageChannel(MagickWand *wand,
-    const ChannelType channel,const unsigned long order,
+    const ChannelType channel,const size_t order,
     const double *kernel)
 </pre>
 
@@ -1128,8 +1128,8 @@
 
 <pre class="code">
   MagickBooleanType MagickCropImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1160,7 +1160,7 @@
 
 <pre class="code">
   MagickBooleanType MagickCycleColormapImage(MagickWand *wand,
-    const long displace)
+    const ssize_t displace)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1184,7 +1184,7 @@
 
 <pre class="code">
   MagickBooleanType MagickConstituteImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows,const char *map,
+    const size_t columns,const size_t rows,const char *map,
     const StorageType storage,void *pixels)
 </pre>
 
@@ -1364,7 +1364,7 @@
 
 <pre class="code">
   MagickBooleanType MagickDistortImage(MagickWand *wand,
-    const DistortImageMethod method,const unsigned long number_arguments,
+    const DistortImageMethod method,const size_t number_arguments,
     const double *arguments,const MagickBooleanType bestfit)
 </pre>
 
@@ -1562,7 +1562,7 @@
 _8c.html" target="source" name="MagickExportImagePixels">MagickExportImagePixels</a></h2>
 <div class="doc-section">
 
-<p>MagickExportImagePixels() extracts pixel data from an image and returns it to you.  The method returns MagickTrue on success otherwise MagickFalse if an error is encountered.  The data is returned as char, short int, int, long, float, or double in the order specified by map.</p></ol>
+<p>MagickExportImagePixels() extracts pixel data from an image and returns it to you.  The method returns MagickTrue on success otherwise MagickFalse if an error is encountered.  The data is returned as char, short int, int, ssize_t, float, or double in the order specified by map.</p></ol>
 
 <p>Suppose you want to extract the first scanline of a 640x480 image as character data in red-green-blue order:</p>
 
@@ -1574,8 +1574,8 @@
 
 <pre class="code">
   MagickBooleanType MagickExportImagePixels(MagickWand *wand,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType storage,
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,const char *map,const StorageType storage,
     void *pixels)
 </pre>
 
@@ -1607,8 +1607,8 @@
 
 <pre class="code">
   MagickBooleanType MagickExtentImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1685,7 +1685,7 @@
 <pre class="code">
   MagickBooleanType MagickFloodfillPaintImage(MagickWand *wand,
     const ChannelType channel,const PixelWand *fill,const double fuzz,
-    const PixelWand *bordercolor,const long x,const long y,
+    const PixelWand *bordercolor,const ssize_t x,const ssize_t y,
     const MagickBooleanType invert)
 </pre>
 
@@ -1763,9 +1763,9 @@
 
 <pre class="code">
   MagickBooleanType MagickFrameImage(MagickWand *wand,
-    const PixelWand *matte_color,const unsigned long width,
-    const unsigned long height,const long inner_bevel,
-    const long outer_bevel)
+    const PixelWand *matte_color,const size_t width,
+    const size_t height,const ssize_t inner_bevel,
+    const ssize_t outer_bevel)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1799,11 +1799,11 @@
 
 <pre class="code">
   MagickBooleanType MagickFunctionImage(MagickWand *wand,
-    const MagickFunction function,const unsigned long number_arguments,
+    const MagickFunction function,const size_t number_arguments,
     const double *arguments)
   MagickBooleanType MagickFunctionImageChannel(MagickWand *wand,
     const ChannelType channel,const MagickFunction function,
-    const unsigned long number_arguments,const double *arguments)
+    const size_t number_arguments,const double *arguments)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1935,7 +1935,7 @@
 <p>The format of the MagickGetImageAlphaChannel method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageAlphaChannel(MagickWand *wand)
+  size_t MagickGetImageAlphaChannel(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2086,7 +2086,7 @@
 <p>The format of the MagickGetImageChannelDepth method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageChannelDepth(MagickWand *wand,
+  size_t MagickGetImageChannelDepth(MagickWand *wand,
     const ChannelType channel)
 </pre>
 
@@ -2175,7 +2175,7 @@
 
 <pre class="code">
   ChannelFeatures *MagickGetImageChannelFeatures(MagickWand *wand,
-    const unsigned long distance)
+    const size_t distance)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2306,7 +2306,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetImageColormapColor(MagickWand *wand,
-    const unsigned long index,PixelWand *color)
+    const size_t index,PixelWand *color)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2330,7 +2330,7 @@
 <p>The format of the MagickGetImageColors method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageColors(MagickWand *wand)
+  size_t MagickGetImageColors(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2402,7 +2402,7 @@
 <p>The format of the MagickGetImageCompression method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageCompression(MagickWand *wand)
+  size_t MagickGetImageCompression(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2420,7 +2420,7 @@
 <p>The format of the MagickGetImageDelay method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageDelay(MagickWand *wand)
+  size_t MagickGetImageDelay(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2438,7 +2438,7 @@
 <p>The format of the MagickGetImageDepth method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageDepth(MagickWand *wand)
+  size_t MagickGetImageDepth(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2618,7 +2618,7 @@
 <p>The format of the MagickGetImageHeight method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageHeight(MagickWand *wand)
+  size_t MagickGetImageHeight(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2637,7 +2637,7 @@
 
 <pre class="code">
   PixelWand **MagickGetImageHistogram(MagickWand *wand,
-    unsigned long *number_colors)
+    size_t *number_colors)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2694,7 +2694,7 @@
 <p>The format of the MagickGetImageIterations method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageIterations(MagickWand *wand)
+  size_t MagickGetImageIterations(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2775,7 +2775,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetImagePage(MagickWand *wand,
-    unsigned long *width,unsigned long *height,long *x,long *y)
+    size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2806,7 +2806,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetImagePixelColor(MagickWand *wand,
-    const long x,const long y,PixelWand *color)
+    const ssize_t x,const ssize_t y,PixelWand *color)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2856,8 +2856,8 @@
 
 <pre class="code">
   MagickWand *MagickGetImageRegion(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2930,7 +2930,7 @@
 <p>The format of the MagickGetImageScene method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageScene(MagickWand *wand)
+  size_t MagickGetImageScene(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -2966,7 +2966,7 @@
 <p>The format of the MagickGetImageTicksPerSecond method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageTicksPerSecond(MagickWand *wand)
+  size_t MagickGetImageTicksPerSecond(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -3071,7 +3071,7 @@
 <p>The format of the MagickGetImageWidth method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetImageWidth(MagickWand *wand)
+  size_t MagickGetImageWidth(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -3089,7 +3089,7 @@
 <p>The format of the MagickGetNumberImages method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetNumberImages(MagickWand *wand)
+  size_t MagickGetNumberImages(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -3220,7 +3220,7 @@
 _8c.html" target="source" name="MagickImportImagePixels">MagickImportImagePixels</a></h2>
 <div class="doc-section">
 
-<p>MagickImportImagePixels() accepts pixel datand stores it in the image at the location you specify.  The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The pixel data can be either char, short int, int, long, float, or double in the order specified by map.</p></ol>
+<p>MagickImportImagePixels() accepts pixel datand stores it in the image at the location you specify.  The method returns MagickFalse on success otherwise MagickTrue if an error is encountered.  The pixel data can be either char, short int, int, ssize_t, float, or double in the order specified by map.</p></ol>
 
 <p>Suppose your want to upload the first scanline of a 640x480 image from character data in red-green-blue order:</p>
 
@@ -3232,8 +3232,8 @@
 
 <pre class="code">
   MagickBooleanType MagickImportImagePixels(MagickWand *wand,
-    const long x,const long y,const unsigned long columns,
-    const unsigned long rows,const char *map,const StorageType storage,
+    const ssize_t x,const ssize_t y,const size_t columns,
+    const size_t rows,const char *map,const StorageType storage,
     const void *pixels)
 </pre>
 
@@ -3369,7 +3369,7 @@
 
 <p>MagickLiquidRescaleImage() rescales image with seam carving.</p></ol>
 
-<p>MagickBooleanType MagickLiquidRescaleImage(MagickWand *wand, const unsigned long columns,const unsigned long rows, const double delta_x,const double rigidity)</p></ol>
+<p>MagickBooleanType MagickLiquidRescaleImage(MagickWand *wand, const size_t columns,const size_t rows, const double delta_x,const double rigidity)</p></ol>
 
 <p>A description of each parameter follows:</p></ol>
 
@@ -3553,7 +3553,7 @@
 
 <pre class="code">
   MagickWand *MagickMorphImages(MagickWand *wand,
-    const unsigned long number_frames)
+    const size_t number_frames)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -3575,9 +3575,9 @@
 
 <pre class="code">
   MagickBooleanType MagickMorphologyImage(MagickWand *wand,
-    MorphologyMethod method,const long iterations,KernelInfo *kernel)
+    MorphologyMethod method,const ssize_t iterations,KernelInfo *kernel)
   MagickBooleanType MagickMorphologyImageChannel(MagickWand *wand,
-    ChannelType channel,MorphologyMethod method,const long iterations,
+    ChannelType channel,MorphologyMethod method,const ssize_t iterations,
     KernelInfo *kernel)
 </pre>
 
@@ -3630,7 +3630,7 @@
 <ol><p>the standard deviation of the Gaussian, in pixels.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
  </div>
 <h2><a href="http://www.imagemagick.org/api/MagickWand/magick-image
@@ -3672,7 +3672,7 @@
 
 <pre class="code">
   MagickBooleanType MagickNewImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows,
+    const size_t columns,const size_t rows,
     const PixelWand *background)
 </pre>
 
@@ -3934,7 +3934,7 @@
 <ol><p>the draw wand.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
  </div>
 <h2><a href="http://www.imagemagick.org/api/MagickWand/magick-image
@@ -4012,8 +4012,8 @@
 
 <pre class="code">
   MagickBooleanType MagickQuantizeImage(MagickWand *wand,
-    const unsigned long number_colors,const ColorspaceType colorspace,
-    const unsigned long treedepth,const MagickBooleanType dither,
+    const size_t number_colors,const ColorspaceType colorspace,
+    const size_t treedepth,const MagickBooleanType dither,
     const MagickBooleanType measure_error)
 </pre>
 
@@ -4032,7 +4032,7 @@
 <ol><p>Normally, this integer value is zero or one.  A zero or one tells Quantize to choose a optimal tree depth of Log4(number_colors).      A tree of this depth generally allows the best representation of the reference image with the least amount of memory and the fastest computational speed.  In some cases, such as an image with low color dispersion (a few number of colors), a value other than Log4(number_colors) is required.  To expand the color tree completely, use a value of 8.</p></ol>
 
 <h5>dither</h5>
-<ol><p>A value other than zero distributes the difference between an original image and the corresponding color reduced image to neighboring pixels along a Hilbert curve.</p></ol>
+<ol><p>A value other than zero distributes the difference between an original image and the corresponding color reduced image to neighboring pixels assize_t a Hilbert curve.</p></ol>
 
 <h5>measure_error</h5>
 <ol><p>A value other than zero measures the difference between the original and quantized images.  This difference is the total quantization error.  The error is computed by summing over all pixels in an image the distance squared in RGB space between each reference pixel value and its quantized value.</p></ol>
@@ -4048,8 +4048,8 @@
 
 <pre class="code">
   MagickBooleanType MagickQuantizeImages(MagickWand *wand,
-    const unsigned long number_colors,const ColorspaceType colorspace,
-    const unsigned long treedepth,const MagickBooleanType dither,
+    const size_t number_colors,const ColorspaceType colorspace,
+    const size_t treedepth,const MagickBooleanType dither,
     const MagickBooleanType measure_error)
 </pre>
 
@@ -4068,7 +4068,7 @@
 <ol><p>Normally, this integer value is zero or one.  A zero or one tells Quantize to choose a optimal tree depth of Log4(number_colors).      A tree of this depth generally allows the best representation of the reference image with the least amount of memory and the fastest computational speed.  In some cases, such as an image with low color dispersion (a few number of colors), a value other than Log4(number_colors) is required.  To expand the color tree completely, use a value of 8.</p></ol>
 
 <h5>dither</h5>
-<ol><p>A value other than zero distributes the difference between an original image and the corresponding color reduced algorithm to neighboring pixels along a Hilbert curve.</p></ol>
+<ol><p>A value other than zero distributes the difference between an original image and the corresponding color reduced algorithm to neighboring pixels assize_t a Hilbert curve.</p></ol>
 
 <h5>measure_error</h5>
 <ol><p>A value other than zero measures the difference between the original and quantized images.  This difference is the total quantization error.  The error is computed by summing over all pixels in an image the distance squared in RGB space between each reference pixel value and its quantized value.</p></ol>
@@ -4111,8 +4111,8 @@
 
 <pre class="code">
   MagickBooleanType MagickRaiseImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y,const MagickBooleanType raise)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y,const MagickBooleanType raise)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4367,7 +4367,7 @@
 
 <pre class="code">
   MagickBooleanType MagickResizeImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows,
+    const size_t columns,const size_t rows,
     const FilterTypes filter,const double blur)
 </pre>
 
@@ -4398,8 +4398,8 @@
 <p>The format of the MagickRollImage method is:</p>
 
 <pre class="code">
-  MagickBooleanType MagickRollImage(MagickWand *wand,const long x,
-    const unsigned long y)
+  MagickBooleanType MagickRollImage(MagickWand *wand,const ssize_t x,
+    const size_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4451,7 +4451,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSampleImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4477,7 +4477,7 @@
 
 <pre class="code">
   MagickBooleanType MagickScaleImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4748,7 +4748,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageChannelDepth(MagickWand *wand,
-    const ChannelType channel,const unsigned long depth)
+    const ChannelType channel,const size_t depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4817,7 +4817,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageColormapColor(MagickWand *wand,
-    const unsigned long index,const PixelWand *color)
+    const size_t index,const PixelWand *color)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4908,7 +4908,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageCompressionQuality(MagickWand *wand,
-    const unsigned long quality)
+    const size_t quality)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4930,7 +4930,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageDelay(MagickWand *wand,
-    const unsigned long delay)
+    const size_t delay)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4952,7 +4952,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageDepth(MagickWand *wand,
-    const unsigned long depth)
+    const size_t depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -4996,7 +4996,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageExtent(MagickWand *wand,
-    const unsigned long columns,const unsigned rows)
+    const size_t columns,const unsigned rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5201,7 +5201,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageIterations(MagickWand *wand,
-    const unsigned long iterations)
+    const size_t iterations)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5311,8 +5311,8 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImagePage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5448,7 +5448,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageScene(MagickWand *wand,
-    const unsigned long scene)
+    const size_t scene)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5470,7 +5470,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetImageTicksPerSecond(MagickWand *wand,
-    const long ticks_per-second)
+    const ssize_t ticks_per-second)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5609,7 +5609,7 @@
 
 <pre class="code">
   MagickBooleanType MagickShadowImage(MagickWand *wand,
-    const double opacity,const double sigma,const long x,const long y)
+    const double opacity,const double sigma,const ssize_t x,const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5670,7 +5670,7 @@
 
 <pre class="code">
   MagickBooleanType MagickShaveImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5690,7 +5690,7 @@
 _8c.html" target="source" name="MagickShearImage">MagickShearImage</a></h2>
 <div class="doc-section">
 
-<p>MagickShearImage() slides one edge of an image along the X or Y axis, creating a parallelogram.  An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis.  The amount of the shear is controlled by a shear angle.  For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis.  Empty triangles left over from shearing the image are filled with the background color.</p></ol>
+<p>MagickShearImage() slides one edge of an image assize_t the X or Y axis, creating a parallelogram.  An X direction shear slides an edge assize_t the X axis, while a Y direction shear slides an edge assize_t the Y axis.  The amount of the shear is controlled by a shear angle.  For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis.  Empty triangles left over from shearing the image are filled with the background color.</p></ol>
 
 <p>The format of the MagickShearImage method is:</p>
 
@@ -5801,7 +5801,7 @@
 <ol><p>the standard deviation of the Gaussian, in pixels.</p></ol>
 
 <h5>angle</h5>
-<ol><p>Apply the effect along this angle.</p></ol>
+<ol><p>Apply the effect assize_t this angle.</p></ol>
 
  </div>
 <h2><a href="http://www.imagemagick.org/api/MagickWand/magick-image
@@ -5837,7 +5837,7 @@
 <pre class="code">
   MagickBooleanType MagickSparseColorImage(MagickWand *wand,
     const ChannelType channel,const SparseColorMethod method,
-    const unsigned long number_arguments,const double *arguments)
+    const size_t number_arguments,const double *arguments)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5873,8 +5873,8 @@
 
 <pre class="code">
   MagickBooleanType MagickSpliceImage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -5926,7 +5926,7 @@
 
 <pre class="code">
   MagickWand *MagickSteganoImage(MagickWand *wand,
-    const MagickWand *watermark_wand,const long offset)
+    const MagickWand *watermark_wand,const ssize_t offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -6061,7 +6061,7 @@
 
 <pre class="code">
   MagickBooleanType MagickThumbnailImage(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -6303,8 +6303,8 @@
 
 <pre class="code">
   MagickBooleanType MagickVignetteImage(MagickWand *wand,
-    const double black_point,const double white_point,const long x,
-    const long y)
+    const double black_point,const double white_point,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -6326,7 +6326,7 @@
 _8c.html" target="source" name="MagickWaveImage">MagickWaveImage</a></h2>
 <div class="doc-section">
 
-<p>MagickWaveImage()  creates a "ripple" effect in the image by shifting the pixels vertically along a sine wave whose amplitude and wavelength is specified by the given parameters.</p></ol>
+<p>MagickWaveImage()  creates a "ripple" effect in the image by shifting the pixels vertically assize_t a sine wave whose amplitude and wavelength is specified by the given parameters.</p></ol>
 
 <p>The format of the MagickWaveImage method is:</p>
 
@@ -6463,7 +6463,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/magick-property.html b/www/api/magick-property.html
index d6d0a7e..2908385 100644
--- a/www/api/magick-property.html
+++ b/www/api/magick-property.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -301,7 +301,7 @@
 <p>The format of the MagickGetCompressionQuality method is:</p>
 
 <pre class="code">
-  unsigned long MagickGetCompressionQuality(MagickWand *wand)
+  size_t MagickGetCompressionQuality(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -439,7 +439,7 @@
 
 <pre class="code">
   char *MagickGetImageArtifacts(MagickWand *wand,
-    const char *pattern,unsigned long *number_artifacts)
+    const char *pattern,size_t *number_artifacts)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -489,7 +489,7 @@
 
 <pre class="code">
   char *MagickGetImageProfiles(MagickWand *wand,
-    unsigned long *number_profiles)
+    size_t *number_profiles)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -535,7 +535,7 @@
 
 <pre class="code">
   char *MagickGetImageProperties(MagickWand *wand,
-    const char *pattern,unsigned long *number_properties)
+    const char *pattern,size_t *number_properties)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -616,7 +616,7 @@
 <p>The format of the MagickGetOptions method is:</p>
 
 <pre class="code">
-  char *MagickGetOptions(MagickWand *wand,unsigned long *number_options)
+  char *MagickGetOptions(MagickWand *wand,size_t *number_options)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -673,7 +673,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetPage(const MagickWand *wand,
-    unsigned long *width,unsigned long *height,long *x,long *y)
+    size_t *width,size_t *height,ssize_t *x,ssize_t *y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -721,7 +721,7 @@
 <p>The format of the MagickGetQuantumDepth method is:</p>
 
 <pre class="code">
-  const char *MagickGetQuantumDepth(unsigned long *depth)
+  const char *MagickGetQuantumDepth(size_t *depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -739,7 +739,7 @@
 <p>The format of the MagickGetQuantumRange method is:</p>
 
 <pre class="code">
-  const char *MagickGetQuantumRange(unsigned long *range)
+  const char *MagickGetQuantumRange(size_t *range)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -807,7 +807,7 @@
 
 <pre class="code">
   double *MagickGetSamplingFactor(MagickWand *wand,
-    unsigned long *number_factors)
+    size_t *number_factors)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -829,7 +829,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetSize(const MagickWand *wand,
-    unsigned long *columns,unsigned long *rows)
+    size_t *columns,size_t *rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -854,7 +854,7 @@
 
 <pre class="code">
   MagickBooleanType MagickGetSizeOffset(const MagickWand *wand,
-    long *offset)
+    ssize_t *offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -893,7 +893,7 @@
 <p>The format of the MagickGetVersion method is:</p>
 
 <pre class="code">
-  const char *MagickGetVersion(unsigned long *version)
+  const char *MagickGetVersion(size_t *version)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1053,7 +1053,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetCompressionQuality(MagickWand *wand,
-    const unsigned long quality)
+    const size_t quality)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1075,7 +1075,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetDepth(MagickWand *wand,
-    const unsigned long depth)
+    const size_t depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1374,8 +1374,8 @@
 
 <pre class="code">
   MagickBooleanType MagickSetPage(MagickWand *wand,
-    const unsigned long width,const unsigned long height,const long x,
-    const long y)
+    const size_t width,const size_t height,const ssize_t x,
+    const ssize_t y)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1529,7 +1529,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
-    const unsigned long number_factors,const double *sampling_factors)
+    const size_t number_factors,const double *sampling_factors)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1554,7 +1554,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetSize(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows)
+    const size_t columns,const size_t rows)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1579,8 +1579,8 @@
 
 <pre class="code">
   MagickBooleanType MagickSetSizeOffset(MagickWand *wand,
-    const unsigned long columns,const unsigned long rows,
-    const long offset)
+    const size_t columns,const size_t rows,
+    const ssize_t offset)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -1627,7 +1627,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/magick-wand.html b/www/api/magick-wand.html
index 1fe2cc2..c5c194a 100644
--- a/www/api/magick-wand.html
+++ b/www/api/magick-wand.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -292,7 +292,7 @@
 <p>The format of the MagickGetIteratorIndex method is:</p>
 
 <pre class="code">
-  long MagickGetIteratorIndex(MagickWand *wand)
+  ssize_t MagickGetIteratorIndex(MagickWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -329,7 +329,7 @@
 
 <pre class="text">
   char **MagickQueryConfigureOptions(const char *pattern,
-    unsigned long *number_options)
+    size_t *number_options)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -439,7 +439,7 @@
 <p>The format of the MagickQueryFonts function is:</p>
 
 <pre class="text">
-  char **MagickQueryFonts(const char *pattern,unsigned long *number_fonts)
+  char **MagickQueryFonts(const char *pattern,size_t *number_fonts)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -462,7 +462,7 @@
 
 <pre class="text">
   char **MagickQueryFonts(const char *pattern,
-    unsigned long *number_formats)
+    size_t *number_formats)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -538,7 +538,7 @@
 
 <pre class="code">
   MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
-    const long index)
+    const ssize_t index)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -632,7 +632,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/magick.html b/www/api/magick.html
index 3f4fe31..92e575e 100644
--- a/www/api/magick.html
+++ b/www/api/magick.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,9 +141,6 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
-<div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
-</div>
 </div>
 </div>
 

diff --git a/www/api/memory.html b/www/api/memory.html
index c92c1f1..28a934b 100644
--- a/www/api/memory.html
+++ b/www/api/memory.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
diff --git a/www/api/module.html b/www/api/module.html
index a40a1e1..3a6b3ab 100644
--- a/www/api/module.html
+++ b/www/api/module.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -219,7 +219,7 @@
 
 <pre class="text">
   const ModuleInfo **GetModuleInfoList(const char *pattern,
-    unsigned long *number_modules,ExceptionInfo *exception)
+    size_t *number_modules,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -243,7 +243,7 @@
 <p>The format of the GetModuleList function is:</p>
 
 <pre class="text">
-  char **GetModuleList(const char *pattern,unsigned long *number_modules,
+  char **GetModuleList(const char *pattern,size_t *number_modules,
     ExceptionInfo *exception)
 </pre>
 
diff --git a/www/api/monitor.html b/www/api/monitor.html
index 9a50ca7..eae0f81 100644
--- a/www/api/monitor.html
+++ b/www/api/monitor.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/api/montage.html b/www/api/montage.html
index 6c153ca..0ea720b 100644
--- a/www/api/montage.html
+++ b/www/api/montage.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/api/morphology.html b/www/api/morphology.html
index 1ea31f6..57ab5ae 100644
--- a/www/api/morphology.html
+++ b/www/api/morphology.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,6 +141,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+</div>
 </div>
 </div>
 

@@ -149,13 +152,13 @@
 

 <div class="main">

 

-<p class="navigation-index">[<a href="#same variable That is the IsNaN">same variable That is the IsNaN</a> &bull; <a href="#AcquireKernelInfo">AcquireKernelInfo</a> &bull; <a href="#AcquireKernelBuiltIn">AcquireKernelBuiltIn</a> &bull; <a href="#CloneKernelInfo">CloneKernelInfo</a> &bull; <a href="#DestroyKernelInfo">DestroyKernelInfo</a> &bull; <a href="#ExpandKernelInfo">ExpandKernelInfo</a> &bull; <a href="#MorphologyApply">MorphologyApply</a> &bull; <a href="#MorphologyImageChannel">MorphologyImageChannel</a> &bull; <a href="#ScaleGeometryKernelInfo">ScaleGeometryKernelInfo</a> &bull; <a href="#ScaleKernelInfo">ScaleKernelInfo</a> &bull; <a href="#ShowKernelInfo">ShowKernelInfo</a> &bull; <a href="#UnityAddKernelInfo">UnityAddKernelInfo</a> &bull; <a href="#ZeroKernelNans">ZeroKernelNans</a>]</p>
+<p class="navigation-index">[<a href="#** This macro  IsNaN">** This macro  IsNaN</a> &bull; <a href="#AcquireKernelInfo">AcquireKernelInfo</a> &bull; <a href="#AcquireKernelBuiltIn">AcquireKernelBuiltIn</a> &bull; <a href="#CloneKernelInfo">CloneKernelInfo</a> &bull; <a href="#DestroyKernelInfo">DestroyKernelInfo</a> &bull; <a href="#ExpandKernelInfo">ExpandKernelInfo</a> &bull; <a href="#MorphologyApply">MorphologyApply</a> &bull; <a href="#MorphologyImageChannel">MorphologyImageChannel</a> &bull; <a href="#ScaleGeometryKernelInfo">ScaleGeometryKernelInfo</a> &bull; <a href="#ScaleKernelInfo">ScaleKernelInfo</a> &bull; <a href="#ShowKernelInfo">ShowKernelInfo</a> &bull; <a href="#UnityAddKernelInfo">UnityAddKernelInfo</a> &bull; <a href="#ZeroKernelNans">ZeroKernelNans</a>]</p>
 
 <h2><a href="http://www.imagemagick.org/api/MagickCore/morphology
-_8c.html" target="source" name="same variable That is the IsNaN">same variable That is the IsNaN</a></h2>
+_8c.html" target="source" name="** This macro  IsNaN">** This macro  IsNaN</a></h2>
 <div class="doc-section">
 
-<p>same variable That is the IsNaN() macro is only true if the value is NaN. </p>
+<p>** This macro  IsNaN() is thus is only true if the value given is NaN. </p>
  </div>
 <h2><a href="http://www.imagemagick.org/api/MagickCore/morphology
 _8c.html" target="source" name="AcquireKernelInfo">AcquireKernelInfo</a></h2>
@@ -165,7 +168,7 @@
 
 <p>The kernel so generated can be any rectangular array of floating point values (doubles) with the 'control point' or 'pixel being affected' anywhere within that array of values.</p></ol>
 
-<p>Previously IM was restricted to a square of odd size using the exact center as origin, this is no longer the case, and any rectangular kernel with any value being declared the origin. This in turn allows the use of highly asymmetrical kernels.</p></ol>
+<p>Previously IM was restricted to a square of odd size using the exact center as origin, this is no ssize_ter the case, and any rectangular kernel with any value being declared the origin. This in turn allows the use of highly asymmetrical kernels.</p></ol>
 
 <p>The floating point values in the kernel can also include a special value known as 'nan' or 'not a number' to indicate that this value is not part of the kernel array. This allows you to shaped the kernel within its rectangular area. That is 'nan' values provide a 'mask' for the kernel shape.  However at least one non-nan value must be provided for correct working of a kernel.</p></ol>
 
@@ -185,7 +188,7 @@
 
 <p>" kernel ; kernel ; kernel ; "</p></ol>
 
-<p>Any extra ';' characters (at start, end or between kernel defintions are simply ignored.</p></ol>
+<p>Any extra ';' characters, at start, end or between kernel defintions are simply ignored.</p></ol>
 
 <p>Note that 'name' kernels will start with an alphabetic character while the new kernel specification has a ':' character in its specification string. If neither is the case, it is assumed an old style of a simple list of numbers generating a odd-sized square kernel has been given.</p></ol>
 
@@ -268,7 +271,13 @@
 
 <p>Roberts:{angle} Roberts convolution kernel (3x3) 0, 0, 0 -1, 1, 0 0, 0, 0 Prewitt:{angle} Prewitt Edge convolution kernel (3x3) -1, 0, 1 -1, 0, 1 -1, 0, 1 Compass:{angle} Prewitt's "Compass" convolution kernel (3x3) -1, 1, 1 -1,-2, 1 -1, 1, 1 Kirsch:{angle} Kirsch's "Compass" convolution kernel (3x3) -3,-3, 5 -3, 0, 5 -3,-3, 5</p></ol>
 
-<p>FreiChen:{type},{angle} Frei-Chen Edge Detector is a set of 9 unique convolution kernels that are specially weighted.  They should not be normalized. After applying each to the original image, the results is then added together.  The square root of the resulting image is the cosine of the edge, and the direction of the feature detection.</p></ol>
+<p>FreiChen:{type},{angle} Frei-Chen Edge Detector is a set of 9 unique convolution kernels that are specially weighted.</p></ol>
+
+<p>Type 0: |   -1,     0,   1     | | -sqrt(2), 0, sqrt(2) | |   -1,     0,   1     |</p></ol>
+
+<p>This is basically the unnormalized discrete kernel that can be used instead ot a Sobel kernel.</p></ol>
+
+<p>The next 9 kernel types are specially pre-weighted.  They should not be normalized. After applying each to the original image, the results is then added together.  The square root of the resulting image is the cosine of the edge, and the direction of the feature detection.</p></ol>
 
 <p>Type 1: |  1,   sqrt(2),  1 | |  0,     0,      0 | / 2*sqrt(2) | -1,  -sqrt(2), -1 |</p></ol>
 
@@ -290,6 +299,10 @@
 
 <p>The first 4 are for edge detection, the next 4 are for line detection and the last is to add a average component to the results.</p></ol>
 
+<p>Using a special type of '-1' will return all 9 pre-weighted kernels as a multi-kernel list, so that you can use them directly (without normalization) with the special "-set option:morphology:compose Plus" setting to apply the full FreiChen Edge Detection Technique.</p></ol>
+
+<p>If 'type' is large it will be taken to be an actual rotation angle for the default FreiChen (type 0) kernel.  As such  FreiChen:45  will look like a  Sobel:45  but with 'sqrt(2)' instead of '2' values.</p></ol>
+
 
 <p>Boolean Kernels</p></ol>
 
@@ -321,7 +334,7 @@
 
 <p>Hit and Miss Kernels</p></ol>
 
-<p>Peak:radius1,radius2 Find any peak larger than the pixels the fall between the two radii. The default ring of pixels is as per "Ring". Edges Find edges of a binary shape Corners Find corners of a binary shape Ridges Find single pixel ridges or thin lines Ridges2 Find 2 pixel thick ridges or lines LineEnds Find end points of lines (for pruning a skeletion) LineJunctions Find three line junctions (within a skeletion) ConvexHull Octagonal thicken kernel, to generate convex hulls of 45 degrees Skeleton Thinning kernel, which leaves behind a skeletion of a shape</p></ol>
+<p>Peak:radius1,radius2 Find any peak larger than the pixels the fall between the two radii. The default ring of pixels is as per "Ring". Edges Find edges of a binary shape Corners Find corners of a binary shape Ridges Find single pixel ridges or thin lines Ridges2 Find 2 pixel thick ridges or lines Ridges3 Find 2 pixel thick diagonal ridges (experimental) LineEnds Find end points of lines (for pruning a skeletion) LineJunctions Find three line junctions (within a skeletion) ConvexHull Octagonal thicken kernel, to generate convex hulls of 45 degrees Skeleton Thinning kernel, which leaves behind a skeletion of a shape</p></ol>
 
 <p>Distance Measuring Kernels</p></ol>
 
@@ -344,7 +357,7 @@
 _8c.html" target="source" name="CloneKernelInfo">CloneKernelInfo</a></h2>
 <div class="doc-section">
 
-<p>CloneKernelInfo() creates a new clone of the given Kernel List so that its can be modified without effecting the original.  The cloned kernel should be destroyed using DestoryKernelInfo() when no longer needed.</p></ol>
+<p>CloneKernelInfo() creates a new clone of the given Kernel List so that its can be modified without effecting the original.  The cloned kernel should be destroyed using DestoryKernelInfo() when no ssize_ter needed.</p></ol>
 
 <p>The format of the CloneKernelInfo method is:</p>
 
@@ -414,7 +427,7 @@
 
 <pre class="code">
   Image *MorphologyApply(const Image *image,MorphologyMethod method,
-    const long iterations,const KernelInfo *kernel,
+    const ssize_t iterations,const KernelInfo *kernel,
     const CompositeMethod compose, const double bias,
     ExceptionInfo *exception)
 </pre>
@@ -460,10 +473,10 @@
 
 <pre class="code">
   Image *MorphologyImage(const Image *image,MorphologyMethod method,
-    const long iterations,KernelInfo *kernel,ExceptionInfo *exception)
+    const ssize_t iterations,KernelInfo *kernel,ExceptionInfo *exception)
 </pre>
 
-<p>Image *MorphologyImageChannel(const Image *image, const ChannelType channel,MorphologyMethod method,const long iterations, KernelInfo *kernel,ExceptionInfo *exception)</p></ol>
+<p>Image *MorphologyImageChannel(const Image *image, const ChannelType channel,MorphologyMethod method,const ssize_t iterations, KernelInfo *kernel,ExceptionInfo *exception)</p></ol>
 
 <p>A description of each parameter follows:</p></ol>
 
@@ -634,7 +647,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/paint.html b/www/api/paint.html
index 3ecf791..d42a12f 100644
--- a/www/api/paint.html
+++ b/www/api/paint.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -167,7 +167,7 @@
 <pre class="code">
   MagickBooleanType FloodfillPaintImage(Image *image,
     const ChannelType channel,const DrawInfo *draw_info,
-    const MagickPixelPacket target,const long x_offset,const long y_offset,
+    const MagickPixelPacket target,const ssize_t x_offset,const ssize_t y_offset,
     const MagickBooleanType invert)
 </pre>
 
@@ -326,7 +326,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/pixel-iterator.html b/www/api/pixel-iterator.html
index c61a23c..02a2e3f 100644
--- a/www/api/pixel-iterator.html
+++ b/www/api/pixel-iterator.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -271,8 +271,8 @@
 <p>The format of the NewPixelRegionIterator method is:</p>
 
 <pre class="code">
-  PixelIterator NewPixelRegionIterator(MagickWand *wand,const long x,
-    const long y,const unsigned long width,const unsigned long height)
+  PixelIterator NewPixelRegionIterator(MagickWand *wand,const ssize_t x,
+    const ssize_t y,const size_t width,const size_t height)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -294,7 +294,7 @@
 
 <pre class="code">
   PixelWand **PixelGetCurrentIteratorRow(PixelIterator *iterator,
-    unsigned long *number_wands)
+    size_t *number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -374,7 +374,7 @@
 
 <pre class="code">
   PixelWand **PixelGetNextIteratorRow(PixelIterator *iterator,
-    unsigned long *number_wands)
+    size_t *number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -396,7 +396,7 @@
 
 <pre class="code">
   PixelWand **PixelGetPreviousIteratorRow(PixelIterator *iterator,
-    unsigned long *number_wands)
+    size_t *number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -454,7 +454,7 @@
 
 <pre class="code">
   MagickBooleanType PixelSetIteratorRow(PixelIterator *iterator,
-    const long row)
+    const ssize_t row)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/pixel-view.html b/www/api/pixel-view.html
index 95a5bb0..f7d65ef 100644
--- a/www/api/pixel-view.html
+++ b/www/api/pixel-view.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,9 +141,6 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
-<div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
-</div>
 </div>
 </div>
 

@@ -182,7 +179,7 @@
 
 <pre class="code">
   PixelView *DestroyPixelView(PixelView *pixel_view,
-    const unsigned long number_wands,const unsigned long number_threads)
+    const size_t number_wands,const size_t number_threads)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -268,7 +265,7 @@
 <p>The format of the GetPixelViewHeight method is:</p>
 
 <pre class="code">
-  unsigned long GetPixelViewHeight(const PixelView *pixel_view)
+  size_t GetPixelViewHeight(const PixelView *pixel_view)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -355,7 +352,7 @@
 <p>The format of the GetPixelViewWidth method is:</p>
 
 <pre class="code">
-  unsigned long GetPixelViewWidth(const PixelView *pixel_view)
+  size_t GetPixelViewWidth(const PixelView *pixel_view)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -373,7 +370,7 @@
 <p>The format of the GetPixelViewX method is:</p>
 
 <pre class="code">
-  long GetPixelViewX(const PixelView *pixel_view)
+  ssize_t GetPixelViewX(const PixelView *pixel_view)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -391,7 +388,7 @@
 <p>The format of the GetPixelViewY method is:</p>
 
 <pre class="code">
-  long GetPixelViewY(const PixelView *pixel_view)
+  ssize_t GetPixelViewY(const PixelView *pixel_view)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -445,8 +442,8 @@
 <p>The format of the NewPixelViewRegion method is:</p>
 
 <pre class="code">
-  PixelView *NewPixelViewRegion(MagickWand *wand,const long x,
-    const long y,const unsigned long width,const unsigned long height)
+  PixelView *NewPixelViewRegion(MagickWand *wand,const ssize_t x,
+    const ssize_t y,const size_t width,const size_t height)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/pixel-wand.html b/www/api/pixel-wand.html
index 9eb7290..de45c2c 100644
--- a/www/api/pixel-wand.html
+++ b/www/api/pixel-wand.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -200,7 +200,7 @@
 
 <pre class="code">
   PixelWand **ClonePixelWands(const PixelWand **wands,
-    const unsigned long number_wands)
+    const size_t number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -240,7 +240,7 @@
 
 <pre class="code">
   PixelWand **DestroyPixelWands(PixelWand **wand,
-    const unsigned long number_wands)
+    const size_t number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -317,7 +317,7 @@
 <p>The format of the NewPixelWands method is:</p>
 
 <pre class="code">
-  PixelWand **NewPixelWands(const unsigned long number_wands)
+  PixelWand **NewPixelWands(const size_t number_wands)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -497,7 +497,7 @@
 <p>The format of the PixelGetColorCount method is:</p>
 
 <pre class="code">
-  unsigned long PixelGetColorCount(const PixelWand *wand)
+  size_t PixelGetColorCount(const PixelWand *wand)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -997,7 +997,7 @@
 <p>The format of the PixelSetColorCount method is:</p>
 
 <pre class="code">
-  void PixelSetColorCount(PixelWand *wand,const unsigned long count)
+  void PixelSetColorCount(PixelWand *wand,const size_t count)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/profile.html b/www/api/profile.html
index 2e34a5e..d44b7f7 100644
--- a/www/api/profile.html
+++ b/www/api/profile.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
diff --git a/www/api/property.html b/www/api/property.html
index 0e8b6c8..a024229 100644
--- a/www/api/property.html
+++ b/www/api/property.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/api/quantize.html b/www/api/quantize.html
index 607c490..16f1e23 100644
--- a/www/api/quantize.html
+++ b/www/api/quantize.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -347,7 +347,7 @@
 <p>The format of the PosterizeImage method is:</p>
 
 <pre class="code">
-  MagickBooleanType PosterizeImage(Image *image,const unsigned long levels,
+  MagickBooleanType PosterizeImage(Image *image,const size_t levels,
     const MagickBooleanType dither)
 </pre>
 
@@ -482,7 +482,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/registry.html b/www/api/registry.html
index f1bcf24..77c1572 100644
--- a/www/api/registry.html
+++ b/www/api/registry.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
diff --git a/www/api/resize.html b/www/api/resize.html
index 17bf664..1c9b555 100644
--- a/www/api/resize.html
+++ b/www/api/resize.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,6 +141,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+</div>
 </div>
 </div>
 

@@ -161,7 +164,7 @@
 
 <pre class="code">
   Image *AdaptiveResizeImage(const Image *image,
-    const unsigned long columns,const unsigned long rows,
+    const size_t columns,const size_t rows,
     ExceptionInfo *exception)
 </pre>
 
@@ -264,7 +267,7 @@
 
 <pre class="code">
   Image *LiquidRescaleImage(const Image *image,
-    const unsigned long columns,const unsigned long rows,
+    const size_t columns,const size_t rows,
     const double delta_x,const double rigidity,ExceptionInfo *exception)
 </pre>
 
@@ -302,8 +305,8 @@
 <p>The format of the ResizeImage method is:</p>
 
 <pre class="code">
-  Image *ResizeImage(Image *image,const unsigned long columns,
-    const unsigned long rows,const FilterTypes filter,const double blur,
+  Image *ResizeImage(Image *image,const size_t columns,
+    const size_t rows,const FilterTypes filter,const double blur,
     ExceptionInfo *exception)
 </pre>
 
@@ -337,8 +340,8 @@
 <p>The format of the SampleImage method is:</p>
 
 <pre class="code">
-  Image *SampleImage(const Image *image,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+  Image *SampleImage(const Image *image,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -365,8 +368,8 @@
 <p>The format of the ScaleImage method is:</p>
 
 <pre class="code">
-  Image *ScaleImage(const Image *image,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+  Image *ScaleImage(const Image *image,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -393,8 +396,8 @@
 <p>The format of the ThumbnailImage method is:</p>
 
 <pre class="code">
-  Image *ThumbnailImage(const Image *image,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+  Image *ThumbnailImage(const Image *image,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -423,8 +426,8 @@
 <p>The format of the ZoomImage method is:</p>
 
 <pre class="code">
-  Image *ZoomImage(const Image *image,const unsigned long columns,
-    const unsigned long rows,ExceptionInfo *exception)
+  Image *ZoomImage(const Image *image,const size_t columns,
+    const size_t rows,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/resource.html b/www/api/resource.html
index e34fbc9..04ca9b4 100644
--- a/www/api/resource.html
+++ b/www/api/resource.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,6 +141,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+</div>
 </div>
 </div>
 

@@ -318,7 +321,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/segment.html b/www/api/segment.html
index 7cad87f..857c257 100644
--- a/www/api/segment.html
+++ b/www/api/segment.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -141,9 +141,6 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
-<div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
-</div>
 </div>
 </div>
 

diff --git a/www/api/shear.html b/www/api/shear.html
index 5a19fd4..33eb8d2 100644
--- a/www/api/shear.html
+++ b/www/api/shear.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -235,7 +235,7 @@
 _8c.html" target="source" name="ShearImage">ShearImage</a></h2>
 <div class="doc-section">
 
-<p>ShearImage() creates a new image that is a shear_image copy of an existing one.  Shearing slides one edge of an image along the X or Y axis, creating a parallelogram.  An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis.  The amount of the shear is controlled by a shear angle.  For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis.  Empty triangles left over from shearing the image are filled with the background color defined by member 'background_color' of the image..  ShearImage() allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p></ol>
+<p>ShearImage() creates a new image that is a shear_image copy of an existing one.  Shearing slides one edge of an image assize_t the X or Y axis, creating a parallelogram.  An X direction shear slides an edge assize_t the X axis, while a Y direction shear slides an edge assize_t the Y axis.  The amount of the shear is controlled by a shear angle.  For X direction shears, x_shear is measured relative to the Y axis, and similarly, for Y direction shears y_shear is measured relative to the X axis.  Empty triangles left over from shearing the image are filled with the background color defined by member 'background_color' of the image..  ShearImage() allocates the memory necessary for the new Image structure and returns a pointer to the new image.</p></ol>
 
 <p>ShearImage() is based on the paper "A Fast Algorithm for General Raster Rotatation" by Alan W. Paeth.</p></ol>
 
@@ -265,7 +265,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/signature.html b/www/api/signature.html
index d3ad219..f9a6ce0 100644
--- a/www/api/signature.html
+++ b/www/api/signature.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -179,7 +179,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/statistic.html b/www/api/statistic.html
index b667b3c..eceb567 100644
--- a/www/api/statistic.html
+++ b/www/api/statistic.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -202,11 +202,11 @@
 
 <pre class="code">
   MagickBooleanType FunctionImage(Image *image,
-    const MagickFunction function,const long number_parameters,
+    const MagickFunction function,const ssize_t number_parameters,
     const double *parameters,ExceptionInfo *exception)
   MagickBooleanType FunctionImageChannel(Image *image,
     const ChannelType channel,const MagickFunction function,
-    const long number_parameters,const double *argument,
+    const ssize_t number_parameters,const double *argument,
     ExceptionInfo *exception)
 </pre>
 
@@ -360,7 +360,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/api/stream.html b/www/api/stream.html
index 6e81aa9..90f6022 100644
--- a/www/api/stream.html
+++ b/www/api/stream.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
diff --git a/www/api/transform.html b/www/api/transform.html
index 6217037..49ac878 100644
--- a/www/api/transform.html
+++ b/www/api/transform.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -305,8 +305,8 @@
 <p>The format of the RollImage method is:</p>
 
 <pre class="code">
-  Image *RollImage(const Image *image,const long x_offset,
-    const long y_offset,ExceptionInfo *exception)
+  Image *RollImage(const Image *image,const ssize_t x_offset,
+    const ssize_t y_offset,ExceptionInfo *exception)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
diff --git a/www/api/version.html b/www/api/version.html
index 51afcfa..758099e 100644
--- a/www/api/version.html
+++ b/www/api/version.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../../www/download.html">Download</a>
 </div>
@@ -219,7 +219,7 @@
 <p>The format of the GetMagickQuantumDepth method is:</p>
 
 <pre class="code">
-  const char *GetMagickQuantumDepth(unsigned long *depth)
+  const char *GetMagickQuantumDepth(size_t *depth)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -237,7 +237,7 @@
 <p>The format of the GetMagickQuantumRange method is:</p>
 
 <pre class="code">
-  const char *GetMagickQuantumRange(unsigned long *range)
+  const char *GetMagickQuantumRange(size_t *range)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -270,7 +270,7 @@
 <p>The format of the GetMagickVersion method is:</p>
 
 <pre class="code">
-  const char *GetMagickVersion(unsigned long *version)
+  const char *GetMagickVersion(size_t *version)
 </pre>
 
 <p>A description of each parameter follows:</p></ol>
@@ -286,7 +286,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/architecture.html b/www/architecture.html
index 011dd5e..c3063b6 100644
--- a/www/architecture.html
+++ b/www/architecture.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/binary-releases.html b/www/binary-releases.html
index 001f4b8..d6725d1 100644
--- a/www/binary-releases.html
+++ b/www/binary-releases.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -373,7 +373,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/changelog.html b/www/changelog.html
index 4788b21..213e67f 100644
--- a/www/changelog.html
+++ b/www/changelog.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -154,7 +154,8 @@
 

 <ul><dt>2010-05-25  6.6.2.1 Anthony Thyssen &lt;A.Thyssen@griffith...&gt;</dt>
   <li> Finish for Square Array Rotates (off center origin rotate)</li>
-  <li> Added HitAndMiss kernel Ridges2 to find 2 pixel thick ridges</li><br />
+  <li> Added HitAndMiss kernel Ridges2 to find 2 pixel thick ridges</li>
+  <li> Added FreiChen:0,{angle}  FreiChen:{angle} and FreiChen:-1 variations    to complete this kernels definition</li><br />
 <dt>2010-05-24  6.6.2-1 Cristy  &lt;quetzlzacatenango@image...&gt;</dt>
   <li> Respect density when rendering SVG images.</li>
   <li> Set AVI handler to the MPEG coder.</li>
@@ -1546,7 +1547,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/cipher.html b/www/cipher.html
index 0f37ee1..a833893 100644
--- a/www/cipher.html
+++ b/www/cipher.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/color.html b/www/color.html
index c60eed0..be3ea74 100644
--- a/www/color.html
+++ b/www/color.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/command-line-options.html b/www/command-line-options.html
index 15de06d..74f682a 100644
--- a/www/command-line-options.html
+++ b/www/command-line-options.html
@@ -53,6 +53,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -79,9 +92,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -93,21 +103,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -146,7 +146,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -5946,7 +5946,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/command-line-processing.html b/www/command-line-processing.html
index fd12245..4e830b8 100644
--- a/www/command-line-processing.html
+++ b/www/command-line-processing.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -635,7 +635,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/command-line-tools.html b/www/command-line-tools.html
index 5228f82..c0ec754 100644
--- a/www/command-line-tools.html
+++ b/www/command-line-tools.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -154,11 +154,11 @@
 

 <p class="navigation-index">[<a href="#animate">animate</a> &bull; <a href="#compare">compare</a> &bull; <a href="#composite">composite</a> &bull; <a href="#conjure">conjure</a> &bull; <a href="#convert">convert</a> &bull; <a href="#display">display</a> &bull; <a href="#identify">identify</a> &bull; <a href="#import">import</a> &bull; <a href="#mogrify">mogrify</a> &bull; <a href="#montage">montage</a> &bull; <a href="#stream">stream</a>]</p>
 
-<p>ImageMagick includes a number of command-line utilities for manipulating images.  Most of you are probably accustomed to editing images one at a time with a graphical user interface (GUI) with such programs as <a href="http://www.gimp.org" target="662470774">gimp</a> or <a href="http://www.adobe.com" target="1688247065">Photoshop</a>.  However, a GUI is not always convenient.  Suppose you want to process an image dynamically from a web script or you want to apply the same operations to many images or repeat a specific operation at different times to the same or different image.  For these types of operations, the command-line image processing utility is appropriate.</p>
+<p>ImageMagick includes a number of command-line utilities for manipulating images.  Most of you are probably accustomed to editing images one at a time with a graphical user interface (GUI) with such programs as <a href="http://www.gimp.org" target="2139580869">gimp</a> or <a href="http://www.adobe.com" target="1072930310">Photoshop</a>.  However, a GUI is not always convenient.  Suppose you want to process an image dynamically from a web script or you want to apply the same operations to many images or repeat a specific operation at different times to the same or different image.  For these types of operations, the command-line image processing utility is appropriate.</p>
 
 <p>The ImageMagick command-line tools exit with a status of 0 if the command line arguments have a proper syntax and no problems are encountered.  Expect a descriptive message and an exit status of 1 if any exception occurs such as improper syntax, a problem reading or writing an image, or any other problem that prevents the command from completing successfully.</p>
 
-<p>In the paragraphs below, find a short description for each command-line tool. Click on the program name to get details about the program usage and a list of command-line options that alters how the program behaves.  If you are just getting acquainted with ImageMagick, start with the <a href="#convert">convert</a> program.  Be sure to peruse Anthony Thyssen's tutorial on how to use ImageMagick utilities to <a href="http://www.imagemagick.org/Usage/" target="1698856177">convert, compose, or edit</a> images from the command-line.</p>
+<p>In the paragraphs below, find a short description for each command-line tool. Click on the program name to get details about the program usage and a list of command-line options that alters how the program behaves.  If you are just getting acquainted with ImageMagick, start with the <a href="#convert">convert</a> program.  Be sure to peruse Anthony Thyssen's tutorial on how to use ImageMagick utilities to <a href="http://www.imagemagick.org/Usage/" target="1477343843">convert, compose, or edit</a> images from the command-line.</p>
 
 <div style="margin: auto;">
   <h2><a name="animate"></a><a href="../www/animate.html">animate</a></h2>
diff --git a/www/compare.html b/www/compare.html
index 754d289..78eb20d 100644
--- a/www/compare.html
+++ b/www/compare.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -396,7 +396,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/composite.html b/www/composite.html
index a438311..7d0272e 100644
--- a/www/composite.html
+++ b/www/composite.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/conjure.html b/www/conjure.html
index fe409de..86eeded 100644
--- a/www/conjure.html
+++ b/www/conjure.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/contact.html b/www/contact.html
index 5942bbe..4193be1 100644
--- a/www/contact.html
+++ b/www/contact.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -160,7 +160,7 @@
     <h2>Contact the Development Team</h2>
   </div>
 
-  <p>Use this form to contact the ImageMagick Wizards for any of the issues listed below.  You can expect a reply within 24-48 hours if your message is a sponsorshp, license, or security issue.  The bug and documentation issues are for reporting only.  For any other issue, post your message to the <a href="http://www.imagemagick.org/discourse-server" target="1477747561">discourse server</a>.</p>
+  <p>Use this form to contact the ImageMagick Wizards for any of the issues listed below.  You can expect a reply within 24-48 hours if your message is a sponsorshp, license, or security issue.  The bug and documentation issues are for reporting only.  For any other issue, post your message to the <a href="http://www.imagemagick.org/discourse-server" target="241191165">discourse server</a>.</p>
   <fieldset>
   <legend>Contact the Wizards</legend>
 	<p>Enter this code, <em class="warn">
@@ -216,7 +216,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/convert.html b/www/convert.html
index 1b27514..f0c8a4b 100644
--- a/www/convert.html
+++ b/www/convert.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/display.html b/www/display.html
index 2cc6233..5bef90a 100644
--- a/www/display.html
+++ b/www/display.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/download.html b/www/download.html
index 71098e1..aeb955b 100644
--- a/www/download.html
+++ b/www/download.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/escape.html b/www/escape.html
index ffb4d68..b323036 100644
--- a/www/escape.html
+++ b/www/escape.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/examples.html b/www/examples.html
index 755a07c..88b72cd 100644
--- a/www/examples.html
+++ b/www/examples.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -152,7 +152,7 @@
 

 <div class="main">

 

-<p>Here are a few examples of what you can do with an image using ImageMagick from the command line, a program interface, or script.  You can generate this image yourself with this <a href="../www/perl-magick.html">PerlMagick</a> script, <a href="../www/source/examples.pl" target="928521769">examples.pl</a>.</p><br />
+<p>Here are a few examples of what you can do with an image using ImageMagick from the command line, a program interface, or script.  You can generate this image yourself with this <a href="../www/perl-magick.html">PerlMagick</a> script, <a href="../www/source/examples.pl" target="1489958562">examples.pl</a>.</p><br />
 
 <div class="viewport">
   <img src="../images/examples.jpg" alt="[ImageMagick]" width="734" height="2972" border="0" name="titlebar-west" />
@@ -164,7 +164,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/exception.html b/www/exception.html
index dadb771..77bcf84 100644
--- a/www/exception.html
+++ b/www/exception.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
diff --git a/www/formats.html b/www/formats.html
index ef930d7..34039f3 100644
--- a/www/formats.html
+++ b/www/formats.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,6 +142,9 @@
 <div  class="sponsor">
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
+<div  class="sponsor">
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+</div>
 </div>
 </div>
 

@@ -1758,7 +1761,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/fx.html b/www/fx.html
index aebb9cb..773bd73 100644
--- a/www/fx.html
+++ b/www/fx.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
diff --git a/www/high-dynamic-range.html b/www/high-dynamic-range.html
index c3ff3c5..8f23acc 100644
--- a/www/high-dynamic-range.html
+++ b/www/high-dynamic-range.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
diff --git a/www/history.html b/www/history.html
index e6e96e0..7c3b80d 100644
--- a/www/history.html
+++ b/www/history.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -164,7 +164,7 @@
 

 <p>The next generation of ImageMagick, version 5, started when Bob Friesenhahn contacted me and suggested I improve the application programming interface so users could leverage the image-processing algorithms from other languages or scripts.  Bob also wrote a C++ wrapper for ImageMagick called Magick++, and began contributing enhancements such as the module loader facility, automatic file identification, and test suites.  In the mean-time, the project picked up a few other notable contributors: Glenn Randers-Pehrson, William Radcliffe, and Leonard Rosenthol.  By now, ImageMagick was being utilized by tens of thousands of users, who reacted gruffly when a new release broke an existing API call or script.  The other members of the group wanted to freeze the API and command line but I was not quite ready, since ImageMagick was not quite what I had envisioned it could be. Bob and the others created a fork of ImageMagick while I continued to develop ImageMagick.</p>

 

-<p>I did not work alone for long.  Anthony Thyssen contacted me about deficiencies in the ImageMagick command line programs.  He pointed out that the command line was confusing when dealing with more than one image. He suggested an orderly, well-defined method for dealing with the command line, and this became ImageMagick version 6 (the current release). His efforts are detailed on his web pages, <a href="http://www.imagemagick.org/Usage/" target="1749761894">Examples of ImageMagick Usage</a>.  I highly recommend that you peruse his site. He has illustrated the power of ImageMagick in ways that even I did not know were possible.</p>

+<p>I did not work alone for long.  Anthony Thyssen contacted me about deficiencies in the ImageMagick command line programs.  He pointed out that the command line was confusing when dealing with more than one image. He suggested an orderly, well-defined method for dealing with the command line, and this became ImageMagick version 6 (the current release). His efforts are detailed on his web pages, <a href="http://www.imagemagick.org/Usage/" target="78624356">Examples of ImageMagick Usage</a>.  I highly recommend that you peruse his site. He has illustrated the power of ImageMagick in ways that even I did not know were possible.</p>

 

 <p>Another notable contributer, Fred Weinhaus, makes available a plethora of command-line <a href="http://www.fmwconcepts.com/imagemagick/">scripts</a> that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.</p>

 

diff --git a/www/identify.html b/www/identify.html
index b216f5f..77adaf8 100644
--- a/www/identify.html
+++ b/www/identify.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/import.html b/www/import.html
index a97468c..8500c48 100644
--- a/www/import.html
+++ b/www/import.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/index.html b/www/index.html
index 6643f31..0fb68d9 100644
--- a/www/index.html
+++ b/www/index.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -223,7 +223,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/install-source.html b/www/install-source.html
index 388c620..4637145 100644
--- a/www/install-source.html
+++ b/www/install-source.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -223,7 +223,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/jp2.html b/www/jp2.html
index b8287ba..630c077 100644
--- a/www/jp2.html
+++ b/www/jp2.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/license.html b/www/license.html
index 9ce8327..d345d04 100644
--- a/www/license.html
+++ b/www/license.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -274,7 +274,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/links.html b/www/links.html
index b62c0b6..f7fe96b 100644
--- a/www/links.html
+++ b/www/links.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -160,23 +160,23 @@
   <h2><a name="command-line"></a>Command-line Tutorials</h2>
 </div>
 <ul>
-  <dt><a href="http://www.imagemagick.org/Usage/" target="1440832921">Examples of ImageMagick Usage</a></dt>
-  <dt><a href="http://software.newsforge.com/article.pl?sid=05/04/29/1358220" target="748064062">Advanced image editing from the command line with ImageMagick</a></dt>
-  <dt><a href="http://www.applematters.com/index.html/section/comments/1113/" target="430547501">Best Open Source Software for the Macintosh</a></dt>
-  <dt><a href="http://software.newsforge.com/article.pl?sid=05/07/01/1959251" target="341840970">Command-line animations using ImageMagick</a></dt>
-  <dt><a href="http://www.builderau.com.au/program/linux/soa/Convert_images_with_open_source_ImageMagick/0,339028299,339271774,00.htm" target="259812856">Convert Images with Open Source ImageMagick</a></dt>
-  <dt><a href="http://polishlinux.org/apps/graphics/enchanting-pictures-with-imagemagick/" target="1378168274">Enchanting Pictures with ImageMagick</a></dt>
-  <dt><a href="http://www-106.ibm.com/developerworks/library/l-graf/?ca=dnt-428" target="354298709">Graphics from the Command Line</a></dt>
-  <dt><a href="http://www.ars-informatica.ca/article.html?article=22" target="113350292">Image creation, conversion and manipulation with ImageMagick</a></dt>
-  <dt><a href="http://www.applematters.com/index.html/section/comments/2104/" target="866925004">Image Editing for Power Users on the Mac</a></dt>
-  <dt><a href="http://applications.linux.com/article.pl?sid=05/03/29/1525217" target="1213554210">ImageMagick: A graphics wizard for the command line</a></dt>
-  <dt><a href="http://www.ioncannon.net/linux/81/5-imagemagick-command-line-examples-part-1/" target="1624465778">ImageMagick command line examples - part 1</a></dt>
-  <dt><a href="http://www.ioncannon.net/linux/72/5-imagemagick-command-line-examples-part-2/" target="1554670319">ImageMagick command line examples - part 2</a></dt>
-  <dt><a href="http://www.rabuser.info/jmagick.html" target="838966435">ImageMagick &amp; Java</a></dt>
-  <dt><a href="http://www.jpeek.com/articles/linuxmag/0606.pdf" target="902842038">ImageMagick, Part One</a></dt>
-  <dt><a href="http://www.jpeek.com/articles/linuxmag/0607.pdf" target="1862200715">ImageMagick, Part Two</a></dt>
-  <dt><a href="http://www-106.ibm.com/developerworks/library/l-graf2/?ca=dgr-lnxw15GraphicsLine" target="1591283755">More Graphics from the Command Line</a></dt>
-  <dt><a href="http://www.ffnn.nl/pages/projects/ubuntu-firefox-themes.html" target="578517690">Ubuntu Firefox Themes</a></dt>
+  <dt><a href="http://www.imagemagick.org/Usage/" target="2057531562">Examples of ImageMagick Usage</a></dt>
+  <dt><a href="http://software.newsforge.com/article.pl?sid=05/04/29/1358220" target="1936343383">Advanced image editing from the command line with ImageMagick</a></dt>
+  <dt><a href="http://www.applematters.com/index.html/section/comments/1113/" target="328723375">Best Open Source Software for the Macintosh</a></dt>
+  <dt><a href="http://software.newsforge.com/article.pl?sid=05/07/01/1959251" target="1114735352">Command-line animations using ImageMagick</a></dt>
+  <dt><a href="http://www.builderau.com.au/program/linux/soa/Convert_images_with_open_source_ImageMagick/0,339028299,339271774,00.htm" target="746310148">Convert Images with Open Source ImageMagick</a></dt>
+  <dt><a href="http://polishlinux.org/apps/graphics/enchanting-pictures-with-imagemagick/" target="423093620">Enchanting Pictures with ImageMagick</a></dt>
+  <dt><a href="http://www-106.ibm.com/developerworks/library/l-graf/?ca=dnt-428" target="123622535">Graphics from the Command Line</a></dt>
+  <dt><a href="http://www.ars-informatica.ca/article.html?article=22" target="1219372961">Image creation, conversion and manipulation with ImageMagick</a></dt>
+  <dt><a href="http://www.applematters.com/index.html/section/comments/2104/" target="1262705389">Image Editing for Power Users on the Mac</a></dt>
+  <dt><a href="http://applications.linux.com/article.pl?sid=05/03/29/1525217" target="547140977">ImageMagick: A graphics wizard for the command line</a></dt>
+  <dt><a href="http://www.ioncannon.net/linux/81/5-imagemagick-command-line-examples-part-1/" target="75194583">ImageMagick command line examples - part 1</a></dt>
+  <dt><a href="http://www.ioncannon.net/linux/72/5-imagemagick-command-line-examples-part-2/" target="155264046">ImageMagick command line examples - part 2</a></dt>
+  <dt><a href="http://www.rabuser.info/jmagick.html" target="1126021493">ImageMagick &amp; Java</a></dt>
+  <dt><a href="http://www.jpeek.com/articles/linuxmag/0606.pdf" target="1510660620">ImageMagick, Part One</a></dt>
+  <dt><a href="http://www.jpeek.com/articles/linuxmag/0607.pdf" target="1844115243">ImageMagick, Part Two</a></dt>
+  <dt><a href="http://www-106.ibm.com/developerworks/library/l-graf2/?ca=dgr-lnxw15GraphicsLine" target="625264757">More Graphics from the Command Line</a></dt>
+  <dt><a href="http://www.ffnn.nl/pages/projects/ubuntu-firefox-themes.html" target="1719333387">Ubuntu Firefox Themes</a></dt>
 </ul>
 
 <div style="margin: auto;">
@@ -184,18 +184,18 @@
 </div>
 
 <ul>
-  <dt><a href="http://www-128.ibm.com/developerworks/openwww/source/library/os-mosaic/?ca=dgr-lnxw09MosaicImages" target="982322298">Create Mosaic Images with Perl and ImageMagick</a></dt>
-  <dt><a href="http://builder.com.com/5100-6371-5924990.html" target="1452762965">Convert images for printing with MagickWand for PHP</a></dt>
-  <dt><a href="http://www.sitepoint.com/article/dynamic-images-imagemagick" target="1430905539">Create Dynamic Images with ImageMagick</a></dt>
-  <dt><a href="http://www.clearimageonline.com/builder/pdf/imageservices.pdf" target="575231933">Image Services Add-on for Aestiva's HTML/OS and H2O</a></dt>
-  <dt><a href="http://www.ioncannon.net/php/75/how-to-compile-imagemagick-for-php-by-hand/" target="1571933907">How to compile ImageMagick for PHP by hand</a></dt>
-  <dt><a href="http://members.shaw.ca/el.supremo/MagickWand/" target="2047286347">MagickWand Examples in C</a></dt>
-  <dt><a href="http://www.html-editors.com/contest/1/82-read.html" target="497750793">PHP Extensions: MagickWand for PHP</a></dt>
-  <dt><a href="http://www.evolt.org/article/PHP_frontend_to_ImageMagick/17/55650/" target="743723758">PHP frontend to ImageMagick</a></dt>
-  <dt><a href="http://www.ioncannon.net/php/61/php-imagemagick-magickwand-examples/" target="510353107">PHP ImageMagick MagickWand Examples</a></dt>
-  <dt><a href="http://www.imagemagick.org/RMagick/doc/rvgtut.html" target="1702556266">RVG - Ruby Vector Graphics</a></dt>
-  <dt><a href="http://www.devshed.com/c/a/PHP/Security-Images-with-PHP-and-ImageMagick/" target="460247516">Security Images with PHP and ImageMagick</a></dt>
-  <dt><a href="http://www.rubblewebs.co.uk/imagemagick/" target="686658539">Simple Uses of PHP and ImageMagick</a></dt>
+  <dt><a href="http://www-128.ibm.com/developerworks/openwww/source/library/os-mosaic/?ca=dgr-lnxw09MosaicImages" target="1143914817">Create Mosaic Images with Perl and ImageMagick</a></dt>
+  <dt><a href="http://builder.com.com/5100-6371-5924990.html" target="29948301">Convert images for printing with MagickWand for PHP</a></dt>
+  <dt><a href="http://www.sitepoint.com/article/dynamic-images-imagemagick" target="1329651001">Create Dynamic Images with ImageMagick</a></dt>
+  <dt><a href="http://www.clearimageonline.com/builder/pdf/imageservices.pdf" target="257784731">Image Services Add-on for Aestiva's HTML/OS and H2O</a></dt>
+  <dt><a href="http://www.ioncannon.net/php/75/how-to-compile-imagemagick-for-php-by-hand/" target="1789874180">How to compile ImageMagick for PHP by hand</a></dt>
+  <dt><a href="http://members.shaw.ca/el.supremo/MagickWand/" target="1720777731">MagickWand Examples in C</a></dt>
+  <dt><a href="http://www.html-editors.com/contest/1/82-read.html" target="2118783244">PHP Extensions: MagickWand for PHP</a></dt>
+  <dt><a href="http://www.evolt.org/article/PHP_frontend_to_ImageMagick/17/55650/" target="392553355">PHP frontend to ImageMagick</a></dt>
+  <dt><a href="http://www.ioncannon.net/php/61/php-imagemagick-magickwand-examples/" target="1406408123">PHP ImageMagick MagickWand Examples</a></dt>
+  <dt><a href="http://www.imagemagick.org/RMagick/doc/rvgtut.html" target="1011458416">RVG - Ruby Vector Graphics</a></dt>
+  <dt><a href="http://www.devshed.com/c/a/PHP/Security-Images-with-PHP-and-ImageMagick/" target="582733917">Security Images with PHP and ImageMagick</a></dt>
+  <dt><a href="http://www.rubblewebs.co.uk/imagemagick/" target="1888076076">Simple Uses of PHP and ImageMagick</a></dt>
 </ul>
 
 <div style="margin: auto;">
@@ -203,10 +203,10 @@
 </div>
 
 <ul>
-  <dt><a href="http://beta.bigmedium.com/blog/imagemagick-install-osx.shtml" target="636192298">Installing ImageMagick on Mac OS X</a></dt>
-  <dt><a href="http://www.cloudgoessocial.net/2010/02/10/imagemagick-for-iphone-via-snowleopard/" target="1843891772">ImageMagick on iPhone</a></dt>
-  <dt><a href="http://www.cloudgoessocial.net/2009/07/09/imagemagick-on-iphone-xcode/" target="2127491460">ImageMagick on iPhone - Xcode</a></dt>
-  <dt><a href="http://www.digitalsanctum.com/?s=ImageMagick" target="1384256360">Installing ImageMagick from Source on Ubuntu</a></dt>
+  <dt><a href="http://beta.bigmedium.com/blog/imagemagick-install-osx.shtml" target="1359558414">Installing ImageMagick on Mac OS X</a></dt>
+  <dt><a href="http://www.cloudgoessocial.net/2010/02/10/imagemagick-for-iphone-via-snowleopard/" target="25355972">ImageMagick on iPhone</a></dt>
+  <dt><a href="http://www.cloudgoessocial.net/2009/07/09/imagemagick-on-iphone-xcode/" target="1798123991">ImageMagick on iPhone - Xcode</a></dt>
+  <dt><a href="http://www.digitalsanctum.com/?s=ImageMagick" target="1148418149">Installing ImageMagick from Source on Ubuntu</a></dt>
 </ul>
 
 <div style="margin: auto;">
@@ -214,24 +214,24 @@
 </div>
 
 <ul>
-  <dt><a href="http://www.xs4all.nl/%7Ebvdwolf/main/foto/down_sample/down_sample.htm" target="126955625">Down-sampling Methods</a></dt>
+  <dt><a href="http://www.xs4all.nl/%7Ebvdwolf/main/foto/down_sample/down_sample.htm" target="354079348">Down-sampling Methods</a></dt>
 </ul>
 
 <div style="margin: auto;">
   <h2><a name="book-review"></a>ImageMagick Book Review</h2>
 </div>
 <ul>
-  <dt><a href="http://www.linux.com/article.pl?sid=06/09/29/1917210" target="321848782">Book review: ImageMagick Tricks</a></dt>
-  <dt><a href="http://books.slashdot.org/books/06/03/13/1442239.shtml" target="1644069217">The Definitive Guide To ImageMagick</a></dt>
+  <dt><a href="http://www.linux.com/article.pl?sid=06/09/29/1917210" target="765375695">Book review: ImageMagick Tricks</a></dt>
+  <dt><a href="http://books.slashdot.org/books/06/03/13/1442239.shtml" target="1894728298">The Definitive Guide To ImageMagick</a></dt>
 </ul>
 
 <div style="margin: auto;">
   <h2><a name="command-line"></a>Mailing List Archives</h2>
 </div>
 <ul>
-  <dt><a href="http://www.archivesat.com/ImageMagick_Users_List/" target="1505123900">ImageMagick Users List</a></dt>
-  <dt><a href="http://www.archivesat.com/ImageMagick_Developer_List/" target="676147491">ImageMagick Developers List</a></dt>
-  <dt><a href="http://www.archivesat.com/ImageMagick_Defect_Support/" target="1757419509">ImageMagick Bugs List</a></dt>
+  <dt><a href="http://www.archivesat.com/ImageMagick_Users_List/" target="777172968">ImageMagick Users List</a></dt>
+  <dt><a href="http://www.archivesat.com/ImageMagick_Developer_List/" target="888998230">ImageMagick Developers List</a></dt>
+  <dt><a href="http://www.archivesat.com/ImageMagick_Defect_Support/" target="966617611">ImageMagick Bugs List</a></dt>
 </ul>
 
 <div style="margin: auto;">
@@ -239,13 +239,13 @@
 </div>
 <dl>
   <dt>Denmark</dt>
-    <dd><a href="http://imagemagick.europnews.de" target="224565256">http://imagemagick.europnews.de</a></dd><br />
+    <dd><a href="http://imagemagick.europnews.de" target="2039878357">http://imagemagick.europnews.de</a></dd><br />
   <dt>Germany</dt>
-    <dd><a href="http://imagemagick.linux-mirror.org" target="1889701701">http://imagemagick.linux-mirror.org</a></dd><br />
+    <dd><a href="http://imagemagick.linux-mirror.org" target="1436139208">http://imagemagick.linux-mirror.org</a></dd><br />
   <dt>Ireland</dt>
-    <dd><a href="http://imagemagick.oss-mirror.org" target="1234401640">http://imagemagick.oss-mirror.org</a></dd><br />
+    <dd><a href="http://imagemagick.oss-mirror.org" target="1041812194">http://imagemagick.oss-mirror.org</a></dd><br />
   <dt>United States</dt>
-    <dd><a href="http://www.imagemagick.org" target="1779235575">http://www.imagemagick.org</a></dd>
+    <dd><a href="http://www.imagemagick.org" target="47658755">http://www.imagemagick.org</a></dd>
 </dl>
 
 <div style="margin: auto;">
@@ -253,16 +253,16 @@
 </div>
 
 <ul>
-  <dt><a href="http://gmic.sourceforge.net/" target="581184488">G'MIC</a>: convert, manipulate and visualize generic 1D/2D/3D multi-spectral image files</dt>
-  <dt><a href="http://www.beesoft.org/index.html?id=imagicom" target="2137243678">Image Commander</a>: bulk picture processing with a GUI</dt>
+  <dt><a href="http://gmic.sourceforge.net/" target="414677053">G'MIC</a>: convert, manipulate and visualize generic 1D/2D/3D multi-spectral image files</dt>
+  <dt><a href="http://www.beesoft.org/index.html?id=imagicom" target="404989166">Image Commander</a>: bulk picture processing with a GUI</dt>
 </ul>
 
 <div style="margin: auto;">
   <h2><a name="other-projects"></a>Other Projects Hosted by ImageMagick Studio</h2>
 </div>
 <ul>
-  <dt><a href="http://www.wizards-toolkit.org" target="1493952642">Wizard's Toolkit</a></dt>
-  <dt><a href="http://www.multipole.org" target="24984596">Computational Simulation of Multi-Body Interactions with O(n) Scaling</a></dt>
+  <dt><a href="http://www.wizards-toolkit.org" target="1891773998">Wizard's Toolkit</a></dt>
+  <dt><a href="http://www.multipole.org" target="1039941810">Computational Simulation of Multi-Body Interactions with O(n) Scaling</a></dt>
 </ul>
 
 

diff --git a/www/magick-core.html b/www/magick-core.html
index 366c886..212f2fd 100644
--- a/www/magick-core.html
+++ b/www/magick-core.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -287,7 +287,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/magick-vector-graphics.html b/www/magick-vector-graphics.html
index 1dffda1..b625776 100644
--- a/www/magick-vector-graphics.html
+++ b/www/magick-vector-graphics.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/magick-wand.html b/www/magick-wand.html
index 9e9422f..96d3c6c 100644
--- a/www/magick-wand.html
+++ b/www/magick-wand.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/miff.html b/www/miff.html
index 2cd0f66..a6aff4e 100644
--- a/www/miff.html
+++ b/www/miff.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -308,7 +308,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/mirrors.html b/www/mirrors.html
index 0e19776..a8bef11 100644
--- a/www/mirrors.html
+++ b/www/mirrors.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -155,9 +155,9 @@
 <p>The ImageMagick web site is available from a variety of web mirrors around the world listed below.</p>
 <dl class="magick-mirror">
   <dt>France</dt>
-    <dd><a href="http://imagemagick.europnews.de/" target="1562032002">http://imagemagick.europnews.de/</a></dd><br />
+    <dd><a href="http://imagemagick.europnews.de/" target="1979861">http://imagemagick.europnews.de/</a></dd><br />
   <dt>Unites States</dt>
-    <dd><a href="http://www.imagemagick.org/" target="221710334">http://www.imagemagick.org/</a></dd>
+    <dd><a href="http://www.imagemagick.org/" target="189063829">http://www.imagemagick.org/</a></dd>
 </dl>
 <p>If you want to add a new web-site mirror, please <a href="http://www.imagemagick.org/script/contact.php">contact us</a>.</p>
 

diff --git a/www/mogrify.html b/www/mogrify.html
index 67017f1..f1aff9e 100644
--- a/www/mogrify.html
+++ b/www/mogrify.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -1278,7 +1278,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/montage.html b/www/montage.html
index 80a836f..59dcde5 100644
--- a/www/montage.html
+++ b/www/montage.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -698,7 +698,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/motion-picture.html b/www/motion-picture.html
index c34f72f..3e12fa4 100644
--- a/www/motion-picture.html
+++ b/www/motion-picture.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -285,7 +285,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/perl-magick.html b/www/perl-magick.html
index 62c22b0..0fb09d8 100644
--- a/www/perl-magick.html
+++ b/www/perl-magick.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
@@ -2558,7 +2558,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/quantize.html b/www/quantize.html
index 0ae6bd9..a4013c2 100644
--- a/www/quantize.html
+++ b/www/quantize.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -285,7 +285,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/resources.html b/www/resources.html
index ca9b604..2ab1fe6 100644
--- a/www/resources.html
+++ b/www/resources.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
@@ -407,7 +407,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/search.html b/www/search.html
index f9138bb..8c1b6d5 100644
--- a/www/search.html
+++ b/www/search.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Online-Magazin" href="http://www.unkostenbeitrag.de/" title="Online-Magazin">Online-Magazin</a><!-- 20101101000200 -->
 </div>
 </div>
 </div>
diff --git a/www/sitemap.html b/www/sitemap.html
index 5cdeafc..998e933 100644
--- a/www/sitemap.html
+++ b/www/sitemap.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -163,7 +163,7 @@
 <dl>

   <dd><a href="../www/index.html">Introduction</a>: convert, edit, and compose images from the command-line or program interface.</dd>

   <dd><a href="../www/examples.html">Examples of ImageMagick usage</a>: a few examples that show what you can do with an image using ImageMagick.</dd>

-  <dd><a href="http://www.imagemagick.org/Usage/" target="1661293893">Anthony Thyssen's examples of ImageMagick usage</a>:  a comprehensive tutorial of using ImageMagick from the command line.</dd>

+  <dd><a href="http://www.imagemagick.org/Usage/" target="38995743">Anthony Thyssen's examples of ImageMagick usage</a>:  a comprehensive tutorial of using ImageMagick from the command line.</dd>

   <dd><a href="../www/color.html">Color names</a>: how to specify a color name, a hex color, or a numerical RGB, RGBA, HSL, HSLA, CMYK, or CMYKA color.</dd>

   <dd><a href="../www/resources.html">Resources</a>: ImageMagick depends on external resources including configuration files, loadable modules, fonts, and environment variables.</dd>

   <dd><a href="../www/architecture.html">Architecture</a>: get to know more about the software and algorithms behind ImageMagick.</dd>

@@ -177,12 +177,12 @@
 <dl>

   <dd><a href="../www/download.html">Download ImageMagick</a>: ImageMagick source and binary distributions are available from a variety of FTP and Web mirrors.</dd>

   <ul>

-    <dd><a href="http://www.imagemagick.org/download" target="904133372">Unix source</a>: Unix source distributions.</dd>

-    <dd><a href="http://www.imagemagick.org/download/windows" target="223350009">Windows source</a>: Windows source distributions.</dd>

-    <dd><a href="http://www.imagemagick.org/download/binaries" target="46955981">Unix and Windows binaries</a>: Unix and Windows binary distributions.</dd>

+    <dd><a href="http://www.imagemagick.org/download" target="199647799">Unix source</a>: Unix source distributions.</dd>

+    <dd><a href="http://www.imagemagick.org/download/windows" target="33238112">Windows source</a>: Windows source distributions.</dd>

+    <dd><a href="http://www.imagemagick.org/download/binaries" target="8351190">Unix and Windows binaries</a>: Unix and Windows binary distributions.</dd>

     <dd><a href="../www/subversion.html">Subversion repository</a>: stable and development source releases.</dd>

-    <dd><a href="http://www.magickwand.org/" target="300859894">MagickWand for PHP</a>: a native PHP-extension to the ImageMagick MagickWand API.</dd>

-    <dd><a href="http://www.imagemagick.org/download/delegates" target="397353394">Delegate libraries</a>: ImageMagick depends on a number of optional delegate libraries to extend its functionality.</dd>

+    <dd><a href="http://www.magickwand.org/" target="1556692322">MagickWand for PHP</a>: a native PHP-extension to the ImageMagick MagickWand API.</dd>

+    <dd><a href="http://www.imagemagick.org/download/delegates" target="1463485437">Delegate libraries</a>: ImageMagick depends on a number of optional delegate libraries to extend its functionality.</dd>

   </ul>

 </dl>

 

@@ -221,7 +221,7 @@
   <dd><a href="../www/command-line-processing.html">Command line processing</a>: the anatomy of the command line.</dd>

   <dd><a href="../www/command-line-options.html">Command line options</a>: annotated list of all options that can appear on the command-line.</dd>

   <dd><a href="../www/fx.html">Fx</a>: apply a mathematical expression to an image or image channels.</dd>

-  <dd><a href="http://www.fmwconcepts.com/imagemagick/" target="2091293206">Fred's ImageMagick Scripts</a>:  a plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.</dd>

+  <dd><a href="http://www.fmwconcepts.com/imagemagick/" target="1531879885">Fred's ImageMagick Scripts</a>:  a plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.</dd>

 </dl>

 

 <div style="margin: auto;">

@@ -231,21 +231,21 @@
 <dl>

   <dd><a href="../www/api.html">Program interfaces</a>: application programming interfaces.</dd>

   <ul>

-    <dd><a href="http://www.imagemagick.org/ChMagick" target="1438233142">ChMagick</a>: is a <a href="http://www.softintegration.com/" target="1847585627">Ch</a> an embeddable MagickCore C/C++ interpreter for cross-platform scripting.</dd>

-    <dd><a href="http://common-lisp.net/project/cl-magick/" target="1865995968">CL-Magick</a>: provides a Common Lisp interface to the ImageMagick library.</dd>

-    <dd><a href="https://gna.org/projects/g2f/" target="1406253164">G2F</a>: implements an Ada 95 binding to a subset of the low-level MagickCore library.</dd>

-    <dd><a href="http://www.imagemagick.org/Magick++" target="1327163985">Magick++</a>: provides an object-oriented C++ interface to ImageMagick.</dd>

-    <dd><a href="http://pecl.html.net/package/imagick" target="2135360226">IMagick</a>: is a native PHP extension to create and modify images using the ImageMagick API.</dd>

-    <dd><a href="http://www.yeo.id.au/jmagick/" target="1778321790">JMagick</a>: provides an object-oriented Java interface to ImageMagick.</dd>

+    <dd><a href="http://www.imagemagick.org/ChMagick" target="1611152352">ChMagick</a>: is a <a href="http://www.softintegration.com/" target="416195177">Ch</a> an embeddable MagickCore C/C++ interpreter for cross-platform scripting.</dd>

+    <dd><a href="http://common-lisp.net/project/cl-magick/" target="8851090">CL-Magick</a>: provides a Common Lisp interface to the ImageMagick library.</dd>

+    <dd><a href="https://gna.org/projects/g2f/" target="1048350523">G2F</a>: implements an Ada 95 binding to a subset of the low-level MagickCore library.</dd>

+    <dd><a href="http://www.imagemagick.org/Magick++" target="322960500">Magick++</a>: provides an object-oriented C++ interface to ImageMagick.</dd>

+    <dd><a href="http://pecl.html.net/package/imagick" target="1299567650">IMagick</a>: is a native PHP extension to create and modify images using the ImageMagick API.</dd>

+    <dd><a href="http://www.yeo.id.au/jmagick/" target="1749877214">JMagick</a>: provides an object-oriented Java interface to ImageMagick.</dd>

     <dd><a href="../www/magick-core.html">MagickCore</a>: C API, recommended for wizard-level developers.</dd>

     <dd><a href="../www/magick-wand.html">MagickWand</a>: convert, compose, and edit images from the C language.</dd>

-    <dd><a href="http://www.magickwand.org/" target="1485616845">MagickWand for PHP</a>: a native PHP-extension to the ImageMagick MagickWand API.</dd>

-    <dd><a href="http://code.google.com/p/nmagick" target="1371219238">nMagick</a>: is a port of the ImageMagick library to the haXe and Neko platforms.</dd>

-    <dd><a href="http://wiki.lazarus.freepascal.org/index.html/PascalMagick" target="1790108053">PascalMagick</a>: a Pascal binding for the MagickWand API and also the low-level MagickCore library.</dd>

+    <dd><a href="http://www.magickwand.org/" target="1029746599">MagickWand for PHP</a>: a native PHP-extension to the ImageMagick MagickWand API.</dd>

+    <dd><a href="http://code.google.com/p/nmagick" target="1563340945">nMagick</a>: is a port of the ImageMagick library to the haXe and Neko platforms.</dd>

+    <dd><a href="http://wiki.lazarus.freepascal.org/index.html/PascalMagick" target="89961498">PascalMagick</a>: a Pascal binding for the MagickWand API and also the low-level MagickCore library.</dd>

     <dd><a href="../www/perl-magick.html">PerlMagick</a>: convert, compose, and edit images from the Perl language.</dd>

-    <dd><a href="http://www.imagemagick.org/download/python/" target="1504978100">PythonMagick</a>: an object-oriented Python interface to ImageMagick.</dd>

-    <dd><a href="http://rmagick.rubyforge.org/" target="356592937">RMagick</a>: is an interface between the Ruby programming language and ImageMagick.</dd>

-    <dd><a href="http://tclmagick.sourceforge.net/" target="450920078">TclMagick</a>: a native Tcl-extension to the ImageMagick MagickWand API.</dd>

+    <dd><a href="http://www.imagemagick.org/download/python/" target="12035034">PythonMagick</a>: an object-oriented Python interface to ImageMagick.</dd>

+    <dd><a href="http://rmagick.rubyforge.org/" target="168290147">RMagick</a>: is an interface between the Ruby programming language and ImageMagick.</dd>

+    <dd><a href="http://tclmagick.sourceforge.net/" target="768443181">TclMagick</a>: a native Tcl-extension to the ImageMagick MagickWand API.</dd>

   </ul>

 </dl>

 

@@ -265,8 +265,8 @@
 </div>

 

 <dl>

-  <dd><a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&amp;camp=1789&amp;tag=imagemagick-20&amp;creative=9325&amp;path=tg/detail/-/1590595904/qid=1123551819/sr=8-1/ref=pd_bbs_sbs_1?v=glance%26s=books%26n=507846" target="807768422">Definitive Guide to ImageMagick</a>: this book explains ImageMagick in a practical, learn-by-example fashion.</dd>

-  <dd><a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&amp;camp=1789&amp;tag=imagemagick-20&amp;creative=9325&amp;path=tg/detail/-/1904811868/qid=1123551819/sr=8-1/ref=pd_bbs_sbs_1?v=glance%26s=books%26n=507846" target="1757215045">ImageMagick Tricks</a>: this book is packed with examples of photo manipulations, logo creation, animations, and complete web projects.</dd>

+  <dd><a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&amp;camp=1789&amp;tag=imagemagick-20&amp;creative=9325&amp;path=tg/detail/-/1590595904/qid=1123551819/sr=8-1/ref=pd_bbs_sbs_1?v=glance%26s=books%26n=507846" target="298274689">Definitive Guide to ImageMagick</a>: this book explains ImageMagick in a practical, learn-by-example fashion.</dd>

+  <dd><a href="http://www.amazon.com/exec/obidos/redirect?link_code=ur2&amp;camp=1789&amp;tag=imagemagick-20&amp;creative=9325&amp;path=tg/detail/-/1904811868/qid=1123551819/sr=8-1/ref=pd_bbs_sbs_1?v=glance%26s=books%26n=507846" target="1955390941">ImageMagick Tricks</a>: this book is packed with examples of photo manipulations, logo creation, animations, and complete web projects.</dd>

   <dd><a href="http://www.imagemagick.org/discourse-server">Discourse server</a>: get help from fellow ImageMagick users and developers, post to these forums.</dd>

   <dd><a href="http://www.imagemagick.org/script/contact.php">Contact the Wizards</a>: for bug reports (only if you do not want to sign up to the <a href="http://www.imagemagick.org/discourse-server">discourse server</a>), a source or documentation patch, a security or license issue, or if you want to be a sponsor of the ImageMagick project.</dd>

 </dl>

@@ -276,7 +276,7 @@
 </div>

 

 <dl>

-  <dd><a href="http://www.imagemagick.org/discourse-server/viewforum.html?f=3" target="1966391126">Report bugs and vulnerabilities</a>: our highest priority is to fix security defects and bug reports, usually within 48 hours of your report.  The bug discourse server requires that you register.  If you do not want to register, you can <a href="contact.html">contact the ImageMagick developers</a> with a convenient web form.</dd>

+  <dd><a href="http://www.imagemagick.org/discourse-server/viewforum.html?f=3" target="2084620641">Report bugs and vulnerabilities</a>: our highest priority is to fix security defects and bug reports, usually within 48 hours of your report.  The bug discourse server requires that you register.  If you do not want to register, you can <a href="contact.html">contact the ImageMagick developers</a> with a convenient web form.</dd>

   <dd><a href="../www/sponsors.html">Sponsor ImageMagick</a>: contribute bug fixes, enhancements, hardware, funds, etc. to ensure the ImageMagick project thrives.</dd>

   <dd><a href="../www/t-shirt.html">ImageMagick t-shirt</a>: donate $25 USD and we acknowledge your gift with a logoed t-shirt.</dd>

 </dl>

@@ -302,8 +302,8 @@
   <h2><a name="sandbox"></a>Technology Sandbox</h2>

 </div>

 <dl>

-  <dd><a href="http://www.fmwconcepts.com/imagemagick/linkcounter.html?dir=fourier_transforms/&linkname=fourier.html" target="1471214043">Fourier Transform Processing With ImageMagick</a></dd>

-  <dd><a href="http://www.imagemagick.org/Usage/fourier/" target="245180082">ImageMagick v6 Examples -- Fourier Transforms</a></dd>

+  <dd><a href="http://www.fmwconcepts.com/imagemagick/linkcounter.html?dir=fourier_transforms/&linkname=fourier.html" target="1179897715">Fourier Transform Processing With ImageMagick</a></dd>

+  <dd><a href="http://www.imagemagick.org/Usage/fourier/" target="36606223">ImageMagick v6 Examples -- Fourier Transforms</a></dd>

 </dl>

 

 

diff --git a/www/sponsors.html b/www/sponsors.html
index 4b95960..be4334f 100644
--- a/www/sponsors.html
+++ b/www/sponsors.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
diff --git a/www/stream.html b/www/stream.html
index c0b3573..4638211 100644
--- a/www/stream.html
+++ b/www/stream.html
@@ -50,6 +50,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -76,9 +89,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -90,21 +100,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -143,7 +143,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
+   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
 </div>
 </div>
 </div>
diff --git a/www/subversion.html b/www/subversion.html
index f69b8c9..0d34965 100644
--- a/www/subversion.html
+++ b/www/subversion.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -142,7 +142,7 @@
    <a title="Sponsor: Druckerei Online" href="http://www.allesdruck.de">Druckerei Online</a><!-- 201012011200 allesdruck.de-->
 </div>
 <div  class="sponsor">
-   <a title="Sponsor: Webdesign" href="http://www.renehornig.com/" title="Webdesign">Webdesign</a><!-- 20110101000120 -->
+   <a title="Sponsor: Lampe Berger" href="http://www.geschenke-elsen.de/" title="Lampe Berger">Lampe Berger</a><!-- 20106101000040 -->
 </div>
 </div>
 </div>
@@ -176,7 +176,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>

diff --git a/www/t-shirt.html b/www/t-shirt.html
index 9da0b56..6e791c7 100644
--- a/www/t-shirt.html
+++ b/www/t-shirt.html
@@ -49,6 +49,19 @@
 </div>
 <div class="sep"></div>

 <div class="menu">
+  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
+</div>
+<div class="sub">
+    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
+</div>
+<div class="sep"></div>

+<div class="menu">
   <a title="Command-line Tools" href="../www/command-line-tools.html">Command-line Tools</a>
 </div>
 <div class="sub">
@@ -75,9 +88,6 @@
 <div class="sub">
     <a title="Program Interface: Magick++" href="../Magick++/">Magick++</a>
 </div>
-<div class="menu">
-  <a title="Architecture" href="../www/architecture.html">Architecture</a>
-</div>
 <div class="sep"></div>

 <div  class="menu">
    <a title="Install from Source" href="../www/install-source.html">Install from Source</a>
@@ -89,21 +99,11 @@
     <a title="Install from Source: Windows" href="../www/install-source.html#windows">Windows</a>
  </div>
 <div class="menu">
-  <a title="Binary Releases" href="../www/binary-releases.html">Binary Releases</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Unix" href="../www/binary-releases.html#unix">Unix</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: MacOS X" href="../www/binary-releases.html#macosx">Mac OS X</a>
-</div>
-<div class="sub">
-    <a title="Binary Release: Windows" href="../www/binary-releases.html#windows">Windows</a>
-</div>
-<div class="menu">
   <a title="Resources" href="../www/resources.html">Resources</a>
 </div>
-<div class="sep"></div>

+<div class="menu">
+  <a title="Architecture" href="../www/architecture.html">Architecture</a>
+</div>
 <div class="menu">
   <a title="Download" href="../www/download.html">Download</a>
 </div>
@@ -191,7 +191,7 @@
  <!--    <span id="linkbar-west">&nbsp;</span>  -->

     <span id="linkbar-center">

       <a href="http://www.imagemagick.org/discourse-server/">Discourse Server</a> &bull;

-    <a href="http://www.imagemagick.org/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

+    <a href="http://studio.webbyland.com/ImageMagick/MagickStudio/scripts/MagickStudio.cgi">Studio</a>

     </span>

     <span id="linkbar-east">&nbsp;</span>

   </div>