當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageProcessingException類代碼示例

本文整理匯總了Java中com.drew.imaging.ImageProcessingException的典型用法代碼示例。如果您正苦於以下問題:Java ImageProcessingException類的具體用法?Java ImageProcessingException怎麽用?Java ImageProcessingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ImageProcessingException類屬於com.drew.imaging包,在下文中一共展示了ImageProcessingException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readExif

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private static HashMap<String, String> readExif(File file) throws ImageProcessingException, IOException {
	HashMap<String, String> map = new HashMap<String, String>();
	InputStream is = null;
	is = new FileInputStream(file);

	Metadata metadata = ImageMetadataReader.readMetadata(is);
	Iterable<Directory> iterable = metadata.getDirectories();
	for (Iterator<Directory> iter = iterable.iterator(); iter.hasNext();) {
		Directory dr = iter.next();
		Collection<Tag> tags = dr.getTags();
		for (Tag tag : tags)
			map.put(tag.getTagName(), tag.getDescription());
	}
	_tracer.debug("Got Exif. " + file.getAbsolutePath() + "\r\n" + map.toString());
	is.close();
	return map;
}
 
開發者ID:probestar,項目名稱:PhotoCollector,代碼行數:18,代碼來源:PhotoCollectorUtils.java

示例2: getOrientation

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private String getOrientation(ImageFile src) {
	try {
		Metadata metadata = ImageMetadataReader.readMetadata(src.getInputStream());
		Directory directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
		if (directory != null) {
			for (Tag tag : directory.getTags()) {
				if ("Orientation".equals(tag.getTagName())) {
					return tag.getDescription();
				}
			}
		}
	} catch (IOException|ImageProcessingException e) {
		logger.error("Image orientation error", e);
	}
	return "";
}
 
開發者ID:web-education,項目名稱:mod-image-resizer,代碼行數:17,代碼來源:ImageResizer.java

示例3: fixOrientation

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
public void fixOrientation() throws ImageMutationFailedException {
    try {
        Metadata metadata = originalImageMetaData();

        ExifIFD0Directory exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
        if (exifIFD0Directory == null) {
            return;
        } else if (exifIFD0Directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
            int exifOrientation = exifIFD0Directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
            if(exifOrientation != 1) {
                rotate(exifOrientation);
                exifIFD0Directory.setInt(ExifIFD0Directory.TAG_ORIENTATION, 1);
            }
        }
    } catch (ImageProcessingException | IOException | MetadataException e) {
        throw new ImageMutationFailedException("failed to fix orientation", e);
    }
}
 
開發者ID:jonathan68,項目名稱:react-native-camera,代碼行數:19,代碼來源:MutableImage.java

示例4: getDateFromImgEXIF

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
/**
 * @param f
 * @return
 * @throws IOException
 */
private String getDateFromImgEXIF(final File file) throws IOException {
	String date = null;
	if (file.isFile()) {
		try {
			final Metadata metadata = ImageMetadataReader
					.readMetadata(file);
			// obtain the Exif directory
			final Directory directory = metadata
					.getDirectory(ExifSubIFDDirectory.class);
			if (null != directory) {
				final Date tagDate = directory
						.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
				if (null != tagDate) {
					date = this.sdf.format(tagDate);
				}
			}
		} catch (final ImageProcessingException e) {
			// e.printStackTrace();
		}
	}
	return date;
}
 
開發者ID:caomu,項目名稱:img,代碼行數:28,代碼來源:Distribute.java

示例5: getExifDate

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
/**
 *
 * @param filePath
 * @return
 */
private String getExifDate(File file) {

  try {
    Metadata metadata = ImageMetadataReader.readMetadata(file);
    Directory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
    int dateTag = ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL;

    if (directory != null && directory.containsTag(dateTag)) {
      Date date = directory.getDate(dateTag, TimeZone.getDefault());
      return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
    } else {
      return "";
    }
  } catch (ImageProcessingException | IOException ex) {
    LOGGER.log(Level.INFO, 
        "Exif error for {0}: {1}",
        new String[]{file.getName(), ex.getLocalizedMessage()}
    );
    return "";
  }
}
 
開發者ID:yarl,項目名稱:pattypan,代碼行數:27,代碼來源:CreateFilePane.java

示例6: nacti

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
@Override
protected void nacti(final InputStream istm, final String name, final IImportBuilder builder, final Future<?> future) throws IOException {
	if (future.isCancelled()) {
		return;
	}
	BufferedInputStream bis;
	if (istm instanceof BufferedInputStream) {
		bis = (BufferedInputStream) istm;
	} else {
		bis = new BufferedInputStream(istm);
	}
	Metadata imageMetadata;
	try {
		imageMetadata = ImageMetadataReader.readMetadata(bis, true);
	} catch (final ImageProcessingException e) {
		log.error("The input stream for file " + name + "couldn't be loaded!", e);
		return;
	}
	final GpsDirectory gpsDirectory = imageMetadata.getDirectory(GpsDirectory.class);
	if (gpsDirectory == null) {
		log.info("Image has no GPS metadata.");
		return;
	}
	final GeoLocation exifLocation = gpsDirectory.getGeoLocation();
	if (exifLocation != null) {
		final GpxWpt gpxWpt = new GpxWpt();
		gpxWpt.wgs = new Wgs(exifLocation.getLatitude(), exifLocation.getLongitude());
		gpxWpt.name = Iterables.getLast(Arrays.asList(name.split(Pattern.quote(File.separator))), "");
		gpxWpt.link.href = name;
		gpxWpt.desc = "EXIF coordinates";
		gpxWpt.type = "pic";
		gpxWpt.sym = "Photo";
		builder.addGpxWpt(gpxWpt);
	} else {
		log.info("Image {} has GPS metadata, but no lat/lon information.", name);
	}
}
 
開發者ID:marvertin,項目名稱:geokuk,代碼行數:38,代碼來源:NacitacImageMetadata.java

示例7: main

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
public static void main(String args[]) throws IOException, ImageProcessingException {
	String tiffstr = utilities.BrowserDialogs.chooseFile();
	InputStream is = new BufferedInputStream(new FileInputStream(tiffstr));
	SeekableStream seekstr = new FileCacheSeekableStream(is);
	TIFFDirectory tiffdir = new TIFFDirectory(seekstr, 0);
	for (int i = 0; i < tiffdir.getNumEntries(); i++) {
		// System.out.println(i);
		// System.out.println(tiffdir.getField(i));
	}

	boolean cSB = seekstr.canSeekBackwards();
	// System.out.println(cSB);
	File tifffile = new File(tiffstr);
	getImageTiffMetadata(tifffile);

	getExifTiffData(tifffile);
}
 
開發者ID:friesey,項目名稱:preservation-tools,代碼行數:18,代碼來源:TiffTestClass.java

示例8: getOrientation

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private static int getOrientation(BufferedInputStream bis) throws IOException {
	try {
		Metadata metadata = ImageMetadataReader.readMetadata(bis);
		Directory directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
		if (directory != null) {
			return directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
		}
		return 1;
	} catch (MetadataException | ImageProcessingException me) {
		return 1;
	}
}
 
開發者ID:oglimmer,項目名稱:lunchy,代碼行數:13,代碼來源:ImageScaler.java

示例9: nactiKdyzUmis

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
@Override
protected void nactiKdyzUmis(InputStream istm, String jmeno, IImportBuilder builder, Future<?> future)
    throws IOException {
  if (!VALID_FILENAME_REGEX.matcher(jmeno).matches()) {
    return;
  }
  BufferedInputStream bis;
  if (istm instanceof BufferedInputStream) {
    bis = (BufferedInputStream) istm;
  } else {
    bis = new BufferedInputStream(istm);
  }
  Metadata imageMetadata;
  try {
    imageMetadata = ImageMetadataReader.readMetadata(bis, true);
  } catch (ImageProcessingException e) {
    log.error("The input stream with name " + jmeno + " couldn't be loaded!", e);
    return;
  }
  GpsDirectory gpsDirectory = imageMetadata.getDirectory(GpsDirectory.class);
  if (gpsDirectory == null) {
    log.info("Image {} has no GPS metadata.", jmeno);
    return;
  }
  GeoLocation exifLocation = gpsDirectory.getGeoLocation();
  if (exifLocation != null) {
    GpxWpt gpxWpt = new GpxWpt();
    gpxWpt.wgs = new Wgs(exifLocation.getLatitude(), exifLocation.getLongitude());
    gpxWpt.name = Iterables.getLast(Arrays.asList(jmeno.split(Pattern.quote(File.separator))), "");
    gpxWpt.link.href = jmeno;
    gpxWpt.desc = "EXIF coordinates";
    gpxWpt.type = "pic";
    gpxWpt.sym = "Photo";
    builder.addGpxWpt(gpxWpt);
  } else {
    log.info("Image {} has GPS metadata, but no lat/lon information.", jmeno);
  }
}
 
開發者ID:Danstahr,項目名稱:Geokuk,代碼行數:39,代碼來源:NacitacImageMetadata.java

示例10: buildMedia

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
protected final Media buildMedia(final MediaUploadBatch context) throws MediaReaderException, IOException {
    final String fileName = getFile().getAbsolutePath();
    try {
        final Metadata rawMetadata = ImageMetadataReader.readMetadata(getFile());
        final byte[] thumbnail;
        if (rawMetadata.containsDirectoryOfType(ExifThumbnailDirectory.class)) {
            final ExifThumbnailDirectory thumbnailDirectory = rawMetadata.getFirstDirectoryOfType(ExifThumbnailDirectory.class);
            if (thumbnailDirectory.hasThumbnailData()) {
                thumbnail = thumbnailDirectory.getThumbnailData();
            } else {
                thumbnail = new byte[0];
            }
        } else {
            thumbnail = new byte[0];
        }
        final Map<String, Object> metadata = new HashMap<>(rawMetadata.getDirectoryCount());
        for (final Directory directory : rawMetadata.getDirectories()) {
            copy(directory, metadata);
            preProcess(context, directory, metadata);
        }
        return new Media(getFile(), fileName, context.getTemplate(), metadata, thumbnail);
    } catch (final ImageProcessingException e) {
        throw new MediaReaderException(e);
    }
}
 
開發者ID:edouardhue,項目名稱:comeon,代碼行數:26,代碼來源:PictureReader.java

示例11: getImageDate

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
Date getImageDate(File file) throws Exception {
  try {
    Metadata metadata = ImageMetadataReader.readMetadata(file);
    ExifSubIFDDirectory exifSubIFDDirectory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
    int tagDatetimeOriginal = ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL;

    ExifIFD0Directory exifIFD0Directory;
    exifIFD0Directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
    int tagDatetime = ExifIFD0Directory.TAG_DATETIME;
    if (exifSubIFDDirectory != null && exifSubIFDDirectory.getDate(tagDatetimeOriginal,
                                                                   TimeZone.getDefault()) !=
                                       null) {
      return exifSubIFDDirectory.getDate(tagDatetimeOriginal, TimeZone.getDefault());
    }
    if (exifIFD0Directory != null && exifIFD0Directory.getDate(tagDatetime,
                                                               TimeZone.getDefault()) != null) {
      return exifIFD0Directory.getDate(tagDatetime, TimeZone.getDefault());
    }
    throw new CouldNotParseDateException();
  }
  catch (ImageProcessingException | IOException e) {
    throw new CouldNotParseDateException("File: " + file.getName());
  }
}
 
開發者ID:kotlinski,項目名稱:image-sort-master,代碼行數:25,代碼來源:FileDateInterpreter.java

示例12: getJpegData

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
protected void getJpegData(byte[] toMatch, int i, List<Integer> offsets, int resultIndex) {
    try {
        Metadata reader = JpegMetadataReader
                .readMetadata(new ByteArrayInputStream(Arrays.copyOfRange(toMatch, i - offsets.get(resultIndex), toMatch.length)));
        ExifIFD0Directory info = reader.getFirstDirectoryOfType(ExifIFD0Directory.class);
        String cameraMake = null;
        String cameraModel = null;
        if (info != null) {
            cameraMake = info.getString(ExifDirectoryBase.TAG_MAKE);
            cameraModel = info.getString(ExifDirectoryBase.TAG_MODEL);
        }
        for (Directory dir : reader.getDirectoriesOfType(GpsDirectory.class)) {
            GpsDescriptor descriptor = new GpsDescriptor((GpsDirectory) dir);

            Map<String, String> gpsInfoDict = new LinkedHashMap<>();
            gpsInfoDict.put("Camera Make: ", cameraMake);
            gpsInfoDict.put("Camera Model: ", cameraModel);
            gpsInfoDict.put("Latitude: ", tagOrEmpty(descriptor.getGpsLatitudeDescription()));
            gpsInfoDict.put("Longitude: ", tagOrEmpty(descriptor.getGpsLongitudeDescription()));
            gpsInfoDict.put("Altitude: ", descriptor.getGpsAltitudeDescription());
            gpsInfoDict.put("Altitude Reference: ", descriptor.getGpsAltitudeRefDescription());
            gpsInfoDict.put("Timestamp: ", descriptor.getGpsTimeStampDescription());

            if (notEmptyGPS(descriptor.getGpsLatitudeDescription(), descriptor.getGpsLongitudeDescription())) {
                logGPS(gpsInfoDict);
                wasGPSFound = true;
            }

        }

    }
    catch (IOException | ImageProcessingException e) {
        e.printStackTrace();
    }
}
 
開發者ID:ciphertechsolutions,項目名稱:IO,代碼行數:36,代碼來源:MagicCarver.java

示例13: originalImageMetaData

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private Metadata originalImageMetaData() throws ImageProcessingException, IOException {
    if(this.originalImageMetaData == null) {//this is expensive, don't do it more than once
        originalImageMetaData = ImageMetadataReader.readMetadata(
                new BufferedInputStream(new ByteArrayInputStream(originalImageData)),
                originalImageData.length
        );
    }
    return originalImageMetaData;
}
 
開發者ID:jonathan68,項目名稱:react-native-camera,代碼行數:10,代碼來源:MutableImage.java

示例14: addFile

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private void addFile(Path file) {
    try {
        io.getOut().println(file.toString());
        Metadata metadata = ImageMetadataReader.readMetadata(file.toFile());
        ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
        if (directory != null) {
            addPhoto(directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL),
                    file);
        }
    } catch (ImageProcessingException | IOException | SQLException ex) {
        // Swallow
    }
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:14,代碼來源:SourceDirScanner.java

示例15: getExifDate

import com.drew.imaging.ImageProcessingException; //導入依賴的package包/類
private Date getExifDate(byte[] imgRaw) throws ImageProcessingException, IOException {
    Metadata metadata = ImageMetadataReader.readMetadata(
            new BufferedInputStream(new ByteArrayInputStream(imgRaw)));
    ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
    if (directory == null) {
        return null;
    }
    return directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
}
 
開發者ID:alex-ersh,項目名稱:GuessMe,代碼行數:10,代碼來源:ImagePairProducer.java


注:本文中的com.drew.imaging.ImageProcessingException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。