See the FileProvider example in https://developer.android.com/training/camera/photobasics
972178
public static Uri getUriForInternalMedia(Context context, File file) {
        String authority = context.getPackageName() + ".fileprovider";
        return FileProvider.getUriForFile(context, authority, file);
    }
133751
def doorient(self):
        
        assert self.cal1Dfn.is_file(
        ), 'please specify filename for each camera under [cam]/cal1Dname: in .ini file  {}'.format(self.cal1Dfn)

        with h5py.File(self.cal1Dfn, 'r') as f:
            az = f['az'][()]
            el = f['el'][()]
            ra = f['ra'][()]
            dec = f['dec'][()]

        assert az.ndim == el.ndim == 2
        assert az.shape == el.shape

        if self.transpose:
            logging.debug(
                'tranposing cam #{} az/el/ra/dec data. '.format(self.name))
            az = az.T
            el = el.T
            ra = ra.T
            dec = dec.T
        if self.fliplr:
            logging.debug(
                'flipping horizontally cam #{} az/el/ra/dec data.'.format(self.name))
            az = np.fliplr(az)
            el = np.fliplr(el)
            ra = np.fliplr(ra)
            dec = np.fliplr(dec)
        if self.flipud:
            logging.debug(
                'flipping vertically cam #{} az/el/ra/dec data.'.format(self.name))
            az = np.flipud(az)
            el = np.flipud(el)
            ra = np.flipud(ra)
            dec = np.flipud(dec)
        if self.rotccw != 0:
            logging.debug(
                'rotating cam #{} az/el/ra/dec data.'.format(self.name))
            az = np.rot90(az, self.rotccw)
            el = np.rot90(el, self.rotccw)
            ra = np.rot90(ra, self.rotccw)
            dec = np.rot90(dec, self.rotccw)

        self.az = az
        self.el = el
        self.ra = ra
        self.dec = dec
741842
function wireUsePhotoHandlers(){
    
    $usePhoto.bind('click submit', function(e){
       
      if(e.target.id === 'facebook-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $facebookDestination.hide()

        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
        
        closeOneUp()
        
        $stepFourDestinationWrapper.show()

        progressToNextStep($stepThree, function(){

          $stepFour.slideDown(333)

        })

      }

      if(e.target.id === 'twitter-use-photo'){
        
        // We don't want to show the facebook option, because
        // it is the source of the image.
        $twitterDestination.hide()
        
        _photoToUse = localStorage.imageToPipe || $('.one-up:visible').find('img')[0].src
                
        closeOneUp()

        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }


      if(e.target.id === 'url-use-photo'){
        
        _photoToUse = $photoFromUrl.val() || localStorage.imageToPipe
        
        $stepThreeDestinationWrapper.show()
        
        progressToNextStep($stepTwo, function(){

          $stepThree.slideDown(333)

        })

      }
      
      localStorage.imageToPipe = _photoToUse

      console.log(_photoToUse)
      console.log(localStorage.imageToPipe)
      return false

    }) // end bind()
    
  }
936134
function FileListBuilder ( parent ) {

    this.files = [];

    this.directory = null;

    this.addFile = function ( file ) {
        this.files.push( file );
        return this;
    };

    // Adds a directory of files 
    this.push = function ( directory ) {
        var child = new FileListBuilder( this );
        this.files = this.files.concat( [ directory+'_.header.js', directory+'*.js' ] );
        child.directory = directory;
        return child;
    };

    this.pop = function () {
        if ( this.directory ) {
            this.files = this.files.concat( ['!'+this.directory+'_.footer.js', this.directory+'_.footer.js' ]  );
        }
        if ( parent ) {
            parent.files = parent.files.concat( this.files );
        }
        return parent;
    };

    this.get = function () {
        return this.files;
    };
}
944070
function initModule($fh, cameraOptionsBuilder, mode) {
  var moduleName = 'wfm.step.gallery';
  // require http module to get server baseUrl
  var ngModule = angular.module(moduleName, []);

  require('../../dist');

  ngModule.directive('gallery', function($templateCache) {
    return {
      restrict: 'E'
      , template: $templateCache.get('wfm-template/gallery.tpl.html')
      , controller: function($scope) {
        var self = this;

        getServerUrl($fh).then(function(serverBaseUrl) {
          var baseFileUrl = new URL('/file/', serverBaseUrl);
          $scope.pictures = self.getPictures(baseFileUrl);
        });

        self.getPictures = function(baseFileUrl) {
          var gallery = $scope.result.submission.gallery;
          var pictures = [];
          for (var i in gallery) {
            if (gallery[i]) {
              if (mode === "admin") {
                pictures.push(baseFileUrl + gallery[i].id);
              } else {
                pictures.push(gallery[i].uri);
              }
            }
          }
          return pictures;
        };
      },
      controllerAs: 'ctrl'
    };
  });

  ngModule.directive('galleryForm', ['$templateCache', '$http', '$mdDialog', function($templateCache, $http, $mdDialog) {
    return {
      restrict: 'E'
      , template: $templateCache.get('wfm-template/gallery-form.tpl.html')
      , controller: function($scope) {
        var self = this;
        var fileManagerClient = {
          upload: function(uri, formData) {
            return $http({
              url: uri,
              method: 'POST',
              headers: {
                'Content-Type': undefined
              },
              data: formData
            });
          },
          download: function(uri) {
            return $http({
              method: 'GET',
              url: uri
            });
          }
        };

        getServerUrl($fh).then(function(serverBaseUrl) {
          var url = new URL('/file/', serverBaseUrl);
          self.fileManager = new FileManager(url.toString(), 'gallery', fileManagerClient);
          self.camera = new Camera(cameraOptionsBuilder);
        });

        self.model = {};
        self.parentController = $scope.$parent;
        self.back = function(event) {
          self.parentController.ctrl.triggerBackStep(self.model);
          event.preventDefault();
          event.stopPropagation();
        };
        self.done = function(event) {
          self.parentController.ctrl.triggerCompleteStep(self.model);
          event.preventDefault();
          event.stopPropagation();
        };

        self.addImage = function(uri, id) {
          $scope.$apply(function() {
            self.model.gallery = self.model.gallery || [];
            self.model.gallery.push({ uri: uri, id: id });
          });
        };

        self.takePicture = function() {
          if (!window.navigator.camera) {
            var alert = $mdDialog.alert({
              title: 'Camera not available in browser',
              textContent: 'Camera plugin not available. Try running project in emulator or using `cordova run browser`.',
              ok: 'Close'
            });
            return $mdDialog.show(alert);
          }
          self.camera.capture().then(function(captureResponse) {
            captureResponse.id = uuid.create().toString();
            self.addImage(captureResponse.value, captureResponse.id);
            return captureResponse;
          }).then(function(captureResponse) {
            var file = {
              uri: captureResponse.value,
              type: captureResponse.type,
              id: captureResponse.id
            };
            return self.fileManager.scheduleFileToBeUploaded(file);
          }).catch(console.error);
        };
      }
      , controllerAs: 'ctrl'
    };
  }]);

  return moduleName;
}
1191177
def img(self, id):
        """"""
        return self._serve_file(os.path.join(media_path, 'img', id))
816189
def _generate_examples(self, images_dir_path):
    
    parent_dir = tf.io.gfile.listdir(images_dir_path)[0]
    walk_dir = os.path.join(images_dir_path, parent_dir)
    dirs = tf.io.gfile.listdir(walk_dir)

    for d in dirs:
      if tf.io.gfile.isdir(os.path.join(walk_dir, d)):
        for full_path, _, fname in tf.io.gfile.walk(os.path.join(walk_dir, d)):
          for image_file in fname:
            if image_file.endswith(".jpg"):
              image_path = os.path.join(full_path, image_file)
              yield {
                  "image": image_path,
                  "label": d.lower(),
              }
774474
function image(ph, fireErr) {
    if (arguments.length < 2) {
        fireErr = false;
    }
    var doit   = new DoIt(),
        jn     = doit.join(),
        marker = "data:image";

    if (isString(ph) && ph.length > marker.length) {
        // use "for" instead of "indexOf === 0"
        var i = 0;
        for(; i < marker.length && marker[i] === ph[i]; i++) {}

        if (i < marker.length) {
            var file = ZFS.read(ph);
            if (file !== null) {
                ph = "data:image/" + file.ext +  ";base64," + file.data;
            }
        }
    }

    $zenv.loadImage(ph,
        function(img) {
            jn(img);
        },
        function(img, e) {
            if (fireErr === true) {
                doit.error(e);
            } else {
                jn(img);
            }
        }
    );
    return doit;
}
1211301
def _view(self, filepath, format):
        """"""
        methodnames = [
            '_view_%s_%s' % (format, backend.PLATFORM),
            '_view_%s' % backend.PLATFORM,
        ]
        for name in methodnames:
            view_method = getattr(self, name, None)
            if view_method is not None:
                break
        else:
            raise RuntimeError('%r has no built-in viewer support for %r '
                'on %r platform' % (self.__class__, format, backend.PLATFORM))
        view_method(filepath)
1253259
def connect_to_images(region=None, public=True):
    """"""
    return _create_client(ep_name="image", region=region, public=public)
738791
protected void addImagesToBook(final BuildData buildData, final String locale, final String imageFolder, boolean revertToDefaultLocale,
            boolean logErrors) {
        // Load the database constants
        final byte[] failpenguinPng = blobConstantProvider.getBlobConstant(
                buildData.getServerEntities().getFailPenguinBlobConstantId()).getValue();

        // Download the image files that were identified in the processing stage
        float imageProgress = 0;
        final float imageTotal = buildData.getImageLocations().size();
        final int showPercent = 10;
        int lastPercent = 0;

        for (final TopicImageData imageLocation : buildData.getImageLocations()) {
            // Check if the app should be shutdown
            if (isShuttingDown.get()) {
                return;
            }

            boolean success = false;

            final int extensionIndex = imageLocation.getImageName().lastIndexOf(".");
            final int pathIndex = imageLocation.getImageName().lastIndexOf("/");
            final int hypenIndex = imageLocation.getImageName().lastIndexOf("-");

            if (    /* characters were found */
                    extensionIndex != -1 && pathIndex != -1
                    /* the path character was found before the extension */ && extensionIndex > pathIndex) {
                try {
                    /*
                     * The file name minus the extension should be an integer that references an ImageFile record ID.
                     */
                    final String imageID;
                    if (hypenIndex != -1) {
                        imageID = imageLocation.getImageName().substring(pathIndex + 1, Math.min(extensionIndex, hypenIndex));
                    } else {
                        imageID = imageLocation.getImageName().substring(pathIndex + 1, extensionIndex);
                    }

                    /*
                     * If the image is the failpenguin the that means that an error has already occurred most likely from not
                     * specifying an image file at all.
                     */
                    if (imageID.equals(BuilderConstants.FAILPENGUIN_PNG_NAME)) {
                        success = false;
                        buildData.getErrorDatabase().addError(imageLocation.getTopic(), ErrorType.INVALID_IMAGES,
                                "No image filename specified. Must be in the format [ImageFileID].extension e.g. 123.png, " +
                                        "" + "or images/321.jpg");
                    } else {
                        final ImageWrapper imageFile = imageProvider.getImage(Integer.parseInt(imageID));
                        // TODO Uncomment this once Image Revisions are fixed.
//                        if (imageLocation.getRevision() == null) {
//                            imageFile = imageProvider.getImage(Integer.parseInt(imageID));
//                        } else {
//                            imageFile = imageProvider.getImage(Integer.parseInt(imageID), imageLocation.getRevision());
//                        }

                        // Find the image that matches this locale. If the locale isn't found then use the default locale
                        LanguageImageWrapper languageImageFile = null;
                        if (imageFile.getLanguageImages() != null && imageFile.getLanguageImages().getItems() != null) {
                            final List<LanguageImageWrapper> languageImages = imageFile.getLanguageImages().getItems();
                            for (final LanguageImageWrapper image : languageImages) {
                                if (image.getLocale().getValue().equals(locale)) {
                                    languageImageFile = image;
                                    break;
                                } else if (revertToDefaultLocale && image.getLocale().getValue().equals(
                                        buildData.getDefaultLocale()) && languageImageFile == null) {
                                    languageImageFile = image;
                                }
                            }
                        }

                        if (languageImageFile != null && languageImageFile.getImageData() != null) {
                            success = true;
                            addToZip(buildData.getBookLocaleFolder() + imageLocation.getImageName(), languageImageFile.getImageData(),
                                    buildData);
                        } else if (logErrors) {
                            buildData.getErrorDatabase().addError(imageLocation.getTopic(), ErrorType.INVALID_IMAGES,
                                    "ImageFile ID " + imageID + " from image location " + imageLocation.getImageName() + " was not found!");
                        }
                    }
                } catch (final NumberFormatException ex) {
                    success = false;
                    if (logErrors) {
                        buildData.getErrorDatabase().addError(imageLocation.getTopic(), ErrorType.INVALID_IMAGES,
                                imageLocation.getImageName() + " is not a valid image. Must be in the format [ImageFileID].extension e.g." +
                                        " 123" +
                                        ".png, or images/321.jpg");
                        log.debug("", ex);
                    }
                } catch (final Exception ex) {
                    success = false;
                    if (logErrors) {
                        buildData.getErrorDatabase().addError(imageLocation.getTopic(), ErrorType.INVALID_IMAGES,
                                imageLocation.getImageName() + " is not a valid image. Must be in the format [ImageFileID].extension e.g." +
                                        " 123" +
                                        ".png, or images/321.jpg");
                        log.debug("", ex);
                    }
                }
            }

            // Put in a place holder in the image couldn't be found
            if (logErrors && !success) {
                buildData.getOutputFiles().put(imageFolder + imageLocation.getImageName(), failpenguinPng);
            }

            final int progress = Math.round(imageProgress / imageTotal * 100);
            if (progress - lastPercent >= showPercent) {
                lastPercent = progress;
                log.info("\tDownloading " + locale + " Images " + progress + "% done");
            }

            ++imageProgress;
        }
    }
402344
def make_image_converters(self, image, configuration, harpoon_spec):
        """"""
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(meta.at("images").at(image), base)

        converter = Converter(convert=convert_image, convert_path=["images", image])
        configuration.add_converter(converter)

        def convert_tasks(path, val):
            spec = harpoon_spec.tasks_spec(available_actions)
            meta = Meta(path.configuration.root(), []).at("images").at(image).at("tasks")
            configuration.converters.started(path)
            tasks = spec.normalise(meta, val)
            for task in tasks.values():
                task.image = image
            return tasks

        converter = Converter(convert=convert_tasks, convert_path=["images", image, "tasks"])
        configuration.add_converter(converter)
510041
private static VideoDevice getVideoDevice(File file) {

		LOG.debug("Creating V4L4J device from file {}", file);

		try {
			return new VideoDevice(file.getAbsolutePath());
		} catch (V4L4JException e) {
			throw new WebcamException("Cannot instantiate V4L4J device from " + file, e);
		}
	}
1338309
public static ContentProviderSimpleAdapter getExternalPhotoSimpleAdapter(Context context) {
    return new ContentProviderSimpleAdapter(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, context);
  }
113709
private void createFileFilter()
	{
		HashMap<String, String[]> extensionMap = MultimediaContainerManager.getSupportedFileExtensionsPerContainer();
		
		ArrayList<FileFilter> chooserFilterArray = new ArrayList<FileFilter>(extensionMap.size() + 1);

		// add all single file extensions grouped by container
		Set<String> containerNameSet = extensionMap.keySet();
		Iterator<String> containerNameIterator = containerNameSet.iterator();
		while (containerNameIterator.hasNext())
		{
			String containerName = containerNameIterator.next();
			String [] extensions = extensionMap.get(containerName);
			StringBuilder fileText = new StringBuilder(containerName);
			fileText.append(" (");
			int ende = extensions.length-1;
			for (int i=0; i<=ende; i++)
			{
				fileText.append("*.").append(extensions[i]);
				if (i<ende) fileText.append(", ");
			}
			fileText.append(')');
			chooserFilterArray.add(new FileChooserFilter(extensions, fileText.toString()));
		}
		// now add playlist as group of files
		chooserFilterArray.add(PlayList.PLAYLIST_FILE_FILTER);

		// now add all playable files at the last step (container extensions and playlist files)
		String [] containerExtensions = MultimediaContainerManager.getSupportedFileExtensions();
		String [] fullSupportedExtensions = new String[containerExtensions.length + PlayList.SUPPORTEDPLAYLISTS.length];
		System.arraycopy(PlayList.SUPPORTEDPLAYLISTS, 0, fullSupportedExtensions, 0, PlayList.SUPPORTEDPLAYLISTS.length);
		System.arraycopy(containerExtensions, 0, fullSupportedExtensions, PlayList.SUPPORTEDPLAYLISTS.length, containerExtensions.length);
		chooserFilterArray.add(new FileChooserFilter(fullSupportedExtensions, "All playable files"));
		// add default "all files" - WE DO NOT DO THAT ANYMORE ;)
//		chooserFilterArray.add(new FileChooserFilter("*", "All files"));
		
		fileFilterLoad = new FileFilter[chooserFilterArray.size()];
		chooserFilterArray.toArray(fileFilterLoad);

		fileFilterExport = new FileFilter[1];
		fileFilterExport[0] = new FileChooserFilter(javax.sound.sampled.AudioFileFormat.Type.WAVE.getExtension(), javax.sound.sampled.AudioFileFormat.Type.WAVE.toString());
	}
886373
function imagePreviewProvider(editor, pos, token, line) {
        var cm = editor._codeMirror;

        // Check for image name
        var urlRegEx = /url\(([^\)]*)\)/gi,
            tokenString,
            urlMatch;

        if (token.type === "string") {
            tokenString = token.string;
        } else {
            urlMatch = urlRegEx.exec(line);
            while (urlMatch) {
                if (pos.ch < urlMatch.index) {
                    // match is past cursor, so stop looping
                    break;
                } else if (pos.ch <= urlMatch.index + urlMatch[0].length) {
                    tokenString = urlMatch[1];
                    break;
                }
                urlMatch = urlRegEx.exec(line);
            }
        }

        if (!tokenString) {
            return null;
        }

        // Strip leading/trailing quotes, if present
        tokenString = tokenString.replace(/(^['"])|(['"]$)/g, "");

        var sPos, ePos;
        var docPath = editor.document.file.fullPath;
        var imgPath;

        // Determine whether or not this URL/path is likely to be an image.
        var parsed = PathUtils.parseUrl(tokenString);
        // If the URL has a protocol, check if it's one of the supported protocols
        var hasProtocol = parsed.protocol !== "" && validProtocols.indexOf(parsed.protocol.trim().toLowerCase()) !== -1;
        var ext = parsed.filenameExtension.replace(/^\./, '');
        var language = LanguageManager.getLanguageForExtension(ext);
        var id = language && language.getId();
        var isImage = id === "image" || id === "svg";

        // Use this URL if this is an absolute URL and either points to a
        // filename with a known image extension, or lacks an extension (e.g.,
        // a web service that returns an image). Honour the extensionlessImagePreview
        // preference as well in the latter case.
        if (hasProtocol && (isImage || (!ext && extensionlessImagePreview))) {
            imgPath = tokenString;
        }
        // Use this filename if this is a path with a known image extension.
        else if (!hasProtocol && isImage) {
            imgPath = "file:///" + FileUtils.getDirectoryPath(docPath) + tokenString;
        }

        if (!imgPath) {
            return null;
        }

        if (urlMatch) {
            sPos = {line: pos.line, ch: urlMatch.index};
            ePos = {line: pos.line, ch: urlMatch.index + urlMatch[0].length};
        } else {
            sPos = {line: pos.line, ch: token.start};
            ePos = {line: pos.line, ch: token.end};
        }

        var imgPreview = "<div class='image-preview'>"          +
                         "    <img src=\"" + imgPath + "\">"    +
                         "</div>";
        var coord = cm.charCoords(sPos);
        var xpos = (cm.charCoords(ePos).left - coord.left) / 2 + coord.left;

        var showHandler = function () {
            // Hide the preview container until the image is loaded.
            $previewContainer.hide();

            $previewContainer.find(".image-preview > img").on("load", function () {
                $previewContent
                    .append("<div class='img-size'>" +
                                this.naturalWidth + " &times; " + this.naturalHeight + " " + Strings.UNIT_PIXELS +
                            "</div>"
                        );
                $previewContainer.show();
                positionPreview(editor, popoverState.xpos, popoverState.ytop, popoverState.ybot);
            }).on("error", function (e) {
                e.preventDefault();
                hidePreview();
            });
        };

        return {
            start: sPos,
            end: ePos,
            content: imgPreview,
            onShow: showHandler,
            xpos: xpos,
            ytop: coord.top,
            ybot: coord.bottom,
            _imgPath: imgPath
        };
    }
1000989
private void visitImage(CmsObject cms, File f) {

        f.length();
        String oName = f.getAbsolutePath().substring(CmsImageLoader.getImageRepositoryPath().length());
        oName = getVFSName(cms, oName);

        List files = (List)m_filePaths.get(oName);
        if (files == null) {
            files = new ArrayList();
            m_filePaths.put(oName, files);
        }
        files.add(f.getAbsolutePath());

        List variations = (List)m_variations.get(oName);
        if (variations == null) {
            variations = new ArrayList();
            m_variations.put(oName, variations);

        }
        oName += " (";
        oName += f.length() + " Bytes)";
        variations.add(oName);
    }