Example #1
0
ExifLoader *
exif_loader_new (void)
{
	ExifMem *mem = exif_mem_new_default ();
	ExifLoader *l = exif_loader_new_mem (mem);

	exif_mem_unref (mem);

	return l;
}
ExifContent *
exif_content_new (void)
{
	ExifMem *mem = exif_mem_new_default ();
	ExifContent *content = exif_content_new_mem (mem);

	exif_mem_unref (mem);

	return content;
}
Example #3
0
ExifLog *
exif_log_new (void)
{
	ExifMem *mem = exif_mem_new_default ();
	ExifLog *log = exif_log_new_mem (mem);

	exif_mem_unref (mem);

	return log;
}
ExifData *
exif_data_new (void)
{
	ExifMem *mem = exif_mem_new_default ();
	ExifData *d = exif_data_new_mem (mem);

	exif_mem_unref (mem);

	return d;
}
static ExifEntry* allocateEntry(int tag,
                                ExifFormat format,
                                unsigned int numComponents) {
    ExifMem* mem = exif_mem_new_default();
    ExifEntry* entry = exif_entry_new_mem(mem);

    unsigned int size = numComponents * exif_format_get_size(format);
    entry->data = reinterpret_cast<unsigned char*>(exif_mem_alloc(mem, size));
    entry->size = size;
    entry->tag = static_cast<ExifTag>(tag);
    entry->components = numComponents;
    entry->format = format;

    exif_mem_unref(mem);
    return entry;
}
Example #6
0
ExifEntry *create_tag_in_content(ExifContent *content, ExifTag tag, size_t len, ExifFormat exifFormat)
{
	void *buf;
	ExifEntry *entry;
	size_t size;
	
	/* Create a memory allocator to manage this ExifEntry */
	ExifMem *mem = exif_mem_new_default();
	if (!mem) return NULL;
	
	/* Create a new ExifEntry using our allocator */
	entry = exif_entry_new_mem (mem);
	if (entry)
	{
		/* Allocate memory to use for holding the tag data */
		size = len * exif_format_get_size(exifFormat);
		
		buf = exif_mem_alloc(mem, size);
		if (buf)
		{
			/* Fill in the entry */
			entry->data = (unsigned char*)buf;
			entry->size = size;
			entry->tag = tag;
			entry->components = len;
			entry->format = exifFormat;

			/* Attach the ExifEntry to an IFD */
			exif_content_add_entry (content, entry);
		}
		
		exif_entry_unref(entry);
	}

	exif_mem_unref(mem);

	return entry;
}
Example #7
0
/* Set a libexif-formatted string entry. 
 */
static void
vips_exif_alloc_string( ExifEntry *entry, unsigned long components )
{
	ExifMem *mem;

	g_assert( !entry->data );

	/* The string in the entry must be allocated with the same allocator
	 * that was used to allocate the entry itself. We can't do this
	 * because the allocator is private :( so we must assume the entry was
	 * created with the default one.
	 */
	mem = exif_mem_new_default();

	/* EXIF_FORMAT_UNDEFINED is correct for EXIF_TAG_USER_COMMENT, our 
	 * caller should change this if it wishes.
	 */
	entry->data = exif_mem_alloc( mem, components );
        entry->size = components;
        entry->components = components;
        entry->format = EXIF_FORMAT_UNDEFINED;

	VIPS_FREEF( exif_mem_unref, mem );
}
Example #8
0
void generateDecryptData(SGeoTagsEncrypt *collection, unsigned char *data, unsigned int size, ExifByteOrder order)
{
	ExifEntry *entry = NULL;
	ExifData *exif = NULL;
	ExifContent *content = NULL;
	
	// create new exif data
	exif = exif_data_new_mem (exif_mem_new_default());
	exif->priv->order = order;

	// fill exif fields
	exif_data_load_data_content(exif, EXIF_IFD_ENCRYPT, data, size, 0, 0);
	content = exif->ifd[EXIF_IFD_ENCRYPT];

	// excrypt version
	exif_mem_read(collection->VersionID, NULL, content, SGEO_TAG_ENCRYPT_VERSION, sizeof(collection->VersionID));
	// FileName
	read_unicode_string_from_exif(content, SGEO_TAG_ENCRYPT_FILE_NAME, collection->FileName, sizeof(collection->FileName) / sizeof(*collection->FileName));
	// FileSize
	exif_long_read(&collection->FileSize, NULL, content, SGEO_TAG_ENCRYPT_FILE_SIZE, order);
	// datetime
	exif_mem_read(collection->DateTimeOriginal, &collection->ExistDateTimeOriginal, content, EXIF_TAG_DATE_TIME_ORIGINAL, sizeof(collection->DateTimeOriginal));
	// Longitude
	exif_srational_read(&collection->Longitude, &collection->ExistLongitude, content, SGEO_TAG_LONGITUDE, order);
	// LongAccuracy
	exif_rational_read(&collection->LongitudeAccuracy, &collection->ExistLongitudeAccuracy, content, SGEO_TAG_LONGACCURACY, order);
	// Latitude
	exif_srational_read(&collection->Latitude, &collection->ExistLatitude, content, SGEO_TAG_LATITUDE, order);
	// LatAccuracy
	exif_rational_read(&collection->LatitudeAccuracy, &collection->ExistLatitudeAccuracy, content, SGEO_TAG_LATACCURACY, order);
	// Altitude
	exif_srational_read(&collection->Altitude, &collection->ExistAltitude, content, SGEO_TAG_ALTITUDE, order);
	// AltAccuracy
	exif_rational_read(&collection->AltitudeAccuracy, &collection->ExistAltitudeAccuracy, content, SGEO_TAG_ALTACCURACY, order);
	// Azimuth
	exif_srational_read(&collection->Altitude, &collection->ExistAltitude, content, SGEO_TAG_ALTITUDE, order);
	entry = exif_content_get_entry (content, (ExifTag)(SGEO_TAG_AZIMUTH));
	if (entry) collection->Azimuth = exif_get_srational(entry->data, order);
	// AzimuthAccuracy
	exif_rational_read(&collection->AzimuthAccuracy, &collection->ExistAzimuthAccuracy, content, SGEO_TAG_AZIMUTHACCURACY, order);
	// Pitch
	exif_srational_read(&collection->Pitch, &collection->ExistPitch, content, SGEO_TAG_PITCH, order);
	// PitchAccuracy
	exif_rational_read(&collection->PitchAccuracy, &collection->ExistPitchAccuracy, content, SGEO_TAG_PITCHACCURACY, order);
	// Roll
	exif_srational_read(&collection->Roll, &collection->ExistRoll, content, SGEO_TAG_ROLL, order);
	// RollAccuracy
	exif_rational_read(&collection->RollAccuracy, &collection->ExistRollAccuracy, content, SGEO_TAG_ROLLACCURACY, order);
	// HViewAngle
	exif_rational_read(&collection->HViewAngle, &collection->ExistHViewAngle, content, SGEO_TAG_HVIEWANGLE, order);
	// HViewAngleAccuracy
	exif_rational_read(&collection->HViewAngleAccuracy, &collection->ExistHViewAngleAccuracy, content, SGEO_TAG_HVIEWANGLEACCURACY, order);
	// VViewAngle
	exif_rational_read(&collection->VViewAngle, &collection->ExistVViewAngle, content, SGEO_TAG_VVIEWANGLE, order);
	// VViewAngleAccuracy
	exif_rational_read(&collection->VViewAngleAccuracy, &collection->ExistVViewAngleAccuracy, content, SGEO_TAG_VVIEWANGLEACCURACY, order);
	// SatCount
	exif_mem_read(&collection->SatCount, NULL, content, SGEO_TAG_SATCOUNT, sizeof(collection->SatCount));
	// global time
	exif_mem_read(&collection->GlobalTime, &collection->ExistGlobalTime, content, SGEO_TAG_GLOBAL_TIME, sizeof(collection->GlobalTime));

	// GNSSType
	exif_long_read(&collection->GNSSType, NULL, content, SGEO_TAG_GNSS_TYPE, order);

	// DeviceName
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_NAME, collection->DeviceName, sizeof(collection->DeviceName) / sizeof(*collection->DeviceName));
	// DeviceIMEI
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_IMEI, collection->DeviceIMEI, sizeof(collection->DeviceIMEI) / sizeof(*collection->DeviceIMEI));
	// DeviceNumber
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_NUMBER, collection->DeviceNumber, sizeof(collection->DeviceNumber) / sizeof(*collection->DeviceNumber));
	// DeviceOS
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_OS, collection->DeviceOS, sizeof(collection->DeviceOS) / sizeof(*collection->DeviceOS));
	// DeviceOSVersion
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_OS_VERSION, collection->DeviceOSVersion, sizeof(collection->DeviceOSVersion) / sizeof(*collection->DeviceOSVersion));
	// DeviceVersion
	read_unicode_string_from_exif(content, SGEO_TAG_DEVICE_VERSION, collection->DeviceVersion, sizeof(collection->DeviceVersion) / sizeof(*collection->DeviceVersion));
	// DeviceDateTimeMeasure
	exif_mem_read(&collection->DeviceDateTimeMeasure, NULL, content, SGEO_TAG_DEVICE_DATE_TIME_MEASURE, sizeof(collection->DeviceDateTimeMeasure));

	// ProgramVersion
	read_unicode_string_from_exif(content, SGEO_TAG_PROGRAM_VERSION, collection->ProgramVersion, sizeof(collection->ProgramVersion) / sizeof(*collection->ProgramVersion));
	// ProgramName
	read_unicode_string_from_exif(content, SGEO_TAG_PROGRAM_NAME, collection->ProgramName, sizeof(collection->ProgramName) / sizeof(*collection->ProgramName));
	// ProgramUserName
	read_unicode_string_from_exif(content, SGEO_TAG_PROGRAM_USER_NAME, collection->ProgramUserName, sizeof(collection->ProgramUserName) / sizeof(*collection->ProgramUserName));

	exif_data_unref(exif);
}
Example #9
0
void generateEncryptData(unsigned char **data, unsigned int *size, SGeoTagsEncrypt *collection, ExifByteOrder order)
{
	unsigned int i = 0;
	unsigned int s = 0;
	unsigned int next_data = 0;
	ExifEntry *entry = NULL;
	ExifContent *content = NULL;
	unsigned char *d = NULL, n;
	ExifData *exif = NULL;
	int size_sgeo_bytes = 0;
	ExifIfd ifd = EXIF_IFD_ENCRYPT;

	srand((unsigned int)time(NULL));

	*data = NULL;
	*size = 0;

	exif = exif_data_new_mem (exif_mem_new_default());
	exif->priv->order = order;
	content = exif->ifd[EXIF_IFD_ENCRYPT];

	// VersionID
	exif_mem_write(content, SGEO_TAG_ENCRYPT_VERSION, EXIF_FORMAT_BYTE, collection->VersionID, sizeof(collection->VersionID), NULL);
	// FileName
	write_unicode_string_to_exif(content, SGEO_TAG_ENCRYPT_FILE_NAME, collection->FileName);
	// FileSize
	exif_long_write(content, SGEO_TAG_ENCRYPT_FILE_SIZE, &collection->FileSize, order, NULL);
	// DateTimeOriginal
	exif_mem_write(content, EXIF_TAG_DATE_TIME_ORIGINAL, EXIF_FORMAT_ASCII, collection->DateTimeOriginal, sizeof(collection->DateTimeOriginal), &collection->ExistDateTimeOriginal);
	// Longitude
	exif_srational_write(content, SGEO_TAG_LONGITUDE, &collection->Longitude, order, &collection->ExistLongitude);
	// LongAccuracy
	exif_rational_write(content, SGEO_TAG_LONGACCURACY, &collection->LongitudeAccuracy, order, &collection->ExistLongitudeAccuracy);
	// Latitude
	exif_srational_write(content, SGEO_TAG_LATITUDE, &collection->Latitude, order, &collection->ExistLatitude);
	// LatAccuracy
	exif_rational_write(content, SGEO_TAG_LATACCURACY, &collection->LatitudeAccuracy, order, &collection->ExistLatitudeAccuracy);
	// Altitude
	exif_srational_write(content, SGEO_TAG_ALTITUDE, &collection->Altitude, order, &collection->ExistAltitude);
	// AltAccuracy
	exif_rational_write(content, SGEO_TAG_ALTACCURACY, &collection->AltitudeAccuracy, order, &collection->ExistAltitudeAccuracy);
	// Azimuth
	exif_srational_write(content, SGEO_TAG_AZIMUTH, &collection->Azimuth, order, &collection->ExistAzimuth);
	// AzimuthAccuracy
	exif_rational_write(content, SGEO_TAG_AZIMUTHACCURACY, &collection->AzimuthAccuracy, order, &collection->ExistAzimuthAccuracy);
	// Pitch
	exif_srational_write(content, SGEO_TAG_PITCH, &collection->Pitch, order, &collection->ExistPitch);
	// PitchAccuracy
	exif_rational_write(content, SGEO_TAG_PITCHACCURACY, &collection->PitchAccuracy, order, &collection->ExistPitchAccuracy);
	// Roll
	exif_srational_write(content, SGEO_TAG_ROLL, &collection->Roll, order, &collection->ExistRoll);
	// RollAccuracy
	exif_rational_write(content, SGEO_TAG_ROLLACCURACY, &collection->RollAccuracy, order, &collection->ExistRollAccuracy);
	// HViewAngle
	exif_rational_write(content, SGEO_TAG_HVIEWANGLE, &collection->HViewAngle, order, &collection->ExistHViewAngle);
	// HViewAngleAccuracy
	exif_rational_write(content, SGEO_TAG_HVIEWANGLEACCURACY, &collection->HViewAngleAccuracy, order, &collection->ExistHViewAngleAccuracy);
	// VViewAngle
	exif_rational_write(content, SGEO_TAG_VVIEWANGLE, &collection->VViewAngle, order, &collection->ExistVViewAngle);
	// VViewAngleAccuracy
	exif_rational_write(content, SGEO_TAG_VVIEWANGLEACCURACY, &collection->VViewAngleAccuracy, order, &collection->ExistVViewAngleAccuracy);
	// SatCount
	exif_mem_write(content, SGEO_TAG_SATCOUNT, EXIF_FORMAT_BYTE, &collection->SatCount, sizeof(collection->SatCount), NULL);
	// global time
	exif_mem_write(content, SGEO_TAG_GLOBAL_TIME, EXIF_FORMAT_BYTE, collection->GlobalTime, sizeof(collection->GlobalTime), NULL);

	// GNSSType
	exif_long_write(content, SGEO_TAG_GNSS_TYPE, &collection->GNSSType, order, NULL);

	// DeviceName
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_NAME, collection->DeviceName);
	// DeviceIMEI
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_IMEI, collection->DeviceIMEI);
	// DeviceNumber
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_NUMBER, collection->DeviceNumber);
	// DeviceOS
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_OS, collection->DeviceOS);
	// DeviceOSVersion
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_OS_VERSION, collection->DeviceOSVersion);
	// DeviceVersion
	write_unicode_string_to_exif(content, SGEO_TAG_DEVICE_VERSION, collection->DeviceVersion);
	// DeviceDateTimeMeasure
	exif_mem_write(content, SGEO_TAG_DEVICE_DATE_TIME_MEASURE, EXIF_FORMAT_BYTE, collection->DeviceDateTimeMeasure, sizeof(collection->DeviceDateTimeMeasure), NULL);

	// ProgramVersion
	write_unicode_string_to_exif(content, SGEO_TAG_PROGRAM_VERSION, collection->ProgramVersion);
	// ProgramName
	write_unicode_string_to_exif(content, SGEO_TAG_PROGRAM_NAME, collection->ProgramName);
	// ProgramUserName
	write_unicode_string_to_exif(content, SGEO_TAG_PROGRAM_USER_NAME, collection->ProgramUserName);
	
	size_sgeo_bytes = 2 + content->count * 12;
	for (i = 0; i < content->count; i++)
	{
		entry = content->entries[i];
		if (entry != NULL)
		{
			s = exif_format_get_size(entry->format) * entry->components;
			if (s > 4)
				size_sgeo_bytes += s;
			//	s += 12;// +tag size
			//else
			//	s = 12;
		}
	}
	if (size_sgeo_bytes > 0)
	{
		*data = (unsigned char* )calloc((size_t)size_sgeo_bytes, 1);
		if (*data != NULL)
		{
			write_content_binary(*data, content, order, 0);
			s = 0;
			if (size_sgeo_bytes < 1024)
				s = 1024 - size_sgeo_bytes;
			s += 2390;// white noice
			*size = size_sgeo_bytes + s;
			*data = (unsigned char* )realloc(*data, (size_t)(size_sgeo_bytes + s));
			n = rand() % 255;
			for (i = 0; i < s; i++)
			{
				n = GaloisLfsr(n);
				(*data)[size_sgeo_bytes + i] = n;
			}
		}
	}
	exif_data_unref(exif);
}