| 1 |
package com.drew.metadata.photoshop; |
| 2 |
|
| 3 |
import com.drew.lang.ByteArrayReader; |
| 4 |
import com.drew.lang.RandomAccessReader; |
| 5 |
import com.drew.lang.SequentialByteArrayReader; |
| 6 |
import com.drew.lang.annotations.NotNull; |
| 7 |
import com.drew.metadata.Directory; |
| 8 |
import com.drew.metadata.Metadata; |
| 9 |
import com.drew.metadata.exif.ExifTiffHandler; |
| 10 |
import com.drew.metadata.icc.IccReader; |
| 11 |
import com.drew.metadata.xmp.XmpReader; |
| 12 |
|
| 13 |
import java.io.IOException; |
| 14 |
import java.util.Set; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public class PhotoshopTiffHandler extends ExifTiffHandler |
| 20 |
{ |
| 21 |
|
| 22 |
|
| 23 |
private static final int TAG_PAGE_MAKER_EXTENSION = 0x014A; |
| 24 |
private static final int TAG_JPEG_TABLES = 0X01B5; |
| 25 |
private static final int TAG_XMP = 0x02BC; |
| 26 |
private static final int TAG_FILE_INFORMATION = 0x83BB; |
| 27 |
private static final int TAG_PHOTOSHOP_IMAGE_RESOURCES = 0x8649; |
| 28 |
private static final int TAG_EXIF_IFD_POINTER = 0x8769; |
| 29 |
private static final int TAG_ICC_PROFILES = 0x8773; |
| 30 |
private static final int TAG_EXIF_GPS = 0x8825; |
| 31 |
private static final int TAG_T_IMAGE_SOURCE_DATA = 0x935C; |
| 32 |
private static final int TAG_T_ANNOTATIONS = 0xC44F; |
| 33 |
|
| 34 |
public PhotoshopTiffHandler(Metadata metadata, Directory parentDirectory) |
| 35 |
{ |
| 36 |
super(metadata, parentDirectory, 0); |
| 37 |
} |
| 38 |
|
| 39 |
public boolean customProcessTag(final int tagOffset, |
| 40 |
final @NotNull Set<Integer> processedIfdOffsets, |
| 41 |
final int tiffHeaderOffset, |
| 42 |
final @NotNull RandomAccessReader reader, |
| 43 |
final int tagId, |
| 44 |
final int byteCount) throws IOException |
| 45 |
{ |
| 46 |
switch (tagId) { |
| 47 |
case TAG_XMP: |
| 48 |
new XmpReader().extract(reader.getBytes(tagOffset, byteCount), _metadata); |
| 49 |
return true; |
| 50 |
case TAG_PHOTOSHOP_IMAGE_RESOURCES: |
| 51 |
new PhotoshopReader().extract(new SequentialByteArrayReader(reader.getBytes(tagOffset, byteCount)), byteCount, _metadata); |
| 52 |
return true; |
| 53 |
case TAG_ICC_PROFILES: |
| 54 |
new IccReader().extract(new ByteArrayReader(reader.getBytes(tagOffset, byteCount)), _metadata); |
| 55 |
return true; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
return super.customProcessTag(tagOffset, processedIfdOffsets, tiffHeaderOffset, reader, tagId, byteCount); |
| 60 |
} |
| 61 |
} |