473,386 Members | 1,702 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,386 software developers and data experts.

Setting description field in a png image served from a web page

I'm writing a page that will get an image which the user wants to download.
I'm trying to find some way to set the "description" field of the file to
write some relevant information to the user.
The code I have (parts found on the internet) looks like this:

private void Page_Load(object sender, System.EventArgs e)
{
MemoryStream memStream = new MemoryStream();
string imageId = Request.QueryString["id"];
imageId = imageId != null ? imageId : "dummy.png";

Response.ContentType = "image/png";
Bitmap oImg;

try
{

oImg = new Bitmap(Server.MapPath(imageId));
}
catch
{
oImg = new Bitmap(16, 16);
}

// set the description field
PropertyItem[] items = oImg.PropertyItems;
PropertyItem propTemp = items[0];
string description = "Exported";
byte[] Value = System.Text.ASCIIEncoding.Unicode.GetBytes(descrip tion);
propTemp.Id = 0x010E; // id of "description" field
propTemp.Type = 2;
propTemp.Len = Value.Length;
propTemp.Value = Value;
oImg.SetPropertyItem(propTemp);

oImg.Save(memStream, System.Drawing.Imaging.ImageFormat.Png); // must use
memory stream as saving png format needs stream to be searchable
memStream.WriteTo(Response.OutputStream);
}

My problem is that this code does not add any data to the description field.
If I look in the outputted image in a program that displays the binary data
the field (tEXtDescription) has been inserted but my string "Exported does
not follow. What is going wrong?

cheers,
mortb
Nov 16 '05 #1
1 1527
here is the data that the page returns, the description should be after the
code "tEXtDescription" but my string "Exported" is not there.
----------------------------------------------------------------------------
---------------------------------------------------

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 28 Apr 2004 12:32:03 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Set-Cookie: ASP.NET_SessionId=taygyx455ovw5smyppmynq55; path=/
Cache-Control: private
Content-Type: image/png
Content-Length: 286

ëPNG

IHDR???C???gAMA?Å
tEXtDescriptionEv?"??IDATHK?òQ?ÇD??ç???EX6l??Jx?ê? òsN??ç??I?@E?
û?C?7¿½SlY?k4???
LiP??FV??ßKüd??^?Qg?M??¼?
K5«h\?ö<eÖ?'+R?TïÿG]?fliP÷?ÇF^£??xqè????q??¼Z?P?;^????
4L?ìà?±r???É?H?t?5/ä«»'p]níK½G?CK§??·?z?Ax?IEND«B`é
Nov 16 '05 #2

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

Similar topics

9
by: Don Seckler | last post by:
I am trying to set up a PHP web page so I can enter data into a database. I created a form: <form action="admin_news_insert_processor.php" method="post" name="frm_Insert_News"...
5
by: Roger Withnell | last post by:
I'm updating a record by opening a recordset, setting the fields and the updating it with objRS.Update. I need to set an image datatype to NULL. objRS("field") = NULL works for datatypes int...
23
by: Erik Schulp | last post by:
Hi all, I am using a background image via a stylsheet. I've used this code: background-image:url("/images/tile.gif"); (which I think is correct) The image doesn't show up however, the path,...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
11
by: Tomek Toczyski | last post by:
What is the best way to attach a caption to an image in xhtml? I can attach a caption to a table by a "<caption>" tag but I would like to do sth similar to an image. How to do it in a natural...
1
by: Rico | last post by:
Hello, I have an ole object field (Access XP/2002) which I store images in. I have a couple of questions regarding this; is it possible to determine the image dimensions? Secondly, is there...
9
by: Mark Denardo | last post by:
This is related to another post I submitted, but I'll be more precise this time. I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUrl="<username>.jpg",...
11
by: nuhura01 | last post by:
Hi.. I have a button to preview image using the following code, which preview the image in html page: Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter Dim...
3
by: fran7 | last post by:
Hi, I have this nice code that returns a random image database record. It works great. What I am trying to do now is to be able to get the "alt" description for the image from another field. If I...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.