467,099 Members | 1,121 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,099 developers. It's quick & easy.

GDI+ and SAVE JPG or BMP on the server

Ada
First of all, I thought this might be a directory security issue but it's not.
I was able to upload the file to the directory via HTTP.

Here's the situation.
I have a JPG file on my server.
..../images/myPIC.jpg

I wanted to draw a box or line using GDI+ on top of myPIC.jpg and then save
the new image to the server.

I was able to draw and display the image on screen but somehow cannot figure
out how to save it to the server.

The code below allows the result to be displayed on screen and it works fine.

newBMP.Save(Response.OutputStream, ImageFormat.Jpeg);

Something else is strange with the above image. When I RIGHT-CLICK and
attempted to save the image, the image cannot be saved. Although it displays
on screen but somehow I cannot copy the image using the RIGHT-CLICK.

Below is the code I used to save the image to the server....

newBMP.Save(Server.MapPath("images/" + "myNewPIC.jpg");
Got the following error:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams) +578
System.Drawing.Image.Save(String filename, ImageFormat format) +59
System.Drawing.Image.Save(String filename) +24

Mar 19 '06 #1
  • viewed: 2409
Share:
2 Replies
> [ExternalException (0x80004005): A generic error occurred in GDI+.]

99.9% of the time, when using GDI, 'a generic error occured' means that the
directory you are trying to save to doesn't ahve the proper permissions.
Typically, you need to make sure that directory is allowing asp.net to
modify files.

-Darrel
Mar 20 '06 #2
Ada
That's what I thought so.
However, I was able to upload file to the directory.
If dir permission doesn't allow READ and WRITE, I would think I wouldn't be
able to upload anything there.

If I added IMAGE control to the web form and allow the result to display in
the IMAGE control, the same SAVE code works.

My goal is that I don't want to display the result on screen.
The practical application would be something like a WATERMARK.
May be I have a TEXTBOX control and allow the ASP.NET and GDI+ to draw a
string on an image(s).
And if necessary, display the result on screen plus save the same result on
the server.


"Darrel" wrote:
[ExternalException (0x80004005): A generic error occurred in GDI+.]


99.9% of the time, when using GDI, 'a generic error occured' means that the
directory you are trying to save to doesn't ahve the proper permissions.
Typically, you need to make sure that directory is allowing asp.net to
modify files.

-Darrel

Mar 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.