Commit 37464bd09 for imagemagick.org

commit 37464bd09607b6922bcbf61a8b4a627365c805b3
Author: Dirk Lemstra <dirk@lemstra.org>
Date:   Sun Jun 8 17:34:54 2025 +0200

    Added missing typecasts.

diff --git a/coders/bmp.c b/coders/bmp.c
index b72b1c5b6..031ebdedd 100644
--- a/coders/bmp.c
+++ b/coders/bmp.c
@@ -2450,7 +2450,7 @@ static MagickBooleanType WriteBMPImage(const ImageInfo *image_info,Image *image,
         profile_size=(MagickOffsetType) GetStringInfoLength(profile);
         if ((profile_size % 4) > 0)
           profile_size_pad=4-(profile_size%4);
-        bmp_info.file_size+=profile_size+profile_size_pad;
+        bmp_info.file_size+=(unsigned int) (profile_size+profile_size_pad);
       }
     (void) WriteBlob(image,2,(unsigned char *) "BM");
     (void) WriteBlobLSBLong(image,bmp_info.file_size);
diff --git a/coders/cin.c b/coders/cin.c
index 160b6559a..649858d4a 100644
--- a/coders/cin.c
+++ b/coders/cin.c
@@ -649,23 +649,23 @@ static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Image film information.
       */
-      cin.film.id=ReadBlobByte(image);
+      cin.film.id=(char) ReadBlobByte(image);
       offset++;
       c=cin.film.id;
       if (c != ~0)
         (void) FormatImageProperty(image,"dpx:film.id","%d",cin.film.id);
-      cin.film.type=ReadBlobByte(image);
+      cin.film.type=(char) ReadBlobByte(image);
       offset++;
       c=cin.film.type;
       if (c != ~0)
         (void) FormatImageProperty(image,"dpx:film.type","%d",cin.film.type);
-      cin.film.offset=ReadBlobByte(image);
+      cin.film.offset=(char) ReadBlobByte(image);
       offset++;
       c=cin.film.offset;
       if (c != ~0)
         (void) FormatImageProperty(image,"dpx:film.offset","%d",
           cin.film.offset);
-      cin.film.reserve1=ReadBlobByte(image);
+      cin.film.reserve1=(char) ReadBlobByte(image);
       offset++;
       cin.film.prefix=ReadBlobLong(image);
       offset+=4;
@@ -1044,14 +1044,14 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
     cin.image.channel[i].max_quantity=2.048f;
     offset+=WriteBlobFloat(image,cin.image.channel[0].max_quantity);
   }
-  offset+=WriteBlobFloat(image,image->chromaticity.white_point.x);
-  offset+=WriteBlobFloat(image,image->chromaticity.white_point.y);
-  offset+=WriteBlobFloat(image,image->chromaticity.red_primary.x);
-  offset+=WriteBlobFloat(image,image->chromaticity.red_primary.y);
-  offset+=WriteBlobFloat(image,image->chromaticity.green_primary.x);
-  offset+=WriteBlobFloat(image,image->chromaticity.green_primary.y);
-  offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.x);
-  offset+=WriteBlobFloat(image,image->chromaticity.blue_primary.y);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.white_point.x);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.white_point.y);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.red_primary.x);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.red_primary.y);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.green_primary.x);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.green_primary.y);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.blue_primary.x);
+  offset+=WriteBlobFloat(image,(float) image->chromaticity.blue_primary.y);
   value=GetCINProperty(image_info,image,"dpx:image.label",exception);
   if (value != (const char *) NULL)
     (void) CopyMagickString(cin.image.label,value,sizeof(cin.image.label));
@@ -1131,14 +1131,14 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   cin.origination.x_pitch=0.0f;
   value=GetCINProperty(image_info,image,"dpx:origination.x_pitch",exception);
   if (value != (const char *) NULL)
-    cin.origination.x_pitch=StringToDouble(value,(char **) NULL);
+    cin.origination.x_pitch=StringToFloat(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.origination.x_pitch);
   cin.origination.y_pitch=0.0f;
   value=GetCINProperty(image_info,image,"dpx:origination.y_pitch",exception);
   if (value != (const char *) NULL)
-    cin.origination.y_pitch=StringToDouble(value,(char **) NULL);
+    cin.origination.y_pitch=StringToFloat(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.origination.y_pitch);
-  cin.origination.gamma=image->gamma;
+  cin.origination.gamma=(float) image->gamma;
   offset+=WriteBlobFloat(image,cin.origination.gamma);
   offset+=WriteBlob(image,sizeof(cin.origination.reserve),(unsigned char *)
     cin.origination.reserve);
@@ -1184,7 +1184,7 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   cin.film.frame_rate=0.0f;
   value=GetCINProperty(image_info,image,"dpx:film.frame_rate",exception);
   if (value != (const char *) NULL)
-    cin.film.frame_rate=StringToDouble(value,(char **) NULL);
+    cin.film.frame_rate=StringToFloat(value,(char **) NULL);
   offset+=WriteBlobFloat(image,cin.film.frame_rate);
   value=GetCINProperty(image_info,image,"dpx:film.frame_id",exception);
   if (value != (const char *) NULL)
diff --git a/coders/cube.c b/coders/cube.c
index 9c132c510..05d8032e0 100644
--- a/coders/cube.c
+++ b/coders/cube.c
@@ -272,22 +272,22 @@ static Image *ReadCUBEImage(const ImageInfo *image_info,
           offset,
           scale;

-        offset.r=(MagickSafeReciprocal((double) (hald_level*hald_level)-1.0)*
-          r)*(cube_level-1.0);
+        offset.r=(float) ((MagickSafeReciprocal(((double) hald_level*hald_level)-1.0)*
+          r)*(cube_level-1.0));
         index.r=floor(offset.r);
         scale.r=offset.r-index.r;
         next.r=index.r+1;
         if ((size_t) index.r == (cube_level-1))
           next.r=index.r;
-        offset.g=(MagickSafeReciprocal(((double) hald_level*hald_level)-1.0)*
-          g)*(cube_level-1.0);
+        offset.g=(float) ((MagickSafeReciprocal(((double) hald_level*hald_level)-1.0)*
+          g)*(cube_level-1.0));
         index.g=floor(offset.g);
         scale.g=offset.g-index.g;
         next.g=index.g+1;
         if ((size_t) index.g == (cube_level-1))
           next.g=index.g;
-        offset.b=(MagickSafeReciprocal(((double) hald_level*hald_level)-1.0)*
-          b)*(cube_level-1.0);
+        offset.b=(float) ((MagickSafeReciprocal(((double) hald_level*hald_level)-1.0)*
+          b)*(cube_level-1.0));
         index.b=floor(offset.b);
         scale.b=offset.b-index.b;
         next.b=index.b+1;
diff --git a/coders/cut.c b/coders/cut.c
index b3b315a59..4a7365883 100644
--- a/coders/cut.c
+++ b/coders/cut.c
@@ -114,7 +114,7 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
         {
           for (bit=0; bit < 8; bit++)
           {
-            index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+            index=(Quantum) ((*p) & (0x80 >> bit) ? 0x01 : 0x00);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -126,7 +126,7 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
           {
             for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
             {
-              index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+              index=(Quantum) ((*p) & (0x80 >> bit) ? 0x01 : 0x00);
               SetPixelIndex(image,index,q);
               if (index < image->colors)
                 SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -141,22 +141,22 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
       {
         for (x=0; x < ((ssize_t) image->columns-3); x+=4)
         {
-            index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -165,21 +165,21 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
         }
        if ((image->columns % 4) != 0)
           {
-            index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
             if ((image->columns % 4) > 1)
               {
-                index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+                index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
                 SetPixelIndex(image,index,q);
                 if (index < image->colors)
                   SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
                 q+=(ptrdiff_t) GetPixelChannels(image);
                 if ((image->columns % 4) > 2)
                   {
-                    index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,
+                    index=(Quantum) ConstrainColormapIndex(image,(*p >> 2) & 0x3,
                       exception);
                     SetPixelIndex(image,index,q);
                     if (index < image->colors)
@@ -197,12 +197,12 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
       {
         for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -211,7 +211,7 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
           }
         if ((image->columns % 2) != 0)
           {
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -224,7 +224,7 @@ static MagickBooleanType InsertRow(Image *image,ssize_t bpp,unsigned char *p,
       {
         for (x=0; x < (ssize_t) image->columns; x++)
           {
-            index=ConstrainColormapIndex(image,*p,exception);
+            index=(Quantum) ConstrainColormapIndex(image,*p,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
diff --git a/coders/dcm.c b/coders/dcm.c
index 8be517dc4..1ad37d911 100644
--- a/coders/dcm.c
+++ b/coders/dcm.c
@@ -4109,25 +4109,25 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           if (map.red != (int *) NULL)
             for (i=0; i < (ssize_t) colors; i++)
             {
-              color=ScaleShortToQuantum(map.red[i]);
+              color=ScaleShortToQuantum((unsigned short) map.red[i]);
               image->colormap[i].red=(MagickRealType) color;
             }
           if (map.green != (int *) NULL)
             for (i=0; i < (ssize_t) colors; i++)
             {
-              color=ScaleShortToQuantum(map.green[i]);
+              color=ScaleShortToQuantum((unsigned short) map.green[i]);
               image->colormap[i].green=(MagickRealType) color;
             }
           if (map.blue != (int *) NULL)
             for (i=0; i < (ssize_t) colors; i++)
             {
-              color=ScaleShortToQuantum(map.blue[i]);
+              color=ScaleShortToQuantum((unsigned short) map.blue[i]);
               image->colormap[i].blue=(MagickRealType) color;
             }
           if (map.gray != (int *) NULL)
             for (i=0; i < (ssize_t) colors; i++)
             {
-              color=ScaleShortToQuantum(map.gray[i]);
+              color=ScaleShortToQuantum((unsigned short) map.gray[i]);
               image->colormap[i].red=(MagickRealType) color;
               image->colormap[i].green=(MagickRealType) color;
               image->colormap[i].blue=(MagickRealType) color;
diff --git a/coders/dds.c b/coders/dds.c
index 83b3b7e0a..90cdc4509 100644
--- a/coders/dds.c
+++ b/coders/dds.c
@@ -2397,7 +2397,7 @@ static MagickBooleanType ReadUncompressedRGBPixels(Image *image,
     {
       if ((dds_info->pixelformat.rgb_bitcount == 8) ||
           (dds_info->extFormat == DXGI_FORMAT_R8_UNORM))
-        SetPixelGray(image,ScaleCharToQuantum(ReadBlobByte(image)),q);
+        SetPixelGray(image,ScaleCharToQuantum((unsigned char) ReadBlobByte(image)),q);
       else if ((dds_info->pixelformat.rgb_bitcount == 16) ||
                (dds_info->extFormat == DXGI_FORMAT_B5G6R5_UNORM))
         {
@@ -3323,7 +3323,7 @@ static void CompressClusterFit(const size_t count,
   {
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
   #pragma omp parallel for schedule(dynamic,1) \
-    num_threads(GetMagickResourceLimit(ThreadResource))
+    num_threads((int) GetMagickResourceLimit(ThreadResource))
 #endif
     for (i=0; i < (ssize_t) count; i++)
     {
@@ -4035,7 +4035,7 @@ static void WriteFourCC(Image *image, const size_t compression,
       }

       for (i=0; i < (ssize_t) count; i++)
-        points[i].w = sqrt(points[i].w);
+        points[i].w=sqrt(points[i].w);

       if (compression == FOURCC_DXT5)
         WriteAlphas(image,alphas,min5,max5,min7,max7);
diff --git a/coders/dib.c b/coders/dib.c
index ca7a80054..b0ef911c1 100644
--- a/coders/dib.c
+++ b/coders/dib.c
@@ -1397,14 +1397,14 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image,
             *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].blue));
             *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].green));
             *q++=ScaleQuantumToChar(ClampToQuantum(image->colormap[i].red));
-            *q++=(Quantum) 0x0;
+            *q++=(unsigned char) 0x0;
           }
           for ( ; i < (ssize_t) 1L << dib_info.bits_per_pixel; i++)
           {
-            *q++=(Quantum) 0x0;
-            *q++=(Quantum) 0x0;
-            *q++=(Quantum) 0x0;
-            *q++=(Quantum) 0x0;
+            *q++=(unsigned char) 0x0;
+            *q++=(unsigned char) 0x0;
+            *q++=(unsigned char) 0x0;
+            *q++=(unsigned char) 0x0;
           }
           (void) WriteBlob(image,(size_t) (4*(1 << dib_info.bits_per_pixel)),
             dib_colormap);
diff --git a/coders/emf.c b/coders/emf.c
index 7c703a4de..60827eeaf 100644
--- a/coders/emf.c
+++ b/coders/emf.c
@@ -776,10 +776,10 @@ static Image *ReadEMFImage(const ImageInfo *image_info,
   graphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
   graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintClearTypeGridFit);
   graphics->Clear(Gdiplus::Color((BYTE) ScaleQuantumToChar(
-    image->background_color.alpha),(BYTE) ScaleQuantumToChar(
-    image->background_color.red),(BYTE) ScaleQuantumToChar(
-    image->background_color.green),(BYTE) ScaleQuantumToChar(
-    image->background_color.blue)));
+    (Quantum) image->background_color.alpha),(BYTE) ScaleQuantumToChar(
+    (Quantum) image->background_color.red),(BYTE) ScaleQuantumToChar(
+    (Quantum) image->background_color.green),(BYTE) ScaleQuantumToChar(
+    (Quantum) image->background_color.blue)));
   graphics->DrawImage(source,0,0,(INT) image->columns,(INT) image->rows);
   delete graphics;
   delete source;
diff --git a/coders/exr.c b/coders/exr.c
index 068e6e2d2..9652ec672 100644
--- a/coders/exr.c
+++ b/coders/exr.c
@@ -1175,17 +1175,19 @@ static MagickBooleanType WriteEXRImage(const ImageInfo *image_info,Image *image,
       break;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      ImfFloatToHalf(QuantumScale*(double) GetPixelRed(image,p),&half_quantum);
+      ImfFloatToHalf((float) (QuantumScale*(double) GetPixelRed(image,p)),
+        &half_quantum);
       scanline[x].r=half_quantum;
-      ImfFloatToHalf(QuantumScale*(double) GetPixelGreen(image,p),
+      ImfFloatToHalf((float) (QuantumScale*(double) GetPixelGreen(image,p)),
         &half_quantum);
       scanline[x].g=half_quantum;
-      ImfFloatToHalf(QuantumScale*(double) GetPixelBlue(image,p),&half_quantum);
+      ImfFloatToHalf((float) (QuantumScale*(double) GetPixelBlue(image,p)),
+        &half_quantum);
       scanline[x].b=half_quantum;
       if ((image->alpha_trait & BlendPixelTrait) == 0)
         ImfFloatToHalf(1.0,&half_quantum);
       else
-        ImfFloatToHalf(QuantumScale*(double) GetPixelAlpha(image,p),
+        ImfFloatToHalf((float) (QuantumScale*(double) GetPixelAlpha(image,p)),
           &half_quantum);
       scanline[x].a=half_quantum;
       p+=(ptrdiff_t) GetPixelChannels(image);
diff --git a/coders/fits.c b/coders/fits.c
index 50f22d20d..4ec6b1e48 100644
--- a/coders/fits.c
+++ b/coders/fits.c
@@ -337,7 +337,7 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
         {
           if (isspace((int) ((unsigned char) keyword[i])) != 0)
             break;
-          keyword[i]=LocaleToLowercase((int) ((unsigned char) keyword[i]));
+          keyword[i]=(char) LocaleToLowercase((int) ((unsigned char) keyword[i]));
         }
         keyword[i]='\0';
         count=ReadBlob(image,72,(unsigned char *) value);
diff --git a/coders/flif.c b/coders/flif.c
index 4c39fda43..4c9d1ee1f 100644
--- a/coders/flif.c
+++ b/coders/flif.c
@@ -213,7 +213,7 @@ static Image *ReadFLIFImage(const ImageInfo *image_info,
     image->dispose=BackgroundDispose;
     for (y=0; y < (ssize_t) image->rows; y++)
     {
-      flif_image_read_row_RGBA16(flifimage,y,pixels,length);
+      flif_image_read_row_RGBA16(flifimage,(uint32_t) y,pixels,length);
       p=pixels;
       q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
       if (q == (Quantum *) NULL)
@@ -489,7 +489,7 @@ static MagickBooleanType WriteFLIFImage(const ImageInfo *image_info,
               *qs++=0xFFFF;
             p+=(ptrdiff_t) GetPixelChannels(image);
           }
-          flif_image_write_row_RGBA16(flifimage,y,pixels,length);
+          flif_image_write_row_RGBA16(flifimage,(uint32_t) y,pixels,length);
         }
       else
         {
@@ -505,11 +505,11 @@ static MagickBooleanType WriteFLIFImage(const ImageInfo *image_info,
               *qc++=0xFF;
             p+=(ptrdiff_t) GetPixelChannels(image);
           }
-          flif_image_write_row_RGBA8(flifimage,y,pixels,length);
+          flif_image_write_row_RGBA8(flifimage,(uint32_t) y,pixels,length);
         }
     }
-    flif_image_set_frame_delay(flifimage,(uint32_t) image->delay*100/
-      image->ticks_per_second);
+    flif_image_set_frame_delay(flifimage,(uint32_t) (image->delay*100/
+      image->ticks_per_second));
     flif_encoder_add_image(flifenc,flifimage);
     if (GetNextImageInList(image) == (Image *) NULL)
       break;
diff --git a/coders/ftxt.c b/coders/ftxt.c
index d665bec5a..766a7fe92 100644
--- a/coders/ftxt.c
+++ b/coders/ftxt.c
@@ -192,7 +192,7 @@ static int ReadInt(Image * image,MagickBooleanType *eofInp,int *chPushed,
     *eofInp = MagickTrue;
   while (isdigit(chIn))
   {
-    *p=chIn;
+    *p=(char) chIn;
     p++;
     if (p-buffer >= MaxTextExtent)
       {
@@ -335,7 +335,7 @@ static void ReadUntil(Image * image,int UntilChar,MagickBooleanType *eofInp,
           *eofInp=MagickTrue;
           break;
         }
-      buf[i++]=chIn;
+      buf[i++]=(char) chIn;
     }
   if (*eofInp)
     *chPushed='\0';
@@ -630,7 +630,7 @@ static Image *ReadFTXTImage(const ImageInfo *image_info,
                   if (q == (Quantum *) NULL)
                     break;
                   for (i=0; i< nExpCh; i++)
-                    q[i]=chVals[i];
+                    q[i]=(char) chVals[i];
                   if (SyncAuthenticPixels(image,exception) == MagickFalse)
                     break;
                 }
diff --git a/coders/hdr.c b/coders/hdr.c
index 7a0204259..f123babda 100644
--- a/coders/hdr.c
+++ b/coders/hdr.c
@@ -259,7 +259,7 @@ static Image *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception)
           do
           {
             if ((size_t) (p-keyword) < (MagickPathExtent-1))
-              *p++=c;
+              *p++=(char) c;
             c=ReadBlobByte(image);
           } while (isalnum((int) ((unsigned char) c)) || (c == '_'));
           *p='\0';
@@ -278,7 +278,7 @@ static Image *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception)
           while ((c != '\n') && (c != '\0') && (c != EOF))
           {
             if ((size_t) (p-value) < (MagickPathExtent-1))
-              *p++=c;
+              *p++=(char) c;
             c=ReadBlobByte(image);
           }
           *p='\0';
diff --git a/coders/html.c b/coders/html.c
index 739cb126e..93b16a63f 100644
--- a/coders/html.c
+++ b/coders/html.c
@@ -212,7 +212,7 @@ static ssize_t WriteURLComponent(Image *image,const int c)

   html5=isalnum(c) != 0 || (c == '-') || (c == '_') || (c == '.') ||
     (c == '!') || (c == '~') || (c == '*') || (c == '\'') || (c == '(') ||
-    (c == ')') ?  c : 0;
+    (c == ')') ?  (char) c : 0;
   if (html5 != 0)
     (void) FormatLocaleString(encoding,MagickPathExtent,"%c",html5);
   else
diff --git a/coders/icon.c b/coders/icon.c
index c9c7db5ff..1e94fb3b3 100644
--- a/coders/icon.c
+++ b/coders/icon.c
@@ -244,7 +244,7 @@ static Image *Read1XImage(Image *image,ExceptionInfo *exception)
           Quantum
             index;

-          index=((byte & (0x80 >> bit)) != 0 ? (i == 0 ? 0x01 : 0x02) : 0x00);
+          index=(Quantum) ((byte & (0x80 >> bit)) != 0 ? (i == 0 ? 0x01 : 0x02) : 0x00);
           if (i == 0)
             SetPixelIndex(image,index,q);
           else
@@ -562,8 +562,8 @@ static Image *ReadICONImage(const ImageInfo *image_info,
                 byte=(size_t) ReadBlobByte(image);
                 for (bit=0; bit < 8; bit++)
                 {
-                  SetPixelIndex(image,((byte & (0x80 >> bit)) != 0 ? 0x01 :
-                    0x00),q);
+                  SetPixelIndex(image,(Quantum) ((byte & (0x80 >> bit)) != 0 ?
+                    0x01 : 0x00),q);
                   q+=(ptrdiff_t) GetPixelChannels(image);
                 }
               }
@@ -572,8 +572,8 @@ static Image *ReadICONImage(const ImageInfo *image_info,
                   byte=(size_t) ReadBlobByte(image);
                   for (bit=0; bit < (image->columns % 8); bit++)
                   {
-                    SetPixelIndex(image,((byte & (0x80 >> bit)) != 0 ? 0x01 :
-                      0x00),q);
+                    SetPixelIndex(image,(Quantum) ((byte & (0x80 >> bit)) != 0 ?
+                      0x01 : 0x00),q);
                     q+=(ptrdiff_t) GetPixelChannels(image);
                   }
                 }
@@ -604,15 +604,15 @@ static Image *ReadICONImage(const ImageInfo *image_info,
               for (x=0; x < ((ssize_t) image->columns-1); x+=2)
               {
                 byte=(size_t) ReadBlobByte(image);
-                SetPixelIndex(image,((byte >> 4) & 0xf),q);
+                SetPixelIndex(image,(Quantum) ((byte >> 4) & 0xf),q);
                 q+=(ptrdiff_t) GetPixelChannels(image);
-                SetPixelIndex(image,((byte) & 0xf),q);
+                SetPixelIndex(image,(Quantum) ((byte) & 0xf),q);
                 q+=(ptrdiff_t) GetPixelChannels(image);
               }
               if ((image->columns % 2) != 0)
                 {
                   byte=(size_t) ReadBlobByte(image);
-                  SetPixelIndex(image,((byte >> 4) & 0xf),q);
+                  SetPixelIndex(image,(Quantum) ((byte >> 4) & 0xf),q);
                   q+=(ptrdiff_t) GetPixelChannels(image);
                 }
               for (x=0; x < (ssize_t) scanline_pad; x++)
@@ -1417,9 +1417,9 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info,
             q=icon_colormap;
             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++=ScaleQuantumToChar((Quantum) next->colormap[i].blue);
+              *q++=ScaleQuantumToChar((Quantum) next->colormap[i].green);
+              *q++=ScaleQuantumToChar((Quantum) next->colormap[i].red);
               *q++=(unsigned char) 0x00;
             }
             for ( ; i < (ssize_t) 1UL << bits_per_pixel; i++)
diff --git a/coders/jbig.c b/coders/jbig.c
index fca44c660..5ab7e7c61 100644
--- a/coders/jbig.c
+++ b/coders/jbig.c
@@ -246,7 +246,7 @@ static Image *ReadJBIGImage(const ImageInfo *image_info,
     {
       if (bit == 0)
         byte=(*p++);
-      index=(byte & 0x80) ? 0 : 1;
+      index=(Quantum) ((byte & 0x80) ? 0 : 1);
       bit++;
       byte<<=1;
       if (bit == 8)
@@ -529,15 +529,15 @@ static MagickBooleanType WriteJBIGImage(const ImageInfo *image_info,
               flags;

             flags=ParseGeometry(image_info->density,&geometry_info);
-            x_resolution=geometry_info.rho;
-            y_resolution=geometry_info.sigma;
+            x_resolution=(size_t) geometry_info.rho;
+            y_resolution=(size_t) geometry_info.sigma;
             if ((flags & SigmaValue) == 0)
               y_resolution=x_resolution;
           }
         if (image->units == PixelsPerCentimeterResolution)
           {
-            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;
+            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,(unsigned long) x_resolution,
           (unsigned long) y_resolution);
diff --git a/coders/jp2.c b/coders/jp2.c
index e9a5e0158..9056a5ff0 100644
--- a/coders/jp2.c
+++ b/coders/jp2.c
@@ -1003,7 +1003,7 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image,
   parameters->cp_disto_alloc=OPJ_TRUE;
   if ((image_info->quality != 0) && (image_info->quality != 100))
     {
-      parameters->tcp_distoratio[0]=(double) image_info->quality;
+      parameters->tcp_distoratio[0]=(float) image_info->quality;
       parameters->cp_fixed_quality=OPJ_TRUE;
       parameters->cp_disto_alloc=OPJ_FALSE;
     }
@@ -1025,9 +1025,9 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image,
       if ((flags & HeightValue) != 0)
         parameters->cp_tdy=(int) geometry.height;
       if ((flags & XValue) != 0)
-        parameters->cp_tx0=geometry.x;
+        parameters->cp_tx0=(int) geometry.x;
       if ((flags & YValue) != 0)
-        parameters->cp_ty0=geometry.y;
+        parameters->cp_ty0=(int) geometry.y;
       parameters->tile_size_on=OPJ_TRUE;
       parameters->numresolution=CalculateNumResolutions((size_t)
         parameters->cp_tdx,(size_t) parameters->cp_tdy);
@@ -1052,7 +1052,7 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image,
           break;
         p++;
       }
-      parameters->tcp_numlayers=i+1;
+      parameters->tcp_numlayers=(int) (i+1);
       parameters->cp_fixed_quality=OPJ_TRUE;
       parameters->cp_disto_alloc=OPJ_FALSE;
     }
@@ -1090,7 +1090,7 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image,
           break;
         p++;
       }
-      parameters->tcp_numlayers=i+1;
+      parameters->tcp_numlayers=(int) (i+1);
       parameters->cp_disto_alloc=OPJ_TRUE;
     }
   if (image_info->sampling_factor != (char *) NULL)
diff --git a/coders/jpeg.c b/coders/jpeg.c
index 8cbfa272a..563a5d39c 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -2192,7 +2192,7 @@ static void WriteProfiles(j_compress_ptr jpeg_info,Image *image,
         marker=JPEG_APP0+StringToInteger(name+3);
         for (i=0; i < (ssize_t) length; i+=65533L)
            jpeg_write_marker(jpeg_info,marker,GetStringInfoDatum(profile)+i,
-             MagickMin((unsigned int) length-i,65533L));
+             MagickMin((unsigned int) (length-i),65533));
       }
     else if (LocaleCompare(name,"EXIF") == 0)
       {
@@ -2275,7 +2275,7 @@ static void WriteProfiles(j_compress_ptr jpeg_info,Image *image,
         length=GetStringInfoLength(xmp_profile);
         for (i=0; i < (ssize_t) length; i+=65533L)
           jpeg_write_marker(jpeg_info,APP_MARKER+1,GetStringInfoDatum(
-            xmp_profile)+i,MagickMin((unsigned int) length-i,65533L));
+            xmp_profile)+i,MagickMin((unsigned int) (length-i),65533));
         xmp_profile=DestroyStringInfo(xmp_profile);
       }
     if (image->debug != MagickFalse)
@@ -2348,7 +2348,7 @@ static inline void JPEGSetSample(const struct jpeg_compress_struct *jpeg_info,
   const unsigned int scale,const Quantum pixel,JSAMPLE *q)
 {
   if (jpeg_info->data_precision > 8)
-    (*(unsigned short *) q)=(ScaleQuantumToShort(pixel)/scale);
+    (*(unsigned short *) q)=(unsigned short) (ScaleQuantumToShort(pixel)/scale);
   *q=(JSAMPLE) ScaleQuantumToChar(pixel);
 }

diff --git a/coders/json.c b/coders/json.c
index ffcb1abd4..c5f79e8dd 100644
--- a/coders/json.c
+++ b/coders/json.c
@@ -967,6 +967,7 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,

   double
     elapsed_time,
+    scale,
     user_time,
     version;

@@ -978,8 +979,7 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,

   size_t
     depth,
-    distance,
-    scale;
+    distance;

   ssize_t
     i,
@@ -1157,7 +1157,6 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
   channel_moments=(ChannelMoments *) NULL;
   channel_phash=(ChannelPerceptualHash *) NULL;
   channel_features=(ChannelFeatures *) NULL;
-  scale=1;
   channel_statistics=GetImageStatistics(image,exception);
   if (channel_statistics == (ChannelStatistics *) NULL)
     return(MagickFalse);
@@ -1221,8 +1220,8 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
   (void) FormatLocaleFile(file,"    },\n");
   scale=1;
   if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
-    scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
-      MAGICKCORE_QUANTUM_DEPTH-image->depth));
+    scale=(double) (QuantumRange/((size_t) QuantumRange >> ((size_t)
+      MAGICKCORE_QUANTUM_DEPTH-image->depth)));
   if (channel_statistics != (ChannelStatistics *) NULL)
     {
       (void) FormatLocaleFile(file,"    \"pixels\": %.20g,\n",
diff --git a/coders/mac.c b/coders/mac.c
index 7e7d2c75b..ffc0964ee 100644
--- a/coders/mac.c
+++ b/coders/mac.c
@@ -201,7 +201,7 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
               {
                 if (bit == 0)
                   byte=(*p++);
-                SetPixelIndex(image,((byte & 0x80) != 0 ? 0x01 : 0x00),q);
+                SetPixelIndex(image,(Quantum) ((byte & 0x80) != 0 ? 0x01 : 0x00),q);
                 bit++;
                 byte<<=1;
                 if (bit == 8)
@@ -236,7 +236,7 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
           {
             if (bit == 0)
               byte=(*p++);
-            SetPixelIndex(image,((byte & 0x80) != 0 ? 0x01 : 0x00),q);
+            SetPixelIndex(image,(Quantum) ((byte & 0x80) != 0 ? 0x01 : 0x00),q);
             bit++;
             byte<<=1;
             if (bit == 8)
diff --git a/coders/map.c b/coders/map.c
index 6b0f992b4..f888221de 100644
--- a/coders/map.c
+++ b/coders/map.c
@@ -232,11 +232,11 @@ static Image *ReadMAPImage(const ImageInfo *image_info,ExceptionInfo *exception)
       break;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      index=ConstrainColormapIndex(image,*p,exception);
+      index=(Quantum) ConstrainColormapIndex(image,*p,exception);
       p++;
       if (image->colors > 256)
         {
-          index=ConstrainColormapIndex(image,(ssize_t) (((size_t) index << 8)+
+          index=(Quantum) ConstrainColormapIndex(image,(ssize_t) (((size_t) index << 8)+
             (size_t) (*p)),exception);
           p++;
         }
@@ -420,20 +420,20 @@ static MagickBooleanType WriteMAPImage(const ImageInfo *image_info,Image *image,
   if (image->colors <= 256)
     for (i=0; i < (ssize_t) image->colors; i++)
     {
-      *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].red);
-      *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].green);
-      *q++=(unsigned char) ScaleQuantumToChar(image->colormap[i].blue);
+      *q++=(unsigned char) ScaleQuantumToChar((Quantum) image->colormap[i].red);
+      *q++=(unsigned char) ScaleQuantumToChar((Quantum) image->colormap[i].green);
+      *q++=(unsigned char) ScaleQuantumToChar((Quantum) image->colormap[i].blue);
     }
   else
     for (i=0; i < (ssize_t) image->colors; i++)
     {
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) >> 8);
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].red) & 0xff);
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) >> 8);
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].green) &
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].red) >> 8);
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].red) & 0xff);
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].green) >> 8);
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].green) &
         0xff);
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) >> 8);
-      *q++=(unsigned char) (ScaleQuantumToShort(image->colormap[i].blue) &
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].blue) >> 8);
+      *q++=(unsigned char) (ScaleQuantumToShort((Quantum) image->colormap[i].blue) &
         0xff);
     }
   (void) WriteBlob(image,packet_size*image->colors,colormap);
diff --git a/coders/mat.c b/coders/mat.c
index 40506bebe..d667813c0 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -201,7 +201,7 @@ static void InsertComplexDoubleRow(Image *image,double *p,int y,double MinVal,
         if ((f+(double) GetPixelRed(image,q)) >= (double) QuantumRange)
           SetPixelRed(image,QuantumRange,q);
         else
-          SetPixelRed(image,(double) GetPixelRed(image,q)+ClampToQuantum(f),q);
+          SetPixelRed(image,GetPixelRed(image,q)+ClampToQuantum(f),q);
         f=(double) GetPixelGreen(image,q)-f/2.0;
         if (IsNaN(f) != 0)
           f=0.0;
@@ -497,7 +497,7 @@ int file;

 MagickBooleanType status;
 int zip_status;
-ssize_t TotalSize = 0;
+ssize_t total_size = 0;

   if(clone_info==NULL) return NULL;
   if(clone_info->file)    /* Close file opened from previous transaction. */
@@ -564,7 +564,7 @@ ssize_t TotalSize = 0;
         break;
       extent=fwrite(decompress_block,1,4096-zip_info.avail_out,mat_file);
       (void) extent;
-      TotalSize += 4096-zip_info.avail_out;
+      total_size += 4096-zip_info.avail_out;

       if(zip_status == Z_STREAM_END) goto DblBreak;
     }
@@ -579,7 +579,7 @@ DblBreak:
   (void)fclose(mat_file);
   RelinquishMagickMemory(cache_block);
   RelinquishMagickMemory(decompress_block);
-  *Size = TotalSize;
+  *Size = (unsigned int) total_size;

   if((clone_info->file=fopen_utf8(clone_info->filename,"rb"))==NULL) goto UnlinkFile;
   if( (image2 = AcquireImage(clone_info,exception))==NULL ) goto EraseFile;
@@ -791,9 +791,9 @@ static Image *ReadMATImageV4(const ImageInfo *image_info,Image *image,
         if (count == -1)
           break;
         if (HDR.Type[1] == 0)
-          InsertComplexDoubleRow(image,(double *) pixels,y,0,0,exception);
+          InsertComplexDoubleRow(image,(double *) pixels,(int) y,0,0,exception);
         else
-          InsertComplexFloatRow(image,(float *) pixels,y,0,0,exception);
+          InsertComplexFloatRow(image,(float *) pixels,(int) y,0,0,exception);
       }
     if (quantum_info != (QuantumInfo *) NULL)
       quantum_info=DestroyQuantumInfo(quantum_info);
@@ -1020,7 +1020,7 @@ MATLAB_KO:
     MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2);
     MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);

-    MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2);
+    MATLAB_HDR.unknown5 = (unsigned short) ReadBlobXXXLong(image2);
     MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF;
     MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;

@@ -1269,8 +1269,8 @@ RestoreMSCWarning
     if (CellType==miDOUBLE || CellType==miSINGLE)        /* Find Min and Max Values for floats */
       {
         CalcMinMax(image2,(int) image_info->endian,MATLAB_HDR.SizeX,
-          MATLAB_HDR.SizeY,CellType,ldblk,BImgBuff,&quantum_info->minimum,
-          &quantum_info->maximum);
+          MATLAB_HDR.SizeY,CellType,(unsigned int) ldblk,BImgBuff,
+          &quantum_info->minimum,&quantum_info->maximum);
       }

     /* Main loop for reading all scanlines */
@@ -1342,8 +1342,8 @@ ExitLoop:

       if (CellType==miDOUBLE || CellType==miSINGLE)
       {
-        CalcMinMax(image2,  (int) image_info->endian, MATLAB_HDR.SizeX,
-          MATLAB_HDR.SizeY, CellType, ldblk, BImgBuff, &MinVal, &MaxVal);
+        CalcMinMax(image2,(int) image_info->endian,MATLAB_HDR.SizeX,
+          MATLAB_HDR.SizeY,CellType,(unsigned int) ldblk,BImgBuff,&MinVal,&MaxVal);
       }

       if (CellType==miDOUBLE)
@@ -1352,7 +1352,7 @@ ExitLoop:
           ReadBlobDoublesXXX(image2, (size_t) ldblk, (double *)BImgBuff);
           if (EOFBlob(image) != MagickFalse)
             break;
-          InsertComplexDoubleRow(image, (double *)BImgBuff, i, MinVal, MaxVal,
+          InsertComplexDoubleRow(image,(double *)BImgBuff,(int) i,MinVal,MaxVal,
             exception);
         }

@@ -1362,7 +1362,7 @@ ExitLoop:
           ReadBlobFloatsXXX(image2, (size_t) ldblk, (float *)BImgBuff);
           if (EOFBlob(image) != MagickFalse)
             break;
-          InsertComplexFloatRow(image,(float *)BImgBuff,i,MinVal,MaxVal,
+          InsertComplexFloatRow(image,(float *)BImgBuff,(int) i,MinVal,MaxVal,
             exception);
         }
     }
diff --git a/coders/meta.c b/coders/meta.c
index 690a9604b..484485a79 100644
--- a/coders/meta.c
+++ b/coders/meta.c
@@ -178,10 +178,10 @@ static int stringnicmp(const char *p,const char *q,size_t n)
       break;
     i=(*p);
     if (islower((int) ((unsigned char) i)) != 0)
-      i=LocaleToUppercase(i);
+      i=LocaleToUppercase((int) i);
     j=(*q);
     if (islower((int) ((unsigned char) j)) != 0)
-      j=LocaleToUppercase(j);
+      j=LocaleToUppercase((int) j);
     if (i != j)
       break;
     n--;
@@ -227,7 +227,7 @@ static size_t convertHTMLcodes(char *s)
       }
       if (o < 6)
         (void) memmove(s+1,s+1+o,strlen(s+1+o)+1);
-      *s=value;
+      *s=(char) value;
       return(o);
     }
   for (i=0; i < (ssize_t) (sizeof(html_codes)/sizeof(html_codes[0])); i++)
diff --git a/coders/mono.c b/coders/mono.c
index 2923be804..53d337ded 100644
--- a/coders/mono.c
+++ b/coders/mono.c
@@ -169,9 +169,9 @@ static Image *ReadMONOImage(const ImageInfo *image_info,
       if (bit == 0)
         byte=(size_t) ReadBlobByte(image);
       if (image_info->endian == LSBEndian)
-        SetPixelIndex(image,((byte & 0x01) != 0) ? 0x00 : 0x01,q);
+        SetPixelIndex(image,(Quantum) (((byte & 0x01) != 0) ? 0x00 : 0x01),q);
       else
-        SetPixelIndex(image,((byte & 0x01) != 0) ? 0x01 : 0x00,q);
+        SetPixelIndex(image,(Quantum) (((byte & 0x01) != 0) ? 0x01 : 0x00),q);
       bit++;
       if (bit == 8)
         bit=0;
diff --git a/coders/msl.c b/coders/msl.c
index dc7a8bfd8..2424e9883 100644
--- a/coders/msl.c
+++ b/coders/msl.c
@@ -665,7 +665,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=(size_t) StringToLong(value);
+                      draw_info->stroke_width=(double) StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -1677,7 +1677,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                         {
                           if (GetPixelAlpha(composite_image,q) == OpaqueAlpha)
                             SetPixelAlpha(composite_image,
-                              ClampToQuantum(opacity),q);
+                              ClampToQuantum((MagickRealType) opacity),q);
                           q+=(ptrdiff_t) GetPixelChannels(composite_image);
                         }
                         if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse)
@@ -2313,7 +2313,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=(size_t) StringToLong(value);
+                      draw_info->stroke_width=(double) StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -4499,7 +4499,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                     }
                   if (LocaleCompare(keyword,"strokewidth") == 0)
                     {
-                      draw_info->stroke_width=(size_t) StringToLong(value);
+                      draw_info->stroke_width=(double) StringToLong(value);
                       break;
                     }
                   if (LocaleCompare(keyword,"style") == 0)
@@ -5823,10 +5823,10 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                   if (value[len-1] == '%') {
                     char  tmp[100];
                     (void) CopyMagickString(tmp,value,(size_t) len);
-                    opac = StringToLong( tmp );
-                    opac = (int)(QuantumRange * ((float)opac/100));
+                    opac = (Quantum) StringToLong( tmp );
+                    opac = (Quantum)(QuantumRange * ((float)opac/100));
                   } else
-                    opac = StringToLong( value );
+                    opac = (Quantum) StringToLong( value );
                   (void) SetImageAlpha( msl_info->image[n], (Quantum) opac,
                     exception);
                   break;
diff --git a/coders/otb.c b/coders/otb.c
index 76904d87d..c1cca395d 100644
--- a/coders/otb.c
+++ b/coders/otb.c
@@ -186,7 +186,7 @@ static Image *ReadOTBImage(const ImageInfo *image_info,ExceptionInfo *exception)
           if (byte == EOF)
             ThrowReaderException(CorruptImageError,"CorruptImage");
         }
-      SetPixelIndex(image,(byte & (0x01 << (7-bit))) ? 0x00 : 0x01,q);
+      SetPixelIndex(image,(Quantum) ((byte & (0x01 << (7-bit))) ? 0x00 : 0x01),q);
       bit++;
       if (bit == 8)
         bit=0;
diff --git a/coders/pango.c b/coders/pango.c
index e5340dc6e..6ffd639ed 100644
--- a/coders/pango.c
+++ b/coders/pango.c
@@ -427,7 +427,7 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
   cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
   cairo_paint(cairo_image);
   cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
-  cairo_translate(cairo_image,page.x,page.y);
+  cairo_translate(cairo_image,(double) page.x,(double) page.y);
   cairo_set_source_rgba(cairo_image,QuantumScale*draw_info->fill.red,
     QuantumScale*draw_info->fill.green,QuantumScale*draw_info->fill.blue,
     QuantumScale*draw_info->fill.alpha);
diff --git a/coders/pcl.c b/coders/pcl.c
index 6c4dadde8..cfb599f56 100644
--- a/coders/pcl.c
+++ b/coders/pcl.c
@@ -398,10 +398,10 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->page=page;
     if (image_info->ping != MagickFalse)
       {
-        image->magick_columns*=image->resolution.x/2.0;
-        image->magick_rows*=image->resolution.y/2.0;
-        image->columns*=image->resolution.x/2.0;
-        image->rows*=image->resolution.y/2.0;
+        image->magick_columns*=(size_t) (image->resolution.x/2.0);
+        image->magick_rows*=(size_t) (image->resolution.y/2.0);
+        image->columns*=(size_t) (image->resolution.x/2.0);
+        image->rows*=(size_t) (image->resolution.y/2.0);
       }
     next_image=SyncNextImageInList(image);
     if (next_image != (Image *) NULL)
@@ -543,7 +543,7 @@ static size_t PCLDeltaCompressImage(const size_t length,
       break;
     replacement=j >= 31 ? 31 : j;
     j-=replacement;
-    delta=i >= 8 ? 8 : i;
+    delta=i >= 8 ? 8 : (int) i;
     *q++=(unsigned char) (((delta-1) << 5) | replacement);
     if (replacement == 31)
       {
@@ -563,7 +563,7 @@ static size_t PCLDeltaCompressImage(const size_t length,
         *q++=(*pixels++);
       if (i == 0)
         break;
-      delta=i;
+      delta=(int) i;
       if (i >= 8)
         delta=8;
       *q++=(unsigned char) ((delta-1) << 5);
@@ -794,9 +794,9 @@ static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image,
           {
             (void) FormatLocaleString(buffer,MagickPathExtent,
               "\033*v%da%db%dc%.20gI",
-              ScaleQuantumToChar(image->colormap[i].red),
-              ScaleQuantumToChar(image->colormap[i].green),
-              ScaleQuantumToChar(image->colormap[i].blue),(double) i);
+              ScaleQuantumToChar((Quantum) image->colormap[i].red),
+              ScaleQuantumToChar((Quantum) image->colormap[i].green),
+              ScaleQuantumToChar((Quantum) image->colormap[i].blue),(double) i);
             (void) WriteBlobString(image,buffer);
           }
           for (one=1; i < (ssize_t) (one << bits_per_pixel); i++)
diff --git a/coders/pcx.c b/coders/pcx.c
index 9b67de3d1..66fcdfc55 100644
--- a/coders/pcx.c
+++ b/coders/pcx.c
@@ -1008,9 +1008,9 @@ static MagickBooleanType WritePCXImage(const ImageInfo *image_info,Image *image,
     if ((image->storage_class == PseudoClass) && (image->colors <= 256))
       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);
+        *q++=ScaleQuantumToChar((Quantum) image->colormap[i].red);
+        *q++=ScaleQuantumToChar((Quantum) image->colormap[i].green);
+        *q++=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
       }
     (void) WriteBlob(image,3*16,(const unsigned char *) pcx_colormap);
     (void) WriteBlobByte(image,pcx_info.reserved);
diff --git a/coders/pdb.c b/coders/pdb.c
index c70498189..f3ed106b8 100644
--- a/coders/pdb.c
+++ b/coders/pdb.c
@@ -389,7 +389,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   count=ReadBlob(image,sizeof(pdb_image.name),(unsigned char *) pdb_image.name);
   if (count != sizeof(pdb_image.name))
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-  pdb_image.version=ReadBlobByte(image);
+  pdb_image.version=(char) ReadBlobByte(image);
   pdb_image.type=(unsigned char) (ReadBlobByte(image));
   pdb_image.reserved_1=ReadBlobMSBLong(image);
   pdb_image.note=ReadBlobMSBLong(image);
@@ -513,7 +513,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         for (x=0; x < (ssize_t) image->columns; x++)
         {
           shift-=2;
-          index=ConstrainColormapIndex(image,3UL-((*p >> shift) & 0x03),
+          index=(Quantum) ConstrainColormapIndex(image,3UL-((*p >> shift) & 0x03),
             exception);
           SetPixelIndex(image,index,q);
           q+=(ptrdiff_t) GetPixelChannels(image);
@@ -550,7 +550,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         for (x=0; x < (ssize_t) image->columns; x++)
         {
           shift-=4;
-          index=ConstrainColormapIndex(image,15UL-((*p >> shift) & 0x0f),
+          index=(Quantum) ConstrainColormapIndex(image,15UL-((*p >> shift) & 0x0f),
             exception);
           SetPixelIndex(image,index,q);
           q+=(ptrdiff_t) GetPixelChannels(image);
@@ -621,7 +621,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               break;
             r=comment+strlen(comment);
           }
-        *r=c;
+        *r=(char) c;
         c=ReadBlobByte(image);
       }
       *r='\0';
diff --git a/coders/pict.c b/coders/pict.c
index fa84f5731..fe2f94422 100644
--- a/coders/pict.c
+++ b/coders/pict.c
@@ -904,10 +904,10 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
   /*
     Skip header : 512 for standard PICT and 4, ie "PICT" for OLE2.
   */
-  header_ole[0]=ReadBlobByte(image);
-  header_ole[1]=ReadBlobByte(image);
-  header_ole[2]=ReadBlobByte(image);
-  header_ole[3]=ReadBlobByte(image);
+  header_ole[0]=(char) ReadBlobByte(image);
+  header_ole[1]=(char) ReadBlobByte(image);
+  header_ole[2]=(char) ReadBlobByte(image);
+  header_ole[3]=(char) ReadBlobByte(image);
   if (!((header_ole[0] == 0x50) && (header_ole[1] == 0x49) &&
       (header_ole[2] == 0x43) && (header_ole[3] == 0x54 )))
     for (i=0; i < 508; i++)
@@ -1288,11 +1288,11 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                       *p,exception);
                     SetPixelIndex(tile_image,index,q);
                     SetPixelRed(tile_image,
-                      tile_image->colormap[(ssize_t) index].red,q);
+                      (Quantum) tile_image->colormap[(ssize_t) index].red,q);
                     SetPixelGreen(tile_image,
-                      tile_image->colormap[(ssize_t) index].green,q);
+                      (Quantum) tile_image->colormap[(ssize_t) index].green,q);
                     SetPixelBlue(tile_image,
-                      tile_image->colormap[(ssize_t) index].blue,q);
+                      (Quantum) tile_image->colormap[(ssize_t) index].blue,q);
                   }
                 else
                   {
@@ -1981,11 +1981,11 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info,
       {
         (void) WriteBlobMSBShort(image,(unsigned short) i);
         (void) WriteBlobMSBShort(image,ScaleQuantumToShort(
-          image->colormap[i].red));
+          (Quantum) image->colormap[i].red));
         (void) WriteBlobMSBShort(image,ScaleQuantumToShort(
-          image->colormap[i].green));
+          (Quantum) image->colormap[i].green));
         (void) WriteBlobMSBShort(image,ScaleQuantumToShort(
-          image->colormap[i].blue));
+          (Quantum) image->colormap[i].blue));
       }
     }
   /*
diff --git a/coders/plasma.c b/coders/plasma.c
index 091b666ca..0abc3624d 100644
--- a/coders/plasma.c
+++ b/coders/plasma.c
@@ -103,11 +103,11 @@ static inline MagickBooleanType PlasmaPixel(Image *image,
     exception);
   if (q == (Quantum *) NULL)
     return(MagickFalse);
-  SetPixelRed(image,((double) QuantumRange*GetPseudoRandomValue(random_info)+
+  SetPixelRed(image,(Quantum) ((double) QuantumRange*GetPseudoRandomValue(random_info)+
     0.5),q);
-  SetPixelGreen(image,((double) QuantumRange*GetPseudoRandomValue(random_info)+
+  SetPixelGreen(image,(Quantum) ((double) QuantumRange*GetPseudoRandomValue(random_info)+
     0.5),q);
-  SetPixelBlue(image,((double) QuantumRange*GetPseudoRandomValue(random_info)+
+  SetPixelBlue(image,(Quantum) ((double) QuantumRange*GetPseudoRandomValue(random_info)+
     0.5),q);
   return(SyncAuthenticPixels(image,exception));
 }
diff --git a/coders/png.c b/coders/png.c
index d5df8b5d2..5a2172e51 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -159,19 +159,19 @@ const struct sRGB_info_struct sRGB_info[] =
 /* LBR01: Replicate top bit */

 #define LBR01PacketRed(pixelpacket) \
-     (pixelpacket).red=(ScaleQuantumToChar((pixelpacket).red) < 0x10 ? \
+     (pixelpacket).red=(ScaleQuantumToChar((Quantum) (pixelpacket).red) < 0x10 ? \
         0 : QuantumRange);

 #define LBR01PacketGreen(pixelpacket) \
-     (pixelpacket).green=(ScaleQuantumToChar((pixelpacket).green) < 0x10 ? \
+     (pixelpacket).green=(ScaleQuantumToChar((Quantum) (pixelpacket).green) < 0x10 ? \
         0 : QuantumRange);

 #define LBR01PacketBlue(pixelpacket) \
-     (pixelpacket).blue=(ScaleQuantumToChar((pixelpacket).blue) < 0x10 ? \
+     (pixelpacket).blue=(ScaleQuantumToChar((Quantum) (pixelpacket).blue) < 0x10 ? \
         0 : QuantumRange);

 #define LBR01PacketAlpha(pixelpacket) \
-     (pixelpacket).alpha=(ScaleQuantumToChar((pixelpacket).alpha) < 0x10 ? \
+     (pixelpacket).alpha=(ScaleQuantumToChar((Quantum) (pixelpacket).alpha) < 0x10 ? \
         0 : QuantumRange);

 #define LBR01PacketRGB(pixelpacket) \
@@ -224,25 +224,25 @@ const struct sRGB_info_struct sRGB_info[] =

 #define LBR02PacketRed(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).red) & 0xc0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).red) & 0xc0; \
      (pixelpacket).red=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 2) | (lbr_bits >> 4) | (lbr_bits >> 6))); \
    }
 #define LBR02PacketGreen(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).green) & 0xc0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).green) & 0xc0; \
      (pixelpacket).green=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 2) | (lbr_bits >> 4) | (lbr_bits >> 6))); \
    }
 #define LBR02PacketBlue(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).blue) & 0xc0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).blue) & 0xc0; \
      (pixelpacket).blue=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 2) | (lbr_bits >> 4) | (lbr_bits >> 6))); \
    }
 #define LBR02PacketAlpha(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).alpha) & 0xc0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).alpha) & 0xc0; \
      (pixelpacket).alpha=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 2) | (lbr_bits >> 4) | (lbr_bits >> 6))); \
    }
@@ -311,19 +311,19 @@ const struct sRGB_info_struct sRGB_info[] =

 #define LBR03PacketRed(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).red) & 0xe0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).red) & 0xe0; \
      (pixelpacket).red=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 3) | (lbr_bits >> 6))); \
    }
 #define LBR03PacketGreen(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).green) & 0xe0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).green) & 0xe0; \
      (pixelpacket).green=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 3) | (lbr_bits >> 6))); \
    }
 #define LBR03PacketBlue(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).blue) & 0xe0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).blue) & 0xe0; \
      (pixelpacket).blue=ScaleCharToQuantum( \
        (lbr_bits | (lbr_bits >> 3) | (lbr_bits >> 6))); \
    }
@@ -368,22 +368,22 @@ const struct sRGB_info_struct sRGB_info[] =

 #define LBR04PacketRed(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).red) & 0xf0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).red) & 0xf0; \
      (pixelpacket).red=ScaleCharToQuantum((lbr_bits | (lbr_bits >> 4))); \
    }
 #define LBR04PacketGreen(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).green) & 0xf0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).green) & 0xf0; \
      (pixelpacket).green=ScaleCharToQuantum((lbr_bits | (lbr_bits >> 4))); \
    }
 #define LBR04PacketBlue(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).blue) & 0xf0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).blue) & 0xf0; \
      (pixelpacket).blue=ScaleCharToQuantum((lbr_bits | (lbr_bits >> 4))); \
    }
 #define LBR04PacketAlpha(pixelpacket) \
    { \
-     unsigned char lbr_bits=ScaleQuantumToChar((pixelpacket).alpha) & 0xf0; \
+     unsigned char lbr_bits=ScaleQuantumToChar((Quantum) (pixelpacket).alpha) & 0xf0; \
      (pixelpacket).alpha=ScaleCharToQuantum((lbr_bits | (lbr_bits >> 4))); \
    }

@@ -746,7 +746,7 @@ LosslessReduceDepthOK(Image *image,ExceptionInfo *exception)
      */

 #define QuantumToCharToQuantumEqQuantum(quantum) \
- (((double) ScaleCharToQuantum((unsigned char) ScaleQuantumToChar(quantum))) == (double) quantum)
+ (((double) ScaleCharToQuantum((unsigned char) ScaleQuantumToChar((Quantum) quantum))) == (double) quantum)

     MagickBooleanType
       ok_to_reduce=MagickFalse;
@@ -1416,7 +1416,7 @@ static void MngReadInfoDiscardObject(MngReadInfo *mng_info,int i)

 static MngReadInfo *MngReadInfoFreeStruct(MngReadInfo *mng_info)
 {
-  ssize_t
+  int
     i;

   if (mng_info == (MngReadInfo *) NULL)
@@ -2830,9 +2830,9 @@ static Image *ReadOnePNGImage(MngReadInfo *mng_info,
         if (ping_file_depth <= 8)
            bkgd_scale *= 257;

-        ping_background->red *= bkgd_scale;
-        ping_background->green *= bkgd_scale;
-        ping_background->blue *= bkgd_scale;
+        ping_background->red *= (png_uint_16) bkgd_scale;
+        ping_background->green *= (png_uint_16) bkgd_scale;
+        ping_background->blue *= (png_uint_16) bkgd_scale;

         if (logging != MagickFalse)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3428,7 +3428,7 @@ static Image *ReadOnePNGImage(MngReadInfo *mng_info,
                 quantum=0;

               quantum|=(*p++);
-              *r=ScaleShortToQuantum(quantum);
+              *r=ScaleShortToQuantum((unsigned short) quantum);
               r++;

               if (ping_color_type == 4)
@@ -3440,7 +3440,7 @@ static Image *ReadOnePNGImage(MngReadInfo *mng_info,

                   quantum|=(*p++);

-                  alpha=ScaleShortToQuantum(quantum);
+                  alpha=ScaleShortToQuantum((unsigned short) quantum);
                   SetPixelAlpha(image,alpha,q);

                   if (alpha != OpaqueAlpha)
@@ -3491,7 +3491,7 @@ static Image *ReadOnePNGImage(MngReadInfo *mng_info,
           SetPixelRed(image,ClampToQuantum(image->colormap[index].red),q);
           SetPixelGreen(image,ClampToQuantum(image->colormap[index].green),q);
           SetPixelBlue(image,ClampToQuantum(image->colormap[index].blue),q);
-          SetPixelIndex(image,index,q);
+          SetPixelIndex(image,(Quantum) index,q);
           r++;
           q+=(ptrdiff_t) GetPixelChannels(image);
         }
@@ -3596,7 +3596,7 @@ static Image *ReadOnePNGImage(MngReadInfo *mng_info,
             {
               for (x=0; x < (int) image->colors; x++)
               {
-                 if (ScaleQuantumToShort(image->colormap[x].red) ==
+                 if (ScaleQuantumToShort((Quantum) image->colormap[x].red) ==
                      transparent_color.alpha)
                  {
                     image->colormap[x].alpha_trait=BlendPixelTrait;
@@ -5487,7 +5487,7 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
                   igamma;

                 igamma=mng_get_long(p);
-                mng_info->global_gamma=((double) igamma)*0.00001;
+                mng_info->global_gamma=((float) igamma)*0.00001f;
                 mng_info->have_global_gama=MagickTrue;
               }

@@ -5783,7 +5783,7 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
             if ((length == 0) || (length % 2) || !memcmp(type,mng_SEEK,4))
               {
                 for (i=1; i < MNG_MAX_OBJECTS; i++)
-                  MngReadInfoDiscardObject(mng_info,i);
+                  MngReadInfoDiscardObject(mng_info,(int) i);
               }

             else
@@ -5794,7 +5794,7 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
                 for (j=1; j < (ssize_t) length; j+=2)
                 {
                   i=p[j-1] << 8 | p[j];
-                  MngReadInfoDiscardObject(mng_info,i);
+                  MngReadInfoDiscardObject(mng_info,(int) i);
                 }
               }

@@ -5831,8 +5831,8 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
                     MngPair
                       old_pair;

-                    old_pair.a=mng_info->x_off[i];
-                    old_pair.b=mng_info->y_off[i];
+                    old_pair.a=(volatile long) mng_info->x_off[i];
+                    old_pair.b=(volatile long) mng_info->y_off[i];
                     new_pair=mng_read_pair(old_pair,(int) p[0],&p[1]);
                     mng_info->x_off[i]=new_pair.a;
                     mng_info->y_off[i]=new_pair.b;
@@ -5861,7 +5861,7 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
                     (double) loop_level, (double) loop_iters);

                 if (loop_iters <= 0)
-                  skipping_loop=loop_level;
+                  skipping_loop=(volatile short) loop_level;

                 else
                   {
@@ -6960,10 +6960,10 @@ static Image *ReadOneMNGImage(MngReadInfo* mng_info,
         /*
           Crop_box is with respect to the upper left corner of the MNG.
         */
-        crop_box.left=mng_info->image_box.left+mng_info->x_off[object_id];
-        crop_box.right=mng_info->image_box.right+mng_info->x_off[object_id];
-        crop_box.top=mng_info->image_box.top+mng_info->y_off[object_id];
-        crop_box.bottom=mng_info->image_box.bottom+mng_info->y_off[object_id];
+        crop_box.left=mng_info->image_box.left+(long) mng_info->x_off[object_id];
+        crop_box.right=mng_info->image_box.right+(long) mng_info->x_off[object_id];
+        crop_box.top=mng_info->image_box.top+(long) mng_info->y_off[object_id];
+        crop_box.bottom=mng_info->image_box.bottom+(long) mng_info->y_off[object_id];
         crop_box=mng_minimum_box(crop_box,mng_info->clip);
         crop_box=mng_minimum_box(crop_box,mng_info->frame);
         crop_box=mng_minimum_box(crop_box,mng_info->object_clip[object_id]);
@@ -7892,12 +7892,12 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info,
      month=1;
   }

-  ptime.year = year;
-  ptime.month = month;
-  ptime.day = day;
-  ptime.hour = hour;
-  ptime.minute = minute;
-  ptime.second = second;
+  ptime.year = (png_uint_16) year;
+  ptime.month = (png_byte) month;
+  ptime.day = (png_byte) day;
+  ptime.hour = (png_byte) hour;
+  ptime.minute = (png_byte) minute;
+  ptime.second = (png_byte) second;
   png_convert_from_time_t(&ptime,GetMagickTime());
   LogMagickEvent(CoderEvent,GetMagickModule(),
       "      png_set_tIME: y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, am=%d",
@@ -8822,8 +8822,8 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
          for (i=0; i<number_opaque; i++)
             colormap[n++] = opaque[i];

-         ping_background.index +=
-           (number_transparent + number_semitransparent);
+         ping_background.index += (png_byte) (number_transparent +
+           number_semitransparent);

          /* image_colors < 257; search the colormap instead of the pixels
           * to get ping_have_color and ping_have_non_bw
@@ -8907,7 +8907,7 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
                       image->colormap[i].green == (double) GetPixelGreen(image,q) &&
                       image->colormap[i].blue == (double) GetPixelBlue(image,q))
                   {
-                    SetPixelIndex(image,i,q);
+                    SetPixelIndex(image,(Quantum) i,q);
                     break;
                   }
                 }
@@ -9208,9 +9208,9 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
             "    Merging two dark red background colors to 3-3-2-1");

-      if (ScaleQuantumToChar(image->background_color.red) == 0x49 &&
-          ScaleQuantumToChar(image->background_color.green) == 0x00 &&
-          ScaleQuantumToChar(image->background_color.blue) == 0x00)
+      if (ScaleQuantumToChar((Quantum) image->background_color.red) == 0x49 &&
+          ScaleQuantumToChar((Quantum) image->background_color.green) == 0x00 &&
+          ScaleQuantumToChar((Quantum) image->background_color.blue) == 0x00)
       {
          image->background_color.red=ScaleCharToQuantum(0x24);
       }
@@ -9250,9 +9250,9 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
       {
          for (i=0; i<image_colors; i++)
          {
-            if (ScaleQuantumToChar(image->colormap[i].red) == 0x49 &&
-                ScaleQuantumToChar(image->colormap[i].green) == 0x00 &&
-                ScaleQuantumToChar(image->colormap[i].blue) == 0x00)
+            if (ScaleQuantumToChar((Quantum) image->colormap[i].red) == 0x49 &&
+                ScaleQuantumToChar((Quantum) image->colormap[i].green) == 0x00 &&
+                ScaleQuantumToChar((Quantum) image->colormap[i].blue) == 0x00)
             {
                image->colormap[i].red=ScaleCharToQuantum(0x24);
             }
@@ -9591,13 +9591,13 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
           mask=0x0001;

        ping_background.red=(png_uint_16)
-         (ScaleQuantumToShort(image->background_color.red) & mask);
+         (ScaleQuantumToShort((Quantum) image->background_color.red) & mask);

        ping_background.green=(png_uint_16)
-         (ScaleQuantumToShort(image->background_color.green) & mask);
+         (ScaleQuantumToShort((Quantum) image->background_color.green) & mask);

        ping_background.blue=(png_uint_16)
-         (ScaleQuantumToShort(image->background_color.blue) & mask);
+         (ScaleQuantumToShort((Quantum) image->background_color.blue) & mask);

        ping_background.gray=(png_uint_16) ping_background.green;
     }
@@ -9645,9 +9645,9 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,

       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);
-        palette[i].blue=ScaleQuantumToChar(image->colormap[i].blue);
+        palette[i].red=ScaleQuantumToChar((Quantum) image->colormap[i].red);
+        palette[i].green=ScaleQuantumToChar((Quantum) image->colormap[i].green);
+        palette[i].blue=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
         if (logging != MagickFalse)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
 #if MAGICKCORE_QUANTUM_DEPTH == 8
@@ -9921,16 +9921,16 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
                  mask=0x0001;

               ping_trans_color.red=(png_uint_16)
-                (ScaleQuantumToShort(image->colormap[0].red) & mask);
+                (ScaleQuantumToShort((Quantum) image->colormap[0].red) & mask);

               ping_trans_color.green=(png_uint_16)
-                (ScaleQuantumToShort(image->colormap[0].green) & mask);
+                (ScaleQuantumToShort((Quantum) image->colormap[0].green) & mask);

               ping_trans_color.blue=(png_uint_16)
-                (ScaleQuantumToShort(image->colormap[0].blue) & mask);
+                (ScaleQuantumToShort((Quantum) image->colormap[0].blue) & mask);

               ping_trans_color.gray=(png_uint_16)
-                (ScaleQuantumToShort(GetPixelInfoIntensity(image,
+                (ScaleQuantumToShort((Quantum) GetPixelInfoIntensity(image,
                    image->colormap)) & mask);

               ping_trans_color.index=(png_byte) 0;
@@ -10045,7 +10045,7 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
                    unsigned char
                      intensity;

-                   intensity=ScaleQuantumToChar(image->colormap[i].red);
+                   intensity=ScaleQuantumToChar((Quantum) image->colormap[i].red);

                    if ((intensity & 0x0f) != ((intensity & 0xf0) >> 4))
                      depth_4_ok=depth_2_ok=depth_1_ok=MagickFalse;
@@ -10086,10 +10086,9 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
               {
                 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);
-                  palette[i].blue=ScaleQuantumToChar(image->colormap[i].blue);
+                  palette[i].red=ScaleQuantumToChar((Quantum) image->colormap[i].red);
+                  palette[i].green=ScaleQuantumToChar((Quantum) image->colormap[i].green);
+                  palette[i].blue=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
                 }

                 if (logging != MagickFalse)
@@ -10140,7 +10139,7 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
                     for (i=0; i < ping_num_trans; i++)
                     {
                        ping_trans_alpha[i]= (png_byte)
-                         ScaleQuantumToChar(image->colormap[i].alpha);
+                         ScaleQuantumToChar((Quantum) image->colormap[i].alpha);
                     }
                   }
               }
@@ -10201,8 +10200,8 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
          {

          ping_background.gray=(png_uint_16) ((maxval/65535.)*
-           (ScaleQuantumToShort(((GetPixelInfoIntensity(image,
-           &image->background_color))) +.5)));
+           (ScaleQuantumToShort((Quantum) (((GetPixelInfoIntensity(image,
+           &image->background_color))) +.5))));

          if (logging != MagickFalse)
            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -10821,7 +10820,7 @@ static MagickBooleanType WriteOnePNGImage(MngWriteInfo *mng_info,
       PNGType(chunk,mng_orNT);
       LogPNGChunk(logging,mng_orNT,1L);
       /* PNG uses Exif orientation values */
-      chunk[4]=Magick_Orientation_to_Exif_Orientation(image->orientation);
+      chunk[4]=(unsigned char) Magick_Orientation_to_Exif_Orientation(image->orientation);
       (void) WriteBlob(image,5,chunk);
       (void) WriteBlobMSBULong(image,crc32(0,chunk,5));
     }
@@ -12414,12 +12413,12 @@ static MagickBooleanType WriteOneJNGImage(MngWriteInfo *mng_info,
   LogPNGChunk(logging,mng_JHDR,16L);
   PNGLong(chunk+4,(png_uint_32) image->columns);
   PNGLong(chunk+8,(png_uint_32) image->rows);
-  chunk[12]=jng_color_type;
+  chunk[12]=(unsigned char) jng_color_type;
   chunk[13]=8;  /* sample depth */
   chunk[14]=8; /*jng_image_compression_method */
   chunk[15]=(unsigned char) (image_info->interlace == NoInterlace ? 0 : 8);
-  chunk[16]=jng_alpha_sample_depth;
-  chunk[17]=jng_alpha_compression_method;
+  chunk[16]=(unsigned char) jng_alpha_sample_depth;
+  chunk[17]=(unsigned char) jng_alpha_compression_method;
   chunk[18]=0; /*jng_alpha_filter_method */
   chunk[19]=0; /*jng_alpha_interlace_method */
   (void) WriteBlob(image,20,chunk);
@@ -12482,9 +12481,9 @@ static MagickBooleanType WriteOneJNGImage(MngWriteInfo *mng_info,
     (void) WriteBlobMSBULong(image,(size_t) (num_bytes-4L));
     PNGType(chunk,mng_bKGD);
     LogPNGChunk(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);
+    red=ScaleQuantumToChar((Quantum) image->background_color.red);
+    green=ScaleQuantumToChar((Quantum) image->background_color.green);
+    blue=ScaleQuantumToChar((Quantum) image->background_color.blue);
     *(chunk+4)=0;
     *(chunk+5)=red;
     *(chunk+6)=0;
@@ -12613,8 +12612,8 @@ static MagickBooleanType WriteOneJNGImage(MngWriteInfo *mng_info,
       (void) WriteBlobMSBULong(image,9L);
       PNGType(chunk,mng_oFFs);
       LogPNGChunk(logging,mng_oFFs,9L);
-      PNGsLong(chunk+4,(ssize_t) (image->page.x));
-      PNGsLong(chunk+8,(ssize_t) (image->page.y));
+      PNGsLong(chunk+4,(png_int_32) (image->page.x));
+      PNGsLong(chunk+8,(png_int_32) (image->page.y));
       chunk[12]=0;
       (void) WriteBlob(image,13,chunk);
       (void) WriteBlobMSBULong(image,crc32(0,chunk,13));
@@ -13429,9 +13428,9 @@ static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image,
          (void) WriteBlobMSBULong(image,6L);
          PNGType(chunk,mng_BACK);
          LogPNGChunk(logging,mng_BACK,6L);
-         red=ScaleQuantumToShort(image->background_color.red);
-         green=ScaleQuantumToShort(image->background_color.green);
-         blue=ScaleQuantumToShort(image->background_color.blue);
+         red=ScaleQuantumToShort((Quantum) image->background_color.red);
+         green=ScaleQuantumToShort((Quantum) image->background_color.green);
+         blue=ScaleQuantumToShort((Quantum) image->background_color.blue);
          PNGShort(chunk+4,red);
          PNGShort(chunk+6,green);
          PNGShort(chunk+8,blue);
@@ -13468,11 +13467,11 @@ static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image,
          for (i=0; i < (ssize_t) image->colors; i++)
          {
            chunk[4+i*3]=(unsigned char) (ScaleQuantumToChar(
-             image->colormap[i].red) & 0xff);
+             (Quantum) image->colormap[i].red) & 0xff);
            chunk[5+i*3]=(unsigned char) (ScaleQuantumToChar(
-             image->colormap[i].green) & 0xff);
+             (Quantum) image->colormap[i].green) & 0xff);
            chunk[6+i*3]=(unsigned char) (ScaleQuantumToChar(
-             image->colormap[i].blue) & 0xff);
+             (Quantum) image->colormap[i].blue) & 0xff);
          }

          (void) WriteBlob(image,data_length+4,chunk);
@@ -13520,9 +13519,9 @@ static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image,

                 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);
-                  chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue);
+                  chunk[4+i*3]=ScaleQuantumToChar((Quantum) image->colormap[i].red);
+                  chunk[5+i*3]=ScaleQuantumToChar((Quantum) image->colormap[i].green);
+                  chunk[6+i*3]=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
                 }

                 (void) WriteBlob(image,data_length+4,chunk);
diff --git a/coders/pnm.c b/coders/pnm.c
index fe44903b1..4889768db 100644
--- a/coders/pnm.c
+++ b/coders/pnm.c
@@ -246,7 +246,7 @@ static char *PNMString(Image *image,char *string,const size_t extent)
           return((char *) NULL);
         break;
       }
-    string[i]=c;
+    string[i]=(char) c;
     if (c == '\n' || c == '\r')
       break;
   }
@@ -409,7 +409,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           do
           {
             if ((size_t) (p-keyword) < (MagickPathExtent-1))
-              *p++=c;
+              *p++=(char) c;
             c=ReadBlobByte(image);
           } while (isalnum((int) ((unsigned char) c)));
           *p='\0';
@@ -421,7 +421,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           while (isalnum((int) ((unsigned char) c)) || (c == '_'))
           {
             if ((size_t) (p-value) < (MagickPathExtent-1))
-              *p++=c;
+              *p++=(char) c;
             c=ReadBlobByte(image);
           }
           *p='\0';
diff --git a/coders/ps2.c b/coders/ps2.c
index cb70ffbcf..119fec120 100644
--- a/coders/ps2.c
+++ b/coders/ps2.c
@@ -1002,9 +1002,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image,
           for (i=0; i < (ssize_t) image->colors; i++)
           {
             (void) FormatLocaleString(buffer,MagickPathExtent,"%02X%02X%02X\n",
-              ScaleQuantumToChar(image->colormap[i].red),
-              ScaleQuantumToChar(image->colormap[i].green),
-              ScaleQuantumToChar(image->colormap[i].blue));
+              ScaleQuantumToChar((Quantum) image->colormap[i].red),
+              ScaleQuantumToChar((Quantum) image->colormap[i].green),
+              ScaleQuantumToChar((Quantum) image->colormap[i].blue));
             (void) WriteBlobString(image,buffer);
           }
           switch (compression)
diff --git a/coders/ps3.c b/coders/ps3.c
index 26333ec03..7dcf338c5 100644
--- a/coders/ps3.c
+++ b/coders/ps3.c
@@ -1503,11 +1503,11 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
               {
                 for (i=0; i < (ssize_t) image->colors; i++)
                 {
-                  pixel=ScaleQuantumToChar(image->colormap[i].red);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].red);
                   (void) WriteBlobByte(image,(unsigned char) pixel);
-                  pixel=ScaleQuantumToChar(image->colormap[i].green);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].green);
                   (void) WriteBlobByte(image,(unsigned char) pixel);
-                  pixel=ScaleQuantumToChar(image->colormap[i].blue);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
                   (void) WriteBlobByte(image,(unsigned char) pixel);
                 }
               }
@@ -1516,11 +1516,11 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
                 Ascii85Initialize(image);
                 for (i=0; i < (ssize_t) image->colors; i++)
                 {
-                  pixel=ScaleQuantumToChar(image->colormap[i].red);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].red);
                   Ascii85Encode(image,(unsigned char) pixel);
-                  pixel=ScaleQuantumToChar(image->colormap[i].green);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].green);
                   Ascii85Encode(image,(unsigned char) pixel);
-                  pixel=ScaleQuantumToChar(image->colormap[i].blue);
+                  pixel=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
                   Ascii85Encode(image,(unsigned char) pixel);
                 }
                 Ascii85Flush(image);
diff --git a/coders/psd.c b/coders/psd.c
index 5ab58c41e..65e97977e 100644
--- a/coders/psd.c
+++ b/coders/psd.c
@@ -1027,7 +1027,7 @@ static MagickBooleanType ReadPSDChannelPixels(Image *image,const ssize_t row,
         {
           SetPSDPixel(image,channel,packet_size,(((unsigned char)
             ((ssize_t) pixel)) & (0x01 << (7-bit))) != 0 ? 0 :
-            (double) QuantumRange,q,exception);
+            QuantumRange,q,exception);
           q+=(ptrdiff_t) GetPixelChannels(image);
           x++;
         }
diff --git a/coders/qoi.c b/coders/qoi.c
index 15af6d06c..886ae5488 100644
--- a/coders/qoi.c
+++ b/coders/qoi.c
@@ -301,9 +301,9 @@ static Image *ReadQOIImage(const ImageInfo *image_info,ExceptionInfo *exception)
         vg=(b & ~QOI_MASK_2) - 32;
         if ((b=ReadBlobByte(image)) == EOF)
           break;
-        px.rgba.r+=vg - 8 + ((b >> 4) & 0x0f);
-        px.rgba.g+=vg;
-        px.rgba.b+=vg - 8 +  (b       & 0x0f);
+        px.rgba.r+=(unsigned char) (vg - 8 + ((b >> 4) & 0x0f));
+        px.rgba.g+=(unsigned char) vg;
+        px.rgba.b+=(unsigned char) (vg - 8 +  (b       & 0x0f));
       }
     else if ((b & QOI_MASK_2) == QOI_OP_RUN)
       {
diff --git a/coders/rgf.c b/coders/rgf.c
index 7ac27ed7b..7545cd996 100644
--- a/coders/rgf.c
+++ b/coders/rgf.c
@@ -181,7 +181,7 @@ static Image *ReadRGFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   p=data;
   for (i=0; i < (ssize_t) (image->columns * image->rows); i++)
     {
-      *p++=ReadBlobByte(image);
+      *p++=(char) ReadBlobByte(image);
     }

   /*
diff --git a/coders/screenshot.c b/coders/screenshot.c
index e0492e884..45238ceba 100644
--- a/coders/screenshot.c
+++ b/coders/screenshot.c
@@ -172,7 +172,7 @@ static Image *ReadSCREENSHOTImage(const ImageInfo *image_info,
       geometry.height=(size_t) GetDeviceCaps(hDC,VERTRES);
       if (image_info->extract != (char *) NULL)
         {
-          geometry.x=MagickMin(screen->extract_info.x,geometry.width);
+          geometry.x=MagickMin(screen->extract_info.x,(ssize_t) geometry.width);
           if (geometry.x < 0)
             {
               geometry.width=(size_t ) MagickMin(0,(ssize_t) geometry.width+
@@ -182,7 +182,7 @@ static Image *ReadSCREENSHOTImage(const ImageInfo *image_info,
           geometry.width=geometry.width-geometry.x;
           if (screen->columns > 0)
             geometry.width=MagickMin(geometry.width,screen->columns);
-          geometry.y=MagickMin(screen->extract_info.y,geometry.height);
+          geometry.y=MagickMin(screen->extract_info.y,(ssize_t) geometry.height);
           if (geometry.y < 0)
             {
               geometry.width=(size_t ) MagickMin(0,(ssize_t) geometry.width+
@@ -239,7 +239,7 @@ static Image *ReadSCREENSHOTImage(const ImageInfo *image_info,
           ThrowReaderException(CoderError,"UnableToCreateBitmap");
         }
       BitBlt(bitmapDC,0,0,(int) screen->columns,(int) screen->rows,hDC,
-        geometry.x,geometry.y,SRCCOPY);
+        (int) geometry.x,(int) geometry.y,SRCCOPY);
       (void) SelectObject(bitmapDC,bitmapOld);

       for (y=0; y < (ssize_t) screen->rows; y++)
diff --git a/coders/sixel.c b/coders/sixel.c
index af5c58710..493037874 100644
--- a/coders/sixel.c
+++ b/coders/sixel.c
@@ -315,7 +315,7 @@ static MagickBooleanType sixel_decode(Image *image,unsigned char *p,
   for (; n < SIXEL_PALETTE_MAX; n++)
     sixel_palet[n]=SIXEL_RGB(255,255,255);
   for (i = 0; i < imsx * imsy; i++)
-    imbuf[i]=background_color_index;
+    imbuf[i]=(sixel_pixel_t) background_color_index;
   while (*p != '\0')
   {
     if ((p[0] == '\033' && p[1] == 'P') || (*p == 0x90))
@@ -541,7 +541,7 @@ static MagickBooleanType sixel_decode(Image *image,unsigned char *p,
                           imbuf=(sixel_pixel_t *) RelinquishMagickMemory(imbuf);
                           return(MagickFalse);
                         }
-                      imbuf[offset]=color_index;
+                      imbuf[offset]=(sixel_pixel_t) color_index;
                       if (max_x < position_x)
                           max_x = position_x;
                       if (max_y < (position_y + i))
@@ -573,7 +573,7 @@ static MagickBooleanType sixel_decode(Image *image,unsigned char *p,
                             return(MagickFalse);
                           }
                         for (x = 0; x < repeat_count; x++)
-                          imbuf[(int) offset+x] = color_index;
+                          imbuf[(int) offset+x]=(sixel_pixel_t) color_index;
                       }
                       if (max_x < (position_x+repeat_count-1))
                         max_x = position_x+repeat_count-1;
@@ -677,9 +677,9 @@ static int sixel_put_flash(sixel_output_t *const context)
   if (context->save_count > 3)
     {
       /* DECGRI Graphics Repeat Introducer ! Pn Ch */
-      nwrite=FormatLocaleString((char *) context->buffer+context->pos,
+      nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
         sizeof(context->buffer),"!%d%c",context->save_count,
-        context->save_pixel);
+        (char) context->save_pixel);
       if (nwrite <= 0)
         return(-1);
       sixel_advance(context,nwrite);
@@ -746,7 +746,7 @@ static int sixel_put_node(sixel_output_t *const context,int x,sixel_node_t *np,
       /* designate palette index */
       if (context->active_palette != np->color)
         {
-          nwrite=FormatLocaleString((char *) context->buffer+context->pos,
+          nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
             sizeof(context->buffer),"#%d",np->color);
           sixel_advance(context,nwrite);
           context->active_palette=np->color;
@@ -804,15 +804,15 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
     return (MagickFalse);
   (void) memset(map,0,len*sizeof(sixel_pixel_t));
   if (context->has_8bit_control)
-    nwrite=FormatLocaleString((char *) context->buffer,sizeof(context->buffer),
+    nwrite=(int) FormatLocaleString((char *) context->buffer,sizeof(context->buffer),
       "\x90" "0;0;0" "q");
   else
-    nwrite=FormatLocaleString((char *) context->buffer,sizeof(context->buffer),
+    nwrite=(int) FormatLocaleString((char *) context->buffer,sizeof(context->buffer),
       "\x1bP" "0;0;0" "q");
   if (nwrite <= 0)
     return(MagickFalse);
   sixel_advance(context,nwrite);
-  nwrite=FormatLocaleString((char *) context->buffer+context->pos,
+  nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
     sizeof(context->buffer),"\"1;1;%d;%d",(int) width,(int) height);
   if (nwrite <= 0)
     {
@@ -824,7 +824,7 @@ static MagickBooleanType sixel_encode_impl(sixel_pixel_t *pixels,size_t width,
     for (n = 0; n < (ssize_t) ncolors; n++)
     {
         /* DECGCI Graphics Color Introducer  # Pc ; Pu; Px; Py; Pz */
-        nwrite=FormatLocaleString((char *) context->buffer+context->pos,
+        nwrite=(int) FormatLocaleString((char *) context->buffer+context->pos,
           sizeof(context->buffer),"#%d;2;%d;%d;%d",n,(palette[n*3+0]*100+127)/
           255,(palette[n*3+1]*100+127)/255,(palette[n*3+2]*100+127)/255);
         if (nwrite <= 0)
@@ -1162,10 +1162,10 @@ static Image *ReadSIXELImage(const ImageInfo *image_info,
         {
           j=(ssize_t) sixel_pixels[y*(ssize_t) image->columns+x];
           j=ConstrainColormapIndex(image,j,exception);
-          SetPixelIndex(image,j,q);
-          SetPixelRed(image,image->colormap[j].red,q);
-          SetPixelGreen(image,image->colormap[j].green,q);
-          SetPixelBlue(image,image->colormap[j].blue,q);
+          SetPixelIndex(image,(Quantum) j,q);
+          SetPixelRed(image,(Quantum) image->colormap[j].red,q);
+          SetPixelGreen(image,(Quantum) image->colormap[j].green,q);
+          SetPixelBlue(image,(Quantum) image->colormap[j].blue,q);
           q+=(ptrdiff_t) GetPixelChannels(image);
         }
         if (SyncAuthenticPixels(image,exception) == MagickFalse)
@@ -1385,9 +1385,9 @@ static MagickBooleanType WriteSIXELImage(const ImageInfo *image_info,
   */
   for (i=0; i < (ssize_t) image->colors; i++)
   {
-    sixel_palette[3*i+0]=ScaleQuantumToChar(image->colormap[i].red);
-    sixel_palette[3*i+1]=ScaleQuantumToChar(image->colormap[i].green);
-    sixel_palette[3*i+2]=ScaleQuantumToChar(image->colormap[i].blue);
+    sixel_palette[3*i+0]=ScaleQuantumToChar((Quantum) image->colormap[i].red);
+    sixel_palette[3*i+1]=ScaleQuantumToChar((Quantum) image->colormap[i].green);
+    sixel_palette[3*i+2]=ScaleQuantumToChar((Quantum) image->colormap[i].blue);
   }
   /*
     Define SIXEL pixels.
@@ -1409,7 +1409,7 @@ static MagickBooleanType WriteSIXELImage(const ImageInfo *image_info,
       break;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      sixel_pixels[y*(ssize_t) image->columns+x]=((ssize_t)
+      sixel_pixels[y*(ssize_t) image->columns+x]=((sixel_pixel_t)
         GetPixelIndex(image,q));
       q+=(ptrdiff_t) GetPixelChannels(image);
     }
diff --git a/coders/sun.c b/coders/sun.c
index f1452c5db..0f173acac 100644
--- a/coders/sun.c
+++ b/coders/sun.c
@@ -557,7 +557,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              SetPixelIndex(image,ConstrainColormapIndex(image,*p,exception),q);
+              SetPixelIndex(image,(Quantum) ConstrainColormapIndex(image,*p,exception),q);
               p++;
               q+=(ptrdiff_t) GetPixelChannels(image);
             }
diff --git a/coders/svg.c b/coders/svg.c
index c617047c4..ed662770d 100644
--- a/coders/svg.c
+++ b/coders/svg.c
@@ -492,10 +492,10 @@ static Image *RenderRSVGImage(const ImageInfo *image_info,Image *image,
     }
   if (apply_density != MagickFalse)
     {
-      image->columns=image->resolution.x*dimension_info.width/
-        DefaultSVGDensity;
-      image->rows=image->resolution.y*dimension_info.height/
-        DefaultSVGDensity;
+      image->columns=(size_t) (image->resolution.x*dimension_info.width/
+        DefaultSVGDensity);
+      image->rows=(size_t) (image->resolution.y*dimension_info.height/
+        DefaultSVGDensity);
     }
   else
     {
@@ -3082,8 +3082,8 @@ static Image *RenderMSVGImage(const ImageInfo *image_info,Image *image,
   svg_info->exception=exception;
   svg_info->image=image;
   svg_info->image_info=image_info;
-  svg_info->bounds.width=image->columns;
-  svg_info->bounds.height=image->rows;
+  svg_info->bounds.width=(double) image->columns;
+  svg_info->bounds.height=(double) image->rows;
   svg_info->svgDepth=0;
   if (image_info->size != (char *) NULL)
     (void) CloneString(&svg_info->size,image_info->size);
@@ -3111,8 +3111,8 @@ static Image *RenderMSVGImage(const ImageInfo *image_info,Image *image,
   parser=(xmlParserCtxtPtr) NULL;
   if (n > 0)
     {
-      parser=xmlCreatePushParserCtxt(sax_handler,(void *) NULL,(char *)
-        message,n,image->filename);
+      parser=xmlCreatePushParserCtxt(sax_handler,(void *) NULL,(const char *)
+        message,(int) n,image->filename);
       if (parser != (xmlParserCtxtPtr) NULL)
         {
           const char *option;
diff --git a/coders/tiff.c b/coders/tiff.c
index 098a2c68c..ac29b1931 100644
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -515,8 +515,8 @@ static MagickBooleanType DecodeLabImage(Image *image,ExceptionInfo *exception)
       b=QuantumScale*(double) GetPixelb(image,q)+0.5;
       if (b > 1.0)
         b-=1.0;
-      SetPixela(image,(double) QuantumRange*a,q);
-      SetPixelb(image,(double) QuantumRange*b,q);
+      SetPixela(image,(Quantum) (QuantumRange*a),q);
+      SetPixelb(image,(Quantum) (QuantumRange*b),q);
       q+=(ptrdiff_t) GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -1760,8 +1760,8 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
     scanline_size=TIFFScanlineSize(tiff);
     if (scanline_size <= 0)
       ThrowTIFFException(ResourceLimitError,"MemoryAllocationFailed");
-    number_pixels=MagickMax((MagickSizeType) image->columns*samples_per_pixel*
-      pow(2.0,ceil(log(bits_per_sample)/log(2.0))),image->columns*
+    number_pixels=MagickMax((MagickSizeType) (image->columns*samples_per_pixel*
+      pow(2.0,ceil(log(bits_per_sample)/log(2.0)))),image->columns*
       rows_per_strip);
     if ((double) scanline_size > 1.5*number_pixels)
       ThrowTIFFException(CorruptImageError,"CorruptImage");
@@ -1954,8 +1954,8 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
                 break;
               if (rows_remaining == 0)
                 {
-                  size=TIFFReadEncodedStrip(tiff,strip_id,strip_pixels,
-                    strip_size);
+                  size=TIFFReadEncodedStrip(tiff,(uint32_t) strip_id,
+                    strip_pixels,strip_size);
                   if (size == -1)
                     break;
                   rows_remaining=rows_per_strip;
@@ -2064,8 +2064,8 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
                 columns_remaining=image->columns-(size_t) x;
                 if ((x+(ssize_t) columns) < (ssize_t) image->columns)
                   columns_remaining=columns;
-                size=TIFFReadTile(tiff,tile_pixels,(uint32) x,(uint32) y,
-                  0,i);
+                size=TIFFReadTile(tiff,tile_pixels,(uint32_t) x,(uint32_t) y,
+                  0,(uint16_t)i);
                 if (size == -1)
                   break;
                 p=tile_pixels;
@@ -2948,8 +2948,8 @@ static MagickBooleanType EncodeLabImage(Image *image,ExceptionInfo *exception)
       b=QuantumScale*(double) GetPixelb(image,q)-0.5;
       if (b < 0.0)
         b+=1.0;
-      SetPixela(image,(double) QuantumRange*a,q);
-      SetPixelb(image,(double) QuantumRange*b,q);
+      SetPixela(image,(Quantum) (QuantumRange*a),q);
+      SetPixelb(image,(Quantum) (QuantumRange*b),q);
       q+=(ptrdiff_t) GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -3033,7 +3033,7 @@ static MagickBooleanType GetTIFFInfo(const ImageInfo *image_info,
   return(MagickTrue);
 }

-static tmsize_t TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,
+static int TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,
   tsample_t sample,Image *image)
 {
   tmsize_t
@@ -3107,7 +3107,7 @@ static tmsize_t TIFFWritePixels(TIFF *tiff,TIFFInfo *tiff_info,ssize_t row,
     if (status < 0)
       break;
   }
-  return(status);
+  return((int) status);
 }

 static ssize_t TIFFWriteCustomStream(unsigned char *data,const size_t count,
@@ -4256,9 +4256,9 @@ static MagickBooleanType WriteTIFFImage(const ImageInfo *image_info,
         (void) memset(blue,0,65536*sizeof(*blue));
         for (i=0; i < (ssize_t) image->colors; i++)
         {
-          red[i]=ScaleQuantumToShort(image->colormap[i].red);
-          green[i]=ScaleQuantumToShort(image->colormap[i].green);
-          blue[i]=ScaleQuantumToShort(image->colormap[i].blue);
+          red[i]=ScaleQuantumToShort((Quantum) image->colormap[i].red);
+          green[i]=ScaleQuantumToShort((Quantum) image->colormap[i].green);
+          blue[i]=ScaleQuantumToShort((Quantum) image->colormap[i].blue);
         }
         (void) TIFFSetField(tiff,TIFFTAG_COLORMAP,red,green,blue);
         red=(uint16 *) RelinquishMagickMemory(red);
diff --git a/coders/tim.c b/coders/tim.c
index 4c094ac5f..db60f32e6 100644
--- a/coders/tim.c
+++ b/coders/tim.c
@@ -272,15 +272,15 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           p=tim_pixels+y*(ssize_t) bytes_per_line;
           for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
-            SetPixelIndex(image,(*p) & 0x0f,q);
+            SetPixelIndex(image,(Quantum) ((*p) & 0x0f),q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            SetPixelIndex(image,(*p >> 4) & 0x0f,q);
+            SetPixelIndex(image,(Quantum) ((*p >> 4) & 0x0f),q);
             p++;
             q+=(ptrdiff_t) GetPixelChannels(image);
           }
           if ((image->columns % 2) != 0)
             {
-              SetPixelIndex(image,(*p >> 4) & 0x0f,q);
+              SetPixelIndex(image,(Quantum) ((*p >> 4) & 0x0f),q);
               p++;
               q+=(ptrdiff_t) GetPixelChannels(image);
             }
diff --git a/coders/tim2.c b/coders/tim2.c
index 50476d73a..2c5f60fc3 100644
--- a/coders/tim2.c
+++ b/coders/tim2.c
@@ -303,15 +303,15 @@ static MagickBooleanType ReadTIM2ImageData(const ImageInfo *image_info,
             p=row_data;
             for (x=0; x < ((ssize_t) image->columns-1); x+=2)
             {
-              SetPixelIndex(image,(*p >> 0) & 0x0F,q);
+              SetPixelIndex(image,(Quantum)((*p >> 0) & 0x0f),q);
               q+=(ptrdiff_t) GetPixelChannels(image);
-              SetPixelIndex(image,(*p >> 4) & 0x0F,q);
+              SetPixelIndex(image,(Quantum)((*p >> 4) & 0x0f),q);
               p++;
               q+=(ptrdiff_t) GetPixelChannels(image);
             }
             if ((image->columns % 2) != 0)
               {
-                SetPixelIndex(image,(*p >> 4) & 0x0F,q);
+                SetPixelIndex(image,(Quantum)((*p >> 4) & 0x0f),q);
                 p++;
                 q+=(ptrdiff_t) GetPixelChannels(image);
               }
@@ -654,10 +654,10 @@ static Image *ReadTIM2Image(const ImageInfo *image_info,
   file_header.magic_num=ReadBlobMSBLong(image);
   if (file_header.magic_num != 0x54494D32) /* "TIM2" */
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-  file_header.format_vers=ReadBlobByte(image);
+  file_header.format_vers=(unsigned char) ReadBlobByte(image);
   if (file_header.format_vers != 0x04)
     ThrowReaderException(CoderError,"ImageTypeNotSupported");
-  file_header.format_type=ReadBlobByte(image);
+  file_header.format_type=(unsigned char) ReadBlobByte(image);
   file_header.image_count=ReadBlobLSBShort(image);
   if (DiscardBlobBytes(image,8) == MagickFalse) /* reserved */
     ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
diff --git a/coders/vicar.c b/coders/vicar.c
index 714087e4e..2e2781deb 100644
--- a/coders/vicar.c
+++ b/coders/vicar.c
@@ -236,7 +236,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
         do
         {
           if ((size_t) (p-keyword) < (MagickPathExtent-1))
-            *p++=c;
+            *p++=(char) c;
           c=ReadBlobByte(image);
           if (c == EOF)
             break;
@@ -265,7 +265,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
             while (c != '\'')
             {
               if ((size_t) (p-value) < (MagickPathExtent-1))
-                *p++=c;
+                *p++=(char) c;
               c=ReadBlobByte(image);
               if (c == EOF)
                 break;
@@ -280,7 +280,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
             while (c != '"')
             {
               if ((size_t) (p-value) < (MagickPathExtent-1))
-                *p++=c;
+                *p++=(char) c;
               c=ReadBlobByte(image);
               if (c == EOF)
                 break;
@@ -295,7 +295,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
             while (c != ')')
             {
               if ((size_t) (p-value) < (MagickPathExtent-1))
-                *p++=c;
+                *p++=(char) c;
               c=ReadBlobByte(image);
               if (c == EOF)
                 break;
@@ -308,7 +308,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
             while (isalnum((int) ((unsigned char) c)))
             {
               if ((size_t) (p-value) < (MagickPathExtent-1))
-                *p++=c;
+                *p++=(char) c;
               c=ReadBlobByte(image);
               if (c == EOF)
                 break;
diff --git a/coders/vips.c b/coders/vips.c
index 83153df05..05d2414e6 100644
--- a/coders/vips.c
+++ b/coders/vips.c
@@ -709,14 +709,14 @@ static MagickBooleanType WriteVIPSImage(const ImageInfo *image_info,
   }
   if (image->units == PixelsPerCentimeterResolution)
     {
-      (void) WriteBlobFloat(image,(image->resolution.x/10));
-      (void) WriteBlobFloat(image,(image->resolution.y/10));
+      (void) WriteBlobFloat(image,(float) (image->resolution.x/10));
+      (void) WriteBlobFloat(image,(float) (image->resolution.y/10));
     }
   else
     if (image->units == PixelsPerInchResolution)
       {
-        (void) WriteBlobFloat(image,(image->resolution.x/25.4));
-        (void) WriteBlobFloat(image,(image->resolution.y/25.4));
+        (void) WriteBlobFloat(image,(float) (image->resolution.x/25.4));
+        (void) WriteBlobFloat(image,(float) (image->resolution.y/25.4));
       }
     else
       {
diff --git a/coders/wbmp.c b/coders/wbmp.c
index dae06647e..5052ab4d0 100644
--- a/coders/wbmp.c
+++ b/coders/wbmp.c
@@ -205,7 +205,7 @@ static Image *ReadWBMPImage(const ImageInfo *image_info,
           if (byte == EOF)
             ThrowReaderException(CorruptImageError,"CorruptImage");
         }
-      SetPixelIndex(image,(byte & (0x01 << (7-bit))) ? 1 : 0,q);
+      SetPixelIndex(image,(Quantum) ((byte & (0x01 << (7-bit))) ? 1 : 0),q);
       bit++;
       if (bit == 8)
         bit=0;
@@ -344,7 +344,7 @@ static void WBMPWriteInteger(Image *image,const size_t value)
     if ((flag == 0) && (octet != 0))
       {
         flag=MagickTrue;
-        n=i+1;
+        n=(int) (i+1);
       }
     buffer[4-i]=octet | (i && (flag || octet))*(0x01 << 7);
     bits-=7;
diff --git a/coders/webp.c b/coders/webp.c
index 1d599fa3e..474808900 100644
--- a/coders/webp.c
+++ b/coders/webp.c
@@ -975,8 +975,8 @@ static MagickBooleanType WriteAnimatedWEBPImage(const ImageInfo *image_info,
     if (memory_info != (MemoryInfo *) NULL)
       (void) AppendValueToLinkedList(memory_info_list,memory_info);
     WebPPictureFree(&picture);
-    effective_delta=frame->delay*1000*MagickSafeReciprocal(
-      frame->ticks_per_second);
+    effective_delta=(size_t) (frame->delay*1000*MagickSafeReciprocal(
+      (double) frame->ticks_per_second));
     if (effective_delta < 10)
       effective_delta=100; /* Consistent with gif2webp */
     frame_timestamp+=effective_delta;
@@ -1148,7 +1148,7 @@ static MagickBooleanType WriteWEBPImage(const ImageInfo *image_info,
     {
       configure.quality=(float) image->quality;
 #if WEBP_ENCODER_ABI_VERSION >= 0x020e
-      configure.near_lossless=(float) image->quality;
+      configure.near_lossless=(int) image->quality;
 #endif
     }
   if (image->quality >= 100)
diff --git a/coders/wpg.c b/coders/wpg.c
index 57a59f2ed..37b45083c 100644
--- a/coders/wpg.c
+++ b/coders/wpg.c
@@ -252,7 +252,7 @@ static unsigned int IsWPG(const unsigned char *magick,const size_t length)

 static int Rd_WP_DWORD(Image *image,size_t *d)
 {
-  unsigned char
+  int
     b;

   b=ReadBlobByte(image);
@@ -297,7 +297,7 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
         {
           for (bit=0; bit < 8; bit++)
           {
-            index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+            index=(Quantum) (((*p) & (0x80 >> bit) ? 0x01 : 0x00));
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -309,7 +309,7 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
           {
             for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
             {
-              index=((*p) & (0x80 >> bit) ? 0x01 : 0x00);
+              index=(Quantum) (((*p) & (0x80 >> bit) ? 0x01 : 0x00));
               SetPixelIndex(image,index,q);
               if (index < image->colors)
                 SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -323,22 +323,22 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
       {
         for (x=0; x < ((ssize_t) image->columns-3); x+=4)
         {
-            index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 2) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -347,21 +347,21 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
         }
        if ((image->columns % 4) != 0)
           {
-            index=ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 6) & 0x3,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
             if ((image->columns % 4) > 1)
               {
-                index=ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
+                index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x3,exception);
                 SetPixelIndex(image,index,q);
                 if (index < image->colors)
                   SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
                 q+=(ptrdiff_t) GetPixelChannels(image);
                 if ((image->columns % 4) > 2)
                   {
-                    index=ConstrainColormapIndex(image,(*p >> 2) & 0x3,
+                    index=(Quantum) ConstrainColormapIndex(image,(*p >> 2) & 0x3,
                       exception);
                     SetPixelIndex(image,index,q);
                     if (index < image->colors)
@@ -379,12 +379,12 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
       {
         for (x=0; x < ((ssize_t) image->columns-1); x+=2)
           {
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
             q+=(ptrdiff_t) GetPixelChannels(image);
-            index=ConstrainColormapIndex(image,(*p) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -393,7 +393,7 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
           }
         if ((image->columns % 2) != 0)
           {
-            index=ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
+            index=(Quantum) ConstrainColormapIndex(image,(*p >> 4) & 0x0f,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -406,7 +406,7 @@ static MagickBooleanType InsertRow(Image *image,unsigned char *p,ssize_t y,
       {
         for (x=0; x < (ssize_t) image->columns; x++)
           {
-            index=ConstrainColormapIndex(image,*p,exception);
+            index=(Quantum) ConstrainColormapIndex(image,*p,exception);
             SetPixelIndex(image,index,q);
             if (index < image->colors)
               SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
@@ -484,7 +484,7 @@ static int UnpackWPGRaster(Image *image,int bpp,ExceptionInfo *exception)
         {
           if(RunCount)  /* repeat next byte runcount * */
             {
-              bbuf=ReadBlobByte(image);
+              bbuf=(unsigned char) ReadBlobByte(image);
               for(i=0;i<(int) RunCount;i++) InsertByte(bbuf);
             }
           else {  /* read next byte as RunCount; repeat 0xFF runcount* */
@@ -503,7 +503,7 @@ static int UnpackWPGRaster(Image *image,int bpp,ExceptionInfo *exception)
                 c=ReadBlobByte(image);
                 if (c < 0)
                   break;
-                InsertByte(c);
+                InsertByte((unsigned char) c);
               }
           }
         else {  /* repeat previous line runcount* */
@@ -596,7 +596,7 @@ static int UnpackWPG2Raster(Image *image,int bpp,ExceptionInfo *exception)

   while( y< (ssize_t) image->rows)
   {
-      bbuf=ReadBlobByte(image);
+      bbuf=(unsigned char) ReadBlobByte(image);

       switch(bbuf)
         {
@@ -676,7 +676,7 @@ static int UnpackWPG2Raster(Image *image,int bpp,ExceptionInfo *exception)
           if(bbuf & 0x80)     /* REP */
             {
               for(i=0; i < SampleSize; i++)
-                SampleBuffer[i]=ReadBlobByte(image);
+                SampleBuffer[i]=(unsigned char) ReadBlobByte(image);
               for(i=0;i<=RunCount;i++)
                 for(bbuf=0;bbuf<SampleSize;bbuf++)
                   InsertByte6(SampleBuffer[bbuf]);
@@ -684,7 +684,7 @@ static int UnpackWPG2Raster(Image *image,int bpp,ExceptionInfo *exception)
           else {      /* NRP */
             for(i=0; i < (ssize_t) ((int) SampleSize*((int) RunCount+1)); i++)
               {
-                bbuf=ReadBlobByte(image);
+                bbuf=(unsigned char) ReadBlobByte(image);
                 InsertByte6(bbuf);
               }
           }
@@ -702,7 +702,7 @@ typedef float tCTM[3][3];
 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;
-ssize_t x;
+int x;
 unsigned DenX;
 unsigned Flags;

@@ -731,7 +731,7 @@ unsigned Flags;
  if(Flags & ROT)
   {
   x=ReadBlobLSBLong(image);  /*Rot Angle*/
-  if(Angle) *Angle=x/65536.0;
+  if(Angle) *Angle=(float)x/65536.0f;
   }
  if(Flags & (ROT|SCL))
   {
@@ -1105,10 +1105,10 @@ static Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   Header.FileId=ReadBlobLSBLong(image);
   Header.DataOffset=(MagickOffsetType) ReadBlobLSBLong(image);
-  Header.ProductType=ReadBlobByte(image);
-  Header.FileType=ReadBlobByte(image);
-  Header.MajorVersion=ReadBlobByte(image);
-  Header.MinorVersion=ReadBlobByte(image);
+  Header.ProductType=(unsigned char) ReadBlobByte(image);
+  Header.FileType=(unsigned char) ReadBlobByte(image);
+  Header.MajorVersion=(unsigned char) ReadBlobByte(image);
+  Header.MinorVersion=(unsigned char) ReadBlobByte(image);
   Header.EncryptKey=ReadBlobLSBShort(image);
   Header.Reserved=ReadBlobLSBShort(image);

@@ -1131,7 +1131,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
           if (EOFBlob(image))
             break;
-          Rec.RecType=(i=ReadBlobByte(image));
+          Rec.RecType=(unsigned char) (i=ReadBlobByte(image));
           if (i==EOF)
             break;
           i=Rd_WP_DWORD(image,&Rec.RecordLength);
@@ -1383,10 +1383,10 @@ static Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception)
           if (EOFBlob(image))
             break;

-          Rec2.Class=(i=ReadBlobByte(image));
+          Rec2.Class=(unsigned char) (i=ReadBlobByte(image));
           if(i==EOF)
             break;
-          Rec2.RecType=(i=ReadBlobByte(image));
+          Rec2.RecType=(unsigned char) (i=ReadBlobByte(image));
           if(i==EOF)
             break;
           Rd_WP_DWORD(image,&Rec2.Extension);
@@ -1402,7 +1402,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception)
       case 1:
               StartWPG.HorizontalUnits=ReadBlobLSBShort(image);
               StartWPG.VerticalUnits=ReadBlobLSBShort(image);
-              StartWPG.PosSizePrecision=ReadBlobByte(image);
+              StartWPG.PosSizePrecision=(unsigned char) ReadBlobByte(image);
               break;
             case 0x0C:    /* Color palette */
               WPG_Palette.StartIndex=ReadBlobLSBShort(image);
@@ -1434,8 +1434,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,ExceptionInfo *exception)
               Bitmap2Header1.Height=ReadBlobLSBShort(image);
               if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0))
                 ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-              Bitmap2Header1.Depth=ReadBlobByte(image);
-              Bitmap2Header1.Compression=ReadBlobByte(image);
+              Bitmap2Header1.Depth=(unsigned char) ReadBlobByte(image);
+              Bitmap2Header1.Compression=(unsigned char) ReadBlobByte(image);

               if(Bitmap2Header1.Compression > 1)
                 continue; /*Unknown compression method */
@@ -1738,7 +1738,7 @@ typedef struct
 static void WPGFlushRLE(WPGRLEInfo *rle_info,Image *image,unsigned char n)
 {
   if (n > rle_info->offset)
-    n=rle_info->offset;
+    n=(unsigned char) rle_info->offset;
   if (n > 0x7F)
     n=0x7F;
   if (n > 0)
@@ -1913,18 +1913,18 @@ static MagickBooleanType WriteWPGImage(const ImageInfo *image_info,Image *image,
       for ( ; i < (ssize_t) ((size_t) 1U << image->depth); i++)
         if (i >= (ssize_t) image->colors)
           {
-            (void) WriteBlobByte(image,i);
-            (void) WriteBlobByte(image,i);
-            (void) WriteBlobByte(image,i);
+            (void) WriteBlobByte(image,(unsigned char) i);
+            (void) WriteBlobByte(image,(unsigned char) i);
+            (void) WriteBlobByte(image,(unsigned char) i);
           }
         else
           {
             (void) WriteBlobByte(image,ScaleQuantumToChar(
-              image->colormap[i].red));
+              (Quantum) image->colormap[i].red));
             (void) WriteBlobByte(image,ScaleQuantumToChar(
-              image->colormap[i].green));
+              (Quantum) image->colormap[i].green));
             (void) WriteBlobByte(image,ScaleQuantumToChar(
-              image->colormap[i].blue));
+              (Quantum) image->colormap[i].blue));
           }
     }
   /*
@@ -1979,7 +1979,7 @@ static MagickBooleanType WriteWPGImage(const ImageInfo *image_info,Image *image,
   (void) WriteBlobByte(image,0);
   (void) SeekBlob(image,offset,SEEK_SET);
   offset=current_offset-offset-4;
-  (void) WriteBlobLSBShort(image,0x8000 | (offset >> 16));
+  (void) WriteBlobLSBShort(image,(unsigned short) (0x8000 | (offset >> 16)));
   (void) WriteBlobLSBShort(image,offset & 0xffff);
   if (y < (ssize_t) image->rows)
     ThrowWriterException(CorruptImageError,"UnableToWriteImageData");
diff --git a/coders/yaml.c b/coders/yaml.c
index 0d587fd48..0871ea3f9 100644
--- a/coders/yaml.c
+++ b/coders/yaml.c
@@ -940,6 +940,7 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,

   double
     elapsed_time,
+    scale,
     user_time,
     version;

@@ -951,8 +952,7 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,

   size_t
     depth,
-    distance,
-    scale;
+    distance;

   ssize_t
     i,
@@ -1130,7 +1130,6 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
   channel_moments=(ChannelMoments *) NULL;
   channel_phash=(ChannelPerceptualHash *) NULL;
   channel_features=(ChannelFeatures *) NULL;
-  scale=1;
   channel_statistics=GetImageStatistics(image,exception);
   if (channel_statistics == (ChannelStatistics *) NULL)
     return(MagickFalse);
@@ -1192,10 +1191,10 @@ static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file,
     }
   }
   (void) FormatLocaleFile(file,"    \n");
-  scale=1;
+  scale=1.0;
   if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
-    scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
-      MAGICKCORE_QUANTUM_DEPTH-image->depth));
+    scale=(double) (QuantumRange/((size_t) QuantumRange >> ((size_t)
+      MAGICKCORE_QUANTUM_DEPTH-image->depth)));
   if (channel_statistics != (ChannelStatistics *) NULL)
     {
       (void) FormatLocaleFile(file,"    pixels: %.20g\n",