Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » JPEG Images do not get rotated correctly
Re: JPEG Images do not get rotated correctly [message #50409 is a reply to message #50393] |
Sun, 21 October 2018 16:20   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
Could you possibly add two lines of code in jpgupp.cpp in order to support Exif "DateTime" -tag:
int JPGRaster::Data::ExifDir(const char *begin, int offset, IFD_TYPE type)
{
const char *e = begin + offset;
int nitems = Exif16(e);
// puts(NFormat("directory %08x: %d items", dir, nitems));
e += 2;
for(int i = 0; i < nitems; i++, e += 12) {
int tag = Exif16(e);
int fmt = Exif16(e + 2);
int count = Exif32(e + 4);
static const int fmtlen[] = {
1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8
};
int len = 0;
if(fmt > 0 && fmt <= __countof(fmtlen))
len = fmtlen[fmt - 1] * count;
const char *data = e + 8;
if(len > 4)
data = begin + Exif32(data);
// puts(NFormat("[%d]: tag %04x fmt %d, count %d, data %s",
// i, tag, fmt, count, BinHexEncode(data, data + len)));
if(type == BASE_IFD) {
if(tag == 0x112)
metadata.Add("orientation", Exif16(data));
if(tag == 0x132)
metadata.Add("DateTime", String(data, 20));
if(tag == 0x8825) {
int offset = Exif32(data);
// puts(NFormat("GPS IFD at %08x", offset));
ExifDir(begin, offset, GPS_IFD);
}
}
else if(type == GPS_IFD) {
if((tag == 2 || tag == 4) && fmt == EXIF_RATIONAL && count == 3) {
metadata.Add(tag == 2 ? "GPSLatitude" : "GPSLongitude",
ExifF5(data + 0) + ExifF5(data + 8) / 60 + ExifF5(data + 16) / 3600);
// puts(NFormat("GPSLatitude: %n %n %n", n1, n2, n3));
}
else if(tag == 6 && fmt == EXIF_RATIONAL && count == 1)
metadata.Add("GPSAltitude", ExifF5(data));
else if(tag == 16 && fmt == EXIF_ASCII && count == 2 && *data)
metadata.Add("GPSImgDirectionRef", String(*data, 1));
else if(tag == 17 && fmt == EXIF_RATIONAL && count == 1)
metadata.Add("GPSImgDirection", ExifF5(data + 0));
}
}
int nextoff = Exif32(e);
// puts(NFormat("next offset = %08x", nextoff));
return nextoff;
}
More specifically those reading:
if(tag == 0x132)
metadata.Add("DateTime", String(data, 20));
This would be great help!
Best regards,
Tom
|
|
|
 |
|
JPEG Images do not get rotated correctly
By: Tom1 on Mon, 01 October 2018 11:01
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Zbych on Wed, 03 October 2018 19:32
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 08:58
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Oblivion on Thu, 04 October 2018 11:28
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 14:03
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 14:33
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Oblivion on Thu, 04 October 2018 18:13
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 04 October 2018 19:05
|
 |
|
Re: JPEG Images do not get rotated correctly
By: mirek on Wed, 10 October 2018 13:20
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Wed, 10 October 2018 13:28
|
 |
|
Re: JPEG Images do not get rotated correctly
By: mirek on Fri, 12 October 2018 19:09
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Fri, 12 October 2018 20:40
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Fri, 12 October 2018 21:21
|
 |
|
Re: JPEG Images do not get rotated correctly
By: mirek on Sat, 13 October 2018 19:07
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Sat, 13 October 2018 22:33
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Sun, 21 October 2018 16:20
|
 |
|
Re: JPEG Images do not get rotated correctly
By: mirek on Wed, 31 October 2018 11:12
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Wed, 31 October 2018 19:30
|
 |
|
Re: JPEG Images do not get rotated correctly
By: mirek on Thu, 01 November 2018 08:34
|
 |
|
Re: JPEG Images do not get rotated correctly
By: Tom1 on Thu, 01 November 2018 09:57
|
Goto Forum:
Current Time: Wed Jun 25 09:57:12 CEST 2025
Total time taken to generate the page: 0.04442 seconds
|