473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

adding a tag to a jpeg image file

I have the following code:

try
{

fi = new FileInfo(fn); //fn is a string from a windows form,
identifying the jpg in the file system
fullPath = fi.DirectoryName + "\\" + fi.Name;
Image bm = Image.FromFile(fullPath, true); //create an image
object from the file identifier
//bm.Tag = txtTag.Text; -- various attempts to set the
Image.Tag, inactivated for this test
//bm.Tag = (object)txtTag.Text;

bm.Save(fullPath, jpg); //this generates a "generic GDI+
error, trapped by a catch block on
//an unspecified exception -- catch(Exception ex)
}

//end code sample
//since I am in the code above merely loading the jpg and trying to save it
without any modification, I don't quite understand what has caused the
error. Any advice appreciated. I'm a neophyte at C#.

Mark Harris
St. Petersburg, FL

Feb 28 '08 #1
1 4479
The Image.Save(string, format) is supposed to throw an exception if saved to
the same file it was created from
http://msdn2.microsoft.com/en-us/library/9t4syfhh.aspx
--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
"Mark Harris" wrote:
I have the following code:

try
{

fi = new FileInfo(fn); //fn is a string from a windows form,
identifying the jpg in the file system
fullPath = fi.DirectoryName + "\\" + fi.Name;
Image bm = Image.FromFile(fullPath, true); //create an image
object from the file identifier
//bm.Tag = txtTag.Text; -- various attempts to set the
Image.Tag, inactivated for this test
//bm.Tag = (object)txtTag.Text;

bm.Save(fullPath, jpg); //this generates a "generic GDI+
error, trapped by a catch block on
//an unspecified exception -- catch(Exception ex)
}

//end code sample
//since I am in the code above merely loading the jpg and trying to save it
without any modification, I don't quite understand what has caused the
error. Any advice appreciated. I'm a neophyte at C#.

Mark Harris
St. Petersburg, FL
Feb 29 '08 #2

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

Similar topics

3
by: Ming | last post by:
Hi All, I want to write a PHP webpage which allows people to upload images (no matter what formats) to me and at the same time converts any non-jpeg image to JPEG. Here's what I have: ...
8
by: Dave Quigley | last post by:
Hello everyone.... Im currently starting my targa support project again for ..NET and I am wondering if there are any particular interfaces or classes that Im supposed to extend in order to do this...
0
by: Fred | last post by:
How can i use VB.NET to write information like Title, Subject, Keywords, Comments, Author to JPEG Image file Actually, I don't really know how to Save image to JPEG format in VB.NET.
13
by: NickName | last post by:
"For the vision impaired, SVG offers tremendous potential for interactive Internet mapping applications as discussed by Gardner and Bulatov (2001).". Now, here's an SVG file with fair/medium...
1
by: diya khan | last post by:
hi frndz.. i wann 2 know that how can i load a JPEG image file in C.. i have loaded a 16 color bitmap file but due 2 colors prb jpeg file is not loaded..:S so plzzzz help me.. thnx in advance..
2
by: ranjeshh | last post by:
How do I display a jpeg image using c..Please gude me as I m new to image processing..I would appreciate if someone could give me a working code with explanation
2
by: JJ | last post by:
I want to somehow add a flag/bit to an image file when I've added a watermark (so I don't add another one). Is there some way of accessing the image file and setting some sort of flag? The image...
6
by: Victory | last post by:
Hi, I need to know the compression type of jpeg (jpg) files. I am using the System.Drawing.Imaging and loading the file using an Image object. The next thing i do, is to examine the propertyItems...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.