.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.Image:

==========================================================================================================================================
|phoenix_title|  **wx.Image**
==========================================================================================================================================

This class encapsulates a platform-independent image.          

An image can be created from data, or using :meth:`wx.Bitmap.ConvertToImage` . An image can be loaded from a file in a variety of formats, and is extensible to new formats via image format handlers. Functions are available to set and get image bits, so it can be used for basic image manipulation. 

A :ref:`wx.Image`  cannot (currently) be drawn directly to a :ref:`wx.DC`. Instead, a platform-specific :ref:`wx.Bitmap`  object must be created from it using the `Bitmap.Bitmap(wxImage,int` depth) constructor. This bitmap can then be drawn in a device context, using :meth:`wx.DC.DrawBitmap` . 

More on the difference between :ref:`wx.Image`  and :ref:`wx.Bitmap`: :ref:`wx.Image`  is just a buffer of ``RGB`` bytes with an optional buffer for the alpha bytes. It is all generic, platform independent and image file format independent code. It includes generic code for scaling, resizing, clipping, and other manipulations of the image data. OTOH, :ref:`wx.Bitmap`  is intended to be a wrapper of whatever is the native image format that is quickest/easiest to draw to a DC or to be the target of the drawing operations performed on a :ref:`wx.MemoryDC`. By splitting the responsibilities between Image/wxBitmap like this then it's easier to use generic code shared by all platforms and image types for generic operations and platform specific code where performance or compatibility is needed. 

One colour value of the image may be used as a mask colour which will lead to the automatic creation of a :ref:`wx.Mask`  object associated to the bitmap object. 



|phoenix_title| Alpha channel support
=====================================

Starting from wxWidgets 2.5.0 :ref:`wx.Image`  supports alpha channel data, that is in addition to a byte for the red, green and blue colour components for each pixel it also stores a byte representing the pixel opacity. An alpha value of 0 corresponds to a transparent pixel (null opacity) while a value of 255 means that the pixel is 100% opaque. The constants ``IMAGE_ALPHA_TRANSPARENT``  and ``IMAGE_ALPHA_OPAQUE``  can be used to indicate those values in a more readable form. While all images have ``RGB`` data, not all images have an alpha channel. Before using :meth:`wx.Image.GetAlpha`   you should check if this image contains an alpha channel with :meth:`wx.Image.HasAlpha` . Currently the ``BMP``, ``PNG``, ``TGA``, and ``TIFF`` format handlers have full alpha channel support for loading so if you want to use alpha you have to use one of these formats. If you initialize the image alpha channel yourself using :meth:`wx.Image.SetAlpha` , you should save it in either ``PNG``, ``TGA``, or ``TIFF`` format to avoid losing it as these are the only handlers that currently support saving with alpha.  



|phoenix_title| Available image handlers
========================================

The following image handlers are available. BMPHandler is always installed by default. To use other image formats, install the appropriate handler with :meth:`wx.Image.AddHandler`   or call :ref:`wx.InitAllImageHandlers`. 

- BMPHandler: For loading (including alpha support) and saving, always installed. 
- :ref:`wx.PNGHandler`: For loading and saving. Includes alpha support. 
- :ref:`wx.JPEGHandler`: For loading and saving. 
- :ref:`wx.GIFHandler`: For loading and saving (see below). 
- :ref:`wx.PCXHandler`: For loading and saving (see below). 
- :ref:`wx.PNMHandler`: For loading and saving (see below). 
- :ref:`wx.TIFFHandler`: For loading and saving. Includes alpha support. 
- :ref:`wx.TGAHandler`: For loading and saving. Includes alpha support. 
- :ref:`wx.IFFHandler`: For loading only. 
- :ref:`wx.XPMHandler`: For loading and saving. 
- ICOHandler: For loading and saving. 
- CURHandler: For loading and saving. 
- ANIHandler: For loading only. 


When saving in ``PCX`` format, :ref:`wx.PCXHandler`  will count the number of different colours in the image; if there are 256 or less colours, it will save as 8 bit, else it will save as 24 bit. Loading PNMs only works for ``ASCII`` or raw ``RGB`` images. When saving in ``PNM`` format, :ref:`wx.PNMHandler`  will always save as raw ``RGB``. Saving GIFs requires images of maximum 8 bpp (see :ref:`Quantize`), and the alpha channel converted to a mask (see :meth:`wx.Image.ConvertAlphaToMask` ). Saving an animated ``GIF`` requires images of the same size (see :meth:`wx.GIFHandler.SaveAnimation` )   



.. seealso:: :ref:`wx.Bitmap`, :ref:`wx.InitAllImageHandlers`, :ref:`PixelData`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Image</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.Image_inheritance.png" alt="Inheritance diagram of Image" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Image.html" title="wx.Image" alt="" coords="5,83,92,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.Image.__init__`                                                       Creates an empty :ref:`wx.Image`  object without an alpha channel.
:meth:`~wx.Image.AddHandler`                                                     Register an image handler.
:meth:`~wx.Image.AdjustChannels`                                                 This function muliplies all 4 channels (red, green, blue, alpha) with
:meth:`~wx.Image.Blur`                                                           Blurs the image in both horizontal and vertical directions by the specified pixel `blurRadius`.
:meth:`~wx.Image.BlurHorizontal`                                                 Blurs the image in the horizontal direction only.
:meth:`~wx.Image.BlurVertical`                                                   Blurs the image in the vertical direction only.
:meth:`~wx.Image.CanRead`                                                        Returns ``True`` if at least one of the available image handlers can read the file with the given name.
:meth:`~wx.Image.ChangeBrightness`                                               Changes the brightness (value) of each pixel in the image.
:meth:`~wx.Image.ChangeHSV`                                                      Changes the hue, the saturation and the brightness (value) of each pixel in the image.
:meth:`~wx.Image.ChangeLightness`                                                Returns a changed version of the image based on the given lightness.
:meth:`~wx.Image.ChangeSaturation`                                               Changes the saturation of each pixel in the image.
:meth:`~wx.Image.CleanUpHandlers`                                                Deletes all image handlers.
:meth:`~wx.Image.Clear`                                                          Initialize the image data with zeroes (the default) or with the byte value given as `value`.
:meth:`~wx.Image.ClearAlpha`                                                     Removes the alpha channel from the image.
:meth:`~wx.Image.ComputeHistogram`                                               Computes the histogram of the image.
:meth:`~wx.Image.ConvertAlphaToMask`                                             If the image has alpha channel, this method converts it to mask.
:meth:`~wx.Image.ConvertToBitmap`                                                ConvertToBitmap(depth=-1) . Bitmap
:meth:`~wx.Image.ConvertToDisabled`                                              Returns disabled (dimmed) version of the image.
:meth:`~wx.Image.ConvertToGreyscale`                                             Returns a greyscale version of the image.
:meth:`~wx.Image.ConvertToMono`                                                  Returns monochromatic version of the image.
:meth:`~wx.Image.ConvertToMonoBitmap`                                            ConvertToMonoBitmap(red, green, blue) . Bitmap
:meth:`~wx.Image.ConvertToRegion`                                                Create a :class:`wx.Region` where the transparent areas match the given ``RGB`` values.
:meth:`~wx.Image.Copy`                                                           Returns an identical copy of this image.
:meth:`~wx.Image.Create`                                                         Creates a fresh image.
:meth:`~wx.Image.Destroy`                                                        Destroys the image data.
:meth:`~wx.Image.FindFirstUnusedColour`                                          Finds the first colour that is never used in the image.
:meth:`~wx.Image.FindHandler`                                                    Finds the handler with the given name.
:meth:`~wx.Image.FindHandlerMime`                                                Finds the handler associated with the given MIME type.
:meth:`~wx.Image.GetAlpha`                                                       Return alpha value at given pixel location.
:meth:`~wx.Image.GetAlphaBuffer`                                                 Returns a writable Python buffer object that is pointing at the Alpha
:meth:`~wx.Image.GetBlue`                                                        Returns the blue intensity at the given coordinate.
:meth:`~wx.Image.GetData`                                                        Returns a copy of the ``RGB`` bytes of the image.
:meth:`~wx.Image.GetDataBuffer`                                                  Returns a writable Python buffer object that is pointing at the ``RGB``
:meth:`~wx.Image.GetDefaultLoadFlags`                                            Returns the currently used default file load flags.
:meth:`~wx.Image.GetGreen`                                                       Returns the green intensity at the given coordinate.
:meth:`~wx.Image.GetHeight`                                                      Gets the height of the image in pixels.
:meth:`~wx.Image.GetImageCount`                                                  If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.
:meth:`~wx.Image.GetImageExtWildcard`                                            Iterates all registered :ref:`wx.ImageHandler`  objects, and returns a string containing file extension masks suitable for passing to file open/save dialog boxes.
:meth:`~wx.Image.GetLoadFlags`                                                   Returns the file load flags used for this object.
:meth:`~wx.Image.GetMaskBlue`                                                    Gets the blue value of the mask colour.
:meth:`~wx.Image.GetMaskGreen`                                                   Gets the green value of the mask colour.
:meth:`~wx.Image.GetMaskRed`                                                     Gets the red value of the mask colour.
:meth:`~wx.Image.GetOption`                                                      Gets a user-defined string-valued option.
:meth:`~wx.Image.GetOptionInt`                                                   Gets a user-defined integer-valued option.
:meth:`~wx.Image.GetOrFindMaskColour`                                            Get the current mask colour or find a suitable unused colour that could be used as a mask colour.
:meth:`~wx.Image.GetPalette`                                                     Returns the palette associated with the image.
:meth:`~wx.Image.GetRed`                                                         Returns the red intensity at the given coordinate.
:meth:`~wx.Image.GetSize`                                                        Returns the size of the image in pixels.
:meth:`~wx.Image.GetSubImage`                                                    Returns a sub image of the current one as long as the rect belongs entirely to the image.
:meth:`~wx.Image.GetType`                                                        Gets the type of image found by :meth:`~Image.LoadFile`   or specified with :meth:`~Image.SaveFile` .
:meth:`~wx.Image.GetWidth`                                                       Gets the width of the image in pixels.
:meth:`~wx.Image.HSVtoRGB`                                                       Converts a color in ``HSV`` color space to ``RGB`` color space.
:meth:`~wx.Image.HasAlpha`                                                       Returns ``True`` if this image has alpha channel, ``False`` otherwise.
:meth:`~wx.Image.HasMask`                                                        Returns ``True`` if there is a mask active, ``False`` otherwise.
:meth:`~wx.Image.HasOption`                                                      Returns ``True`` if the given option is present.
:meth:`~wx.Image.InitAlpha`                                                      Initializes the image alpha channel data.
:meth:`~wx.Image.InitStandardHandlers`                                           Internal use only.
:meth:`~wx.Image.InsertHandler`                                                  Adds a handler at the start of the static list of format handlers.
:meth:`~wx.Image.IsOk`                                                           Returns ``True`` if image data is present.
:meth:`~wx.Image.IsTransparent`                                                  Returns ``True`` if the given pixel is transparent, i.e. either has the mask colour if this image has a mask or if this image has alpha channel and alpha value of this pixel is strictly less than `threshold`.
:meth:`~wx.Image.LoadFile`                                                       Loads an image from an input stream.
:meth:`~wx.Image.Mirror`                                                         Returns a mirrored copy of the image.
:meth:`~wx.Image.Paste`                                                          Copy the data of the given `image`  to the specified position in this image.
:meth:`~wx.Image.RGBtoHSV`                                                       Converts a color in ``RGB`` color space to ``HSV`` color space.
:meth:`~wx.Image.RemoveHandler`                                                  Finds the handler with the given name, and removes it.
:meth:`~wx.Image.Replace`                                                        Replaces the colour specified by `r1`,g1,b1 by the colour `r2`,g2,b2.
:meth:`~wx.Image.Rescale`                                                        Changes the size of the image in-place by scaling it: after a call to this function,the image will have the given width and height.
:meth:`~wx.Image.Resize`                                                         Changes the size of the image in-place without scaling it by adding either a border with the given colour or cropping as necessary.
:meth:`~wx.Image.Rotate`                                                         Rotates the image about the given point, by `angle`  radians.
:meth:`~wx.Image.Rotate180`                                                      Returns a copy of the image rotated by 180 degrees.
:meth:`~wx.Image.Rotate90`                                                       Returns a copy of the image rotated 90 degrees in the direction indicated by `clockwise`.
:meth:`~wx.Image.RotateHue`                                                      Rotates the hue of each pixel in the image by `angle`, which is a float in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees.
:meth:`~wx.Image.SaveFile`                                                       Saves an image in the given stream.
:meth:`~wx.Image.Scale`                                                          Returns a scaled version of the image.
:meth:`~wx.Image.SetAlpha`                                                       Sets the alpha value for the given pixel.
:meth:`~wx.Image.SetAlphaBuffer`                                                 Sets the internal image alpha pointer to point at a Python buffer
:meth:`~wx.Image.SetData`                                                        Sets the image data without performing checks.
:meth:`~wx.Image.SetDataBuffer`                                                  Sets the internal image data pointer to point at a Python buffer
:meth:`~wx.Image.SetDefaultLoadFlags`                                            Sets the default value for the flags used for loading image files.
:meth:`~wx.Image.SetLoadFlags`                                                   Sets the flags used for loading image files by this object.
:meth:`~wx.Image.SetMask`                                                        Specifies whether there is a mask or not.
:meth:`~wx.Image.SetMaskColour`                                                  Sets the mask colour for this image (and tells the image to use the mask).
:meth:`~wx.Image.SetMaskFromImage`                                               Sets image's mask so that the pixels that have ``RGB`` value of mr,mg,mb in mask will be masked in the image.
:meth:`~wx.Image.SetOption`                                                      Sets a user-defined option.
:meth:`~wx.Image.SetPalette`                                                     Associates a palette with the image.
:meth:`~wx.Image.SetRGB`                                                         Set the color of the pixel at the given x and y coordinate.
:meth:`~wx.Image.SetType`                                                        Set the type of image returned by :meth:`~Image.GetType` .
:meth:`~wx.Image.Size`                                                           Returns a resized version of this image without scaling it by adding either a border with the given colour or cropping as necessary.
:meth:`~wx.Image.__bool__`                                                       
:meth:`~wx.Image.__nonzero__`                                                    
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.Image.Height`                                                         See :meth:`~wx.Image.GetHeight`
:attr:`~wx.Image.MaskBlue`                                                       See :meth:`~wx.Image.GetMaskBlue`
:attr:`~wx.Image.MaskGreen`                                                      See :meth:`~wx.Image.GetMaskGreen`
:attr:`~wx.Image.MaskRed`                                                        See :meth:`~wx.Image.GetMaskRed`
:attr:`~wx.Image.Type`                                                           See :meth:`~wx.Image.GetType` and :meth:`~wx.Image.SetType`
:attr:`~wx.Image.Width`                                                          See :meth:`~wx.Image.GetWidth`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.Image(Object)

   **Possible constructors**::

       Image()
       
       Image(width, height, clear=True)
       
       Image(sz, clear=True)
       
       Image(name, type=BITMAP_TYPE_ANY, index=-1)
       
       Image(name, mimetype, index=-1)
       
       Image(stream, type=BITMAP_TYPE_ANY, index=-1)
       
       Image(stream, mimetype, index=-1)
       
       Image(width, height, data)
       
       Image(width, height, data, alpha)
       
       Image(size, data)
       
       Image(size, data, alpha)
       
   
   This class encapsulates a platform-independent image.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Creates an empty :ref:`wx.Image`  object without an alpha channel.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, width, height, clear=True)`
      
      Creates an image with the given size and clears it if requested.                  
      
      Does not create an alpha channel. 
      
      
      
      
      :param `width`: Specifies the width of the image.   
      :type `width`: int
      :param `height`: Specifies the height of the image.   
      :type `height`: int
      :param `clear`: If ``True``, initialize the image to black.   
      :type `clear`: bool
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, sz, clear=True)`
      
      This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.                  
      
      
      :param `sz`: 
      :type `sz`: wx.Size
      :param `clear`: 
      :type `clear`: bool
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, name, type=BITMAP_TYPE_ANY, index=-1)`
      
      Creates an image from a file.                  
      
      
      
      
      :param `name`: Name of the file from which to load the image.   
      :type `name`: string
      :param `type`: May be one of the following: 
      
       - ``wx.BITMAP_TYPE_BMP``: Load a Windows bitmap file.  
       - ``wx.BITMAP_TYPE_GIF``: Load a ``GIF`` bitmap file.  
       - ``wx.BITMAP_TYPE_JPEG``: Load a ``JPEG`` bitmap file.  
       - ``wx.BITMAP_TYPE_PNG``: Load a ``PNG`` bitmap file.  
       - ``wx.BITMAP_TYPE_PCX``: Load a ``PCX`` bitmap file.  
       - ``wx.BITMAP_TYPE_PNM``: Load a ``PNM`` bitmap file.  
       - ``wx.BITMAP_TYPE_TIFF``: Load a ``TIFF`` bitmap file.  
       - ``wx.BITMAP_TYPE_TGA``: Load a ``TGA`` bitmap file.  
       - ``wx.BITMAP_TYPE_XPM``: Load a XPM bitmap file.  
       - ``wx.BITMAP_TYPE_ICO``: Load a Windows icon file (``ICO``).  
       - ``wx.BITMAP_TYPE_CUR``: Load a Windows cursor file (``CUR``).  
       - ``wx.BITMAP_TYPE_ANI``: Load a Windows animated cursor file (``ANI``).  
       - ``wx.BITMAP_TYPE_ANY``: Will try to autodetect the format.  
      
       
      
      :type `type`: wx.BitmapType
      :param `index`: Index of the image to load in the case that the image file contains multiple images. This is only used by ``GIF``, ``ICO`` and ``TIFF`` handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the ``GIF`` and ``TIFF`` handler and as the largest and most colourful one by the ``ICO`` handler.  
      :type `index`: int
      
      
      
      
      
      
      
      
                        
      
      
      
      .. note:: 
      
         Depending on how wxWidgets has been configured and by which handlers have been loaded, not all formats may be available. Any handler other than ``BMP`` must be previously initialized with :meth:`wx.Image.AddHandler`   or InitAllImageHandlers.  
      
      
      
      
      
      
      
      .. note:: 
      
         You can use :meth:`GetOptionInt`   to get the hotspot when loading cursor files: ::
      
                            hotspot_x = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X)
                            hotspot_y = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y)
      
      
      
      
      
      
      
      
      
      .. seealso:: :meth:`LoadFile`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, name, mimetype, index=-1)`
      
      Creates an image from a file using MIME-types to specify the type.                  
      
      
      
      
      :param `name`: Name of the file from which to load the image.   
      :type `name`: string
      :param `mimetype`: MIME type string (for example 'image/jpeg')   
      :type `mimetype`: string
      :param `index`: See description in :ref:`wx.Image`  overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, stream, type=BITMAP_TYPE_ANY, index=-1)`
      
      Creates an image from a stream.                  
      
      
      
      
      :param `stream`: Opened input stream from which to load the image. Currently, the stream must support seeking.   
      :type `stream`: wx.InputStream
      :param `type`: See description in :ref:`wx.Image`  overload.   
      :type `type`: wx.BitmapType
      :param `index`: See description in :ref:`wx.Image`  overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, stream, mimetype, index=-1)`
      
      Creates an image from a stream using MIME-types to specify the type.                  
      
      
      
      
      :param `stream`: Opened input stream from which to load the image. Currently, the stream must support seeking.   
      :type `stream`: wx.InputStream
      :param `mimetype`: MIME type string (for example 'image/jpeg')   
      :type `mimetype`: string
      :param `index`: See description in :ref:`wx.Image`  overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, width, height, data)`
      
      Creates an image from ``RGB`` data in memory.  
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, width, height, data, alpha)`
      
      Creates an image from ``RGB`` data in memory, plus an alpha channel  
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, size, data)`
      
      Creates an image from ``RGB`` data in memory.  
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, size, data, alpha)`
      
      Creates an image from ``RGB`` data in memory, plus an alpha channel  
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: AddHandler(handler)

      Register an image handler.                  

      Typical example of use: ::

                      wx.Image.AddHandler(wx.PNGHandler)



      See :ref:`Available image handlers <wx.Image>`  for a list of the available handlers. You can also use :ref:`wx.InitAllImageHandlers`  to add handlers for all the image formats supported by wxWidgets at once. 




      :param `handler`: A heap-allocated handler object which will be deleted by :ref:`wx.Image`  if it is removed later by :meth:`RemoveHandler`   or at program shutdown.   
      :type `handler`: wx.ImageHandler




                  





   .. method:: AdjustChannels(self, factor_red, factor_green, factor_blue, factor_alpha=1.0)

                      This function muliplies all 4 channels (red, green, blue, alpha) with
                      a factor (around 1.0). Useful for gamma correction, colour correction
                      and to add a certain amount of transparency to a image (fade in fade
                      out effects). If factor_alpha is given but the original image has no
                      alpha channel then a alpha channel will be added.
                 

      :rtype: :ref:`wx.Image`








   .. method:: Blur(self, blurRadius)

      Blurs the image in both horizontal and vertical directions by the specified pixel `blurRadius`.                  

      This should not be used when using a single mask colour for transparency. 

                


      :param `blurRadius`: 
      :type `blurRadius`: int




      :rtype: :ref:`wx.Image`







      .. seealso:: :meth:`BlurHorizontal` , :meth:`BlurVertical`     








   .. method:: BlurHorizontal(self, blurRadius)

      Blurs the image in the horizontal direction only.                  

      This should not be used when using a single mask colour for transparency. 

                


      :param `blurRadius`: 
      :type `blurRadius`: int




      :rtype: :ref:`wx.Image`







      .. seealso:: :meth:`Blur` , :meth:`BlurVertical`     








   .. method:: BlurVertical(self, blurRadius)

      Blurs the image in the vertical direction only.                  

      This should not be used when using a single mask colour for transparency. 

                


      :param `blurRadius`: 
      :type `blurRadius`: int




      :rtype: :ref:`wx.Image`







      .. seealso:: :meth:`Blur` , :meth:`BlurHorizontal`     








   .. staticmethod:: CanRead(*args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **CanRead** `(filename)`
      
      Returns ``True`` if at least one of the available image handlers can read the file with the given name.                  
      
      See :meth:`wx.ImageHandler.CanRead`   for more info.                  
      
      
      :param `filename`: 
      :type `filename`: string
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **CanRead** `(stream)`
      
      Returns ``True`` if at least one of the available image handlers can read the data in the given stream.                  
      
      See :meth:`wx.ImageHandler.CanRead`   for more info.                  
      
      
      :param `stream`: 
      :type `stream`: wx.InputStream
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: ChangeBrightness(self, factor)

      Changes the brightness (value) of each pixel in the image.                  

      factor is a float in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent. 

                


      :param `factor`: 
      :type `factor`: float






      .. versionadded:: 4.1/wxWidgets-3.1.6  
     








   .. method:: ChangeHSV(self, angleH, factorS, factorV)

      Changes the hue, the saturation and the brightness (value) of each pixel in the image.                  

      angleH is a float in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees, factorS is a float in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent and factorV is a float in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent. 

                


      :param `angleH`: 
      :type `angleH`: float
      :param `factorS`: 
      :type `factorS`: float
      :param `factorV`: 
      :type `factorV`: float






      .. versionadded:: 4.1/wxWidgets-3.1.6  
     








   .. method:: ChangeLightness(self, alpha)

      Returns a changed version of the image based on the given lightness.                  

      This utility function simply darkens or lightens a color, based on the specified percentage `ialpha`. `ialpha`  of 0 would make the color completely black, 200 completely white and 100 would not change the color. 

                


      :param `alpha`: 
      :type `alpha`: int




      :rtype: :ref:`wx.Image`







      .. versionadded:: 4.1/wxWidgets-3.1.6  
     







      .. note:: 

         This function calls :meth:`wx.Colour.ChangeLightness`   for each pixel in the image.  








   .. method:: ChangeSaturation(self, factor)

      Changes the saturation of each pixel in the image.                  

      factor is a float in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent. 

                


      :param `factor`: 
      :type `factor`: float






      .. versionadded:: 4.1/wxWidgets-3.1.6  
     








   .. staticmethod:: CleanUpHandlers()

      Deletes all image handlers.                  

      This function is called by wxWidgets on exit.                   





   .. method:: Clear(self, value=0)

      Initialize the image data with zeroes (the default) or with the byte value given as `value`.                  

                


      :param `value`: 
      :type `value`: int






      .. versionadded:: 2.9.0 
     








   .. method:: ClearAlpha(self)

      Removes the alpha channel from the image.                  

      This function should only be called if the image has alpha channel data, use :meth:`HasAlpha`   to check for this. 

                 



      .. versionadded:: 2.9.1 
     








   .. method:: ComputeHistogram(self, histogram)

      Computes the histogram of the image.                  

      `histogram`  is a reference to :ref:`wx.ImageHistogram`  object. :ref:`wx.ImageHistogram`  is a specialization of :ref:`HashMap`  "template" and is defined as follows: 

      ::

                  # This is a raw translation of the ImageHistogramEntry
                  # code in C++, not a real Python class
                  class ImageHistogramEntry(object):

                      def __init__(self):

                          self.index = 0
                          self.value = 0



                


      :param `histogram`: 
      :type `histogram`: wx.ImageHistogram




      :rtype: `int`







      :returns: 

         Returns number of colours in the histogram.   








   .. method:: ConvertAlphaToMask(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **ConvertAlphaToMask** `(self, threshold=IMAGE_ALPHA_THRESHOLD)`
      
      If the image has alpha channel, this method converts it to mask.                  
      
      If the image has an alpha channel, all pixels with alpha value less than `threshold`  are replaced with the mask colour and the alpha channel is removed. Otherwise nothing is done. 
      
      The mask colour is chosen automatically using :meth:`FindFirstUnusedColour` , see the overload below if this is not appropriate. 
      
                      
      
      
      :param `threshold`: 
      :type `threshold`: int
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :returns: 
      
         Returns ``True`` on success, ``False`` on error.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **ConvertAlphaToMask** `(self, mr, mg, mb, threshold=IMAGE_ALPHA_THRESHOLD)`
      
      If the image has alpha channel, this method converts it to mask using the specified colour as the mask colour.                  
      
      If the image has an alpha channel, all pixels with alpha value less than `threshold`  are replaced with the mask colour and the alpha channel is removed. Otherwise nothing is done. 
      
      
      
      
      :param `mr`: The red component of the mask colour.   
      :type `mr`: int
      :param `mg`: The green component of the mask colour.   
      :type `mg`: int
      :param `mb`: The blue component of the mask colour.   
      :type `mb`: int
      :param `threshold`: Pixels with alpha channel values below the given threshold are considered to be transparent, i.e. the corresponding mask pixels are set. Pixels with the alpha values above the threshold are considered to be opaque.  
      :type `threshold`: int
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      :returns: 
      
         Returns ``True`` on success, ``False`` on error.   
      
      
      
      
      
      
      
      .. versionadded:: 2.9.0 
          
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: ConvertToBitmap(self, depth=-1)

      
      Convert the image to a :class:`wx.Bitmap`.



   .. method:: ConvertToDisabled(self, brightness=255)

      Returns disabled (dimmed) version of the image.                  

                


      :param `brightness`: 
      :type `brightness`: int




      :rtype: :ref:`wx.Image`







      .. versionadded:: 2.9.0 
     







      .. note:: 

         This function calls :meth:`wx.Colour.MakeDisabled`   for each pixel in the image.  








   .. method:: ConvertToGreyscale(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **ConvertToGreyscale** `(self, weight_r, weight_g, weight_b)`
      
      Returns a greyscale version of the image.                  
      
      The returned image uses the luminance component of the original to calculate the greyscale. Defaults to using the standard ``ITU-T`` BT.601 when converting to ``YUV``, where every pixel equals (R  `weight_r`) + (G  `weight_g`) + (B  `weight_b`). 
      
                      
      
      
      :param `weight_r`: 
      :type `weight_r`: float
      :param `weight_g`: 
      :type `weight_g`: float
      :param `weight_b`: 
      :type `weight_b`: float
      
      
      
      
      :rtype: :ref:`wx.Image`
      
      
      
      
      
      
      
      .. note:: 
      
         This function calls :meth:`wx.Colour.MakeGrey`   for each pixel in the image.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **ConvertToGreyscale** `(self)`
      
      Returns a greyscale version of the image.                  
      
                      
      
      :rtype: :ref:`wx.Image`
      
      
      
      
      
      
      
      .. versionadded:: 2.9.0 
           
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: ConvertToMono(self, r, g, b)

      Returns monochromatic version of the image.                  

      The returned image has white colour where the original has (r,g,b) colour and black colour everywhere else. 

                


      :param `r`: 
      :type `r`: int
      :param `g`: 
      :type `g`: int
      :param `b`: 
      :type `b`: int




      :rtype: :ref:`wx.Image`







      .. note:: 

         This function calls :meth:`wx.Colour.MakeMono`   for each pixel in the image.   








   .. method:: ConvertToMonoBitmap(self, red, green, blue)

      
      Creates a monochrome version of the image and returns it as a :class:`wx.Bitmap`.



   .. method:: ConvertToRegion(self, R=-1, G=-1, B=-1, tolerance=0)

      Create a :class:`wx.Region` where the transparent areas match the given ``RGB`` values. 

      If the ``RGB`` values are not given, then the image's mask colour components will
      be used instead. If a non-zero tolerance is given then the pixels that fall
      into the range of (R,G,B) to (R+tolerance, G+tolerance, B+tolerance) will be
      considered to be transparent.

      If there are no pixels matching the transparent colours then the region
      returned will match the image's full dimensions.

      :param int ```R```: The red component of the transparent colour.
      :param int ```G```: The red component of the transparent colour.
      :param int ```B```: The red component of the transparent colour.
      :param int `tolerance`: Broadens the range of colours that will
              be considered transparent.
      :returns: a :class:`wx.Region` object. 

      :rtype: :ref:`wx.Region`








   .. method:: Copy(self)

      Returns an identical copy of this image.                  

      :rtype: :ref:`wx.Image`








   .. method:: Create(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, width, height, clear=True)`
      
      Creates a fresh image.                  
      
      See :meth:`Image.__init__`   for more info. 
      
                      
      
      
      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      :param `clear`: 
      :type `clear`: bool
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :returns: 
      
         ``True`` if the call succeeded, ``False`` otherwise.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, sz, clear=True)`
      
      This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.                  
      
      
      :param `sz`: 
      :type `sz`: wx.Size
      :param `clear`: 
      :type `clear`: bool
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, width, height, data)`
      
      Create a new image initialized with the given ``RGB`` data. 
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, width, height, data, alpha)`
      
      Create a new image initialized with the given ``RGB`` data and Alpha data. 
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, size, data)`
      
      Create a new image initialized with the given ``RGB`` data. 
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **Create** `(self, size, data, alpha)`
      
      Create a new image initialized with the given ``RGB`` data and Alpha data. 
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Destroy(self)

      Destroys the image data.                   





   .. method:: FindFirstUnusedColour(self, startR=1, startG=0, startB=0)

      Finds the first colour that is never used in the image.                  

      The search begins at given initial colour and continues by increasing R, G and B components (in this order) by 1 until an unused colour is found or the colour space exhausted. 

      The parameters `r`, `g`, `b`  are pointers to variables to save the colour. 

      The parameters `startR`, `startG`, `startB`  define the initial values of the colour. The returned colour will have ``RGB`` values equal to or greater than these. 

                


      :param `startR`: 
      :type `startR`: int
      :param `startG`: 
      :type `startG`: int
      :param `startB`: 
      :type `startB`: int




      :rtype: `tuple`







      :returns: 

         ( `r`, `g`, `b` ) 







      .. note:: 

         This method involves computing the histogram, which is a computationally intensive operation.   








   .. staticmethod:: FindHandler(*args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **FindHandler** `(name)`
      
      Finds the handler with the given name.                  
      
      
      
      
      :param `name`: The handler name.  
      :type `name`: string
      
      
      
      
      
      
      :rtype: :ref:`wx.ImageHandler`
      
      
      
                        
      
      
      
      :returns: 
      
         A pointer to the handler if found, ``None`` otherwise.  
      
      
      
      
      
      
      
      .. seealso:: :ref:`wx.ImageHandler`    
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **FindHandler** `(extension, imageType)`
      
      Finds the handler associated with the given extension and type.                  
      
      
      
      
      :param `extension`: The file extension, such as "bmp".   
      :type `extension`: string
      :param `imageType`: The image type; one of the :ref:`wx.BitmapType`  values.  
      :type `imageType`: wx.BitmapType
      
      
      
      
      
      
      
      
      :rtype: :ref:`wx.ImageHandler`
      
      
      
                        
      
      
      
      :returns: 
      
         A pointer to the handler if found, ``None`` otherwise.  
      
      
      
      
      
      
      
      .. seealso:: :ref:`wx.ImageHandler`    
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **FindHandler** `(imageType)`
      
      Finds the handler associated with the given image type.                  
      
      
      
      
      :param `imageType`: The image type; one of the :ref:`wx.BitmapType`  values.  
      :type `imageType`: wx.BitmapType
      
      
      
      
      
      
      :rtype: :ref:`wx.ImageHandler`
      
      
      
                        
      
      
      
      :returns: 
      
         A pointer to the handler if found, ``None`` otherwise.  
      
      
      
      
      
      
      
      .. seealso:: :ref:`wx.ImageHandler`    
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: FindHandlerMime(mimetype)

      Finds the handler associated with the given MIME type.                  




      :param `mimetype`: MIME type.  
      :type `mimetype`: string






      :rtype: :ref:`wx.ImageHandler`



                  



      :returns: 

         A pointer to the handler if found, ``None`` otherwise.  







      .. seealso:: :ref:`wx.ImageHandler`    








   .. method:: GetAlpha(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **GetAlpha** `(self, x, y)`
      
      Return alpha value at given pixel location.                  
      
      
      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      
      
      
      
      :rtype: `int`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **GetAlpha** `(self)`
      
      Returns a copy of the Alpha bytes of the image. 
      
      :rtype: :ref:`PyObject`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: GetAlphaBuffer(self)

                      Returns a writable Python buffer object that is pointing at the Alpha
                      data buffer inside the :class:`Image`. You need to ensure that you do
                      not use this buffer object after the image has been destroyed. 

      :rtype: :ref:`PyObject`








   .. method:: GetBlue(self, x, y)

      Returns the blue intensity at the given coordinate.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int




      :rtype: `int`








   .. method:: GetData(self)

      Returns a copy of the ``RGB`` bytes of the image. 

      :rtype: :ref:`PyObject`








   .. method:: GetDataBuffer(self)

                      Returns a writable Python buffer object that is pointing at the ``RGB``
                      image data buffer inside the :class:`Image`. You need to ensure that you do
                      not use this buffer object after the image has been destroyed. 

      :rtype: :ref:`PyObject`








   .. staticmethod:: GetDefaultLoadFlags()

      Returns the currently used default file load flags.                  

      See :meth:`SetDefaultLoadFlags`   for more information about these flags. 

                

      :rtype: `int`







      .. versionadded:: 4.1/wxWidgets-3.1.0  
     








   .. method:: GetGreen(self, x, y)

      Returns the green intensity at the given coordinate.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int




      :rtype: `int`








   .. method:: GetHeight(self)

      Gets the height of the image in pixels.                  

                

      :rtype: `int`







      .. seealso:: :meth:`GetWidth` , :meth:`GetSize`     








   .. staticmethod:: GetImageCount(*args, **kw)

      If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.                  

      For the overload taking the parameter `filename`, that's the name of the file to query. For the overload taking the parameter `stream`, that's the opened input stream with image data. 

      See :meth:`wx.ImageHandler.GetImageCount`   for more info. 

      The parameter `type`  may be one of the following values: 

      - ``wx.BITMAP_TYPE_BMP``: Load a Windows bitmap file.  
      - ``wx.BITMAP_TYPE_GIF``: Load a ``GIF`` bitmap file.  
      - ``wx.BITMAP_TYPE_JPEG``: Load a ``JPEG`` bitmap file.  
      - ``wx.BITMAP_TYPE_PNG``: Load a ``PNG`` bitmap file.  
      - ``wx.BITMAP_TYPE_PCX``: Load a ``PCX`` bitmap file.  
      - ``wx.BITMAP_TYPE_PNM``: Load a ``PNM`` bitmap file.  
      - ``wx.BITMAP_TYPE_TIFF``: Load a ``TIFF`` bitmap file.  
      - ``wx.BITMAP_TYPE_TGA``: Load a ``TGA`` bitmap file.  
      - ``wx.BITMAP_TYPE_XPM``: Load a XPM bitmap file.  
      - ``wx.BITMAP_TYPE_ICO``: Load a Windows icon file (``ICO``).  
      - ``wx.BITMAP_TYPE_CUR``: Load a Windows cursor file (``CUR``).  
      - ``wx.BITMAP_TYPE_ANI``: Load a Windows animated cursor file (``ANI``).  
      - ``wx.BITMAP_TYPE_ANY``: Will try to autodetect the format. 


                  



      :returns: 

         Number of available images. For most image handlers, this is 1 (exceptions are ``TIFF`` and ``ICO`` formats as well as animated GIFs for which this function returns the number of frames in the animation).   





      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **GetImageCount** `(filename, type=BITMAP_TYPE_ANY)`
      
      
      
      
      :param `filename`: 
      :type `filename`: string
      :param `type`: 
      :type `type`: wx.BitmapType
      
      
      
      
      :rtype: `int`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **GetImageCount** `(stream, type=BITMAP_TYPE_ANY)`
      
      
      
      
      :param `stream`: 
      :type `stream`: wx.InputStream
      :param `type`: 
      :type `type`: wx.BitmapType
      
      
      
      
      :rtype: `int`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: GetImageExtWildcard()

      Iterates all registered :ref:`wx.ImageHandler`  objects, and returns a string containing file extension masks suitable for passing to file open/save dialog boxes.                  

                

      :rtype: `string`







      :returns: 

         The format of the returned string is  ``"(*.ext1;*.ext2)|*.ext1;*.ext2"`` . It is usually a good idea to prepend a description before passing the result to the dialog. Example:  ::

                                FileDlg = wx.FileDialog(self, "Choose Image", os.getcwd(), "",
                                                        "Image Files " + wx.Image.GetImageExtWildcard(),
                                                        wx.FD_OPEN)









      .. seealso:: :ref:`wx.ImageHandler`    








   .. method:: GetLoadFlags(self)

      Returns the file load flags used for this object.                  

      See :meth:`SetLoadFlags`   for more information about these flags. 

                

      :rtype: `int`







      .. versionadded:: 4.1/wxWidgets-3.1.0  
     








   .. method:: GetMaskBlue(self)

      Gets the blue value of the mask colour.                  

      :rtype: `int`








   .. method:: GetMaskGreen(self)

      Gets the green value of the mask colour.                  

      :rtype: `int`








   .. method:: GetMaskRed(self)

      Gets the red value of the mask colour.                  

      :rtype: `int`








   .. method:: GetOption(self, name)

      Gets a user-defined string-valued option.                  

      Generic options: 

      -  ``IMAGE_OPTION_FILENAME:``   The name of the file from which the image was loaded. 

      Options specific to
      :ref:`wx.GIFHandler`: 

      -  ``IMAGE_OPTION_GIF_COMMENT:``   The comment text that is read from or written to the ``GIF`` file. In an animated ``GIF`` each frame can have its own comment. If there is only a comment in the first frame of a ``GIF`` it will not be repeated in other frames. 





      :param `name`: The name of the option, case-insensitive.   
      :type `name`: string






      :rtype: `string`



                  



      :returns: 

         The value of the option or an empty string if not found. Use :meth:`HasOption`   if an empty string can be a valid option value.  







      .. seealso:: :meth:`SetOption` , :meth:`GetOptionInt` , :meth:`HasOption`     








   .. method:: GetOptionInt(self, name)

      Gets a user-defined integer-valued option.                  

      The function is case-insensitive to `name`. If the given option is not present, the function returns 0. Use :meth:`HasOption`   if 0 is a possibly valid value for the option. 

      Generic options: 

      -  ``IMAGE_OPTION_MAX_WIDTH``   and   ``IMAGE_OPTION_MAX_HEIGHT:``   If either of these options is specified, the loaded image will be scaled down (preserving its aspect ratio) so that its width is less than the max width given if it is not 0  `and`  its height is less than the max height given if it is not 0. This is typically used for loading thumbnails and the advantage of using these options compared to calling :meth:`Rescale`   after loading is that some handlers (only ``JPEG`` one right now) support rescaling the image during loading which is vastly more efficient than loading the entire huge image and rescaling it later (if these options are not supported by the handler, this is still what happens however). These options must be set before calling :meth:`LoadFile`   to have any effect. 




      -  ``IMAGE_OPTION_ORIGINAL_WIDTH``   and   ``IMAGE_OPTION_ORIGINAL_HEIGHT:``   These options will return the original size of the image if either   ``IMAGE_OPTION_MAX_WIDTH``   or   ``IMAGE_OPTION_MAX_HEIGHT``   is specified.  

        .. versionadded:: 2.9.3 
    


      -  ``IMAGE_OPTION_QUALITY:``   ``JPEG`` quality used when saving. This is an integer in 0..100 range with 0 meaning very poor and 100 excellent (but very badly compressed). This option is currently ignored for the other formats. 




      -  ``IMAGE_OPTION_RESOLUTIONUNIT:``   The value of this option determines whether the resolution of the image is specified in centimetres or inches, see ImageResolution enum elements. 




      -  ``IMAGE_OPTION_RESOLUTION`` ,   ``IMAGE_OPTION_RESOLUTIONX``   and   ``IMAGE_OPTION_RESOLUTIONY:``   These options define the resolution of the image in the units corresponding to   ``IMAGE_OPTION_RESOLUTIONUNIT``   options value. The first option can be set before saving the image to set both horizontal and vertical resolution to the same value. The X and Y options are set by the image handlers if they support the image resolution (currently ``BMP``, ``JPEG`` and ``TIFF`` handlers do) and the image provides the resolution information and can be queried after loading the image. 

      Options specific to
      :ref:`wx.PNGHandler`: 

      -  ``IMAGE_OPTION_PNG_FORMAT:``   Format for saving a ``PNG`` file, see ImagePNGType for the supported values.   
      -  ``IMAGE_OPTION_PNG_BITDEPTH:``   Bit depth for every channel (R/G/B/A).   
      -  ``IMAGE_OPTION_PNG_FILTER:``   Filter for saving a ``PNG`` file, see libpng (`http://www.libpng.org/pub/png/libpng-1.2.5-manual.html <http://www.libpng.org/pub/png/libpng-1.2.5-manual.html>`_) for possible values (e.g. ``PNG_FILTER_NONE``, ``PNG_FILTER_SUB``, ``PNG_FILTER_UP``, etc).  
      -  ``IMAGE_OPTION_PNG_COMPRESSION_LEVEL:``   Compression level (0..9) for saving a ``PNG`` file. A high value creates smaller-but-slower ``PNG`` file. Note that unlike other formats (e.g. ``JPEG``) the ``PNG`` format is always lossless and thus this compression level doesn't tradeoff the image quality.   
      -  ``IMAGE_OPTION_PNG_COMPRESSION_MEM_LEVEL:``   Compression memory usage level (1..9) for saving a ``PNG`` file. A high value means the saving process consumes more memory, but may create smaller ``PNG`` file.   
      -  ``IMAGE_OPTION_PNG_COMPRESSION_STRATEGY:``   Possible values are 0 for default strategy, 1 for filter, and 2 for Huffman-only. You can use OptiPNG (`http://optipng.sourceforge.net/ <http://optipng.sourceforge.net/>`_) to get a suitable value for your application.  
      -  ``IMAGE_OPTION_PNG_COMPRESSION_BUFFER_SIZE:``   Internal buffer size (in bytes) for saving a ``PNG`` file. Ideally this should be as big as the resulting ``PNG`` file. Use this option if your application produces images with small size variation. 

      Options specific to
      :ref:`wx.TIFFHandler`: 

      -  ``IMAGE_OPTION_TIFF_BITSPERSAMPLE:``   Number of bits per sample (channel). Currently values of 1 and 8 are supported. A value of 1 results in a black and white image. A value of 8 (the default) can mean greyscale or ``RGB``, depending on the value of   ``IMAGE_OPTION_TIFF_SAMPLESPERPIXEL`` .   
      -  ``IMAGE_OPTION_TIFF_SAMPLESPERPIXEL:``   Number of samples (channels) per pixel. Currently values of 1 and 3 are supported. A value of 1 results in either a greyscale (by default) or black and white image, depending on the value of   ``IMAGE_OPTION_TIFF_BITSPERSAMPLE`` . A value of 3 (the default) will result in an ``RGB`` image.   
      -  ``IMAGE_OPTION_TIFF_COMPRESSION:``   Compression type. By default it is set to 1 (``COMPRESSION_NONE``). Typical other values are 5 (``COMPRESSION_LZW``) and 7 (``COMPRESSION_JPEG``). See tiff.h for more options.   
      -  ``IMAGE_OPTION_TIFF_PHOTOMETRIC:``   Specifies the photometric interpretation. By default it is set to 2 (``PHOTOMETRIC_RGB``) for ``RGB`` images and 0 (``PHOTOMETRIC_MINISWHITE``) for greyscale or black and white images. It can also be set to 1 (``PHOTOMETRIC_MINISBLACK``) to treat the lowest value as black and highest as white. If you want a greyscale image it is also sufficient to only specify   ``IMAGE_OPTION_TIFF_PHOTOMETRIC``   and set it to either ``PHOTOMETRIC_MINISWHITE`` or ``PHOTOMETRIC_MINISBLACK``. The other values are taken care of. 

      Options specific to
      :ref:`wx.GIFHandler`: 

      -  ``IMAGE_OPTION_GIF_TRANSPARENCY:``   How to deal with transparent pixels. By default, the color of transparent pixels is changed to bright pink, so that if the image is accidentally drawn without transparency, it will be obvious. Normally, this would not be noticed, as these pixels will not be rendered. But in some cases it might be useful to load a ``GIF`` without making any modifications to its colours. Use   ``IMAGE_OPTION_GIF_TRANSPARENCY_UNCHANGED``   to keep the colors correct. Use   ``IMAGE_OPTION_GIF_TRANSPARENCY_HIGHLIGHT``   to convert transparent pixels to pink (default). This option has been added in wxWidgets 3.1.1. 





      :param `name`: The name of the option, case-insensitive.   
      :type `name`: string






      :rtype: `int`



                  



      :returns: 

         The value of the option or 0 if not found. Use :meth:`HasOption`   if 0 can be a valid option value.  







      .. note:: 

         Be careful when combining the options  ``IMAGE_OPTION_TIFF_SAMPLESPERPIXEL`` ,   ``IMAGE_OPTION_TIFF_BITSPERSAMPLE`` , and   ``IMAGE_OPTION_TIFF_PHOTOMETRIC`` . While some measures are taken to prevent illegal combinations and/or values, it is still easy to abuse them and come up with invalid results in the form of either corrupted images or crashes.  







      .. seealso:: :meth:`SetOption` , :meth:`GetOption`     








   .. method:: GetOrFindMaskColour(self)

      Get the current mask colour or find a suitable unused colour that could be used as a mask colour.                  

      Returns ``True`` if the image currently has a mask.                  

      :rtype: `tuple`







      :returns: 

         ( `r`, `g`, `b` ) 








   .. method:: GetPalette(self)

      Returns the palette associated with the image.                  

      Currently the palette is only used when converting to :ref:`wx.Bitmap`  under Windows. 

      Some of the :ref:`wx.Image`  handlers have been modified to set the palette if one exists in the image file (usually 256 or less colour images in ``GIF`` or ``PNG`` format).                  

      :rtype: :ref:`wx.Palette`








   .. method:: GetRed(self, x, y)

      Returns the red intensity at the given coordinate.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int




      :rtype: `int`








   .. method:: GetSize(self)

      Returns the size of the image in pixels.                  

                

      :rtype: :ref:`wx.Size`







      .. versionadded:: 2.9.0 
    







      .. seealso:: :meth:`GetHeight` , :meth:`GetWidth`     








   .. method:: GetSubImage(self, rect)

      Returns a sub image of the current one as long as the rect belongs entirely to the image.                  


      :param `rect`: 
      :type `rect`: wx.Rect




      :rtype: :ref:`wx.Image`








   .. method:: GetType(self)

      Gets the type of image found by :meth:`LoadFile`   or specified with :meth:`SaveFile` .                  

                

      :rtype: :ref:`wx.BitmapType`







      .. versionadded:: 2.9.0 
     








   .. method:: GetWidth(self)

      Gets the width of the image in pixels.                  

                

      :rtype: `int`







      .. seealso:: :meth:`GetHeight` , :meth:`GetSize`     








   .. staticmethod:: HSVtoRGB(hsv)

      Converts a color in ``HSV`` color space to ``RGB`` color space.                  


      :param `hsv`: 
      :type `hsv`: HSVValue




      :rtype: :ref:`RGBValue`








   .. method:: HasAlpha(self)

      Returns ``True`` if this image has alpha channel, ``False`` otherwise.                  

                

      :rtype: `bool`







      .. seealso:: :meth:`GetAlpha` , :meth:`SetAlpha`     








   .. method:: HasMask(self)

      Returns ``True`` if there is a mask active, ``False`` otherwise.                  

      :rtype: `bool`








   .. method:: HasOption(self, name)

      Returns ``True`` if the given option is present.                  

      The function is case-insensitive to `name`. 

      The lists of the currently supported options are in :meth:`GetOption`   and :meth:`GetOptionInt`   function docs. 

                


      :param `name`: 
      :type `name`: string




      :rtype: `bool`







      .. seealso:: :meth:`SetOption` , :meth:`GetOption` , :meth:`GetOptionInt`     








   .. method:: InitAlpha(self)

      Initializes the image alpha channel data.                  

      It is an error to call it if the image already has alpha data. If it doesn't, alpha data will be by default initialized to all pixels being fully opaque. But if the image has a mask colour, all mask pixels will be completely transparent.                   





   .. staticmethod:: InitStandardHandlers()

      Internal use only.                  

      Adds standard image format handlers. It only install BMPHandler for the time being, which is used by :ref:`wx.Bitmap`. 

      This function is called by wxWidgets on startup, and shouldn't be called by the user. 

                 



      .. seealso:: :ref:`wx.ImageHandler`, :ref:`wx.InitAllImageHandlers`, :ref:`Quantize`    








   .. staticmethod:: InsertHandler(handler)

      Adds a handler at the start of the static list of format handlers.                  




      :param `handler`: A new image format handler object. There is usually only one instance of a given handler class in an application session.  
      :type `handler`: wx.ImageHandler




                  



      .. seealso:: :ref:`wx.ImageHandler`    








   .. method:: IsOk(self)

      Returns ``True`` if image data is present.                  

      :rtype: `bool`








   .. method:: IsTransparent(self, x, y, threshold=IMAGE_ALPHA_THRESHOLD)

      Returns ``True`` if the given pixel is transparent, i.e. either has the mask colour if this image has a mask or if this image has alpha channel and alpha value of this pixel is strictly less than `threshold`.                  


      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      :param `threshold`: 
      :type `threshold`: int




      :rtype: `bool`








   .. method:: LoadFile(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **LoadFile** `(self, stream, type=BITMAP_TYPE_ANY, index=-1)`
      
      Loads an image from an input stream.                  
      
      If the file can't be loaded, this function returns ``False`` and logs an error using :ref:`wx.LogError`. If the file can be loaded but some problems were detected while doing it, it can also call :ref:`wx.LogWarning`  to notify about these problems. If this is undesirable, use :meth:`SetLoadFlags`   to reset  ``Load_Verbose``   flag and suppress these warnings. 
      
      
      
      
      :param `stream`: Opened input stream from which to load the image. Currently, the stream must support seeking.   
      :type `stream`: wx.InputStream
      :param `type`: May be one of the following: 
      
       - ``wx.BITMAP_TYPE_BMP``: Load a Windows bitmap file.  
       - ``wx.BITMAP_TYPE_GIF``: Load a ``GIF`` bitmap file.  
       - ``wx.BITMAP_TYPE_JPEG``: Load a ``JPEG`` bitmap file.  
       - ``wx.BITMAP_TYPE_PNG``: Load a ``PNG`` bitmap file.  
       - ``wx.BITMAP_TYPE_PCX``: Load a ``PCX`` bitmap file.  
       - ``wx.BITMAP_TYPE_PNM``: Load a ``PNM`` bitmap file.  
       - ``wx.BITMAP_TYPE_TIFF``: Load a ``TIFF`` bitmap file.  
       - ``wx.BITMAP_TYPE_TGA``: Load a ``TGA`` bitmap file.  
       - ``wx.BITMAP_TYPE_XPM``: Load a XPM bitmap file.  
       - ``wx.BITMAP_TYPE_ICO``: Load a Windows icon file (``ICO``).  
       - ``wx.BITMAP_TYPE_CUR``: Load a Windows cursor file (``CUR``).  
       - ``wx.BITMAP_TYPE_ANI``: Load a Windows animated cursor file (``ANI``).  
       - ``wx.BITMAP_TYPE_ANY``: Will try to autodetect the format.  
      
       
      
      :type `type`: wx.BitmapType
      :param `index`: Index of the image to load in the case that the image file contains multiple images. This is only used by ``GIF``, ``ICO`` and ``TIFF`` handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the ``GIF`` and ``TIFF`` handler and as the largest and most colourful one by the ``ICO`` handler.  
      :type `index`: int
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      :returns: 
      
         ``True`` if the operation succeeded, ``False`` otherwise. If the optional index parameter is out of range, ``False`` is returned and a call to :ref:`wx.LogError`  takes place.  
      
      
      
      
      
      
      
      .. note:: 
      
         Depending on how wxWidgets has been configured, not all formats may be available.  
      
      
      
      
      
      
      
      .. note:: 
      
         You can use :meth:`GetOptionInt`   to get the hotspot when loading cursor files: ::
      
                            hotspot_x = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X)
                            hotspot_y = image.GetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y)
      
      
      
      
      
      
      
      
      
      .. seealso:: :meth:`SaveFile`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **LoadFile** `(self, name, type=BITMAP_TYPE_ANY, index=-1)`
      
      Loads an image from a file.                  
      
      If no handler type is provided, the library will try to autodetect the format. 
      
      
      
      
      :param `name`: Name of the file from which to load the image.   
      :type `name`: string
      :param `type`: See the description in the :meth:`LoadFile`   overload.   
      :type `type`: wx.BitmapType
      :param `index`: See the description in the :meth:`LoadFile`   overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **LoadFile** `(self, name, mimetype, index=-1)`
      
      Loads an image from a file.                  
      
      If no handler type is provided, the library will try to autodetect the format. 
      
      
      
      
      :param `name`: Name of the file from which to load the image.   
      :type `name`: string
      :param `mimetype`: MIME type string (for example 'image/jpeg')   
      :type `mimetype`: string
      :param `index`: See the description in the :meth:`LoadFile`   overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **LoadFile** `(self, stream, mimetype, index=-1)`
      
      Loads an image from an input stream.                  
      
      
      
      
      :param `stream`: Opened input stream from which to load the image. Currently, the stream must support seeking.   
      :type `stream`: wx.InputStream
      :param `mimetype`: MIME type string (for example 'image/jpeg')   
      :type `mimetype`: string
      :param `index`: See the description in the :meth:`LoadFile`   overload.   
      :type `index`: int
      
      
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Mirror(self, horizontally=True)

      Returns a mirrored copy of the image.                  

      The parameter `horizontally`  indicates the orientation.                  


      :param `horizontally`: 
      :type `horizontally`: bool




      :rtype: :ref:`wx.Image`








   .. method:: Paste(self, image, x, y, alphaBlend=IMAGE_ALPHA_BLEND_OVER)

      Copy the data of the given `image`  to the specified position in this image.                  

      Takes care of the mask colour and out of bounds problems. 




      :param `image`: The image containing the data to copy, must be valid.   
      :type `image`: wx.Image
      :param `x`: The horizontal position of the position to copy the data to.   
      :type `x`: int
      :param `y`: The vertical position of the position to copy the data to.   
      :type `y`: int
      :param `alphaBlend`: This parameter (new in  3.1.5) determines whether the alpha values of the original image replace (default) or are composed with the alpha channel of this image. Notice that alpha blending overrides the mask handling.   
      :type `alphaBlend`: wx.ImageAlphaBlendMode










                  





   .. staticmethod:: RGBtoHSV(rgb)

      Converts a color in ``RGB`` color space to ``HSV`` color space.                  


      :param `rgb`: 
      :type `rgb`: RGBValue




      :rtype: :ref:`HSVValue`








   .. staticmethod:: RemoveHandler(name)

      Finds the handler with the given name, and removes it.                  

      The handler is also deleted. 




      :param `name`: The handler name.  
      :type `name`: string






      :rtype: `bool`



                  



      :returns: 

         ``True`` if the handler was found and removed, ``False`` otherwise.  







      .. seealso:: :ref:`wx.ImageHandler`    








   .. method:: Replace(self, r1, g1, b1, r2, g2, b2)

      Replaces the colour specified by `r1`,g1,b1 by the colour `r2`,g2,b2.                  


      :param `r1`: 
      :type `r1`: int
      :param `g1`: 
      :type `g1`: int
      :param `b1`: 
      :type `b1`: int
      :param `r2`: 
      :type `r2`: int
      :param `g2`: 
      :type `g2`: int
      :param `b2`: 
      :type `b2`: int







   .. method:: Rescale(self, width, height, quality=IMAGE_QUALITY_NORMAL)

      Changes the size of the image in-place by scaling it: after a call to this function,the image will have the given width and height.                  

      For a description of the `quality`  parameter, see the :meth:`Scale`   function. Returns the (modified) image itself. 

                


      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      :param `quality`: 
      :type `quality`: wx.ImageResizeQuality




      :rtype: :ref:`wx.Image`







      .. seealso:: :meth:`Scale`     








   .. method:: Resize(self, size, pos, red=-1, green=-1, blue=-1)

      Changes the size of the image in-place without scaling it by adding either a border with the given colour or cropping as necessary.                  

      The image is pasted into a new image with the given `size`  and background colour at the position `pos`  relative to the upper left of the new image. 

      If `red`  = green = blue = -1 then use either the current mask colour if set or find, use, and set a suitable mask colour for any newly exposed areas. 

                


      :param `size`: 
      :type `size`: wx.Size
      :param `pos`: 
      :type `pos`: wx.Point
      :param `red`: 
      :type `red`: int
      :param `green`: 
      :type `green`: int
      :param `blue`: 
      :type `blue`: int




      :rtype: :ref:`wx.Image`







      :returns: 

         The (modified) image itself.  







      .. seealso:: :ref:`wx.Size`    








   .. method:: Rotate(self, angle, rotationCentre, interpolating=True, offsetAfterRotation=None)

      Rotates the image about the given point, by `angle`  radians.                  

      Passing ``True`` to `interpolating`  results in better image quality, but is slower. 

      If the image has a mask, then the mask colour is used for the uncovered pixels in the rotated image background. Else, black (rgb 0, 0, 0) will be used. 

      Returns the rotated image, leaving this image intact.                  


      :param `angle`: 
      :type `angle`: float
      :param `rotationCentre`: 
      :type `rotationCentre`: wx.Point
      :param `interpolating`: 
      :type `interpolating`: bool
      :param `offsetAfterRotation`: 
      :type `offsetAfterRotation`: wx.Point




      :rtype: :ref:`wx.Image`








   .. method:: Rotate180(self)

      Returns a copy of the image rotated by 180 degrees.                  

                

      :rtype: :ref:`wx.Image`







      .. versionadded:: 2.9.2 
     








   .. method:: Rotate90(self, clockwise=True)

      Returns a copy of the image rotated 90 degrees in the direction indicated by `clockwise`.                  


      :param `clockwise`: 
      :type `clockwise`: bool




      :rtype: :ref:`wx.Image`








   .. method:: RotateHue(self, angle)

      Rotates the hue of each pixel in the image by `angle`, which is a float in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees.                  


      :param `angle`: 
      :type `angle`: float







   .. method:: SaveFile(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, stream, mimetype)`
      
      Saves an image in the given stream.                  
      
      
      
      
      :param `stream`: Opened output stream to save the image to.   
      :type `stream`: wx.OutputStream
      :param `mimetype`: MIME type.  
      :type `mimetype`: string
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      :returns: 
      
         ``True`` if the operation succeeded, ``False`` otherwise.  
      
      
      
      
      
      
      
      .. note:: 
      
         Depending on how wxWidgets has been configured, not all formats may be available.  
      
      
      
      
      
      
      
      .. note:: 
      
         You can use :meth:`SetOption`   to set the hotspot when saving an image into a cursor file (default hotspot is in the centre of the image): ::
      
                            image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_X, hotspotX)
                            image.SetOption(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY)
      
      
      
      
      
      
      
      
      
      .. seealso:: :meth:`LoadFile`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, name, type)`
      
      Saves an image in the named file.                  
      
      
      
      
      :param `name`: Name of the file to save the image to.   
      :type `name`: string
      :param `type`: Currently these types can be used: 
      
       - ``wx.BITMAP_TYPE_BMP``: Save a ``BMP`` image file.  
       - ``wx.BITMAP_TYPE_JPEG``: Save a ``JPEG`` image file.  
       - ``wx.BITMAP_TYPE_PNG``: Save a ``PNG`` image file.  
       - ``wx.BITMAP_TYPE_PCX``: Save a ``PCX`` image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).  
       - ``wx.BITMAP_TYPE_PNM``: Save a ``PNM`` image file (as raw ``RGB`` always).  
       - ``wx.BITMAP_TYPE_TIFF``: Save a ``TIFF`` image file.  
       - ``wx.BITMAP_TYPE_XPM``: Save a XPM image file.  
       - ``wx.BITMAP_TYPE_ICO``: Save a Windows icon file (``ICO``). The size may be up to 255 wide by 127 high. A single image is saved in 8 colors at the size supplied.  
       - ``wx.BITMAP_TYPE_CUR``: Save a Windows cursor file (``CUR``).  
      
       
      
      :type `type`: wx.BitmapType
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, name, mimetype)`
      
      Saves an image in the named file.                  
      
      
      
      
      :param `name`: Name of the file to save the image to.   
      :type `name`: string
      :param `mimetype`: MIME type.   
      :type `mimetype`: string
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, name)`
      
      Saves an image in the named file.                  
      
      File type is determined from the extension of the file name. Note that this function may fail if the extension is not recognized! You can use one of the forms above to save images to files with non-standard extensions. 
      
      
      
      
      :param `name`: Name of the file to save the image to.   
      :type `name`: string
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SaveFile** `(self, stream, type)`
      
      Saves an image in the given stream.                  
      
      
      
      
      :param `stream`: Opened output stream to save the image to.   
      :type `stream`: wx.OutputStream
      :param `type`: MIME type.   
      :type `type`: wx.BitmapType
      
      
      
      
      
      
      
      
      :rtype: `bool`
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Scale(self, width, height, quality=IMAGE_QUALITY_NORMAL)

      Returns a scaled version of the image.                  

      This is also useful for scaling bitmaps in general as the only other way to scale bitmaps is to blit a :ref:`wx.MemoryDC`  into another :ref:`wx.MemoryDC`. 

      The parameter `quality`  determines what method to use for resampling the image, see ImageResizeQuality documentation. 

      It should be noted that although using  ``IMAGE_QUALITY_HIGH``   produces much nicer looking results it is a slower method. Downsampling will use the box averaging method which seems to operate very fast. If you are upsampling larger images using this method you will most likely notice that it is a bit slower and in extreme cases it will be quite substantially slower as the bicubic algorithm has to process a lot of data. 

      It should also be noted that the high quality scaling may not work as expected when using a single mask colour for transparency, as the scaling will blur the image and will therefore remove the mask partially. Using the alpha channel will work. 

      Example: ::

                  # get the bitmap from somewhere
                  bmp = wx.Bitmap('my_png.png', wx.BITMAP_TYPE_PNG)

                  # rescale it to have size of 32*32
                  if bmp.GetWidth() != 32 or bmp.GetHeight() != 32:

                      image = bmp.ConvertToImage()
                      bmp = wx.Bitmap(image.Scale(32, 32))

                      # another possibility:
                      image.Rescale(32, 32)
                      bmp = wx.Bitmap(image)



                


      :param `width`: 
      :type `width`: int
      :param `height`: 
      :type `height`: int
      :param `quality`: 
      :type `quality`: wx.ImageResizeQuality




      :rtype: :ref:`wx.Image`







      .. note:: 

         The algorithm used for the default (normal) quality value doesn't work with images larger than 65536 (2^16) pixels in either dimension for 32-bit programs. For 64-bit programs the limit is 2^48 and so not relevant in practice.  







      .. seealso:: :meth:`Rescale`     








   .. method:: SetAlpha(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetAlpha** `(self, x, y, alpha)`
      
      Sets the alpha value for the given pixel.                  
      
      This function should only be called if the image has alpha channel data, use :meth:`HasAlpha`   to check for this.                  
      
      
      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      :param `alpha`: 
      :type `alpha`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetAlpha** `(self, alpha)`
      
      This function is similar to :meth:`SetData`   and has similar restrictions.                  
      
      The pointer passed to it may however be ``None`` in which case the function will allocate the alpha array internally –  this is useful to add alpha channel data to an image which doesn't have any. 
      
      If the pointer is not ``None``, it must have one byte for each image pixel and be allocated with malloc(). :ref:`wx.Image`  takes ownership of the pointer and will free it unless `static_data`  parameter is set to ``True`` –  in this case the caller should do it.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetAlphaBuffer(self, alpha)

                      Sets the internal image alpha pointer to point at a Python buffer
                      object.  This can save making an extra copy of the data but you must
                      ensure that the buffer object lives lives at least as long as the
                      :class:`Image` does.  





   .. method:: SetData(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetData** `(self, data)`
      
      Sets the image data without performing checks.                  
      
      The data given must have the size (widthheight3) or results will be unexpected. Don't use this method if you aren't sure you know what you are doing. 
      
      The data must have been allocated with  ``malloc()`` ,  **NOT**  with  ``operator``   new. 
      
      If `static_data`  is ``False``, after this call the pointer to the data is owned by the :ref:`wx.Image`  object, that will be responsible for deleting it. Do not pass to this function a pointer obtained through :meth:`GetData` .                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetData** `(self, data, new_width, new_height)`
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetDataBuffer(self, *args, **kw)

                      Sets the internal image data pointer to point at a Python buffer
                      object.  This can save making an extra copy of the data but you must
                      ensure that the buffer object lives lives at least as long as the
                      :class:`Image` does.  


      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetDataBuffer** `(self, data)`
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetDataBuffer** `(self, data, new_width, new_height)`
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. staticmethod:: SetDefaultLoadFlags(flags)

      Sets the default value for the flags used for loading image files.                  

      This method changes the global value of the flags used for all the subsequently created :ref:`wx.Image`  objects by default. It doesn't affect the already existing objects. 

      By default, the global flags include  ``Load_Verbose``   flag value. 

                


      :param `flags`: 
      :type `flags`: int






      .. versionadded:: 4.1/wxWidgets-3.1.0  
     







      .. seealso:: :meth:`LoadFile` , :meth:`SetLoadFlags` , :meth:`GetDefaultLoadFlags`   








   .. method:: SetLoadFlags(self, flags)

      Sets the flags used for loading image files by this object.                  

      The flags will affect any future calls to :meth:`LoadFile`   for this object. To change the flags for all image objects, call :meth:`SetDefaultLoadFlags`   before creating any of them. 

      Currently the only defined flag is  ``Load_Verbose``   which determines if the non-fatal (i.e. not preventing the file from being loaded completely) problems should result in the calls to  :ref:`wx.LogWarning`  function. It is recommended to customize handling of these warnings by e.g. defining a custom log target (see :ref:`Logging Overview <logging overview>`), but if such warnings should be completely suppressed, clearing this flag provides a simple way to do it, for example: ::

          image = wx.Image()
          image.SetLoadFlags(image.GetLoadFlags() & ~wx.Image.Load_Verbose)
          image.LoadFile(...)



                


      :param `flags`: 
      :type `flags`: int






      .. versionadded:: 4.1/wxWidgets-3.1.0  
     







      .. seealso:: :meth:`LoadFile` , :meth:`SetLoadFlags` , :meth:`GetLoadFlags`   








   .. method:: SetMask(self, hasMask=True)

      Specifies whether there is a mask or not.                  

      The area of the mask is determined by the current mask colour.                  


      :param `hasMask`: 
      :type `hasMask`: bool







   .. method:: SetMaskColour(self, red, green, blue)

      Sets the mask colour for this image (and tells the image to use the mask).                  


      :param `red`: 
      :type `red`: int
      :param `green`: 
      :type `green`: int
      :param `blue`: 
      :type `blue`: int







   .. method:: SetMaskFromImage(self, mask, mr, mg, mb)

      Sets image's mask so that the pixels that have ``RGB`` value of mr,mg,mb in mask will be masked in the image.                  

      This is done by first finding an unused colour in the image, setting this colour as the mask colour and then using this colour to draw all pixels in the image who corresponding pixel in mask has given ``RGB`` value. 

      The parameter `mask`  is the mask image to extract mask shape from. It must have the same dimensions as the image. 

      The parameters `mr`, `mg`, `mb`  are the ``RGB`` values of the pixels in mask that will be used to create the mask. 

                


      :param `mask`: 
      :type `mask`: wx.Image
      :param `mr`: 
      :type `mr`: int
      :param `mg`: 
      :type `mg`: int
      :param `mb`: 
      :type `mb`: int




      :rtype: `bool`







      :returns: 

         Returns ``False`` if mask does not have same dimensions as the image or if there is no unused colour left. Returns ``True`` if the mask was successfully applied.  







      .. note:: 

         Note that this method involves computing the histogram, which is a computationally intensive operation.   








   .. method:: SetOption(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetOption** `(self, name, value)`
      
      Sets a user-defined option.                  
      
      The function is case-insensitive to `name`. 
      
      For example, when saving as a ``JPEG`` file, the option **quality**  is used, which is a number between 0 and 100 (0 is terrible, 100 is very good). 
      
      The lists of the currently supported options are in :meth:`GetOption`   and :meth:`GetOptionInt`   function docs. 
      
                      
      
      
      :param `name`: 
      :type `name`: string
      :param `value`: 
      :type `value`: string
      
      
      
      
      
      
      .. seealso:: :meth:`GetOption` , :meth:`GetOptionInt` , :meth:`HasOption`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetOption** `(self, name, value)`
      
      This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.                  
      
      
      :param `name`: 
      :type `name`: string
      :param `value`: 
      :type `value`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetPalette(self, palette)

      Associates a palette with the image.                  

      The palette may be used when converting :ref:`wx.Image`  to :ref:`wx.Bitmap`  (MSW only at present) or in file save operations (none as yet).                  


      :param `palette`: 
      :type `palette`: wx.Palette







   .. method:: SetRGB(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetRGB** `(self, x, y, r, g, b)`
      
      Set the color of the pixel at the given x and y coordinate.                  
      
      
      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int
      :param `r`: 
      :type `r`: int
      :param `g`: 
      :type `g`: int
      :param `b`: 
      :type `b`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetRGB** `(self, rect, red, green, blue)`
      
      Sets the colour of the pixels within the given rectangle.                  
      
      This routine performs bounds-checks for the coordinate so it can be considered a safe way to manipulate the data.                  
      
      
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `red`: 
      :type `red`: int
      :param `green`: 
      :type `green`: int
      :param `blue`: 
      :type `blue`: int
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetType(self, type)

      Set the type of image returned by :meth:`GetType` .                  

      This method is mostly used internally by the library but can also be called from the user code if the image was created from data in the given bitmap format without using :meth:`LoadFile`   (which would set the type correctly automatically). 

      Notice that the image must be created before this function is called. 




      :param `type`: One of bitmap type constants,  ``BITMAP_TYPE_INVALID``   is a valid value for it and can be used to reset the bitmap type to default but   ``BITMAP_TYPE_MAX``   is not allowed here.    
      :type `type`: wx.BitmapType




                  



      .. versionadded:: 2.9.0 
    








   .. method:: Size(self, size, pos, red=-1, green=-1, blue=-1)

      Returns a resized version of this image without scaling it by adding either a border with the given colour or cropping as necessary.                  

      The image is pasted into a new image with the given `size`  and background colour at the position `pos`  relative to the upper left of the new image. 

      If `red`  = green = blue = -1 then the areas of the larger image not covered by this image are made transparent by filling them with the image mask colour (which will be allocated automatically if it isn't currently set). 

      Otherwise, the areas will be filled with the colour with the specified ``RGB`` components. 

                


      :param `size`: 
      :type `size`: wx.Size
      :param `pos`: 
      :type `pos`: wx.Point
      :param `red`: 
      :type `red`: int
      :param `green`: 
      :type `green`: int
      :param `blue`: 
      :type `blue`: int




      :rtype: :ref:`wx.Image`







      .. seealso:: :meth:`Resize`     








   .. method:: __bool__(self)



      :rtype: `int`








   .. method:: __nonzero__(self)



      :rtype: `int`








   .. attribute:: Height

      See :meth:`~wx.Image.GetHeight`


   .. attribute:: MaskBlue

      See :meth:`~wx.Image.GetMaskBlue`


   .. attribute:: MaskGreen

      See :meth:`~wx.Image.GetMaskGreen`


   .. attribute:: MaskRed

      See :meth:`~wx.Image.GetMaskRed`


   .. attribute:: Type

      See :meth:`~wx.Image.GetType` and :meth:`~wx.Image.SetType`


   .. attribute:: Width

      See :meth:`~wx.Image.GetWidth`

