Class Image

java.lang.Object
org.schabi.newpipe.extractor.Image
All Implemented Interfaces:
Serializable

public final class Image extends Object implements Serializable
Class representing images in the extractor.

An image has four properties: its URL, its height, its width and its estimated quality level.

Depending of the services, the height, the width or both properties may be not known. Implementations must use the relevant unknown constants in this case (HEIGHT_UNKNOWN and WIDTH_UNKNOWN), to ensure properly the lack of knowledge of one or both of these properties to extractor clients.

They should also respect the ranges defined in the estimated image resolution levels as much as possible, to ensure consistency to extractor clients.

See Also:
  • Field Details

    • HEIGHT_UNKNOWN

      public static final int HEIGHT_UNKNOWN
      Constant representing that the height of an Image is unknown.
      See Also:
    • WIDTH_UNKNOWN

      public static final int WIDTH_UNKNOWN
      Constant representing that the width of an Image is unknown.
      See Also:
  • Constructor Details

    • Image

      public Image(@Nonnull String url, int height, int width, @Nonnull Image.ResolutionLevel estimatedResolutionLevel) throws NullPointerException
      Construct an Image instance.
      Parameters:
      url - the URL to the image, which should be not null or empty
      height - the image's height
      width - the image's width
      estimatedResolutionLevel - the image's estimated resolution level, which must not be null
      Throws:
      NullPointerException - if estimatedResolutionLevel is null
  • Method Details

    • getUrl

      @Nonnull public String getUrl()
      Get the URL of this Image.
      Returns:
      the Image's URL.
    • getHeight

      public int getHeight()
      Get the height of this Image.

      If it is unknown, HEIGHT_UNKNOWN is returned instead.

      Returns:
      the Image's height or HEIGHT_UNKNOWN
    • getWidth

      public int getWidth()
      Get the width of this Image.

      If it is unknown, WIDTH_UNKNOWN is returned instead.

      Returns:
      the Image's width or WIDTH_UNKNOWN
    • getEstimatedResolutionLevel

      @Nonnull public Image.ResolutionLevel getEstimatedResolutionLevel()
      Get the estimated resolution level of this image.

      If it is unknown, Image.ResolutionLevel.UNKNOWN is returned instead.

      Returns:
      the estimated resolution level, which is never null
      See Also:
    • toString

      @Nonnull public String toString()
      Get a string representation of this Image instance.

      The representation will be in the following format, where url, height, width and estimatedResolutionLevel represent the corresponding properties:

      Image {url=url, height='height, width=width, estimatedResolutionLevel=estimatedResolutionLevel}'

      Overrides:
      toString in class Object
      Returns:
      a string representation of this Image instance