Tries to load a photo and add it to the vCard
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
941403
public void addFile(String filename, VCFHeader vcfHeader, String studyId) {
        // sanity check
        if (StringUtils.isEmpty(filename)) {
            logger.error("VCF filename is empty or null: '{}'", filename);
            return;
        }
        if (vcfHeader == null) {
            logger.error("VCF header is missingDataset not found. Check your study ID: '{}'", studyId);
            return;
        }

        VCFHeaderToVariantFileHeaderConverter headerConverter = new VCFHeaderToVariantFileHeaderConverter();
        VariantFileMetadata variantFileMetadata = new VariantFileMetadata();
        variantFileMetadata.setId(filename);
        variantFileMetadata.setSampleIds(vcfHeader.getSampleNamesInOrder());
        variantFileMetadata.setHeader(headerConverter.convert(vcfHeader));
        addFile(variantFileMetadata, studyId);
    }
206155
public T photos_upload(File photo)
    throws FacebookException, IOException {
    return photos_upload(photo, /*caption*/ null, /*albumId*/ null) ;
  }
514039
public void load() {
		int resp = loadChooser.showOpenDialog(this);
		if (resp == JFileChooser.APPROVE_OPTION) {
			lastSelected = loadChooser.getSelectedFile();
			saveChooser.setCurrentDirectory(loadChooser.getCurrentDirectory());
			try {
				BufferedImage image = ImageIO.read(lastSelected);
				imagePanel.setImage(image);
			} catch (Exception e) {
				e.printStackTrace();
				JOptionPane.showMessageDialog(this, "Unable to load image "+lastSelected.getName()+" ");
			}
		}
	}
689129
def load_image(self, imagepath, width=None, height=None):
        """"""

        if width:
            self.width = width
            self.canvas["width"] = width
        if height:
            self.height = height
            self.canvas["height"] = height

        self.image = imagepath
        size = (self.width, self.height)
        load_image(self.canvas, self.image, bounds=size)
        self.canvas.update_idletasks()
777760
def load_roller_shutter(self, item):
        """"""
        rollershutter = RollerShutter.from_config(self.pyvlx, item)
        self.add(rollershutter)
49568
function addPngFromFile( $file, $x, $y, $w = 0, $h = 0 )
    {
        // read in a png file, interpret it, then add to the system
        $error = 0;
        $fp = @fopen( $file, 'rb' );
        if ( $fp )
        {
            $data = '';
            while ( !feof( $fp ) )
            {
                $data .= fread( $fp, 1024 );
            }
            fclose( $fp );
        }
        else
        {
            $error = 1;
            $errormsg = 'trouble opening file: '.$file;
        }

        if ( !$error )
        {
            $header = chr(137).chr(80).chr(78).chr(71).chr(13).chr(10).chr(26).chr(10);
            if ( substr( $data, 0, 8 ) != $header )
            {
                $error = 1;
                $errormsg = 'this file does not have a valid header';
            }
        }

        if ( !$error )
        {
            // set pointer
            $p = 8;
            $len = strlen($data);
            // cycle through the file, identifying chunks
            $haveHeader = 0;
            $info = array();
            $idata = '';
            $pdata = '';
            while ( $p < $len )
            {
                $chunkLen = $this->PRVT_getBytes($data,$p,4);
                $chunkType = substr($data,$p+4,4);
                //echo $chunkType.' - '.$chunkLen.'<br>';

                switch ( $chunkType )
                {
                case 'IHDR':
                    // this is where all the file information comes from
                    $info['width'] = $this->PRVT_getBytes( $data, $p+8, 4 );
                    $info['height'] = $this->PRVT_getBytes( $data, $p+12, 4);
                    $info['bitDepth'] = ord( $data[$p+16] );
                    $info['colorType'] = ord( $data[$p+17] );
                    $info['compressionMethod'] = ord( $data[$p+18] );
                    $info['filterMethod'] = ord( $data[$p+19] );
                    $info['interlaceMethod'] = ord( $data[$p+20] );
                    //print_r($info);
                    $haveHeader = 1;
                    if ( $info['compressionMethod'] != 0 )
                    {
                        $error = 1;
                        $errormsg = 'unsupported compression method';
                    }
                    if ( $info['filterMethod'] != 0 )
                    {
                        $error = 1;
                        $errormsg = 'unsupported filter method';
                    }
                    break;

                case 'PLTE':
                    $pdata .= substr( $data, $p + 8, $chunkLen );
                    break;
                case 'IDAT':
                    $idata .= substr( $data, $p + 8, $chunkLen );
                    break;
                case 'tRNS':
                    //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
                    //print "tRNS found, color type = ".$info['colorType']."<BR>";
                    $transparency = array();
                    if ( $info['colorType'] == 3 )
                    {
                        // indexed color, rbg
                        /* corresponding to entries in the plte chunk
                        Alpha for palette index 0: 1 byte
                        Alpha for palette index 1: 1 byte
                        ...etc...
                        */
                        // there will be one entry for each palette entry. up until the last non-opaque entry.
                        // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent)
                        $transparency['type'] = 'indexed';
                        $numPalette = strlen($pdata)/3;
                        $trans = 0;
                        for ( $i = $chunkLen; $i >= 0; $i-- )
                        {
                            if ( ord( $data[$p+8+$i] ) == 0 )
                            {
                                $trans = $i;
                            }
                        }
                        $transparency['data'] = $trans;

                    }
                    elseif ( $info['colorType'] == 0 )
                    {
                        // grayscale
                        /* corresponding to entries in the plte chunk
                         Gray: 2 bytes, range 0 .. (2^bitdepth)-1
                        */
                        //$transparency['grayscale']=$this->PRVT_getBytes($data,$p+8,2); // g = grayscale
                        $transparency['type'] = 'indexed';
                        $transparency['data'] = ord( $data[$p+8+1] );

                    }
                    elseif ( $info['colorType'] == 2)
                    {
                        // truecolor
                        /* corresponding to entries in the plte chunk
                        Red: 2 bytes, range 0 .. (2^bitdepth)-1
                        Green: 2 bytes, range 0 .. (2^bitdepth)-1
                        Blue: 2 bytes, range 0 .. (2^bitdepth)-1
                        */
                        $transparency['r'] = $this->PRVT_getBytes( $data, $p+8, 2 ); // r from truecolor
                        $transparency['g'] = $this->PRVT_getBytes( $data, $p+10 ,2 ); // g from truecolor
                        $transparency['b'] = $this->PRVT_getBytes( $data, $p+12 ,2 ); // b from truecolor
                    }
                    else
                    {
                        //unsupported transparency type
                    }
                    // KS End new code
                    break;
                default:
                    break;
                }

                $p += $chunkLen+12;
            }

            if ( !$haveHeader )
            {
                $error = 1;
                $errormsg = 'information header is missing';
            }
            if ( isset( $info['interlaceMethod']) && $info['interlaceMethod'] )
            {
                $error = 1;
                $errormsg = 'There appears to be no support for interlaced images in pdf.';
            }
        }

        if ( !$error && $info['bitDepth'] > 8 )
        {
            $error = 1;
            $errormsg = 'only bit depth of 8 or less is supported';
        }

        if ( !$error )
        {
            if ( $info['colorType'] != 2 && $info['colorType'] != 0 && $info['colorType'] != 3 )
            {
                $error = 1;
                $errormsg = 'transparancey alpha channel not supported, transparency only supported for palette images.';
            }
            else
            {
                switch ( $info['colorType'] )
                {
                case 3:
                    $color = 'DeviceRGB';
                    $ncolor = 1;
                    break;
                case 2:
                    $color = 'DeviceRGB';
                    $ncolor = 3;
                    break;
                case 0:
                    $color = 'DeviceGray';
                    $ncolor = 1;
                    break;
                }
            }
        }
        if ( $error )
        {
            eZDebug::writeError( 'Adding PNG file, '. $file .', to PDF failed: '.$errormsg, 'Cpdf::addPngFromFile' );
            $this->addMessage('PNG error - ('.$file.') '.$errormsg);
            return false;
        }
        if ( $w == 0 )
        {
            $w = $h/$info['height'] * $info['width'];
        }
        if ( $h == 0 )
        {
            $h = $w * $info['height'] / $info['width'];
        }
        //print_r($info);
        // so this image is ok... add it in.
        $this->numImages++;
        $im = $this->numImages;
        $label = 'I'.$im;
        $this->numObj++;
    //  $this->o_image($this->numObj,'new',array('label'=>$label,'data'=>$idata,'iw'=>$w,'ih'=>$h,'type'=>'png','ic'=>$info['width']));
        $options = array( 'label' => $label,
                          'data' => $idata,
                          'bitsPerComponent' => $info['bitDepth'],
                          'pdata' => $pdata,
                          'iw' => $info['width'],
                          'ih' => $info['height'],
                          'type' => 'png',
                          'color' => $color,
                          'ncolor' => $ncolor );

        if ( isset( $transparency ) )
        {
            $options['transparency'] = $transparency;
        }
        $this->o_image( $this->numObj, 'new', $options );

        $this->objects[$this->currentContents]['c'].="\nq";
        $this->objects[$this->currentContents]['c'].="\n".sprintf('%.3F',$w)." 0 0 ".sprintf('%.3F',$h)." ".sprintf('%.3F',$x)." ".sprintf('%.3F',$y)." cm";
        $this->objects[$this->currentContents]['c'].="\n/".$label.' Do';
        $this->objects[$this->currentContents]['c'].="\nQ";
    }
724200
def OnInsertBitmap(self, event):
        """"""

        key = self.grid.actions.cursor
        # Get file name

        wildcard = _("Bitmap file") + " (*)|*"
        if rsvg is not None:
            wildcard += "|" + _("SVG file") + " (*.svg)|*.svg"

        message = _("Select image for current cell")
        style = wx.OPEN | wx.CHANGE_DIR
        filepath, index = \
            self.grid.interfaces.get_filepath_findex_from_user(wildcard,
                                                               message, style)
        if index == 0:
            # Bitmap loaded
            try:
                img = wx.EmptyImage(1, 1)
                img.LoadFile(filepath)
            except TypeError:
                return

            if img.GetSize() == (-1, -1):
                # Bitmap could not be read
                return

            code = self.grid.main_window.actions.img2code(key, img)

        elif index == 1 and rsvg is not None:
            # SVG loaded
            with open(filepath) as infile:
                try:
                    code = infile.read()
                except IOError:
                    return
                if is_svg(code):
                    code = 'u"""' + code + '"""'
                else:
                    # Does not seem to be an svg file
                    return

        else:
            code = None

        if code:
            self.grid.actions.set_code(key, code)
362644
def add_image(self, batch_id, image_id, image_properties=None):
    """"""
    if batch_id not in self._data:
      raise KeyError('Batch with ID "{0}" does not exist'.format(batch_id))
    if image_properties is None:
      image_properties = {}
    if not isinstance(image_properties, dict):
      raise ValueError('image_properties has to be dict, however it was: '
                       + str(type(image_properties)))
    self._data[batch_id]['images'][image_id] = image_properties.copy()
1259468
def render_pictures(context, selection='recent', amount=3):
    """"""
    pictures = Image.objects.filter(
        folder__id__in=Gallery.objects.filter(is_published=True).values_list(
            'folder__pk', flat=True))
    if selection == 'recent':
        context.update({
            'pictures': pictures.order_by('-uploaded_at')[:amount]
        })
    elif selection == 'random':
        context.update({
            'pictures': pictures.order_by('?')[:amount]
        })
    else:
        return None
    return context
722601
public void setPhoto(Photo photo) {
        PhotoType type = photo.getType();
        if (postType != null && !postType.equals(type)) {
            throw new IllegalArgumentException("Photos must all be the same type (source or data)");
        } else if (postType == PhotoType.SOURCE && pendingPhotos.size() > 0) {
            throw new IllegalArgumentException("Only one source URL can be provided");
        }
        pendingPhotos = new ArrayList<Photo>();
        pendingPhotos.add(photo);
        this.postType = type;
    }
162790
def add_files(session, imagedir, verbose):
  """"""

  def add_file(session, basename, userid, shotid, sessionid):
    """Parse a single filename and add it to the list."""
    session.add(File(userid, basename, sessionid, shotid))

  filenames = os.listdir(imagedir)
  for filename in filenames:
    basename, extension = os.path.splitext(filename)
    if extension == db_file_extension:
      if verbose>1: print("  Adding file '%s'..." % (basename))
      parts = string.split(basename, "_")
      ctype = parts[0]
      shotid = int(parts[2])
      userid = ctype + '_%d' % int(parts[1])
      if parts[0] == "Impostor":
        sessionid = 3
      elif parts[0] == "Genuine" and shotid <= 6:
        sessionid = 1
      elif parts[0] == "Genuine" and shotid > 6:
        sessionid = 2
        shotid = shotid - 6
      add_file(session, basename, userid, shotid, sessionid)
1200338
function(callback) {
		
		if(!this.ifLoad) {
			this.history.push('add to stack task: jpegToData');
			this.stack(this.jpegToData, callback);
			return;
		} 
		
		var that = this;
		
		this.history.push('jpeg decode');
		var jpeg = new this.jpeg_node();

		jpeg.parse(new Uint8Array(this.data));
		jpeg.decode(function(pixels) {
			that.width = jpeg.width;
			that.height = jpeg.height;
			that.bpp = 4;
			that.data = pixels;
			callback.call(that);
		});
	}
862311
def LoadImage(filename):
    ''''''
    app_dir = os.path.dirname(os.path.realpath(__file__))
    path = os.path.join(app_dir, 'images', filename)
    return Tkinter.PhotoImage(file=path)
9010
def _load_bitmap(filename):
    

    basedir = os.path.join(rcParams['datapath'],'images')

    bmpFilename = os.path.normpath(os.path.join(basedir, filename))
    if not os.path.exists(bmpFilename):
        raise IOError('Could not find bitmap file "%s"; dying'%bmpFilename)

    bmp = wx.Bitmap(bmpFilename)
    return bmp
229502
function (successCallback, errorCallback) {
            try {
                createCameraUI();
                startCameraPreview(
                    // Callback for Take button - captures intermediate image file.
                    function () {
                        var encodingProperties = Windows.Media.MediaProperties.ImageEncodingProperties.createJpeg(),
                            overwriteCollisionOption = Windows.Storage.CreationCollisionOption.replaceExisting,
                            tempFolder = Windows.Storage.ApplicationData.current.temporaryFolder;

                        tempFolder.createFileAsync("cameraCaptureImage.jpg", overwriteCollisionOption).done(function (capturedFile) {
                            capture.capturePhotoToStorageFileAsync(encodingProperties, capturedFile).done(function () {
                                // store intermediate result in object's global variable
                                capturedPictureFile = capturedFile;
                                // show pre-captured image and toggle visibility of all buttons
                                previewContainer.style.backgroundImage = 'url("' + 'ms-appdata:///temp/' + capturedFile.name + '")';
                                toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                            }, function (err) {
                                destroyCameraPreview();
                                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                            });
                        }, function (err) {
                            destroyCameraPreview();
                            errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, err);
                        });
                    },
                    // error + cancel callback
                    function (err) {
                        destroyCameraPreview();
                        errorCallback(err);
                    },
                    // Callback for Select button - copies intermediate file into persistent application's storage
                    function () {
                        var generateUniqueCollisionOption = Windows.Storage.CreationCollisionOption.generateUniqueName,
                            localFolder = Windows.Storage.ApplicationData.current.localFolder;

                        capturedPictureFile.copyAsync(localFolder, capturedPictureFile.name, generateUniqueCollisionOption).done(function (copiedFile) {
                            destroyCameraPreview();
                            successCallback(copiedFile);
                        }, function(err) {
                            destroyCameraPreview();
                            errorCallback(err);
                        });
                    },
                    // Callback for retake button - just toggles visibility of necessary elements
                    function () {
                        toggleElements('capturePreview', 'takePicture', 'cancelCapture', 'selectPicture', 'retakePicture');
                    }
                );
            } catch (ex) {
                destroyCameraPreview();
                errorCallback(CaptureError.CAPTURE_INTERNAL_ERR, ex);
            }
        }
1024263
def add(image_path, file_name=None):
    """"""
    if file_name is not None:
        dst_path = os.path.join(IMG_DIR, str(Path(file_name).stem + Path(image_path).suffix))
    else:
        dst_path = IMG_DIR

    if os.path.isfile(image_path):
        shutil.copy2(image_path, dst_path)