Add a photo to specific picasa web album
@param [file] $photo [uploaded photo file object]
17847
function addPhoto($photo) {
        if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) {
            $o = array('state' => false); 
        } else {
            
            $photos = new Zend_Gdata_Photos($this->client);
            
            $fd = $photos->newMediaFileSource($photo["tmp_name"]);
            $fd->setContentType($photo["type"]);
            
            $entry = new Zend_Gdata_Photos_PhotoEntry();
            $entry->setMediaSource($fd);
            $entry->setTitle($photos->newTitle($photo["name"]));
            
            $albumQuery = new Zend_Gdata_Photos_AlbumQuery;
            $albumQuery->setUser($this->user);
            $albumQuery->setAlbumId($this->album);
            
            $albumEntry = $photos->getAlbumEntry($albumQuery);
            
            $result = $photos->insertPhotoEntry($entry, $albumEntry);
            if ($result) {
                $o = array('state' => true, 'id' => $result->getGphotoId());                 
            } else {
                $o = array('state' => false); 
            }            
        }
        return $o;
    }
485034
public function upload($file, $format = 'json', $album = null, $name = null, $title = null, $description = null)
	{
		return $this->post('https://api.imgur.com/3/image.' . $format, array(
			'image' => $file,
			'album' => $album,
			'name' => $name,
			'title' => $title,
			'description' => $description
		), array(
			'Authorization: Client-ID ' . $this->key
		));
	}
292414
public function setPhoto($src, $href = null)
    {
        if (isset($href)) {
            $this->photo = new Link(new Image($src), $href);
        } else {
            $this->photo = new Image($src);
        }

        return $this;
    }
1315830
def add_pic(self, post_data):
        '''
        
        '''
        img_entity = self.request.files['file'][0]
        filename = img_entity["filename"]

        if filename and allowed_file(filename):
            pass
        else:
            return False

        _, hou = os.path.splitext(filename)
        signature = str(uuid.uuid1())
        outfilename = '{0}{1}'.format(signature, hou)
        outpath = 'static/upload/{0}'.format(signature[:2])
        if os.path.exists(outpath):
            pass
        else:
            os.makedirs(outpath)
        with open(os.path.join(outpath, outfilename), "wb") as fileout:
            fileout.write(img_entity["body"])
        path_save = os.path.join(signature[:2], outfilename)
        sig_save = os.path.join(signature[:2], signature)

        imgpath = os.path.join(outpath, signature + '_m.jpg')
        imgpath_sm = os.path.join(outpath, signature + '_sm.jpg')

        ptr_image = Image.open(os.path.join('static/upload', path_save))
        tmpl_size = (768, 768)
        thub_size = (256, 256)
        (imgwidth, imgheight) = ptr_image.size
        if imgwidth < tmpl_size[0] and imgheight < tmpl_size[1]:
            tmpl_size = (imgwidth, imgheight)
        ptr_image.thumbnail(tmpl_size)

        im0 = ptr_image.convert('RGB')
        im0.save(imgpath, 'JPEG')

        im0.thumbnail(thub_size)
        im0.save(imgpath_sm, 'JPEG')

        create_pic = MEntity.create_entity(signature,
                                           path_save,
                                           post_data['desc'] if 'desc' in post_data else '',
                                           kind=post_data['kind'] if 'kind' in post_data else '1')
        if self.entity_ajax == False:
            self.redirect('/entity/{0}_m.jpg'.format(sig_save))
        else:
            if create_pic:
                output = {'path_save': imgpath}
            else:
                output = {'path_save': ''}
            return json.dump(output, self)
1286770
function groups_pools_add ($photo_id, $group_id)
    {
        /** http://www.flickr.com/services/api/flickr.groups.pools.add.html */
        $this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
        return $this->parsed_response ? true : false;
    }
531671
def addPhoto(self, photo):
        
        method = 'flickr.photosets.addPhoto'

        _dopost(method, auth=True, photoset_id=self.id, photo_id=photo.id)

        self.__count += 1
        return True
444278
function favorites_add ($photo_id)
    {
        /** http://www.flickr.com/services/api/flickr.favorites.add.html */
        $this->request('flickr.favorites.add', array('photo_id'=>$photo_id), TRUE);
        return $this->parsed_response ? true : false;
    }
1312036
protected function storeAsImage(UploadedFile $file, array $data)
    {
        // Store uploaded image, to work it.
        $this->storeAsFile($file, $data);

        // Prepare local variables.
        $properties = [];
        $disk = $this->storageDisk($data['disk']);
        $path_prefix = $data['type'].DS.$data['category'].DS;
        $path_suffix = DS.$data['name'].'.'.$data['extension'];
        $quality = setting('files.images_quality', 75);
        $is_convert = setting('files.images_is_convert', true);

        // Resave original file.
        $image = $this->imageResave(
            $this->getAbsolutePathAttribute(),
            $disk->path($path_prefix.trim($path_suffix, DS)),
            setting('files.images_max_width', 3840),
            setting('files.images_max_height', 2160),
            $quality, $is_convert
        );

        if ($image) {
            // If extension has changed, then delete original file.
            if ($data['extension'] != $image['extension']) {
                $disk->delete($this->path);
            }

            // Revision attributes.
            $this->attributes['mime_type'] = $image['mime_type'];
            $this->attributes['extension'] = $image['extension'];
            $this->attributes['filesize'] = $image['filesize'];
            $properties = [
                'width' => $image['width'],
                'height' => $image['height'],
            ];

            $path_suffix = DS.$data['name'].'.'.$image['extension'];
        }

        // Cutting images.
        foreach ($this->thumbSizes() as $key => $value) {
            @$disk->makeDirectory($path_prefix.$key);
            $image = $this->imageResave(
                $this->getAbsolutePathAttribute(),
                $disk->path($path_prefix.$key.$path_suffix),
                setting('files.images_'.$key.'_width', $value),
                setting('files.images_'.$key.'_height', $value),
                $quality, $is_convert
            );

            if (! $image) break;

            // Add to options.
            $properties += [
                $key => [
                    'width' => $image['width'],
                    'height' => $image['height'],
                    'filesize' => $image['filesize'],
                ]
            ];
        }

        return $this->setAttribute('properties', $properties);
    }
1155771
def replace(self, photo_file, **kwds):
        
        result = self._client.photo.replace(self, photo_file, **kwds)
        self._replace_fields(result.get_fields())
146925
public function addImage(Image $image)
    {
        // Find the image based on UUID inside the internal state.
        $existingImage = $this->images->findImageByUUID($image->getMediaObjectId());

        if ($existingImage === null) {
            $this->apply(
                $this->createImageAddedEvent($image)
            );
        }
    }
972489
public function removePhoto($photo)
    {
        $photos = AnHelperArray::getIterator($photo);

        foreach ($photos as $photo) {
            if ($edge = $this->photos->find($photo)) {
                $edge->delete();
            }
        }
    }
823879
protected function _actionUpdatephotos($context)
    {
        $this->execute('addphoto', $context);
        $photo_ids = (array) AnConfig::unbox($context->data->photo_id);

        foreach ($this->getItem()->photos as $photo) {
            if (!in_array($photo->id, $photo_ids)) {
                $this->getItem()->removePhoto($photo);
            }
        }

        return $this->getItem();
    }
332701
def _add_photo(self, card, name):
        """"""
        try:
            photo_file = join(dirname(self._filename), 'photo/%s.jpeg' % name)
            jpeg = open(photo_file, 'rb').read()
            photo = card.add('photo')
            photo.type_param = 'jpeg'
            photo.encoding_param = 'b'
            photo.value = jpeg
        except IOError:
            pass
1077082
public static function upload($file)
    {
        $photo = self::create();

        $image_manager = new ImageManager(['driver' => 'imagick']);

        $disk = Storage::disk(config('mustard.storage.disk', 'local'));

        if (!file_exists($file)) {
            RuntimeException("File $file does not exist");
        }

        $dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
        $quality = config('mustard.storage.photo.quality', 90);

        $disk->makeDirectory($dest_dir);

        $photo_id = $photo->getKey();

        Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
            if (!file_exists($file)) {
                RuntimeException("File $file no longer exists");
            }

            $image_manager = new ImageManager(['driver' => 'imagick']);

            $disk = Storage::disk(config('mustard.storage.disk', 'local'));

            if ($file != "$dest_dir/$photo_id.jpg") {
                $image = $image_manager->make($file);

                $disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));

                $image->destroy();
            }

            $image = $image_manager->make($file)->heighten(83);

            $disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));

            $image->destroy();

            $image = $image_manager->make($file)->widen(500);

            $disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));

            $image->destroy();

            $photo = Photo::find($photo_id);

            $photo->processed = true;

            $photo->save();

            $job->delete();
        });

        return $photo;
    }
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)
221395
public function add_stored_file($file) {
        if (is_numeric($file)) {
            $this->files[$file] = $file;
        } else {
            $this->files[$file->get_id()] = $file;
        }
    }
1267269
public function setPhoto($photo)
	{
		if (is_string($photo)) {
			$this->photo = $photo;
		} else if (is_resource($photo)) {
			$this->addMultipart("photo", $photo);
			$this->photo = "attach://photo";
		} else if ($photo instanceof InputFile) {
			$this->addMultipart("photo", $photo->getFile());
			$this->photo = "attach://photo";
		}
	}