Package com.drew.metadata

Examples of com.drew.metadata.Metadata


       
  }
 
  protected static void showEXIF(File jpegFile) throws Exception{

    Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
    Directory exif = metadata.getDirectory(ExifDirectory.class);
    int orie = exif.getInt(ExifDirectory.TAG_ORIENTATION);
    if(orie!=1)
      System.out.println(jpegFile.getName()+":"+orie);
   
      Iterator tags = exif.getTagIterator();
View Full Code Here


   * @return �Ƿ���EXIF��Ϣ
   */
  public static boolean fillExifInfo(String img_path, Photo photo){
    //Reading EXIF
    try {
      Metadata metadata = JpegMetadataReader.readMetadata(new File(img_path));
      if(!metadata.containsDirectory(ExifDirectory.class))
        return false;
      Directory exif = metadata.getDirectory(ExifDirectory.class);
      if(exif!=null){
        if(exif.containsTag(ExifDirectory.TAG_ORIENTATION))
          photo.setOrientation(exif.getInt(ExifDirectory.TAG_ORIENTATION));
        if(exif.containsTag(ExifDirectory.TAG_MAKE))
          photo.setManufacturer(exif.getString(ExifDirectory.TAG_MAKE));
View Full Code Here

            image.setValue(Image._I_IMAGE, pic);
           
            File jpegFile = new File(filename);
           
            try {
                Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
                if (metadata.containsDirectory(ExifDirectory.class)) {
                    Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
                   
                    try {
                        String camera = exifDirectory.getString(ExifDirectory.TAG_MODEL);
                        image.setValue(Image._Q_CAMERA, camera);
                    } catch (Exception me) {}

                    try {
                        int compression = exifDirectory.getInt(ExifDirectory.TAG_COMPRESSION);
                        image.setValue(Image._O_COMPRESSION, Long.valueOf(compression));
                    } catch (Exception me) {}


                    try {
                        String description = exifDirectory.getString(ExifDirectory.TAG_IMAGE_DESCRIPTION);
                        image.setValue(Image._B_DESCRIPTION, description);
                    } catch (Exception me) {}

                    try {
                        Date date = exifDirectory.getDate(ExifDirectory.TAG_DATETIME);
                        if (date != null) {
                            cal.setTime(date);
                            cal.set(Calendar.HOUR_OF_DAY, 0);
                            cal.set(Calendar.MINUTE, 0);
                            cal.set(Calendar.SECOND, 0);
                            image.setValue(Image._N_DATE, cal.getTime());
                        }
                    } catch (Exception me) {}
                }
               
                if (metadata.containsDirectory(IptcDirectory.class)) {
                    try {
                        Directory iptcDirectory = metadata.getDirectory(IptcDirectory.class);
                        String city = iptcDirectory.getString(IptcDirectory.TAG_CITY);
                        String country = iptcDirectory.getString(IptcDirectory.TAG_COUNTRY_OR_PRIMARY_LOCATION);
                        String state = iptcDirectory.getString(IptcDirectory.TAG_PROVINCE_OR_STATE);
                       
                        String location = "";
View Full Code Here

            try {
                segmentReader = new JpegSegmentReader(new ByteArrayInputStream(b));

                byte[] exifSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APP1);
                byte[] iptcSegment = segmentReader.readSegment(JpegSegmentReader.SEGMENT_APPD);
                Metadata metadata = new Metadata();
                new ExifReader(exifSegment).extract(metadata);
                new IptcReader(iptcSegment).extract(metadata);
               
                @SuppressWarnings("unchecked")
                Iterator<Directory> directories = metadata.getDirectoryIterator();
                HashMap<String, String> props = new HashMap<String, String>();
                while (directories.hasNext()) {
                    Directory directory = directories.next();
                    @SuppressWarnings("unchecked")
                    Iterator<Tag> tags = directory.getTagIterator();
View Full Code Here

        ExistingElementMutation<Vertex> mutation = data.getElement().prepareMutation();
        List<String> properties = new ArrayList<String>();

        File imageFile = data.getLocalFile();
        if (imageFile != null) {
            Metadata imageMetadata = null;
            try {
                imageMetadata = ImageMetadataReader.readMetadata(imageFile);
            } catch (Exception e) {
                LOGGER.error("Could not read metadata from imageFile: %s", imageFile, e);
            }
View Full Code Here

        //new ImageTransform(false, 0) is the original image orientation, with no flip needed, and no rotation needed.
        ImageTransform imageTransform = new ImageTransform(false, 0);

        try {
            //Attempt to retrieve the metadata from the image.
            Metadata metadata = ImageMetadataReader.readMetadata(localFile);
            if (metadata != null) {
                ExifIFD0Directory exifDir = metadata.getDirectory(ExifIFD0Directory.class);
                if (exifDir != null) {
                    Integer orientationInteger = exifDir.getInteger(ExifIFD0Directory.TAG_ORIENTATION);
                    if (orientationInteger != null) {
                        imageTransform = convertOrientationToTransform(orientationInteger);
                    }
View Full Code Here

   */
  private String getPrintableExifInfo(ImageActionVO vo){
    try {
      StringBuffer appendInfo = new StringBuffer();
        //get image meta object
      Metadata metadata = JpegMetadataReader.readMetadata(vo.getInputImageFile());
      Directory exifDic = metadata.getDirectory(ExifDirectory.class);
      //camera module
      if(vo.getParams().isAppendCamera()){
        String info = getExifInfo(exifDic,ExifDirectory.TAG_MODEL);
        if(!StringUtil.isNullOrBlank(info)){
          appendInfo.append(StringUtil.getPrintString(info));
View Full Code Here

            return;
        }
        InputStream in = null;
        try {
            in = fileHandler.getInputStream();
            Metadata metadata = JpegMetadataReader.readMetadata(in);
            in.close();
            Directory exifIFD0Directory = metadata.getDirectory(ExifIFD0Directory.class);
            Directory exifSubIFDDirectory = metadata.getDirectory(ExifSubIFDDirectory.class);
            Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
            if (exifIFD0Directory != null) {
                setupCameraModel(image, exifIFD0Directory);
            }
            if (exifSubIFDDirectory != null) {
                setupCreatedDate(image, exifSubIFDDirectory);
View Full Code Here

    }

    public Date readOriginalTime(File jpeg) throws IOException, ParseException{
        String dateString = null;
        try{
            Metadata meta = (new ExifReader(jpeg)).extract();
            ExifDirectory exif = (ExifDirectory) meta.getDirectory(ExifDirectory.class);
            dateString = exif.getString(ExifDirectory.TAG_DATETIME_ORIGINAL);
        } catch (JpegProcessingException ex){
            throw toIOException(ex, jpeg);
        }
        //interpret the dateString as an UTC dateTime value
View Full Code Here

    }

    public Wpt readGPSTag(File jpeg) throws IOException, ParseException{
        Wpt result = null;
        try{
            Metadata meta = (new ExifReader(jpeg)).extract();
            boolean hasGpsDirectory = meta.containsDirectory(GpsDirectory.class);
            if(hasGpsDirectory){
                GpsDirectory gps = (GpsDirectory) meta.getDirectory(GpsDirectory.class);
                if(gps.hasErrors()){
                    System.err.println("Warning: GPS directory has errors");
                    java.util.Iterator it = gps.getErrors();
                    while(it.hasNext()){
                        System.out.println(it.next());
                    }
                }
                java.util.Iterator tagiter = gps.getTagIterator();
                int i = 0;
                while(tagiter.hasNext()){
                    tagiter.next();
                    i++;
                }
                if(i == 0){
                    hasGpsDirectory = false;
                } else {
                    result = wptFromGpsTag(gps);
                }
            }
            if (!hasGpsDirectory) {
                System.err.println("Warning no dedicated GPS directory found. Looking for GPS info in main Exif directory.");
                Directory dir = meta.getDirectory(ExifDirectory.class);
                if(dir.hasErrors()){
                    System.err.println("Warning: Exif directory has errors.");
                    java.util.Iterator it = dir.getErrors();
                    while(it.hasNext()){
                        System.out.println(it.next());
View Full Code Here

TOP

Related Classes of com.drew.metadata.Metadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.