Adding an logo-image/tekst to an existing image.

R

Richard

On my webpage I am making I want that if users view any image in my gallery
a small logo/tekst will appear in the image.
I know it's possible but I haven't got a clue how to get a logo or tekst on
a image.

Does someone got an example or somewhere I can read more about it except the
MSDN?

thx in advance.

Richard
 
A

ashelley

On my webpage I am making I want that if users view any image in my gallery
a small logo/tekst will appear in the image.
I know it's possible but I haven't got a clue how to get a logo or tekst on
a image.

Does someone got an example or somewhere I can read more about it except the
MSDN?

thx in advance.

Richard

you can use System.Drawing.Image. you will have to read about this
class as well as the Bitmap class in order to be able to combine an
image with another.

-Adam
 
S

Steven Cheng[MSFT]

Hi Richard,

As for how to manipulating image in asp.net web application and add some
mark/logo in it so as to protect them from linked by other user or sites.
Here are my suggestions:

First of all, Adam's suggestion that use the GDI+ api under the
System.Drawing.Image namespace is quite reasonable and it has provided
sufficient interfaces for manipulating image. And as for add our custom
flag/mark in the image in our web app when they're requested by other
users, gerenally we need to do the following steps:

1. Define a HttpHandler to service all the image request and use GDI+ code
to manipulate the image and output it to user.

2. After built the HttpHandler , register it in web.config of the asp.net
web application. And don't forget to set the ISAPI extension in IIS's
virtual dir ,we have to mapp the image extension(we want to processed by
our handler) to the aspnet_isapi.dll.

In addition, here are some tech articles discussing manipulating image in
asp.net

#Watermark Website Images At Runtime
http://www.codeproject.com/aspnet/httpImageHandler.asp

#HTTP Handlers for Images in ASP.NET
http://www.c-sharpcorner.com/Code/2003/June/HTTPHandlersForImages.asp

#Image Generation Service for ASP.NET 1.1
http://msdn.microsoft.com/msdnmag/issues/04/04/CuttingEdge/default.aspx

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
B

bloomfield

As Steven said.
Here is a piece of code I used to implement such a http handler. The
handler is adding some text to the image. You should remove the security
check...

public class AddJpegCopyrightHttpHandler : IHttpHandler
{
const string COPYRIGHT_NOTICE = "© a copyright notice";
private SolidBrush brush = new SolidBrush(Color.Gray);

public AddJpegCopyrightHttpHandler()
{
}

#region Implementation of IHttpHandler
public void ProcessRequest(System.Web.HttpContext context)
{
string filePath = context.Request.MapPath(context.Request.FilePath);

PhotoGaleryPrincipal user = System.Web.HttpContext.Current.User as
PhotoGaleryPrincipal;
bool isPrivate = filePath.IndexOf("\\PrivateGalery\\") != -1;
if( (user == null && isPrivate) || (user != null &&
!user.AlowPrivateAccess && isPrivate) )
{
throw new System.Security.SecurityException("The picture you
requested is in a private galery. You must be logged in and have access
to private galeries to access this picture.");
}

Bitmap photo = (Bitmap)Bitmap.FromFile(filePath);
if( photo.Width > 200 && photo.Height > 200 )
{
Graphics g = Graphics.FromImage(photo);
Font font = new Font("verdana", photo.Height / 100);
SizeF size = g.MeasureString(COPYRIGHT_NOTICE, font);
g.DrawString(COPYRIGHT_NOTICE, font, brush, photo.Width -
size.Width - 10, photo.Height - size.Height * 1.2F);
g.Dispose();
}
context.Response.ContentType = "image/jpeg";
photo.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}

public bool IsReusable
{
get
{
return true;
}
}
#endregion


}

hope this helps
____________________
www.bloomfield.as.ro
 
S

Steven Cheng[MSFT]

Hi Richard,

Have you had a chance to check out the suggestions in the former replies or
have you got any further ideas on this issue? If there're anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
R

Richard

the HTTPHandler stuff is still a bit out of my league. atm I am reading more
about it and
from all I have seen I like what you can do with it so its a much know for
me.

I still have some issue's with putting another logo on an existing image but
the text works for me now.
I guess I just have to read some more and play a bit with it.

Anyway, thx for the help,

Richard
 
Y

Yan-Hong Huang[MSFT]

Hello Richard,

Steven is OOF these two days. :) However, if there is any more question on it, please feel free to post in the group. We will follow up with you.

Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top