util

util / SmartImageDownloader / 0.2.20

README.md

1. Introduction

The smart image downloader generates data API download links for given URLs.

In many cases end-users provide non-direct links to the images themselves (like the webpage that has the image instead), and behave the service (website) to expect to recognize the image in the URL. This algorithm detects the image in a wide range domains (web services), and saves the image to the data API.

For some websites, it also parses album photos, hence it may return multiple data API URLs, if multiple images exist in the given webpage.

List of Supported Web Sites:

  • Imgur: images & albums
  • Dropbox: images & albums
  • Twitter: image tweets
  • Flickr: images & albums
  • Box: images & albums
  • Google Photos: images & albums
  • Google Drive: images & albums
  • Pinterest: pins & boards
  • 500px: images
  • Wikipedia: images
  • Imageshack: images
  • 4chan: post images
  • Instagram: images & albums

Input:

  • (Required): Website Url.
  • (Optional): Resize image (width, height or max dimension)
  • (Optional): Image format (png, jpg, bmp, etc.)

Output:

  • List of data API image link(s).
  • Original Image Dimensions.
  • Resized Image Dimensions. (only if image is resized)

Examples

Example 1.

Parameter 1: Wikipedia image web page link.

{
  "image": "https://en.wikipedia.org/wiki/Barack_Obama#/media/File:President_Barack_Obama.jpg"
}

Output:

{
  "originalDimensions": [
    {
      "height": 3356,
      "width": 2687
    }
  ],
  "savePath": [
    "data://.algo/util/SmartImageDownloader/temp/418ff024-dbb3-42eb-8e4d-3084b3dba00d.jpg"
  ]
}

Example 2

Parameter 1. Wikipedia image web page link.

Parameter 2. Image resizing settings.

{
  "image": "https://en.wikipedia.org/wiki/Barack_Obama#/media/File:President_Barack_Obama.jpg",
  "resize": {
    "width": 512,
    "height": 512
  }
}

Output:

{
  "originalDimensions": [
    {
      "height": 3356,
      "width": 2687
    }
  ],
  "resizedDimensions": [
    {
      "height": 512,
      "width": 512
    }
  ],
  "savePath": [
    "data://.algo/util/SmartImageDownloader/temp/7ebeeaf6-66b1-4d71-b7f6-a08dfcf0d89c.jpg"
  ]
}

Example 3

Parameter 1. Wikipedia image web page link.

Parameter 2. Image format setting.

{
  "image": "https://en.wikipedia.org/wiki/Barack_Obama#/media/File:President_Barack_Obama.jpg",
  "format": "png"
}

Output:

{
  "originalDimensions": [
    {
      "height": 3356,
      "width": 2687
    }
  ],
  "savePath": [
    "data://.algo/util/SmartImageDownloader/temp/8d0a406c-de5e-45e2-8b54-0f6ff60a825c.png"
  ]
}

Example 4

Parameter 1. Wikipedia image web page link.

Parameter 2. Max dimension for image resizing (autoscales according to largest side -width or height-). eg. if 600, larger side becomes 1200, other side scales according to width/height ratio.

{
  "image": "https://en.wikipedia.org/wiki/Barack_Obama#/media/File:President_Barack_Obama.jpg",
  "resize": 600
}

Output:

{
  "originalDimensions": [
    {
      "height": 3356,
      "width": 2687
    }
  ],
  "resizedDimensions": [
    {
      "height": 600,
      "width": 480
    }
  ],
  "savePath": [
    "data://.algo/util/SmartImageDownloader/temp/81917ff3-9b07-4694-b3e2-f260b162da8f.jpg"
  ]
}