Skip to content

Instantly share code, notes, and snippets.

@edsu
Created March 26, 2014 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/9788858 to your computer and use it in GitHub Desktop.
Save edsu/9788858 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
It looks like some TIFF files are being rotated when saved as JPEGs. Grab this TIFF file:
http://inkdroid.org/tmp/foo.tif
Convert it to a JPEG. Now open both of them and notice how the JPG has been flipped. Is it possible that there
is orientation metadata in the TIFF is being stripped when the image is saved as a JPEG?
"""
import Image
i = Image.open('foo.tif')
i.save('i.jpg')
@wiredfool
Copy link

Pillow debug:

tag: ImageWidth (256) - type: short (3) - value: (2789,)
tag: ImageLength (257) - type: short (3) - value: (3493,)
tag: BitsPerSample (258) - type: short (3) - value: (8, 8, 8)
tag: Compression (259) - type: short (3) - value: (1,)
tag: PhotometricInterpretation (262) - type: short (3) - value: (2,)
tag: StripOffsets (273) - type: long (4) - value: (24896,)
tag: SamplesPerPixel (277) - type: short (3) - value: (3,)
tag: RowsPerStrip (278) - type: short (3) - value: (3493,)
tag: StripByteCounts (279) - type: long (4) - value: (29225931,)
tag: XMP (700) - type: byte (1) - value: <table: 16743 bytes>
tag: IptcNaaInfo (33723) - type: long (4) - value: <table: 28 bytes>
tag: PhotoshopInfo (34377) - type: byte (1) - value: <table: 7388 bytes>
tag: ICCProfile (34675) - type: undefined (7) - value: <table: 560 bytes>

Imagemagick:
Orientation: RightTop
Properties:
crs:AlreadyApplied: True
date:create: 2014-03-26T10:39:09-07:00
date:modify: 2014-03-26T10:39:09-07:00
dc:format: image/tiff
exif:ColorSpace: 65535
exif:DateTimeDigitized: 2014-02-27T16:16:08-05:00
exif:DateTimeOriginal: 2014-02-27T16:16:08-05:00
exif:ExifVersion: 0220
exif:ExposureTime: 1/15
exif:FileSource: 3
exif:LightSource: 255
exif:PixelXDimension: 2789
exif:PixelYDimension: 3493
exif:SceneType: 1
exif:ShutterSpeedValue: 3906891/1000000
photoshop:ColorMode: 3
photoshop:DateCreated: 2014-02-27
photoshop:ICCProfile: Adobe RGB (1998)
photoshop:LegacyIPTCDigest: E38F75F94E3ED63E411B74761B0FCF31
signature: cdd51e8a491e7ab9bbe4dd004476d197c98b384e9cd3e112bda23400f6b68d7d
tiff:endian: lsb
tiff:ImageLength: 3493
tiff:ImageWidth: 2789
tiff:Make: Phase One
tiff:Model: P 65+
tiff:photometric: RGB
tiff:PhotometricInterpretation: 2
tiff:rows-per-strip: 1
tiff:SamplesPerPixel: 3
tiff:XResolution: 300/1
tiff:YResolution: 300/1
xap:CreateDate: 2014-02-27T16:16:08-05:00
xap:CreatorTool: Capture One 5 Macintosh
xap:MetadataDate: 2014-03-20T10:51-04:00
xap:ModifyDate: 2014-03-13T10:38:19-04:00
xapMM:DocumentID: xmp.did:9421D286742C6811871FD9B88158FBAF
xapMM:InstanceID: xmp.iid:9421D286742C6811871FD9B88158FBAF
xapMM:OriginalDocumentID: xmp.did:9421D286742C6811871FD9B88158FBAF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment