Edit Exif Data in iOS Photos Gallery/ LIbrary without Creating Another Copy - ios

Is there a way to edit/ modify the exif data of the photot that are part of iOS photo library / gallery on the iPhone. Whenever I try to do that, iOS tries to save it as a separate image file. However, I would like to modify the exif data, without creating another copy of the photo. I used libexif as mentioned in the links below, however libexif lets you read and modify the data, but I could not figure out a way to store in the same file.
Gallery APIs in IOS (ALAsset, PhotoKit) do not seem to provide direct access to underlying physical file. They only provide APIs using which the image content can be accessed/ updated or inserted. They do not seem to have apis to modify the exif data. Also, libexif seems to work on the raw filename path. Is there a way to get the raw filename using PhotoKit or ALAsset ?
Am I missing something? Any help or pointers will be deeply appreciated.
How to write or modify EXIF data for an existing image on the filesystem, without loading the image?
Save original image data with modified metadata (no re-encoding) on iOS

Related

Modifying JPEG Metadata without Recompressing Image in iOS

I'm trying to use
CGImageSourceCreateWithData
CGImageDestinationCreateWithData
and then
CGImageDestinationAddImageFromSource
but this discards any thumbnails or other embedded information in the original file. What I want to do is read in the file, alter its metadata, and write it out with the alterations only. But I'll settle for reading everything out of it, and putting it back again. Right now a 1.2MB image file gets converted to a 437kB file with the loss of additional data.
Is there something other than CGImage I can use? Can this even be done with the iOS API?
The problem you face is that the structure of the metadata depends upon the specific JPEG file format you are using.
You need to look at CGImageProperties. You're going to have to make sure the properties for your specific file format get copied as well.
What I was looking for was a read-modify-write operation for image files that allowed changes but otherwise maintained unaltered data. I've determined through research and testing that this is not possible in iOS. The closest mechanism available is CGImage processing, but this only allows you to read selected information from a source image (such as image, thumbnail, properties), and then use some of that information (image, properties) to create a new destination file. There's no way to include a thumbnail in the new destination file, and no way to get around recompressing the image.
As of iOS 7 you can use CGImageDestinationCopyImageSource "to modify EXIF and other image metadata in JPEG, PNG, PSD, and TIFF files without recompressing the image data"
https://developer.apple.com/library/archive/qa/qa1895/_index.html

XML SDK 2.0 - Images - Excel file

With the use of the Open XML SDK 2.0, I did preformed the Reflected Code of an Excel file.
Along with other things, the Excel file has some images in some of the cells. When I run the code that was generated, the file show the images just fine.
What I need to do is to programatically inject images in place of the
images that are there now. The thing is, I cannot find where the images are at in the code that was generated. How can I figure this out? Also what is the easiest way to replace those images with new ones programmatically?
You may want to take a look at a similar question about inserting images into Excel files with OpenXML SDK: C# & OpenXML: Insert an image into an excel document.
Basically, those files are created as separate document parts. The answer I linked to should show You how to insert a new image into a document, however, in order to substitute existing images with your custom ones, you could probably just modify the binary data of appropriate ImagePart (and some other associated properties).
If You need some help with the code performing this task, let me know.

Writing Image to ALAssetsLibrary Results in a Different File Hash

I have an application that is downloading images from a server and inserting them into the iPhone's ALAssetsLibrary so that the user can see those images in their saved album. I am trying to do a confirmation by comparing file hashes to ensure the image was downloaded successfully. I have the file hash as the file exists on the server. Once I finish writing the image to the ALAssetsLibrary, I generate a file hash on the client. I'm observing that the file hashes are different but the files appear to be the same. I'm curious as to whether or not the client is altering these images somehow that I may not know about (aspect ratio, scale, metadata, etc). Any guidance, opinions, or advice would be helpful.
The image-data itself is not altered during import into the Assets-Library. However, I observed that JPEG files get about 10KB bigger, after they have been imported into the Assets-Library. The Assets-Library seems to add a JFIF-Metadata-Dictionary to the file, if not already present.

Can i save an image to the native Photos directory on an Ipad?

I've got my camera saving images fine to the app path, but my client wants to be able to access the photos from the photos directory (the path that images appear in when you use the native camera apps on the ipad)... I seem to get a "File I/O Error" if i try to save to the "///var/mobile/Media/Photos/" directory, which seems to be the location... is it possible? or is there no security or something involved with that?
I've never used it, but you want to use the CameraRoll class. It should do what you want, and seems straight forward to use based on it's simple/short API.
Here's an Adobe cookbook example that uses the CameraUI class as well.

Why do we need to call jpeg_write_marker() and jpeg_write_header() after jpeg_start_compress() ? [libjpeg]

From my understanding, libjpeg is a library used to compress the image data. I should be able to write the marker metadata without calling jpeg_start_compress() function.
I have 2 questions:
Why doesn't libjpeg allow that?
If I have a source jpeg file (which is already compressed), how can I just modify the metadata details? Is there any flag which I can set to notify the library that we are dealing with compressed images and we just need to modify the metadata details?
Please help.

Resources