Extract a list of exif infos
11422
def extract_exif(self):
        '''
        
        '''
        width, height = self.extract_image_size()
        make, model = self.extract_make(), self.extract_model()
        orientation = self.extract_orientation()
        geo = self.extract_geo()
        capture = self.extract_capture_time()
        direction = self.extract_direction()
        d = {
            'width': width,
            'height': height,
            'orientation': orientation,
            'direction': direction,
            'make': make,
            'model': model,
            'capture_time': capture
        }
        d['gps'] = geo
        return d
369024
def extract_locals(trcback):
    

    output = []
    stack = extract_stack(get_inner_most_frame(trcback))
    for frame, file_name, line_number, name, context, index in stack:
        args_names, nameless, keyword = extract_arguments(frame)
        arguments, nameless_args, keyword_args, locals = OrderedDict(), [], {}, {}
        for key, data in frame.f_locals.iteritems():
            if key == nameless:
                nameless_args = map(repr, frame.f_locals.get(nameless, ()))
            elif key == keyword:
                keyword_args = dict((arg, repr(value)) for arg, value in frame.f_locals.get(keyword, {}).iteritems())
            elif key in args_names:
                arguments[key] = repr(data)
            else:
                locals[key] = repr(data)
        output.append(((name, file_name, line_number), (arguments, nameless_args, keyword_args, locals)))
    return output
1328435
def info(self):
        """"""
        return {'coordinates': self._coordinates(),
                'imageinfo': self._imageinfo(),
                'miscinfo': self._miscinfo(),
                'unit': self._unit()
                }
699658
def _find_inline_images(contentsinfo):
    ""

    for n, inline in enumerate(contentsinfo.inline_images):
        yield ImageInfo(
            name='inline-%02d' % n, shorthand=inline.shorthand, inline=inline
        )
7673
def uncompress_archives(file_names, temp_dir):
    
    result = []
    for filename in file_names:
        if filename.endswith(".tar") or filename.endswith(".tar.gz") or filename.endswith(".tar.bz2"):
            obj = tarfile.open(filename, "r")
            extracted_file_names = []
            for j, member in enumerate(obj.getmembers()):
                obj.extract(member, temp_dir)
                extracted_filename = os.path.join(temp_dir, obj.getnames()[j])
                extracted_file_names.append(extracted_filename)
                archives[extracted_filename] = filename
            result.extend(extracted_file_names[:])
        elif filename.endswith(".zip"):
            obj = zipfile.ZipFile(filename)
            extracted_file_names = []
            for j, info in enumerate(obj.infolist()):
                obj.extract(info, path=temp_dir)
                extracted_filename = os.path.join(temp_dir, obj.namelist()[j])
                extracted_file_names.append(extracted_filename)
                archives[extracted_filename] = filename
            result.extend(extracted_file_names[:])
        else:
            result.append(filename)

    return result
290807
def extract_chm (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    # archmage can only extract in non-existing directories
    # so a nice dirname is created
    name = util.get_single_outfile("", archive)
    outfile = os.path.join(outdir, name)
    return [cmd, '-x', os.path.abspath(archive), outfile]
904276
def img_binary_list():
        
        qemu_imgs = []
        for path in Qemu.paths_list():
            try:
                for f in os.listdir(path):
                    if (f == "qemu-img" or f == "qemu-img.exe") and \
                            os.access(os.path.join(path, f), os.X_OK) and \
                            os.path.isfile(os.path.join(path, f)):
                        qemu_path = os.path.join(path, f)
                        version = yield from Qemu._get_qemu_img_version(qemu_path)
                        qemu_imgs.append({"path": qemu_path, "version": version})
            except OSError:
                continue

        return qemu_imgs
1152004
def get_image_files(c:PathOrStr, check_ext:bool=True, recurse=False)->FilePathList:
    ""
    return get_files(c, extensions=(image_extensions if check_ext else None), recurse=recurse)
426554
def merge_segments(segments, exif=b""):
    
    if segments[1][0:2] == b"\xff\xe0" and \
       segments[2][0:2] == b"\xff\xe1" and \
       segments[2][4:10] == b"Exif\x00\x00":
        if exif:
            segments[2] = exif
            segments.pop(1)
        elif exif is None:
            segments.pop(2)
        else:
            segments.pop(1)
    elif segments[1][0:2] == b"\xff\xe0":
        if exif:
            segments[1] = exif
    elif segments[1][0:2] == b"\xff\xe1" and \
         segments[1][4:10] == b"Exif\x00\x00":
        if exif:
            segments[1] = exif
        elif exif is None:
            segments.pop(1)
    else:
        if exif:
            segments.insert(1, exif)
    return b"".join(segments)
1349401
def extract_subsec(self):
        '''
        
        '''
        fields = [
            'Image SubSecTimeOriginal',
            'EXIF SubSecTimeOriginal',
            'Image SubSecTimeDigitized',
            'EXIF SubSecTimeDigitized',
            'Image SubSecTime',
            'EXIF SubSecTime'
        ]
        sub_sec, _ = self._extract_alternative_fields(
            fields, default='', field_type=str)
        return sub_sec
952444
def get_exif_by_number(*tag)
      hash = {}
      if tag.length.zero?
        exif_data = self['EXIF:!']
        if exif_data
          exif_data.split("\n").each do |exif|
            tag, value = exif.split('=')
            tag = tag[1, 4].hex
            hash[tag] = value
          end
        end
      else
        get_exif_by_number # ensure properties is populated with exif data
        tag.each do |num|
          rval = self[format('#%04X', num.to_i)]
          hash[num] = rval == 'unknown' ? nil : rval
        end
      end
      hash
    end
814520
function getDescriptors(images) {
  const result = [];
  for (let image of images) {
    result.push(extractHOG(image));
  }

  const heights = images.map((img) => img.height);
  const maxHeight = Math.max.apply(null, heights);
  const minHeight = Math.min.apply(null, heights);
  for (let i = 0; i < images.length; i++) {
    const img = images[i];
    let bonusFeature = 1;
    if (minHeight !== maxHeight) {
      bonusFeature = (img.height - minHeight) / (maxHeight - minHeight);
    }
    result[i].push(bonusFeature);
  }
  return result;
}
1020177
def get_metadata(self, digest, content, mime_type):
        """"""

        # XXX: ad-hoc for now, refactor later
        if mime_type.startswith("image/"):
            img = Image.open(BytesIO(content))
            ret = {}
            if not hasattr(img, "_getexif"):
                return {}
            info = img._getexif()
            if not info:
                return {}
            for tag, value in info.items():
                decoded = TAGS.get(tag, tag)
                ret["EXIF:" + str(decoded)] = value
            return ret
        else:
            if mime_type != "application/pdf":
                content = self.to_pdf(digest, content, mime_type)

            with make_temp_file(content) as in_fn:
                try:
                    output = subprocess.check_output(["pdfinfo", in_fn])
                except OSError:
                    logger.error("Conversion failed, probably pdfinfo is not installed")
                    raise

            ret = {}
            for line in output.split(b"\n"):
                if b":" in line:
                    key, value = line.strip().split(b":", 1)
                    key = str(key)
                    ret["PDF:" + key] = str(value.strip(), errors="replace")

            return ret
989204
def verify_exif(filename):
    '''
    
    '''
    # required tags in IFD name convention
    required_exif = required_fields()
    exif = ExifRead(filename)
    required_exif_exist = exif.fields_exist(required_exif)
    return required_exif_exist
195208
def extract_image_size(self):
        '''
        
        '''
        width, _ = self._extract_alternative_fields(
            ['Image ImageWidth', 'EXIF ExifImageWidth'], -1, int)
        height, _ = self._extract_alternative_fields(
            ['Image ImageLength', 'EXIF ExifImageLength'], -1, int)
        return width, height
1056526
function exif(buf, options, cb) {
  try {
    const exif = new _ExifReader.ExifReader();
    exif.load(buf);

    // The MakerNote tag can be really large. Remove it to lower memory usage.
    if (!options.hasOwnProperty('hasMakerNote') || !options.hasMakerNote) {
      exif.deleteTag('MakerNote');
    }

    const metadata = exif.getAllTags();

    cb(null, metadata);
  } catch (err) {
    if (err.message === 'No Exif data') {
      cb(null, {});
    } else {
      cb(err);
    }
  }
}
1048814
def image_files
      return [] if input.nil?
      valid_extensions = library::VALID_EXTENSIONS
      expansions = Array(valid_extensions).map{|ext| File.join(input, "**", "#{config[:glob]}.#{ext}")}
      files = SpriteFactory.find_files(*expansions)
      files = files.reject{ |file| exclude?(file) }
      files
    end