MBS Updating EXIF Information CGImageDestinationMBS

Just a little background. After I have the photos rotated, I am trying to update the Orientation Properties within the JPEG header. I tried using the following codes but it doesn’t seems to change anything even though the Finalize method does show as true.

Here are my codes

[code] dim dpath as folderitem
dpath = getfolderitem(filename,folderitem.pathtypeshell)
dim c as new cgimagesourcembs(dpath)
dim img as cgimagembs = c.createimageatindex(0)
dim globalprop as dictionary = c.properties
dim p as Dictionary = c.PropertiesAtIndex(0)

dim d as new CGImageDestinationMBS(dpath,“public.jpeg”,1)

d.SetPropertiesCF(globalprop)

p.value(d.kCGImageDestinationOrientation) = 1
p.value(d.kCGImageDestinationMetadata) = true
p.value(d.kCGImageDestinationMergeMetadata) = true

p.value(c.kCGImagePropertyOrientation) = 1
p.value(c.kCGImagePropertyIPTCImageOrientation) = 1
p.value(c.kCGImagePropertyTIFFOrientation) = 1

p.value(c.kCGImageSourceCreateThumbnailFromImageAlways) = true
p.value(c.kCGImageSourceCreateThumbnailWithTransform) = true
p.value(c.kCGImageSourceThumbnailMaxPixelSize) = 200

d.AddImage(img,p)

if d.Finalize then

xstatus = "EXIF Change"

else

xstatus = "Failed"

end if
[/code]

I am not sure where I went wrong. In the debug, the Orientation did change within the Dictionary and the d.Finalize did show it works but the actual Header information did not change as reported by Preview.

I hope someone can help point the right direction. Thank you so much.

This seems to work and gives a nice example:

[code] // files
dim dpath as folderitem = SpecialFolder.Desktop.Child(“test.jpg”)
dim opath as folderitem = dpath.parent.Child(“output.jpg”)

// open source
dim imageSource as new cgimagesourcembs(dpath)

// read image
dim img as cgimagembs = imageSource.createimageatindex(0)

// global properties
dim globalprop as dictionary = imageSource.properties
// per image properties
dim p as Dictionary = imageSource.PropertiesAtIndex(0)

dim imageDest as new CGImageDestinationMBS(opath,“public.jpeg”,1)

'const orientation = 1 // top left
const orientation = 3 // bottom right

// set globals
imageDest.SetPropertiesCF(globalprop)

// now set new orientation
p.value(imageDest.kCGImageDestinationOrientation) = orientation
p.value(imageDest.kCGImageDestinationMergeMetadata) = true

// change tiff dictionary, if present
dim dTIFF as Dictionary = p.lookup(imageSource.kCGImagePropertyTIFFDictionary, nil)
if dTIFF <> nil then
dTIFF.value(imageSource.kCGImagePropertyTIFFOrientation) = orientation
end if

// change iptc dictionary, if present
dim dIPTC as Dictionary = p.lookup(imageSource.kCGImagePropertyIPTCDictionary, nil)
if dIPTC <> nil then
dIPTC.value(imageSource.kCGImagePropertyIPTCImageOrientation) = orientation
end if

// write out image
imageDest.AddImage(img,p)
call imageDest.Finalize[/code]

Thanks Christian. I seems the problem was not codes but that the file.delete folder did not work so it didn’t overwrite the original files.

I tried to search Exif on the Monkeybread site, but as usual, Google suggested whatever site, except MBS.

Christian, is there any way with your plugins to change the information in a picture, as displayed by Photoshop in the Menu File/File Info.

In particular, I want to be able to fill the Copyright Status and Copyright Notice fields.

TIA

The google site search on the documentation page works perfectly.

For Exif you can use XMP Plugin, GraphicsMagick plugin and CGImageSource class.
Depends on what you need exactly.

For Mac only projects, try CGImageSource first.

Sure, it works perfectly :

Your search - exif site:monkeybread.net - did not match any documents.

Suggestions:

Make sure all words are spelled correctly.
Try different keywords.
Try more general keywords.
Try fewer keywords.
Ad
Online EXIF Viewer?
Adwww.urbanbird.io/editor?
View and Edit the metadata of your pictures.

I am sorry, but this is useless.

What I need is a way to set the content of the Copyright Status and Copyright notice fields of a picture. Is it possible with MBS plugins ?

Try with XMP since Copyright Status is a Photoshop only field.

Your domain in the search is wrong.
Please use the google search field on the website.

On monkeybread.net you find the documentation for DynaPDF, at least the web version I made for people, so they find something when using google.

The MBS Xojo Plugin documentation is on monkeybreadsoftware.net.

[quote=341004:@Christian Schmitz]Your domain in the search is wrong.
Please use the google search field on the website.[/quote]

Christian, this IS the search field on http://monkeybread.net

Frankly, this should not be my problem. As for DynaPDF, if it is the only product available, thank you but no thank you.

The search field on monkeybread.net search that site.
You want to search monkeybreadsoftware.net, please search with that domain.

Seems ImageMagick can do it :
http://www.imagemagick.org/script/command-line-options.php?ImageMagick=m1p7m1l4edbn28tg0qnrejp5a4#comment

I could not find anything at http://www.monkeybreadsoftware.net/plugincontent-mbsimagemagickplugin.shtml indicating it would support comment

[quote=341024:@Christian Schmitz]The search field on monkeybread.net search that site.
You want to search monkeybreadsoftware.net, please search with that domain.[/quote]

why would monkeybread.net redirect to a Dynapdf specific one and the other not ?
Visually the two look so similar I also find this confusing that there’s any difference

[quote=341022:@Michel Bujardet]Christian, this IS the search field on http://monkeybread.net

Frankly, this should not be my problem. As for DynaPDF, if it is the only product available, thank you but no thank you.[/quote]

Michel,

I believe this might be the link which you want to look at for the CGImage

https://www.monkeybreadsoftware.net/class-cgimagesourcembs.shtml

I did use the CGImage but the file size of my JPEG files dropped by about 1mb when I change the EXIF tags. In the end for my app, I ended up just using EXIFTool via Shell to make the EXIF change.

http://owl.phy.queensu.ca/~phil/exiftool/examples.html

Exiftool is great for this.

I have GraphicsMagick plugin and an example shows how to display EXIF.

[quote=341040:@Edwin Lau]Michel,

I believe this might be the link which you want to look at for the CGImage

https://www.monkeybreadsoftware.net/class-cgimagesourcembs.shtml

I did use the CGImage but the file size of my JPEG files dropped by about 1mb when I change the EXIF tags. In the end for my app, I ended up just using EXIFTool via Shell to make the EXIF change.

http://owl.phy.queensu.ca/~phil/exiftool/examples.html[/quote]

Great.

Thank you so much, Edwin :slight_smile: I will have to go ExifTool, since I am creating a Windows app, and the plugin to access EXIF is only available for Mac.

Are you altering the actual image or simply updating the meta data?

The code I’ve seen posted here reads the image in (decompressing it) and then writes it back out again (recompression). You need to use the function CGImageDestinationCopyImageSource to avoid re-processing the image data.

[quote=341214:@Sam Rowlands]Are you altering the actual image or simply updating the meta data?

The code I’ve seen posted here reads the image in (decompressing it) and then writes it back out again (recompression). You need to use the function CGImageDestinationCopyImageSource to avoid re-processing the image data.[/quote]

Ah, I don’t see the function in CGImageDestinationMBS. Anyways, ExifTool in this instance does the job nicely which did not strip off some custom EXIF tags.

Which is good to know; while the TIFF guidelines (yes the TIFF spec is used for image meta data) say that apps should always preserve the meta data even if they don’t understand it. But it appears the no-one follows the guidelines.

It kinda pisses me off as I developed a non-destructive file format based upon the TIFF spec and it was fecking awesome IMHO. Alas no other application followed the TIFF guidelines and would break this format as soon as they saved. Basically the format contained two images, the original and the modified version. Most applications (including Adobe’s own apps and they developed the spec) would overwrite the file with only one image instead of two and strip off the custom meta data that my application used.