https://vk.com/dev/objects/photo
160152
def from_json(cls, session, photo_json):
        
        photo = cls()
        photo.id = photo_json.get('id')
        photo.album_id = photo_json.get('album_id')
        photo.owner_id = photo_json.get('owner_id')
        photo.user_id = photo_json.get('user_id')
        photo.text = photo_json.get('text')
        photo.type = "photo"
        photo.date = photo_json.get('date')
        photo.photo_75 = photo_json.get('photo_75')
        photo.photo_130 = photo_json.get('photo_130')
        photo.photo_604 = photo_json.get('photo_604')
        photo.photo_807 = photo_json.get('photo_807')
        photo.photo_1280 = photo_json.get('photo_1280')
        photo.photo_2560 = photo_json.get('photo_2560')
        photo._session = session
        return photo
590103
def download_photo_async(photo):
    
    photo_id = photo['id']
    photo_title = photo['title']
    download_url = get_photo_url(photo_id)
    photo_format = download_url.split('.')[-1]
    photo_title = photo_title + '.' + photo_format
    file_path = directory + os.sep + photo_title
    logger.info('Download %s...', photo_title.encode('utf-8'))
    req = [grequests.get(download_url)]
    counter_lock = multiprocessing.Lock()
    for resp in grequests.map(req):
        with open(file_path, 'w') as f:
            f.write(resp.content)
            with counter_lock:
                global counter
                counter -= 1
        logger.info(
            'The number of pictures remaining: %s', counter
        )
33295
def image_get(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_operator_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.get_image(**kwargs)
648648
function(source, callback) {
        var url = this.getSignedResourceUrl('POST', this.getImagesUrl()),
            isFile = isBrowser && source instanceof window.File,
            onComplete = callback.onComplete || callback,
            onProgress = callback.onProgress || null;

        request({
            method: 'POST',
            uri: url,
            body: source,
            headers: {
                'Accept': 'application/json',
                'User-Agent': 'imboclient-js',
                'Content-Length': isFile ? source.size : source.length
            },
            onComplete: function(err, res, body) {
                body = jsonparse(body);
                onComplete(err, body ? body.imageIdentifier : null, body, res);
            },
            onProgress: onProgress
        });

        return this;
    }
756993
function diffImage(existing, proposed, options) {
  let { bytes, dateformat, imageSize, Table, toFile, colors } = utils;

  existing = toFile(existing, options);
  proposed = toFile(proposed, options);

  let table = new Table({ head: ['Attribute', 'Existing', 'Replacement', 'Diff'] });
  let dimensionsA = imageSize(existing.path);
  let dimensionsB = imageSize(proposed.path);
  let statA = existing.stat;
  let statB = proposed.stat;

  let isSmaller = existing.size > proposed.size;
  let sizeDiff = isSmaller ? '-' : '+';
  sizeDiff += bytes(Math.abs(existing.size - proposed.size));

  // dates
  let mtimeA = statA ? dateformat(statA.mtime) : 'New';
  let mtimeB = statB ? dateformat(statB.mtime) : 'New';
  if (statA.mtime && statB.mtime && statA.mtime < statB.mtime) {
    mtimeB = colors.green(mtimeB);
  } else {
    mtimeA = colors.green(mtimeA);
  }

  let birthtimeA = statA ? dateformat(statA.birthtime) : 'New';
  let birthtimeB = statB ? dateformat(statB.birthtime) : 'New';
  if (statA.birthtime && statB.birthtime && statA.birthtime < statB.birthtime) {
    birthtimeB = colors.green(birthtimeB);
  } else {
    birthtimeA = colors.green(birthtimeA);
  }

  // size
  let sizeA = bytes(existing.size);
  let sizeB = bytes(proposed.size);

  if (isSmaller) {
    sizeDiff = colors.red(sizeDiff);
    dimensionsA = colors.green(dimensionsA);
    sizeA = colors.green(sizeA);
  } else {
    sizeDiff = colors.green(sizeDiff);
    dimensionsB = colors.green(dimensionsB);
    sizeB = colors.green(sizeB);
  }

  table.push(['Path', existing.relative, proposed.relative, '']);
  table.push(['Size', sizeA, sizeB, sizeDiff]);
  table.push(['Dimensions', dimensionsA, dimensionsB, 'N/A']);
  table.push(['Date created', birthtimeA, birthtimeB, 'N/A']);
  table.push(['Date modified', mtimeA, mtimeB, 'N/A']);
  return table.toString();
}
865994
def attach_photo(self, photo: typing.Union[InputMediaPhoto, base.InputFile],
                     caption: base.String = None):
        
        if not isinstance(photo, InputMedia):
            photo = InputMediaPhoto(media=photo, caption=caption)
        self.attach(photo)
564504
def thumb(self, obj):
        
        format, created = Format.objects.get_or_create(name='newman_thumb',
                                                       defaults={
            'max_width': 100,
            'max_height': 100,
            'flexible_height': False,
            'stretch': False,
            'nocrop': True,
        })

        if created:
            format.sites = Site.objects.all()

        info = obj.get_formated_photo(format)

        return '<a href="%(href)s"><img src="%(src)s"></a>' % {
            'href': '%s/' % obj.pk,
            'src': info['url']
        }
32626
function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
    {
        /** http://www.flickr.com/services/api/flickr.photos.notes.add.html */
        $this->request("flickr.photos.notes.add", array("photo_id" => $photo_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE);
        return $this->parsed_response ? $this->parsed_response['note'] : false;
    }
597495
def _get_album_or_image(json, imgur):
    """"""
    if json['is_album']:
        return Gallery_album(json, imgur, has_fetched=False)
    return Gallery_image(json, imgur)
1294674
def image_url(self):
        """"""
        return construct_api_url(self.input, 'image', self.resolvers, False, self.get3d, False, **self.kwargs)
788518
private String parsePhotoId(GraphObject graphObject) {
        String photoId = null;

        if (graphObject != null) {
            JSONObject jsonObject = graphObject.getInnerJSONObject();
            if (jsonObject != null) {
                photoId = jsonObject.optString(SHARE_KEY_PHOTO_ID, null);
            }
        }
        return photoId;
    }
900964
function contact_photo($args)
    {
        // pre-conditions, exit if photo already exists or invalid input
        if (!empty($args['url']) || !empty($args['data'])
            || (empty($args['record']) && empty($args['email']))
        ) {
            return $args;
        }

        $rcmail = rcmail::get_instance();

        // supporting edit/add action may be tricky, let's not do this
        if ($rcmail->action == 'show' || $rcmail->action == 'photo') {
            $email = $args['email'];
            if (!$email && $args['record']) {
                $addresses = rcube_addressbook::get_col_values('email', $args['record'], true);
                if (!empty($addresses)) {
                    $email = $addresses[0];
                }
            }

            if ($email) {
                require_once __DIR__ . '/identicon_engine.php';

                $identicon = new identicon_engine($email);

                if ($rcmail->action == 'show') {
                    // set photo URL using data-uri
                    if (($icon = $identicon->getBinary()) && ($icon = base64_encode($icon))) {
                        $mimetype    =$identicon->getMimetype();
                        $args['url'] = sprintf('data:%s;base64,%s', $mimetype, $icon);
                    }
                }
                else {
                    // send the icon to the browser
                    $identicon = new identicon_engine($email);
                    if ($identicon->sendOutput()) {
                        exit;
                    }
                }
            }
        }

        return $args;
    }
385338
def upload(self, photo_file, **kwds):
        
        with open(photo_file, 'rb') as in_file:
            result = self._client.post("/photo/upload.json",
                                       files={'photo': in_file},
                                       **kwds)["result"]
        return Photo(self._client, result)
423786
def photo(self):
        
        if isinstance(self.result, types.BotInlineResult):
            return self.result.thumb
        elif isinstance(self.result, types.BotInlineMediaResult):
            return self.result.photo
611271
function toDataURL (image, options) {
  var src = '';
  var async, callback;

  options = options || {};

  async = typeof options.callback === 'function';

  callback = async ? options.callback : function (err, data) {
    if (err) {
      throw err;
    }
    return data;
  };

  function _convert (err, img) {
    if (err) {
      return callback(err);
    }
    var result;
    cors(img);
    result = convert(img, options.width, options.height);
    return callback(null, (options.purify ? purify(result) : result));
  }

  if (isImage(image)) {
    src = image.src || '';
  } else if (typeof image === 'string') {
    if (!async) {
      return callback(new Error('the url mode should be called with a callback'));
    }
    src = image;
  } else {
    return callback(new Error('image should be an Image Object or a string'));
  }

  return async ? createImage(src, _convert) : _convert(null, image);
}
516115
def searchPhotos(self, title, **kwargs):
        
        return self.search(libtype='photo', title=title, **kwargs)
602785
function postImage(options, filename, headers, cb) {
    Step(
        function readImage() {
            fs.readFile(filename, this);
        },
        function(err, filecontents) {
            if (err) {
                console.log('Unable to read file', __dirname);
                return;
            }
            postData(null, [{
                type: 'image/jpeg',
                keyname: 'image',
                valuename: 'image.jpg',
                data: filecontents
            }], options, headers, this);
        },
        function(err, response, body) {
            cb && cb(err, response);
            console.log("response code " + response.statusCode, ", body is : ", body);
        }
    );
}