Skip to content

Commit

Permalink
Set parent dir for ICC/Photoshop dirs in Exif
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Oct 14, 2018
1 parent 6df33da commit cfd2a10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/com/drew/metadata/exif/ExifTiffHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ public boolean customProcessTag(final int tagOffset,
// Custom processing for ICC Profile data
if (tagId == ExifSubIFDDirectory.TAG_INTER_COLOR_PROFILE) {
final byte[] iccBytes = reader.getBytes(tagOffset, byteCount);
new IccReader().extract(new ByteArrayReader(iccBytes), _metadata);
new IccReader().extract(new ByteArrayReader(iccBytes), _metadata, _currentDirectory);
return true;
}

// Custom processing for Photoshop data
if (tagId == ExifSubIFDDirectory.TAG_PHOTOSHOP_SETTINGS && _currentDirectory instanceof ExifIFD0Directory) {
final byte[] photoshopBytes = reader.getBytes(tagOffset, byteCount);
new PhotoshopReader().extract(new SequentialByteArrayReader(photoshopBytes), byteCount, _metadata);
new PhotoshopReader().extract(new SequentialByteArrayReader(photoshopBytes), byteCount, _metadata, _currentDirectory);
return true;
}

Expand Down
10 changes: 10 additions & 0 deletions Source/com/drew/metadata/photoshop/PhotoshopReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.drew.lang.SequentialByteArrayReader;
import com.drew.lang.SequentialReader;
import com.drew.lang.annotations.NotNull;
import com.drew.lang.annotations.Nullable;
import com.drew.metadata.Directory;
import com.drew.metadata.Metadata;
import com.drew.metadata.exif.ExifReader;
import com.drew.metadata.icc.IccReader;
Expand Down Expand Up @@ -73,10 +75,18 @@ public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metada
}

public void extract(@NotNull final SequentialReader reader, int length, @NotNull final Metadata metadata)
{
extract(reader, length, metadata, null);
}

public void extract(@NotNull final SequentialReader reader, int length, @NotNull final Metadata metadata, @Nullable final Directory parentDirectory)
{
PhotoshopDirectory directory = new PhotoshopDirectory();
metadata.addDirectory(directory);

if (parentDirectory != null)
directory.setParent(parentDirectory);

// Data contains a sequence of Image Resource Blocks (IRBs):
//
// 4 bytes - Signature; mostly "8BIM" but "PHUT", "AgHg" and "DCSR" are also found
Expand Down

0 comments on commit cfd2a10

Please sign in to comment.