473,467 Members | 1,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Add EXIF Tag to JPEG

Hi

I was wandering if anyone knew if it was possible to add custom EXIF
tags (such as Photographer and Title) to a JPEG image, or to modify
the existing tags (such as ImageDescription).

There is an extremely good article on Code Project for reading these
tags, but I cannot find any information on how to modify them:

http://www.codeproject.com/cs/media/photoproperties.asp

Thanks

Blu.
Nov 20 '05 #1
9 10579
Hi,

[I'm writing this assuming you are using C++ .NET]

this is what I wrote yesterday nite, after I found out you can't create
and assign PropertyItem to an image. I don't know why this behaviour is
by design - makes no sense to me, to go the "save and reload then
modify"-way? Maybe Bob can explain this... ?!?

You have to write a wrapper in C# to retrieve the codec - also a
behaviour by design - and also makes no sense to me, I believe MS
screwed up on this one!

It should be easy to port that code to any other .NET lang...
If you have a problem, drop me a line.

Regards,

Martin
[C#-Wrapper for codec retrievement]
public static ImageCodecInfo GetEncoderCodec(string mimetype)
{
ImageCodecInfo[] codecs=ImageCodecInfo.GetImageEncoders();

ImageCodecInfo ici=null;

foreach(ImageCodecInfo codec in codecs)
{
if(codec.MimeType==mimetype)
{
ici=codec;
break;
}
}

return ici;
}
[Fill and Write the comment field:] ImageCodecInfo *ici = ImageCodecHelper::GetEncoderCodec("image/jpeg");

EncoderParameters *ep = new EncoderParameters();
// set quality to 70% ep->Param[0]=new System::Drawing::Imaging::EncoderParameter(System: :Drawing::Imaging::Encoder::Quality, (__int64)70);
//this is the way to get the property Items static_cast<Bitmap*>(pBLeft->Image)->Save((Application::StartupPath->Concat(S"\\temp.jpg")), ici, ep);
Bitmap *bmp = new Bitmap(Application::StartupPath->Concat(S"\\temp.jpg"));

System::Drawing::Imaging::PropertyItem *pi[] = bmp->PropertyItems;//static_cast<Bitmap*>(pBLeft->Image)->PropertyItems;
//retrieve comment from given Commentfield String *str = m_pbHLeft->GetComment();
//convert to unsigned char array and set
//required fields for unrestricted user comment
unsigned char uc_str __gc[]= new unsigned char __gc [str->Length+8];
//undefined charset for(int i=0; i<8; i++)
{
uc_str[i] = 0;
}
//string data for(int i=0; i<str->Length; i++)
{
uc_str[i+8] = Convert::ToByte(str->Chars[i]);
}
//exif user comment w/o restriction pi[0]->Id = 0x9286;
pi[0]->Type = 2;
pi[0]->Len = str->Length+8;
pi[0]->Value = uc_str;
//Set the Property item to the selected Image static_cast<Bitmap*>(pBLeft->Image)->SetPropertyItem(pi[0]);
//save the image with the properties set static_cast<Bitmap*>(pBLeft->Image)->Save(sfd->FileName, ici, ep);

bmp->Dispose();
File::Delete(Application::StartupPath->Concat(S"\\temp.jpg"));

Nov 20 '05 #2
Hi,

forgot about this, you might want to download this file and have a look
at it. There you will find all the valid tag IDs for the Exif2.2 tags.

http://www.exif.org/Exif2-2.PDF
Have fun,

Martin
Nov 20 '05 #3
>forgot about this, you might want to download this file and have a look
at it. There you will find all the valid tag IDs for the Exif2.2 tags.

http://www.exif.org/Exif2-2.PDF


Thanks mate. Looks great, unfortunately I only have knowledge of VB,
could you give me a hand on the conversion side please?

Cheers

Blu
Nov 20 '05 #4
I don't know much about VB. But you only have to find the appropriate
calls to the namespace funcs and then replace them... But I will give my
best to support you on this - give it a try and then post the code and
tell me where the problem is... I should be able to help you.

Martin

BluDog wrote:
forgot about this, you might want to download this file and have a look
at it. There you will find all the valid tag IDs for the Exif2.2 tags.

http://www.exif.org/Exif2-2.PDF

Thanks mate. Looks great, unfortunately I only have knowledge of VB,
could you give me a hand on the conversion side please?

Cheers

Blu

Nov 20 '05 #5
Blu,
You can also use an ocx from WaterMarker.
Check on www.watermarker.com and follow the AIS Exif ActiveX. I use it for
reading exif information but it can also be used to write infos.

HTH

Eric

"BluDog" <ne**@nospam.bludog.net> a écrit dans le message de
news:0t********************************@4ax.com...
forgot about this, you might want to download this file and have a look
at it. There you will find all the valid tag IDs for the Exif2.2 tags.

http://www.exif.org/Exif2-2.PDF


Thanks mate. Looks great, unfortunately I only have knowledge of VB,
could you give me a hand on the conversion side please?

Cheers

Blu

Nov 20 '05 #6
Thanks Eric,

but I don't use commercial libraries - it's a codex.

Eric Hourant wrote:
Blu,
You can also use an ocx from WaterMarker.
Check on www.watermarker.com and follow the AIS Exif ActiveX. I use it for
reading exif information but it can also be used to write infos.

HTH

Eric

"BluDog" <ne**@nospam.bludog.net> a écrit dans le message de
news:0t********************************@4ax.com...
forgot about this, you might want to download this file and have a look
at it. There you will find all the valid tag IDs for the Exif2.2 tags.

http://www.exif.org/Exif2-2.PDF


Thanks mate. Looks great, unfortunately I only have knowledge of VB,
could you give me a hand on the conversion side please?

Cheers

Blu


Nov 20 '05 #7
Martin

I have converted the C# wrapper bit to VB no probs:

Public Shared Function GetEncoderCodec(ByVal mimetype As String) As
ImageCodecInfo

Dim codecs() As ImageCodecInfo =
ImageCodecInfo.GetImageEncoders()
Dim codec As ImageCodecInfo

For Each codec In codecs
If codec.MimeType = mimetype Then Return codec
Next

End Function
But the rest, this is C++, i am assuming from your post that this can
only be acheived using C++ and cannot be converted to VB?

Is this correct?

Cheers

Blu
Nov 20 '05 #8
Hi,

no this is all .Net standard stuff. You don't have to worry about quit a
lot of things like the pointer stuff. This is normal object as it is in
VB. Give it a try, you should encounter no problems.

I'm leaving office now, if you have any further questions on this, I
will answer them tomorrow morning.

Martin

BluDog wrote:
Martin

I have converted the C# wrapper bit to VB no probs:

Public Shared Function GetEncoderCodec(ByVal mimetype As String) As
ImageCodecInfo

Dim codecs() As ImageCodecInfo =
ImageCodecInfo.GetImageEncoders()
Dim codec As ImageCodecInfo

For Each codec In codecs
If codec.MimeType = mimetype Then Return codec
Next

End Function
But the rest, this is C++, i am assuming from your post that this can
only be acheived using C++ and cannot be converted to VB?

Is this correct?

Cheers

Blu

Nov 20 '05 #9
check out LEADTOOLS (www.leadtools.com), it can handle that no problem.
"BluDog" <ne**@nospam.bludog.net> wrote in message
news:ol********************************@4ax.com...
Hi

I was wandering if anyone knew if it was possible to add custom EXIF
tags (such as Photographer and Title) to a JPEG image, or to modify
the existing tags (such as ImageDescription).

There is an extremely good article on Code Project for reading these
tags, but I cannot find any information on how to modify them:

http://www.codeproject.com/cs/media/photoproperties.asp

Thanks

Blu.

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tommy | last post by:
Hi. I try to use PEL (pel.sourceforge.net) to copy some exif information from orginial camera jpeg to resized copy with php gd library. But without success:( 1) File is uploaded to server...
0
by: leo | last post by:
hi there i'm using gene cash's EXIF.py module to find out the shoting time of an jpeg image. this module works usually like a beauty, but some images raise an exception: Traceback (most...
2
by: Vladish | last post by:
Hi all, I wonder, if anybody here has any source code or component, which can read EXIF informations from JPEG pictures. Or some good, easy to understood, description of JPEG files. I didn't...
3
by: BluDog | last post by:
Hi I was wandering if anyone knew if it was possible to add custom EXIF tags (such as Photographer and Title) to a JPEG image, or to modify the existing tags (such as ImageDescription). There...
5
by: TheGanjaMan | last post by:
Hi everyone, I'm trying to write up a simple image stamper application that stamps the Exif date information from the jpegs that I've taken from my digital camera and saves the new file with the...
4
by: Bror Johansson | last post by:
Is there somewhere some Python-module that can be used for adding EXIF-info to JPEG files? (Modules for extraction of EXIF-data are easily found, but lacks - as I see it - capacity to add new...
14
by: Frank | last post by:
I see that ImageFormat includes exif. But I can't find out if I've System.Drawing.Image.FromStream or something like it can read and/or write that format.
8
by: infoseekar | last post by:
Does anyone know what's the right code to read IPTC metadata. I have the code to read EXIF metadata and it gives me alot of information which I don't need. How do I modify this code so it only...
1
by: SPE - Stani's Python Editor | last post by:
Phatch is a simple to use cross-platform GUI Photo Batch Processor Phatch handles all popular image formats and can duplicate (sub)folder hierarchies. It can batch resize, rotate, apply...
15
tlhintoq
by: tlhintoq | last post by:
I'd like to think I can work out most issues, but this one is kicking my butt. What's worse, is that I know I can't be the first guy to want to add a thumbnail to jpg that doesn't already have one. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.