GDI+ and SAVE JPG or BMP on the server

Discussion in 'ASP .Net' started by =?Utf-8?B?QWRh?=, Mar 19, 2006.

  1. 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
     
    =?Utf-8?B?QWRh?=, Mar 19, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?QWRh?=

    Darrel Guest

    > [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
     
    Darrel, Mar 20, 2006
    #2
    1. Advertising

  3. 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
    >
    >
    >
     
    =?Utf-8?B?QWRh?=, Mar 20, 2006
    #3
  4. =?Utf-8?B?QWRh?=

    Joined:
    Nov 9, 2011
    Messages:
    1
    Hi Dear,
    i have the same problem, but i save images in database and read those from DB and write stream on Response.OutputStream.
    i attached error page.
     

    Attached Files:

    , Nov 9, 2011
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry Simpson

    32 dpp BMP to 24dpp BMP??

    Harry Simpson, Oct 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    348
    Harry Simpson
    Oct 30, 2003
  2. =?Utf-8?B?bQ==?=

    JPG generated with GDI+ problem

    =?Utf-8?B?bQ==?=, Mar 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    357
  3. b83503104
    Replies:
    2
    Views:
    324
    Rolf Magnus
    Nov 28, 2003
  4. b83503104
    Replies:
    2
    Views:
    527
    Rolf Magnus
    Nov 28, 2003
  5. Robin van de Water [synthesiSFactory]

    GDI+ is not properly initialized (internal GDI+ error).

    Robin van de Water [synthesiSFactory], Jan 10, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    1,349
    Robin van de Water [synthesiSFactory]
    Jan 10, 2007
Loading...

Share This Page